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

tickets/DM-18051 Add support for other date lookup keys #141

Merged
merged 1 commit into from
Apr 3, 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
11 changes: 6 additions & 5 deletions python/lsst/obs/base/cameraMapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,7 @@ def bypass_defects(self, datasetType, pythonType, butlerLocation, dataId):
"""
detectorName = self._extractDetectorName(dataId)
defectsFitsPath = butlerLocation.locationList[0]

with fits.open(defectsFitsPath) as hduList:
for hdu in hduList[1:]:
if hdu.header["name"] != detectorName:
Expand Down Expand Up @@ -1113,7 +1114,7 @@ def _standardizeExposure(self, mapping, item, dataId, filter=True,

return item

def _defectLookup(self, dataId):
def _defectLookup(self, dataId, dateKey='taiObs'):
"""Find the defects for a given CCD.

Parameters
Expand All @@ -1135,24 +1136,24 @@ def _defectLookup(self, dataId):

dataIdForLookup = {'visit': dataId['visit']}
# .lookup will fail in a posix registry because there is no template to provide.
rows = self.registry.lookup(('taiObs'), ('raw_visit'), dataIdForLookup)
rows = self.registry.lookup((dateKey), ('raw_visit'), dataIdForLookup)
if len(rows) == 0:
return None
assert len(rows) == 1
taiObs = rows[0][0]
dayObs = rows[0][0]

# Lookup the defects for this CCD serial number that are valid at the exposure midpoint.
rows = self.defectRegistry.executeQuery(("path",), ("defect",),
[(ccdKey, "?")],
("DATETIME(?)", "DATETIME(validStart)", "DATETIME(validEnd)"),
(ccdVal, taiObs))
(ccdVal, dayObs))
if not rows or len(rows) == 0:
return None
if len(rows) == 1:
return os.path.join(self.defectPath, rows[0][0])
else:
raise RuntimeError("Querying for defects (%s, %s) returns %d files: %s" %
(ccdVal, taiObs, len(rows), ", ".join([_[0] for _ in rows])))
(ccdVal, dayObs, len(rows), ", ".join([_[0] for _ in rows])))

def _makeCamera(self, policy, repositoryDir):
"""Make a camera (instance of lsst.afw.cameraGeom.Camera) describing
Expand Down