Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-41330: Force visitInfo to use the dataId exposure value #469

Merged
merged 2 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-toml
- repo: https://github.com/psf/black
rev: 23.7.0
rev: 23.10.1
hooks:
- id: black
# It is recommended to specify the latest version of Python
# supported by your project here, or alternatively use
# pre-commit's default_language_version, see
# https://pre-commit.com/#top_level-default_language_version
language_version: python3.10
language_version: python3.11
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
name: isort (python)
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.0.278
rev: v0.1.2
hooks:
- id: ruff
12 changes: 11 additions & 1 deletion python/lsst/obs/base/_fitsRawFormatterBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,17 @@ def makeVisitInfo(self):
visitInfo : `~lsst.afw.image.VisitInfo`
Structured metadata about the observation.
"""
return MakeRawVisitInfoViaObsInfo.observationInfo2visitInfo(self.observationInfo)
visit_info = MakeRawVisitInfoViaObsInfo.observationInfo2visitInfo(self.observationInfo)
if self.dataId and "exposure" in self.dataId:
# Special case exposure existing for this dataset type.
# Want to ensure that the id stored in the visitInfo matches that
# from the dataId from butler, regardless of what may have come
# from the ObservationInfo. In some edge cases they might differ.
exposure_id = self.dataId["exposure"]
if exposure_id != visit_info.id:
visit_info = visit_info.copyWith(id=exposure_id)

return visit_info

@abstractmethod
def getDetector(self, id):
Expand Down
1 change: 1 addition & 0 deletions tests/test_fitsRawFormatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ def test_amp_parameter(self):
self.assertImagesEqual(subexp.image, full[amp.getRawBBox()].image)
self.assertEqual(len(subexp.getDetector()), 1)
self.assertAmplifiersEqual(subexp.getDetector()[0], amp)
self.assertEqual(subexp.visitInfo.id, 2)
# We could try transformed amplifiers here that involve flips
# and offsets, but:
# - we already test the low-level code that does that in afw;
Expand Down