From eb9e4d4b01adca5d15af45fb1f45b676766849b5 Mon Sep 17 00:00:00 2001 From: EmilieMauduit <103190830+EmilieMauduit@users.noreply.github.com> Date: Wed, 24 Jan 2024 11:44:50 +0100 Subject: [PATCH 1/2] Update nenupy.schedule.contamination Added the possibility to plot SourceInLobes objects with time in UTC or LST. --- nenupy/schedule/contamination.py | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/nenupy/schedule/contamination.py b/nenupy/schedule/contamination.py index 85ef1d2..299304f 100644 --- a/nenupy/schedule/contamination.py +++ b/nenupy/schedule/contamination.py @@ -22,6 +22,7 @@ import logging +from threading import local log = logging.getLogger(__name__) import numpy as np @@ -83,12 +84,26 @@ def lst_time(self): # --------------------------------------------------------- # # ------------------------ Methods ------------------------ # - def plot(self, **kwargs): - """ """ + def plot(self, time_unit : str = 'utc', **kwargs): + """ + :param time_unit: + To select in which units the time axe is to be displayed : 'utc' or 'lst'. Default is 'utc'. + For pcolormesh to plot correctly the data, the time list in the wanted unit should be monotonous. + :type time_unit: + str + + """ fig = plt.figure(figsize=kwargs.get("figsize", (10, 6))) + if time_unit == 'utc' : + time_to_plot = self.time.datetime + time_label = f"Time (UTC since {self.time[0].isot.split('.')[0]})" + elif time_unit == 'lst' : + time_to_plot = self.lst_time.rad + time_label = "Local Sidereal Time (rad)" + plt.pcolormesh( - self.time.datetime, + time_to_plot, self.frequency.to(u.MHz).value, self.value, shading="auto", @@ -96,17 +111,18 @@ def plot(self, **kwargs): ) plt.grid(alpha=0.5) plt.ylabel("Frequency (MHz)") - plt.xlabel(f"Time (UTC since {self.time[0].isot.split('.')[0]})") + plt.xlabel(time_label) plt.title(kwargs.get("title", "")) cb = plt.colorbar(pad=0.03) cb.set_label("Sources in beam lobes") # Format of the time axis tick labels ax = plt.gca() - ax.xaxis.set_major_formatter( - mdates.DateFormatter("%H:%M:%S") - ) - fig.autofmt_xdate() + if time_unit == 'utc' : + ax.xaxis.set_major_formatter( + mdates.DateFormatter("%H:%M:%S") + ) + fig.autofmt_xdate() # Add minor ticks ax.minorticks_on() From 22a163e05fc5690c455369b8980a669398f45189 Mon Sep 17 00:00:00 2001 From: EmilieMauduit <103190830+EmilieMauduit@users.noreply.github.com> Date: Wed, 24 Jan 2024 11:46:32 +0100 Subject: [PATCH 2/2] Update contamination.py Noticed a useless import.. --- nenupy/schedule/contamination.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nenupy/schedule/contamination.py b/nenupy/schedule/contamination.py index 299304f..24d1ed7 100644 --- a/nenupy/schedule/contamination.py +++ b/nenupy/schedule/contamination.py @@ -22,7 +22,7 @@ import logging -from threading import local + log = logging.getLogger(__name__) import numpy as np