Skip to content

Commit

Permalink
Add basic lsstCam mapper support
Browse files Browse the repository at this point in the history
LsstCamMapper is now a subclass of LsstBaseMapper.  This allows
the specific translation classes to be specified.
  • Loading branch information
timj committed Mar 20, 2019
1 parent b516e51 commit 9224bbc
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 5 deletions.
1 change: 1 addition & 0 deletions data/input/lsstCam/_mapper
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lsst.obs.lsst.LsstCamMapper
Binary file not shown.
Binary file not shown.
Binary file added data/input/lsstCam/registry.sqlite3
Binary file not shown.
5 changes: 4 additions & 1 deletion python/lsst/obs/lsst/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
from astro_metadata_translator import ObservationInfo
import lsst.log as lsstLog
from .translators.lsst import ROLLOVERTIME
from .translators import LsstCamTranslator
from .lsstCamMapper import LsstCamMapper

EXTENSIONS = ["fits", "gz", "fz"] # Filename extensions to strip off

Expand All @@ -38,7 +40,8 @@ class LsstCamParseTask(ParseTask):
`LSE-400 <https://ls.st/LSE-400>`_.
"""

_translatorClass = None
_mapperClass = LsstCamMapper
_translatorClass = LsstCamTranslator

def __init__(self, config, *args, **kwargs):
super().__init__(config, *args, **kwargs)
Expand Down
16 changes: 14 additions & 2 deletions python/lsst/obs/lsst/lsstCamMapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import lsst.obs.base.yamlCamera as yamlCamera
import lsst.daf.persistence as dafPersist
import lsst.afw.cameraGeom as cameraGeom
from .translators import LsstCamTranslator

__all__ = ["LsstCamMapper", "LsstCamMakeRawVisitInfo"]

Expand All @@ -43,6 +44,10 @@ class LsstCamMakeRawVisitInfo(MakeRawVisitInfoViaObsInfo):
"""Make a VisitInfo from the FITS header of a raw image."""


class LsstCamRawVisitInfo(LsstCamMakeRawVisitInfo):
metadataTranslator = LsstCamTranslator


def assemble_raw(dataId, componentInfo, cls):
"""Called by the butler to construct the composite type "raw".
Expand Down Expand Up @@ -202,8 +207,8 @@ def getWcsFromDetector(detector, boresight, rotation=0*geom.degrees, flipX=False
return wcs


class LsstCamMapper(CameraMapper):
"""The Mapper for LsstCam.
class LsstCamBaseMapper(CameraMapper):
"""The Base Mapper for all LSST-style instruments.
"""

packageName = 'obs_lsst'
Expand Down Expand Up @@ -537,3 +542,10 @@ def std_raw(self, item, dataId, filter=True):
return self._standardizeExposure(self.exposures['raw'], item, dataId, trimmed=False,
setVisitInfo=False, # it's already set, and the metadata's stripped
filter=filter)


class LsstCamMapper(LsstCamBaseMapper):
"""The mapper for lsstCam."""
translatorClass = LsstCamTranslator
MakeRawVisitInfoClass = LsstCamRawVisitInfo
_cameraName = "lsstCam"
2 changes: 1 addition & 1 deletion tests/test_lsstCam.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def setUp(self):
map_python_std_type = lsst.afw.image.ExposureF
map_cpp_type = 'DecoratedImageF'
map_storage_name = 'FitsStorage'
metadata_output_path = os.path.join("processCcd_metadata/2019031900001-NONE/R10/",
metadata_output_path = os.path.join("processCcd_metadata/2019031900001-NONE/R10",
"processCcdMetadata_2019031900001-NONE-R10-S02-det029.yaml")
raw_filename = '2019031900001-R10-S02-det029-000.fits'
default_level = 'visit'
Expand Down
28 changes: 27 additions & 1 deletion tests/test_parsetask.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from lsst.obs.lsst.phosim import PhosimParseTask
from lsst.obs.lsst.imsim import ImsimParseTask
from lsst.obs.lsst.ucd import UcdParseTask
from lsst.obs.lsst.ingest import LsstCamParseTask

TESTDIR = os.path.abspath(os.path.dirname(__file__))
ROOTDIR = os.path.normpath(os.path.join(TESTDIR, os.path.pardir))
Expand Down Expand Up @@ -62,7 +63,9 @@ def _constructParseTask(self, configdir, name, parseTaskClass):
"""
ingestConfig = IngestConfig()
ingestConfig.load(os.path.join(configdir, "ingest.py"))
ingestConfig.load(os.path.join(configdir, name, "ingest.py"))
specificPath = os.path.join(configdir, name, "ingest.py")
if os.path.exists(specificPath):
ingestConfig.load(specificPath)
parser = parseTaskClass(ingestConfig.parse, name=name)
return parser

Expand Down Expand Up @@ -340,6 +343,29 @@ def test_parsetask_ucd_translator(self):
wl = parseTask.translate_testSeqNum(md)
self.assertEqual(wl, 5)

def test_parsetask_lsstCam_translator(self):
"""Run the gen 2 metadata extraction code for lsstCam"""
test_data = (("raw/20190319/R10/2019031900001-R10-S02-det029-000.fits",
dict(
expTime=0.0,
object='UNKNOWN',
imageType='BIAS',
testType='BIAS',
filter='NONE',
lsstSerial='ITL-3800C-041',
date='2019-03-19T15:50:28.145',
dateObs='2019-03-19T15:50:28.145',
run='20190319',
visit=2019031900001,
wavelength=-666,
raftName='R10',
detectorName='S02',
detector=29,
snap=0,
)),
)
self.assertParseCompare(DATADIR, CONFIGDIR, "lsstCam", LsstCamParseTask, test_data)


if __name__ == "__main__":
unittest.main()

0 comments on commit 9224bbc

Please sign in to comment.