Skip to content

Commit

Permalink
Option to skip applying weights to maps to be coadded
Browse files Browse the repository at this point in the history
  • Loading branch information
arahlin committed Aug 14, 2023
1 parent 4578ce8 commit 4d0cb02
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions maps/python/map_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,22 +516,25 @@ class CoaddMaps(object):
If False (default), a warning is issued when the frame contains weighted
Stokes maps without a weights map. Set this option to True when feeding
single bolometer map frames with common weights through a pipeline.
ensure_weighted_maps : bool
If True (default), ensure that maps have had weights applied before
coadding. Otherwise, blindly coadds all input maps.
"""

def __init__(self, map_ids=None, output_map_id=None, ignore_missing_weights=False):
def __init__(self, map_ids=None, output_map_id=None, ignore_missing_weights=False, ensure_weighted_maps=True):
self.coadd_frame = core.G3Frame(core.G3FrameType.Map)
self.coadd_frame["Id"] = output_map_id
if output_map_id is not None:
self.coadd_frame["Id"] = output_map_id
if isinstance(map_ids, str):
map_ids = [map_ids]
self.map_ids = map_ids
self.ignore_missing_weights = ignore_missing_weights
self.ensure_weighted_maps = ensure_weighted_maps

def __call__(self, frame):

if frame.type == core.G3FrameType.EndProcessing:
coadd = self.coadd_frame
self.coadd_frame = None
return [coadd, frame]
return [self.coadd_frame, frame]

if "Id" not in frame:
return
Expand All @@ -541,7 +544,7 @@ def __call__(self, frame):

ValidateMaps(frame, ignore_missing_weights=self.ignore_missing_weights)
input_weighted = True
if not frame["T"].weighted:
if not self.ensure_weighted_maps and not frame["T"].weighted:
input_weighted = False
ApplyWeights(frame)

Expand Down

0 comments on commit 4d0cb02

Please sign in to comment.