Skip to content

Commit 25ecf2a

Browse files
authored
Merge pull request #1174 from lsst/tickets/DM-53063
DM-53063: Add option output connection for the preliminary_visit_mask
2 parents 5a60e81 + 58745f8 commit 25ecf2a

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

python/lsst/pipe/tasks/calibrateImage.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,14 @@ class CalibrateImageConnections(pipeBase.PipelineTaskConnections,
194194
)
195195

196196
# Optional outputs
197+
mask = connectionTypes.Output(
198+
doc="The mask plane of the calibrated exposure, written as a separate "
199+
"output so that it can be passed to downstream tasks even if the "
200+
"exposure is removed to save storage.",
201+
name="preliminary_visit_mask",
202+
storageClass="Mask",
203+
dimensions=("instrument", "visit", "detector"),
204+
)
197205
psf_stars_footprints = connectionTypes.Output(
198206
doc="Catalog of bright unresolved sources detected on the exposure used for PSF determination; "
199207
"includes source footprints.",
@@ -230,6 +238,8 @@ def __init__(self, *, config=None):
230238
del self.astrometry_matches
231239
if "photometry_matches" not in config.optional_outputs:
232240
del self.photometry_matches
241+
if "mask" not in config.optional_outputs:
242+
del self.mask
233243
if not config.do_calibrate_pixels:
234244
del self.applied_photo_calib
235245
if not config.do_illumination_correction:
@@ -246,7 +256,7 @@ class CalibrateImageConfig(pipeBase.PipelineTaskConfig, pipelineConnections=Cali
246256
dtype=str,
247257
# TODO: note somewhere to disable this for benchmarking, but should
248258
# we always have it on for production runs?
249-
default=["psf_stars", "psf_stars_footprints", "astrometry_matches", "photometry_matches"],
259+
default=["psf_stars", "psf_stars_footprints", "astrometry_matches", "photometry_matches", "mask"],
250260
optional=False
251261
)
252262

@@ -848,6 +858,9 @@ def run(
848858
``photometry_matches``
849859
Reference catalog stars matches used in the photometric fit.
850860
(`list` [`lsst.afw.table.ReferenceMatch`] or `lsst.afw.table.BaseCatalog`)
861+
``mask``
862+
Copy of the mask plane of `exposure`.
863+
(`lsst.afw.image.Mask`)
851864
"""
852865
if result is None:
853866
result = pipeBase.Struct()
@@ -967,6 +980,8 @@ def run(
967980
photometry_meta)
968981
if self.config.doMaskDiffractionSpikes:
969982
self.diffractionSpikeMask.run(result.exposure)
983+
if "mask" in self.config.optional_outputs:
984+
result.mask = result.exposure.mask.clone()
970985
except pipeBase.AlgorithmError:
971986
if not have_fit_psf:
972987
result.exposure.setPsf(None)

tests/test_calibrateImage.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,10 @@ def setUp(self):
730730
"initial_photometry_match_detector",
731731
{"instrument", "visit", "detector"},
732732
"Catalog")
733+
butlerTests.addDatasetType(self.repo,
734+
"preliminary_visit_mask",
735+
{"instrument", "visit", "detector"},
736+
"Mask")
733737

734738
# dataIds
735739
self.exposure0_id = self.repo.registry.expandDataId(
@@ -776,6 +780,7 @@ def test_runQuantum(self):
776780
"initial_pvi_background": self.visit_id,
777781
"astrometry_matches": self.visit_id,
778782
"photometry_matches": self.visit_id,
783+
"mask": self.visit_id,
779784
})
780785
mock_run = lsst.pipe.base.testUtils.runTestQuantum(task, self.butler, quantum)
781786

@@ -822,6 +827,7 @@ def test_runQuantum_illumination_correction(self):
822827
"initial_pvi_background": self.visit_id,
823828
"astrometry_matches": self.visit_id,
824829
"photometry_matches": self.visit_id,
830+
"mask": self.visit_id,
825831
})
826832
mock_run = lsst.pipe.base.testUtils.runTestQuantum(task, self.butler, quantum)
827833

@@ -862,6 +868,7 @@ def test_runQuantum_2_snaps(self):
862868
"initial_pvi_background": self.visit_id,
863869
"astrometry_matches": self.visit_id,
864870
"photometry_matches": self.visit_id,
871+
"mask": self.visit_id,
865872
})
866873
mock_run = lsst.pipe.base.testUtils.runTestQuantum(task, self.butler, quantum)
867874

@@ -899,10 +906,12 @@ def test_runQuantum_no_optional_outputs(self):
899906
"initial_pvi_background": self.visit_id,
900907
"astrometry_matches": self.visit_id,
901908
"photometry_matches": self.visit_id,
909+
"mask": self.visit_id,
902910
}
903911

904912
# Check that we can turn off one output at a time.
905-
for optional in ["psf_stars", "psf_stars_footprints", "astrometry_matches", "photometry_matches"]:
913+
for optional in ["psf_stars", "psf_stars_footprints", "astrometry_matches", "photometry_matches",
914+
"mask"]:
906915
config = CalibrateImageTask.ConfigClass()
907916
config.optional_outputs.remove(optional)
908917
task = CalibrateImageTask(config=config)
@@ -944,6 +953,7 @@ def test_runQuantum_no_calibrate_pixels(self):
944953
"initial_pvi_background": self.visit_id,
945954
"astrometry_matches": self.visit_id,
946955
"photometry_matches": self.visit_id,
956+
"mask": self.visit_id,
947957
})
948958
mock_run = lsst.pipe.base.testUtils.runTestQuantum(task, self.butler, quantum)
949959

@@ -992,6 +1002,7 @@ def test_runQuantum_exception(self):
9921002
"initial_pvi_background": self.visit_id,
9931003
"astrometry_matches": self.visit_id,
9941004
"photometry_matches": self.visit_id,
1005+
"mask": self.visit_id,
9951006
})
9961007

9971008
# A generic exception should raise directly.

0 commit comments

Comments
 (0)