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-17493: Read Filter in Gen3 raw formatter. #176

Merged
merged 1 commit into from
Jan 28, 2019
Merged
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
16 changes: 15 additions & 1 deletion python/lsst/obs/subaru/gen3/hsc/rawFormatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@
"""Gen3 Butler Formatters for HSC raw data.
"""

from lsst.afw.image import ImageU, bboxFromMetadata
from lsst.afw.image import ImageU, bboxFromMetadata, Filter
from lsst.afw.geom import makeSkyWcs, Point2D, makeFlippedWcs
from lsst.afw.math import flipImage
from lsst.daf.butler.formatters.fitsRawFormatterBase import FitsRawFormatterBase
from astro_metadata_translator import HscTranslator, ObservationInfo

from ....hsc.makeHscRawVisitInfo import MakeHscRawVisitInfo
from ....hsc.hscFilters import HSC_FILTER_DEFINITIONS

__all__ = ("HyperSuprimeCamRawFormatter", "HyperSuprimeCamCornerRawFormatter")

Expand All @@ -47,6 +49,18 @@ def makeWcs(self, metadata):
center = Point2D(dimensions/2.0)
return makeFlippedWcs(wcs, self.FLIP_LR, self.FLIP_TB, center)

def makeFilter(self, metadata):
obsInfo = ObservationInfo(metadata, translator_class=HscTranslator)
# For historical reasons we need to return a short, lowercase filter
# name that is neither a physical_filter nor an abstract_filter in Gen3
# or a filter data ID value in Gen2.
# We'll suck that out of the definitions used to construct filters
# for HSC in Gen2. This should all get cleaned up in RFC-541.
for d in HSC_FILTER_DEFINITIONS:
if obsInfo.physical_filter == d["name"] or obsInfo.physical_filter in d["alias"]:
return Filter(d["name"], force=True)
return Filter(obsInfo.physical_filter, force=True)

def readImage(self, fileDescriptor):
if fileDescriptor.parameters:
# It looks like the Gen2 std_raw code wouldn't have handled
Expand Down