Skip to content
Open
Changes from all commits
Commits
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
23 changes: 15 additions & 8 deletions sotodlib/toast/ops/splits.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import toast
from toast.utils import Logger
from toast.traits import trait_docs, Int, Unicode, Instance, List, Bool
from toast.timing import function_timer
from toast.timing import function_timer, Timer
from toast.intervals import IntervalList
from toast.observation import default_values as defaults
from toast.ops import Operator, FlagIntervals
Expand Down Expand Up @@ -708,13 +708,6 @@ def splits_exist(self, data, split_name=None):
]:
if not write:
continue
if binner_key is not None:
# get the product name from BinMap
mkey = getattr(self.mapmaker.binning, binner_key)
else:
# hits and covariance are not made by BinMap.
# Try synthesizing the product name
mkey = f"{mname}_{prod}"
fname = os.path.join(
self.output_dir,
f"{self.name}_{spname}_{prod}.{fname_suffix}"
Expand All @@ -726,6 +719,9 @@ def splits_exist(self, data, split_name=None):

def write_splits(self, data, split_name=None):
"""Write out all split products."""
log = Logger.get()
timer = Timer()

if not hasattr(self, "_split_obj"):
msg = "No splits have been created yet, cannot write"
raise RuntimeError(msg)
Expand All @@ -745,6 +741,7 @@ def write_splits(self, data, split_name=None):
else:
fname_suffix = "fits"

timer.start()
for spname, spl in to_write.items():
mname = f"{self.name}_{split_name}"
for prod, binner_key, write in [
Expand All @@ -764,6 +761,10 @@ def write_splits(self, data, split_name=None):
# hits and covariance are not made by BinMap.
# Try synthesizing the product name
mkey = f"{mname}_{prod}"
if mkey not in data:
# FilterBin makes a distinction between filtered
# and unfiltered maps
mkey = f"{mname}_filtered_{prod}"
if mkey not in data:
msg = f"'{mkey}' not found in data. "
msg += f"Available keys are {data.keys()}"
Expand All @@ -777,6 +778,12 @@ def write_splits(self, data, split_name=None):
force_serial=self.mapmaker.write_hdf5_serial,
single_precision=True,
)
log.info_rank(
f"Wrote {spname} {prod} to {fname} in",
comm=data.comm.comm_world,
timer=timer
)

# Clean up all products for this split
for prod in [
"hits",
Expand Down
Loading