Skip to content

Commit

Permalink
Source contamination - set the array factor to NaN if the pointing is…
Browse files Browse the repository at this point in the history
… below the horizon
  • Loading branch information
AlanLoh committed Jan 24, 2024
1 parent dc534e2 commit ddcba25
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion nenupy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
__copyright__ = "Copyright 2023, nenupy"
__credits__ = ["Alan Loh"]
__license__ = "MIT"
__version__ = "2.6.2"
__version__ = "2.6.3"
__maintainer__ = "Alan Loh"
__email__ = "[email protected]"

Expand Down
20 changes: 15 additions & 5 deletions nenupy/schedule/contamination.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def lst_time(self):

# --------------------------------------------------------- #
# ------------------------ Methods ------------------------ #
def plot(self, time_unit : str = 'utc', **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'.
Expand All @@ -95,13 +95,15 @@ def plot(self, time_unit : str = 'utc', **kwargs):
"""
fig = plt.figure(figsize=kwargs.get("figsize", (10, 6)))

if time_unit == 'utc' :
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' :
elif time_unit == "lst":
time_to_plot = self.lst_time.rad
time_label = "Local Sidereal Time (rad)"



# TODO : roll if there is a gap in lst and or utc
plt.pcolormesh(
time_to_plot,
self.frequency.to(u.MHz).value,
Expand All @@ -118,7 +120,7 @@ def plot(self, time_unit : str = 'utc', **kwargs):

# Format of the time axis tick labels
ax = plt.gca()
if time_unit == 'utc' :
if time_unit == "utc":
ax.xaxis.set_major_formatter(
mdates.DateFormatter("%H:%M:%S")
)
Expand Down Expand Up @@ -506,6 +508,8 @@ def _compute_array_factor(self, use_antenna_gain: bool = True) -> np.ndarray:
# Mini-Array selection
ma_mask = np.isin(MA_ROTATIONS, self.miniarray_rotations)
af = 0
below_horizon_mask = self.pointing.horizontal_coordinates.alt.deg <= 0

# Compute the array factor for each Mini-Array
for m in MA_INDICES[ma_mask]:
ma = MiniArray(index=m)
Expand All @@ -523,6 +527,12 @@ def _compute_array_factor(self, use_antenna_gain: bool = True) -> np.ndarray:
log.info("Computing the array factor...")
with ProgressBar() if log.getEffectiveLevel() <= logging.INFO else DummyCtMgr():
array_factor = af.compute()

# Set the array factor to NaN if the pointing is below the horizon
if np.any(below_horizon_mask):
array_factor[below_horizon_mask, ...] = np.nan
log.warning("Some time samples match a sub-horizon pointing, the corresponding array-factor is set to NaN.")

return array_factor / np.max(array_factor, axis=3)[:, :, :, None]


Expand Down

0 comments on commit ddcba25

Please sign in to comment.