From fcb194c2b372d49d0fb252df186deea600cb5bdf Mon Sep 17 00:00:00 2001 From: Akio Taniguchi Date: Thu, 21 Nov 2024 07:28:20 +0000 Subject: [PATCH] #220 Refactor subtract_per_abba_cycle --- decode/qlook.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/decode/qlook.py b/decode/qlook.py index b7fd270..f9311dc 100644 --- a/decode/qlook.py +++ b/decode/qlook.py @@ -1146,9 +1146,19 @@ def mean_in_time(dems: xr.DataArray) -> xr.DataArray: def subtract_per_abba_cycle(dems: xr.DataArray, /) -> xr.DataArray: - """Take each abba-cycle's average which are applied atm corecction""" + """Subtract sky from source with atmospheric correction for each ABBA cycle. + + Args: + dems: 2D DataArray (time x chan) of DEMS per ABBA cycle. + + Returns: + 1D DataArray (chan) of the mean spectrum after subtraction and correction. + If ABBA phases per cycle are incomplete, i.e., some phases are missing, + a spectrum filled with NaN will be returned instead. + + """ if not set(np.unique(dems.abba_phase)) == ABBA_PHASES: - return xr.DataArray(np.nan) + return dems.mean("time") * np.nan return dems.groupby("abba_phase").map(subtract_per_abba_phase).mean("abba_phase")