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-11922: Add hack to convert raft, sensor x,y to one int. Allows validate_drp to run on obs_lsstSim #70

Merged
merged 1 commit into from
Feb 6, 2018
Merged
Show file tree
Hide file tree
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
9 changes: 8 additions & 1 deletion python/lsst/validate/drp/matchreduce.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
from lsst.afw.fits import FitsError
from lsst.validate.base import BlobBase

from .util import (getCcdKeyName, positionRmsFromCat, ellipticity_from_cat)
from .util import (getCcdKeyName, raftSensorToInt, positionRmsFromCat,
ellipticity_from_cat)


__all__ = ['MatchedMultiVisitDataset']
Expand Down Expand Up @@ -205,6 +206,12 @@ def _loadAndMatchCatalogs(self, repo, dataIds, matchRadius,

ccdKeyName = getCcdKeyName(dataIds[0])

# Hack to support raft and sensor 0,1 IDs as ints for multimatch
if ccdKeyName == 'sensor':
ccdKeyName = 'raft_sensor_int'
for vId in dataIds:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this can work. Aren't you shadowing the dictionary you are trying to assign with the iterator variable?
Nevermind, I see now. you are updating the data ids. Disregard the above.

vId[ccdKeyName] = raftSensorToInt(vId)

schema = butler.get(dataset + "_schema").schema
mapper = SchemaMapper(schema)
mapper.addMinimalSchema(schema)
Expand Down
18 changes: 17 additions & 1 deletion python/lsst/validate/drp/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ def getCcdKeyName(dataid):
the different amps/ccds in the same exposure. This function looks
through the reference dataId to locate a field that could be the one.
"""
possibleCcdFieldNames = ['ccd', 'ccdnum', 'camcol']
possibleCcdFieldNames = ['ccd', 'ccdnum', 'camcol', 'sensor']

for name in possibleCcdFieldNames:
if name in dataid:
Expand All @@ -351,6 +351,22 @@ def getCcdKeyName(dataid):
return 'ccd'


def raftSensorToInt(vId):
"""Construct an int that encodes raft, sensor coordinates.

>>> vId = {'filter': 'y', 'raft': '2,2', 'sensor': '1,2', 'visit': 307}
>>> raftSensorToInt(vId)
2212
"""
def pair_to_int(tuple_string):
x, y = tuple_string.split(',')
return 10 * int(x) + 1 * int(y)

raft_int = pair_to_int(vId['raft'])
sensor_int = pair_to_int(vId['sensor'])
return 100*raft_int + sensor_int


def repoNameToPrefix(repo):
"""Generate a base prefix for plots based on the repo name.

Expand Down