Skip to content

Commit 78ef202

Browse files
author
Yoshinori Sueno
committed
introduce in_place
1 parent 2c420b6 commit 78ef202

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

sotodlib/preprocess/processes.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,7 +1273,7 @@ def save(self, proc_aman, source_aman):
12731273
if self.save_cfgs:
12741274
proc_aman.wrap(self.source_flags_name, source_aman)
12751275

1276-
def select(self, meta, proc_aman=None):
1276+
def select(self, meta, proc_aman=None, in_place=True):
12771277
if self.select_cfgs is None:
12781278
return meta
12791279
if proc_aman is None:
@@ -1300,13 +1300,18 @@ def select(self, meta, proc_aman=None):
13001300
elif len(kinds) != len(select_list):
13011301
raise ValueError("Length of kinds must match length of select_source, or just str")
13021302

1303-
keep = np.zeros(meta.dets.count)
1303+
keep_all = np.ones(meta.dets.count, dtype=bool)
1304+
13041305
for source, kind, cut in zip(select_list, kinds, cuts):
13051306
if source in source_flags._fields:
1306-
keep += flag_cut_select(source_flags[source], cut, kind)
1307-
meta.restrict("dets", meta.dets.vals[keep.astype('bool')])
1308-
source_flags.restrict("dets", source_flags.dets.vals[keep.astype('bool')])
1309-
return meta
1307+
keep_all &= flag_cut_select(source_flags[source], cut, kind)
1308+
1309+
if in_place:
1310+
meta.restrict("dets", meta.dets.vals[keep_all])
1311+
source_flags.restrict("dets", source_flags.dets.vals[keep_all])
1312+
return meta
1313+
else:
1314+
return keep_all
13101315

13111316
class HWPAngleModel(_Preprocess):
13121317
"""Apply hwp angle model to the TOD.

0 commit comments

Comments
 (0)