Skip to content
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
b0892f2
rework some preproc functions, test jobdb implementation
Aug 22, 2025
520cb90
some updates
Aug 22, 2025
1051c87
fix typo, only remove failed jobs
Aug 22, 2025
2560b2f
add function to restrict detectors
17-sugiyama Sep 17, 2025
0e86db5
update c1f filter to handle parameter arrays
17-sugiyama Sep 23, 2025
c8a43aa
minor change in get_pca
17-sugiyama Sep 23, 2025
2fa6179
Merge remote-tracking branch 'origin/master' into c1f_and_common_mode
Sep 28, 2025
4a2f6d4
fft_ops has new function ``get_common_noise_params``
Sep 28, 2025
dfbe688
counter_1_over_f accepts parameters in str
Sep 28, 2025
6e6ec40
add PSDFit
Sep 28, 2025
c12f519
update PSDFit
Sep 28, 2025
2f9a172
modified c1f method
Sep 28, 2025
d3d212b
modified c1f script
Sep 28, 2025
d89574e
add functions for pca common noise subtraction
Sep 28, 2025
676275b
add lpf options to build_hpf_params_dict
Sep 28, 2025
37f3e1e
debug
Sep 29, 2025
6375a32
Merge remote-tracking branch 'origin/master' into detector_restrictio…
Sep 29, 2025
62e3401
change LabelAxis to label_axis
17-sugiyama Oct 2, 2025
f633a74
Update counter_1_over_f conditional branch
17-sugiyama Oct 2, 2025
71a9ea4
Update docstring of get_common_noise_params
17-sugiyama Oct 2, 2025
b24c802
Update docstring of GetCommonMode
17-sugiyama Oct 2, 2025
9f366fb
Merge remote-tracking branch 'origin/c1f_and_common_mode' into junna_…
msilvafe Oct 7, 2025
b63f9a6
Merge remote-tracking branch 'origin/detector_restriction_by_t2p_fit'…
msilvafe Oct 7, 2025
64a4bfc
Add t2p selection.
msilvafe Oct 8, 2025
8625498
Modify counter_1_over_f filter to get metadata from proc_aman. Add ea…
satoru99 Oct 9, 2025
7b40402
Merge remote-tracking branch 'origin/master' into junna_preproc
Nov 18, 2025
09c8095
add functions to estimate scan frequency
Nov 18, 2025
77f1695
add t2p leakage estimation in frequency domain
Nov 18, 2025
fe82ece
add preprocesses
Nov 18, 2025
45827ff
Update get_t2p_cuts
17-sugiyama Nov 18, 2025
59bf9a4
push for to allow merge
Nov 19, 2025
675e0db
Merge branch 'master' into 20250822_preproc_update
mmccrackan Nov 19, 2025
f4a3f54
merge fixes
Nov 19, 2025
b083c73
registered ScanFreqCut
17-sugiyama Nov 20, 2025
4d9d4a7
debug t2pleakage.py
17-sugiyama Nov 20, 2025
1994d0f
debug preprocess.py
Nov 20, 2025
20a8537
some fixes/cleanup
Nov 20, 2025
5a09ff4
rework outputs, add jobdb tag
Nov 21, 2025
7370dd9
fix some errors
Nov 21, 2025
5bc134e
Fix t2p leakage splits.
msilvafe Nov 21, 2025
33370e3
Fix errors and add in t2p select.
msilvafe Nov 21, 2025
d1449a2
Generalize build_hpf to build general filter
msilvafe Nov 21, 2025
4040404
Fix select typo.
msilvafe Nov 21, 2025
67dc007
Fix passing in azss stats aman through preprocess.
msilvafe Nov 23, 2025
36e530f
Fix to subtracting azss model when fit is used and params are stored.
msilvafe Nov 23, 2025
6f50ad9
Add missing relcal cut.
msilvafe Nov 25, 2025
88229b1
Add skipping select
msilvafe Nov 25, 2025
fec08ac
Fix calibrate cuts call.
msilvafe Nov 25, 2025
734e5f8
Don't make a copy.
msilvafe Nov 25, 2025
8494d64
Add azss det selection.
msilvafe Dec 1, 2025
7ff3d39
address some comments, rework jobdb, cleanup docstring format
Dec 2, 2025
1ada5df
match dets dict for jobdb, try updating mapmaker
Dec 2, 2025
bc6414f
fix init db jobdb check
Dec 2, 2025
e139212
fix for race condition
Dec 2, 2025
809f76e
handled over flagged azss data.
msilvafe Dec 4, 2025
e0e45ad
add ignore config check option, tqdm to file, docstring fixes
Dec 4, 2025
355dccd
fix typos
Dec 4, 2025
9033846
rework group handing, fix error output
Dec 4, 2025
111e78e
handle None in errlog
Dec 4, 2025
5f71606
add bounds for noise fitting.
msilvafe Dec 5, 2025
b4bbaa6
track failed vs done, fix subdir
Dec 5, 2025
fe4b2ed
Merge branch 'master' into 20250822_preproc_update
mmccrackan Dec 5, 2025
10670ed
fix db creation problem
Dec 5, 2025
6487f38
feat: add functions to add multiple jobs at once
skhrg Dec 6, 2025
4ecd0f2
fix save_proc_aman
Dec 8, 2025
c3e7e9f
Add distribution cut.
msilvafe Dec 8, 2025
3b4378a
Fix typos.
msilvafe Dec 8, 2025
e0024a4
Merge branch 'master' into junna_preproc
msilvafe Dec 9, 2025
bfaf206
Make sim function consistent with data function cuts.
msilvafe Dec 10, 2025
ddd5dff
Add overwriting junna's noise fits for filtering.
msilvafe Dec 11, 2025
f48b32b
Add optional change in fit method.
msilvafe Dec 15, 2025
8d846bb
Fix passing fit type args.
msilvafe Dec 16, 2025
d14316c
Add mean method for calc_wn.
msilvafe Dec 17, 2025
c1c4aa6
Fix t2p subtraction select method to work without valid_data cuts.
msilvafe Dec 17, 2025
b31cf17
Add nan stats in get_good_distribution_flags.
msilvafe Dec 17, 2025
97b5153
Remove load file for fourier filter and add si range to det_bias_flags.
msilvafe Dec 18, 2025
559919d
many updates
Dec 18, 2025
7d33589
fix for jobdb
Dec 18, 2025
3eeb165
docstring fix
Dec 18, 2025
843f713
fix for docstring
Dec 18, 2025
088478c
add compression
Dec 19, 2025
b52c448
fix quanta for float32
Dec 19, 2025
13a1e62
update site pipeline utils imports
Dec 23, 2025
78c2d59
Merge branch 'master' into 20250822_preproc_update
mmccrackan Dec 23, 2025
f295a1b
feat: recombine make_job and create_job and speed up commit_jobs
skhrg Dec 23, 2025
dc6f345
disable existence check, handle cleaned up jobs
Dec 23, 2025
84a418d
fix state
Jan 2, 2026
9aff589
update jobdb
Jan 2, 2026
1df5175
minor docstring fix
mhasself Jan 9, 2026
2961297
Merge remote-tracking branch 'origin' into 20250822_preproc_update
Jan 9, 2026
5d6de5d
update jobdb
Jan 9, 2026
6f0265b
fix mapmaker error handling
Jan 9, 2026
784258c
make preproc db in mapmaker
Jan 12, 2026
f19b0dd
add skip_missing for preproc_or_load_group
Jan 13, 2026
6c720ce
Merge remote-tracking branch 'origin/20250822_preproc_update' into ju…
msilvafe Jan 14, 2026
5d1b1e0
Address mmccracken comments
msilvafe Jan 15, 2026
861c6ce
Merge remote-tracking branch 'origin/junna_preproc' into junna_preproc
msilvafe Jan 15, 2026
d9e10fa
Merge remote-tracking branch 'origin/master' into junna_preproc
msilvafe Jan 15, 2026
e8e942e
Fix crappy merge.
msilvafe Jan 15, 2026
9509bea
Fix some typos.
msilvafe Jan 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 74 additions & 11 deletions sotodlib/preprocess/processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,6 @@ def plot(self, aman, proc_aman, filename):
plot_ds_factor=self.plot_cfgs.get("plot_ds_factor", 50), filename=filename.replace('{name}', f'{ufm}_jump_signal_diff'))
plot_flag_stats(aman, proc_aman[name], flag_type='jumps', filename=filename.replace('{name}', f'{ufm}_jumps_stats'))


class PSDCalc(_Preprocess):
""" Calculate the PSD of the data and add it to the Preprocessing AxisManager under the
"psd" field.
Expand Down Expand Up @@ -455,7 +454,6 @@ def plot(self, aman, proc_aman, filename):
plot_psd(aman, signal=attrgetter(f"{self.wrap}.Pxx")(proc_aman),
xx=attrgetter(f"{self.wrap}.freqs")(proc_aman), filename=filename, **self.plot_cfgs)


class GetStats(_Preprocess):
"""
Get basic statistics from a TOD or its power spectrum.
Expand Down Expand Up @@ -1735,6 +1733,7 @@ def process(self, aman, proc_aman, sim=False):
field = self.process_cfgs.get("noise_fit_array", None)
if field:
noise_fit = proc_aman[field]
noise_fit = noise_fit.restrict('dets', aman.dets.vals, in_place=False)
else:
noise_fit = None

Expand All @@ -1753,6 +1752,7 @@ def process(self, aman, proc_aman, sim=False):
noise_fit=noise_fit,
filter_params=spec.get("filter_params")
)

ffun = getattr(tod_ops.filters, fname)
filters.append(ffun(**params))

Expand Down Expand Up @@ -1954,16 +1954,21 @@ class PCAFilter(_Preprocess):

def __init__(self, step_cfgs):
self.signal = step_cfgs.get('signal', 'signal')
self.model_signal = step_cfgs.get('model_signal', None)

super().__init__(step_cfgs)

def process(self, aman, proc_aman, sim=False):
n_modes = self.process_cfgs.get('n_modes')
signal = aman.get(self.signal)
if self.model_signal is not None:
model_signal = aman.get(self.model_signal)
else:
model_signal = signal.copy()
if aman.dets.count < n_modes:
raise ValueError(f'The number of pca modes {n_modes} is '
f'larger than the number of detectors {aman.dets.count}.')
model = tod_ops.pca.get_pca_model(aman, signal=signal, n_modes=n_modes)
model = tod_ops.pca.get_pca_model(aman, signal=model_signal, n_modes=n_modes)
_ = tod_ops.pca.add_model(aman, model, signal=signal, scale=-1)
return aman, proc_aman

Expand All @@ -1974,28 +1979,45 @@ class GetCommonMode(_Preprocess):
example config file entry::

- name: "get_common_mode"
noise_fit: True
f_max: 2.0
wrap_name: "common_demodQ"
calc:
signal: "signal"
method: "median"
wrap: "signal_commonmode"

save: True

If ``noise_fit`` is True, the 1/f noise fit parameters of the common mode
is wrapped together.
.. autofunction:: sotodlib.tod_ops.pca.get_common_mode
"""
name = 'get_common_mode'
def __init__(self, step_cfgs):
self.noise_fit = step_cfgs.get('noise_fit', False)
self.f_max = step_cfgs.get('f_max', None)
self.wrap_name = step_cfgs.get('wrap_name', 'common_mode')

super().__init__(step_cfgs)

def calc_and_save(self, aman, proc_aman):
common_mode = tod_ops.pca.get_common_mode(aman, **self.calc_cfgs)
common_aman = core.AxisManager(aman.samps)
common_aman.wrap(self.calc_cfgs['wrap'], common_mode, [(0, 'samps')])
if self.noise_fit:
common_aman = tod_ops.fft_ops.get_common_noise_params(aman, signal=common_mode,
f_max=self.f_max)
samps = core.OffsetAxis('samps', aman.samps.count)
common_aman.wrap(self.wrap_name, common_mode, [(0, samps)])
else:
common_aman = core.AxisManager(aman.samps)
common_aman.wrap(self.wrap_name, common_mode, [(0, 'samps')])
self.save(proc_aman, common_aman)
return aman, proc_aman

def save(self, proc_aman, common_aman):
if self.save_cfgs is None:
return
if self.save_cfgs:
proc_aman.wrap(self.calc_cfgs['wrap'], common_aman)
proc_aman.wrap(self.wrap_name, common_aman)

class FilterForSources(_Preprocess):
"""
Expand Down Expand Up @@ -2134,6 +2156,7 @@ class EstimateT2P(_Preprocess):
Example config block::

- name : "estimate_t2p"
fit_in_freq : False
calc:
T_sig_name: 'dsT'
Q_sig_name: 'demodQ'
Expand All @@ -2151,8 +2174,16 @@ class EstimateT2P(_Preprocess):
"""
name = "estimate_t2p"

def __init__(self, step_cfgs):
self.fit_in_freq = step_cfgs.get('fit_in_freq', False)

super().__init__(step_cfgs)

def calc_and_save(self, aman, proc_aman):
t2p_aman = tod_ops.t2pleakage.get_t2p_coeffs(aman, **self.calc_cfgs)
if self.fit_in_freq:
t2p_aman = tod_ops.t2pleakage.get_t2p_coeffs_in_freq(aman, **self.calc_cfgs)
else:
t2p_aman = tod_ops.t2pleakage.get_t2p_coeffs(aman, **self.calc_cfgs)
self.save(proc_aman, t2p_aman)

return aman, proc_aman
Expand All @@ -2178,8 +2209,10 @@ class SubtractT2P(_Preprocess):
name = "subtract_t2p"

def process(self, aman, proc_aman, sim=False):
tod_ops.t2pleakage.subtract_t2p(aman, proc_aman['t2p'],
**self.process_cfgs)
if 't2p' not in proc_aman._fields:
raise ValueError("No t2p field found in proc_aman. Please run estimate_t2p first.")
return meta, proc_aman
tod_ops.t2pleakage.subtract_t2p(aman, proc_aman['t2p'])
return aman, proc_aman

class SplitFlags(_Preprocess):
Expand Down Expand Up @@ -2389,6 +2422,35 @@ def process(self, aman, proc_aman, sim=False):
self.signal_name_U, merge=True)
return aman, proc_aman

class ScanFreqCut(_Preprocess):
"""Apply high-pass cut at the scan frequency.

Example config block::

- name : 'scan_freq_cut'
signal_name_T: 'dsT'
signal_name_Q: 'demodQ'
signal_name_U: 'demodU'
process: True

"""
name = "scan_freq_cut"

def __init__(self, step_cfgs):
self.signal_name_T = step_cfgs.get('signal_name_T', 'dsT')
self.signal_name_Q = step_cfgs.get('signal_name_Q', 'demodQ')
self.signal_name_U = step_cfgs.get('signal_name_U', 'demodU')
super().__init__(step_cfgs)

def process(self, aman, proc_aman, sim=False):
scan_freq = tod_ops.utils.get_scan_freq(aman)
hpf_cfg = {'type': 'sine2', 'cutoff': scan_freq, 'trans_width': scan_freq/10}
filt = tod_ops.get_hpf(hpf_cfg)
aman[self.signal_name_T] = tod_ops.fourier_filter(aman, filt, signal_name=self.signal_name_T, detrend='linear')
aman[self.signal_name_Q] = tod_ops.fourier_filter(aman, filt, signal_name=self.signal_name_Q, detrend='linear')
aman[self.signal_name_U] = tod_ops.fourier_filter(aman, filt, signal_name=self.signal_name_U, detrend='linear')
return aman, proc_aman

class FocalplaneNanFlags(_Preprocess):
"""Find additional detectors which have nans
in their focal plane coordinates.
Expand Down Expand Up @@ -2692,7 +2754,8 @@ def process(self, aman, proc_aman, sim=False):
_Preprocess.register(CombineFlags)
_Preprocess.register(RotateFocalPlane)
_Preprocess.register(RotateQU)
_Preprocess.register(SubtractQUCommonMode)
_Preprocess.register(SubtractQUCommonMode)
_Preprocess.register(ScanFreqCut)
_Preprocess.register(FocalplaneNanFlags)
_Preprocess.register(PointingModel)
_Preprocess.register(BadSubscanFlags)
Expand Down
3 changes: 2 additions & 1 deletion sotodlib/tod_ops/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from .detrend import detrend_tod
from .fft_ops import rfft
from .filters import fourier_filter, fft_trim
from .filters import fourier_filter, fft_trim, get_hpf
from .gapfill import \
get_gap_fill, get_gap_fill_single, \
get_gap_model, get_gap_model_single
Expand All @@ -12,3 +12,4 @@
from .azss import get_azss
from .t2pleakage import get_t2p_coeffs, subtract_t2p
from . import deproject
from . import utils
Loading