Skip to content

DM-56114: Add optional lsst.image format for output images - #471

Merged
isullivan merged 17 commits into
mainfrom
tickets/DM-56114
Oct 12, 2026
Merged

isullivan merged 17 commits into
mainfrom
tickets/DM-56114

Conversation

@isullivan

Copy link
Copy Markdown
Contributor

No description provided.

bbox = pipeBase.connectionTypes.Input(
doc="Bounding box of exposure to determine the geometry of the output template.",
name="{fakesType}calexp.bbox",
storageClass="Box2I",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to add a deprecated bbox connection here, because connections generate config fields and we don't want to break our ability to read only slightly old config files.

unit=astropy.units.nJy,
instrument=data_id["instrument"],
visit=data_id["visit"],
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it would be better to start from the input difference image and then reassign just the image/mask/variance (and maybe not even the last of those?), instead of doing a new from_legacy conversion.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, that seems safer and more efficient. I need to clean up the background I attached in subtractImages, but I shouldn't have added that in the first place. Background subtraction for the difference image is only actually done in detectAndMeasure.

@isullivan
isullivan force-pushed the tickets/DM-56114 branch 4 times, most recently from 98c0a40 to c6f99e3 Compare October 5, 2026 22:20
@isullivan
isullivan force-pushed the tickets/DM-56114 branch 2 times, most recently from f06448c to 48262d4 Compare October 6, 2026 17:22

@TallJimbo TallJimbo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good, but I've got two big-picture issues I'd like to see addressed:

  • I think a lot of tests could be replaced by a much smaller number of calls to lsst.images.tests.compare_visit_image_to_legacy.

  • The exposure_record that from_legacy now takes is there to make it possible to reconstruct an ObservationInfo. I'm sorry I didn't realize the importance of the case where you've already got one of those, but I think it would be a lot better to make obs_info an optional argument to VisitImage.from_legacy (and DifferenceImage.from_legacy) that could be provided instead of exposure_record. That would simplify the code here to the same pattern you already use for other components that are only on the future types and basically just get passed through, while avoiding the chance of any metadata loss.

for maskPlane in self.config.metricsMaskPlanes:
try:
metricsMaskPlanes.append(maskPlane)
metricsMaskPlanes[maskPlane] = difference.mask.getPlaneBitMask(maskPlane)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a global lookup, too. It's an instance method, but I think under the hood it's calling the same global stuff.

Or at least this usually references the global mask plane dict. There might be some edge cases where it's possible for a Mask to have different one, but usually they don't.

Comment thread tests/test_computeSpatiallySampledMetrics.py
Comment thread tests/test_getTemplate.py Outdated
Comment thread tests/test_getTemplate.py
@TallJimbo

Copy link
Copy Markdown
Member

I should add that if you want to try to maintain support for taking legacy preliminary_visit_image datasets here, you could also get the exposure_record by adding dummy connections with exposure dimensions. But that might be more trouble than its worth, and when you do have an ObservationInfo in hand already, that's what you should use.

…storage formats

This adds a dependency on `lsst.images`
Only relevant with the `lsst.images` conversion, and the original error can be raised if `raiseOnUndefinedMaskMap` is set.
The input image already carries the kernel, template records,
observation metadata, PSF, and photometric scaling, so only the pixels,
mask, and background need to be written back. The subtractImages
conversion no longer attaches the background fit with the kernel,
which is unused, so the detectAndMeasure background is the only one
recorded.
The score image variant runs its final detection on the score image, so
the first-pass detections used to fit the background stayed in the
DETECTED planes of the output difference image.
In future mode the background is recorded on the output images, so the
separate difference_background dataset is no longer written.
Needs the daf_butler formatter for ConvolutionKernel datasets.
@isullivan
isullivan merged commit fb11b3e into main Oct 12, 2026
3 checks passed
@isullivan
isullivan deleted the tickets/DM-56114 branch October 12, 2026 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants