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-12029 Use butler metadata getters #55

Merged
merged 2 commits into from
Oct 17, 2017
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
21 changes: 11 additions & 10 deletions python/lsst/jointcal/jointcal.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,16 +232,17 @@ def _build_ccdImage(self, dataRef, associations, jointcalControl):
visit = dataRef.dataId["visit"]
else:
visit = dataRef.getButler().queryMetadata("calexp", ("visit"), dataRef.dataId)[0]

src = dataRef.get("src", flags=lsst.afw.table.SOURCE_IO_NO_FOOTPRINTS, immediate=True)
calexp = dataRef.get("calexp", immediate=True)
visitInfo = calexp.getInfo().getVisitInfo()
detector = calexp.getDetector()
ccdname = detector.getId()

calib = calexp.getCalib()
tanWcs = calexp.getWcs()
bbox = calexp.getBBox()
filt = calexp.getInfo().getFilter().getName()
visitInfo = dataRef.get('calexp_visitInfo')
detector = dataRef.get('calexp_detector')
ccdname = detector.getId()
calib = dataRef.get('calexp_calib')
tanWcs = dataRef.get('calexp_wcs')
bbox = dataRef.get('calexp_bbox')
filt = dataRef.get('calexp_filter')
filterName = filt.getName()
fluxMag0 = calib.getFluxMag0()
photoCalib = afwImage.PhotoCalib(1.0/fluxMag0[0], fluxMag0[1]/fluxMag0[0]**2, bbox)

Expand All @@ -251,12 +252,12 @@ def _build_ccdImage(self, dataRef, associations, jointcalControl):
self.log.warn("no stars selected in ", visit, ccdname)
return tanWcs
self.log.info("%d stars selected in visit %d ccd %d", len(goodSrc.sourceCat), visit, ccdname)
associations.addImage(goodSrc.sourceCat, tanWcs, visitInfo, bbox, filt, photoCalib, detector,
associations.addImage(goodSrc.sourceCat, tanWcs, visitInfo, bbox, filterName, photoCalib, detector,
visit, ccdname, jointcalControl)

Result = collections.namedtuple('Result_from_build_CcdImage', ('wcs', 'key', 'filter'))
Key = collections.namedtuple('Key', ('visit', 'ccd'))
return Result(tanWcs, Key(visit, ccdname), filt)
return Result(tanWcs, Key(visit, ccdname), filterName)

@pipeBase.timeMethod
def run(self, dataRefs, profile_jointcal=False):
Expand Down
6 changes: 3 additions & 3 deletions python/lsst/jointcal/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ def compute_rms(self, data_refs, reference):
Post-jointcal photometric repeatability (PA1 from the SRD).
"""

# DECAM doesn't have "filter" in its registry, so we have to get filter names from VisitInfo.
self.filters = [ref.get('calexp').getInfo().getFilter().getName() for ref in data_refs]
# DECAM doesn't have "filter" in its registry, so we have to get the filter names directly.
self.filters = [ref.get('calexp_filter').getName() for ref in data_refs]
self.visits_per_dataRef = [ref.dataId['visit'] for ref in data_refs]

def compute(catalogs, photoCalibs):
Expand Down Expand Up @@ -118,7 +118,7 @@ def compute(catalogs, photoCalibs):
old_calibs = []
if self.do_photometry:
for ref in data_refs:
calib = ref.get('calexp').getCalib()
calib = ref.get('calexp_calib')
fluxMag0 = calib.getFluxMag0()
old_calibs.append(lsst.afw.image.PhotoCalib(1.0/fluxMag0[0], fluxMag0[1]/fluxMag0[0]**2))

Expand Down