Skip to content

Commit

Permalink
Add <exposure>_detector dataset
Browse files Browse the repository at this point in the history
Pulls the detector from the camera object stored in the CameraMapper.
  • Loading branch information
PaulPrice committed Jul 24, 2017
1 parent d7ce2be commit 36725bc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
15 changes: 15 additions & 0 deletions python/lsst/obs/base/cameraMapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,21 @@ def setMethods(suffix, mapImpl=None, bypassImpl=None, queryImpl=None):
bypassImpl=lambda datasetType, pythonType, location, dataId:
afwImage.Filter(
afwImage.readMetadata(location.getLocationsWithRoot()[0])))
setMethods("detector",
mapImpl=lambda dataId, write=False:
dafPersist.ButlerLocation(
pythonType="lsst.afw.cameraGeom.CameraConfig",
cppType="Config",
storageName="Internal",
locationList="ignored",
dataId=dataId,
mapper=self,
storage=None,
),
bypassImpl=lambda datasetType, pythonType, location, dataId:
self.camera[self._extractDetectorName(dataId)]
)

if subPolicy["storage"] == "FitsCatalogStorage": # a FITS catalog
setMethods("md", bypassImpl=lambda datasetType, pythonType, location, dataId:
afwImage.readMetadata(os.path.join(location.getStorage().root,
Expand Down
8 changes: 7 additions & 1 deletion tests/testCameraMapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def _transformId(self, dataId):
return dataId

def _extractDetectorName(self, dataId):
return "Detector"
return "ccd00"

def std_x(self, item, dataId):
return float(item)
Expand Down Expand Up @@ -258,6 +258,12 @@ def testImage(self):
self.assertEqual(image.getHeight(), 400)
self.assertEqual(image.getWidth(), 300)

def testDetector(self):
mapper = MinMapper2(root=testDir)
butler = dafPersist.ButlerFactory(mapper=mapper).create()
detector = butler.get("raw_detector", ccd=0)
self.assertEqual(detector.getName(), "ccd00")

def testGzImage(self):
mapper = MinMapper2(root=testDir)
loc = mapper.map("someGz", dict(ccd=35))
Expand Down

0 comments on commit 36725bc

Please sign in to comment.