Skip to content

Commit

Permalink
#220 Refactor subtract_per_abba_cycle
Browse files Browse the repository at this point in the history
  • Loading branch information
astropenguin committed Nov 21, 2024
1 parent 7c23dca commit fcb194c
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions decode/qlook.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down

0 comments on commit fcb194c

Please sign in to comment.