Skip to content

Commit

Permalink
Update process method.
Browse files Browse the repository at this point in the history
  • Loading branch information
msilvafe committed Dec 17, 2024
1 parent 29582fe commit c46c7e3
Showing 1 changed file with 34 additions and 11 deletions.
45 changes: 34 additions & 11 deletions sotodlib/preprocess/processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -804,37 +804,60 @@ def process(self, aman, proc_aman):
aman.samps.offset + aman.samps.count - trim))


class EstimateAzSS(_Preprocess):
class AzSS(_Preprocess):
"""Estimates Azimuth Synchronous Signal (AzSS) by binning signal by azimuth of boresight.
All process confgis go to `get_azss`. If `method` is 'interpolate', no fitting applied
and binned signal is directly used as AzSS model. If `method` is 'fit', Legendre polynominal
fitting will be applied and used as AzSS model.
Example configuration block::
- name: "estimate_azss"
- name: "azss"
azss_stats_name: 'azss_statsQ'
calc:
signal: 'demodQ'
azss_stats_name: 'azss_statsQ'
range: [-1.57079, 7.85398]
frange: [-1.57079, 7.85398]
bins: 1080
merge_stats: False
merge_model: False
left_right: True
save: True
process:
subtract: True
.. autofunction:: sotodlib.tod_ops.azss.get_azss
"""
name = "estimate_azss"
name = "azss"
def __init__(self, step_cfgs):
self.azss_stats_name = step_cfgs.get('azss_stats_name', 'azss_stats')

super().__init__(step_cfgs)

def calc_and_save(self, aman, proc_aman):
calc_aman, _ = tod_ops.azss.get_azss(aman, **self.calc_cfgs)
self.save(proc_aman, calc_aman)
# If process is run then just wrap info from process step
if self.process_cfgs:
self.save(proc_aman, aman[self.azss_stats_name])
else:
azss_stats, _ = tod_ops.azss.get_azss(aman,
azss_stats_name=self.azss_stats_name,
merge_stats = False, merge_model=False,
**self.calc_cfgs)
self.save(proc_aman, azss_stats)

def save(self, proc_aman, azss_stats):
if self.save_cfgs is None:
return
if self.save_cfgs:
proc_aman.wrap(self.calc_cfgs["azss_stats_name"], azss_stats)
proc_aman.wrap(self.azss_stats_name, azss_stats)

def process(self, aman, proc_aman):
subtract = self.process_cfgs.get('subtract', False)
if self.azss_stats_name in proc_aman:
if subtract:
tod_ops.azss.get_azss(aman, subtract_in_place=True,
merge_stats = False, merge_model=False)
else:
tod_ops.azss.get_azss(aman, azss_stats_name=self.azss_stats_name,
merge_stats = True, merge_model=False,
subtract_in_place=subtract, **self.calc_cfgs)

class GlitchFill(_Preprocess):
"""Fill glitches. All process configs go to `fill_glitches`.
Expand Down Expand Up @@ -1641,7 +1664,7 @@ def process(self, aman, proc_aman):
_Preprocess.register(SubtractHWPSS)
_Preprocess.register(Apodize)
_Preprocess.register(Demodulate)
_Preprocess.register(EstimateAzSS)
_Preprocess.register(AzSS)
_Preprocess.register(GlitchFill)
_Preprocess.register(FlagTurnarounds)
_Preprocess.register(SubPolyf)
Expand Down

0 comments on commit c46c7e3

Please sign in to comment.