Skip to content

Commit

Permalink
Update nenupy.schedule.contamination
Browse files Browse the repository at this point in the history
Added the possibility to plot SourceInLobes objects with time in UTC or LST.
  • Loading branch information
EmilieMauduit committed Jan 24, 2024
1 parent 22f0a97 commit eb9e4d4
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions nenupy/schedule/contamination.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@


import logging
from threading import local
log = logging.getLogger(__name__)

import numpy as np
Expand Down Expand Up @@ -83,30 +84,45 @@ 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",
cmap=kwargs.get("cmap", "Blues")
)
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()
Expand Down

0 comments on commit eb9e4d4

Please sign in to comment.