simonsobs / sotodlib

Simons Observatory: Time-Ordered Data processing library.
MIT License
16 stars 19 forks source link

Preprocess: New PCA relcal/cuts incompatible with old configs #994

Closed msilvafe closed 1 month ago

msilvafe commented 1 month ago

With the addition of PCA cuts to the pca_relcal method passing calc_cfg: True in the config file does not run so we can not run with the old config files. In particular at this line: https://github.com/simonsobs/sotodlib/blob/a3e0f79e2cb1db8718aec2495ce34cec6ad2aee5/sotodlib/preprocess/processes.py#L1116

We get the following error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[13], line 6
      4 print(f'{time.time()-t0}    {i+1}/{totproc}: {process.name}')
      5 process.process(aman, proc_aman)
----> 6 process.calc_and_save(aman, proc_aman)
      7 update_full_aman(proc_aman, full, True)
      8 process.select(aman, proc_aman)

File ~/Software/sotodlib_preproc_20241009/sotodlib/preprocess/processes.py:1116, in PCARelCal.calc_and_save(self, aman, proc_aman)
   1113 pca_out = tod_ops.pca.get_pca(band_aman,signal=band_aman[self.signal])
   1114 pca_signal = tod_ops.pca.get_pca_model(band_aman, pca_out,
   1115                             signal=band_aman[self.signal])
-> 1116 result_aman = tod_ops.pca.pca_cuts_and_cal(band_aman, pca_signal, **self.calc_cfgs)
   1118 pca_det_mask[m0] = np.logical_or(pca_det_mask[m0], result_aman['pca_det_mask'])
   1119 relcal[m0] = result_aman['relcal']

TypeError: sotodlib.tod_ops.pca.pca_cuts_and_cal() argument after ** must be a mapping, not bool

We need to have a check if np.isinstance(self.calc_cfgs, bool) then don't pass any optional arguments to pca_cuts_and_cal