Skip to content

Commit

Permalink
Merge pull request #469 from lsst/tickets/DM-41330
Browse files Browse the repository at this point in the history
DM-41330: Force visitInfo to use the dataId exposure value
  • Loading branch information
timj committed Oct 26, 2023
2 parents d3f3557 + d20636b commit 7ef8dca
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
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

0 comments on commit 7ef8dca

Please sign in to comment.