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-10156: Replace all uses of Calib with PhotoCalib #49

Merged
merged 2 commits into from
Apr 5, 2019
Merged
Changes from 1 commit
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
27 changes: 14 additions & 13 deletions python/lsst/meas/mosaic/mosaicTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import os
import math
import numpy
import astropy.units

import multiprocessing

Expand Down Expand Up @@ -392,19 +393,19 @@ def readSrc(self, dataRef):
newMatch = table.makeRecord()
newMatch.assign(match[0], mapper)
match[0] = newMatch
primaryFluxKey = refSchema.find(refSchema.join(self.cterm.primary, "flux")).key
secondaryFluxKey = refSchema.find(refSchema.join(self.cterm.secondary, "flux")).key
primaryFluxErrKey = refSchema.find(refSchema.join(self.cterm.primary, "fluxErr")).key
secondaryFluxErrKey = refSchema.find(refSchema.join(self.cterm.secondary, "fluxErr")).key
refFlux1 = numpy.array([m[0].get(primaryFluxKey) for m in matches])
refFlux2 = numpy.array([m[0].get(secondaryFluxKey) for m in matches])
refFluxErr1 = numpy.array([m[0].get(primaryFluxErrKey) for m in matches])
refFluxErr2 = numpy.array([m[0].get(secondaryFluxErrKey) for m in matches])
refMag1 = -2.5*numpy.log10(refFlux1)
refMag2 = -2.5*numpy.log10(refFlux2)
refMag = self.cterm.transformMags(refMag1, refMag2)
refFlux = numpy.power(10.0, -0.4*refMag)
refFluxErr = self.cterm.propagateFluxErrors(refFluxErr1, refFluxErr2)

# extract the matched refCat as a Catalog for the colorterm code
refCat = afwTable.SimpleCatalog(matches[0].first.schema)
refCat.reserve(len(matches))
for x in matches:
record = refCat.addNew()
record.assign(x.first)

refMag, refMagErr = self.cterm.getCorrectedMagnitudes(refCat,
afwImage.Filter(calexp_md).getName())
# NOTE: mosaic assumes fluxes are in Jy
refFlux = (refMag*astropy.units.ABmag).to_value(astropy.units.Jy)

Choose a reason for hiding this comment

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

This is a weird mix of astropy to compute the refFlux and the stack to compute refFluxErr.
Does afwImage.fluxFromABMag work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm trying to get rid of all uses of that in the stack prior to deprecation. See DM-16903.

Unfortunately, astropy doesn't currently have a way to handle the error calculations directly (astropy.uncertainty isn't finished yet), otherwise I would have replaced the other one too.

refFluxErr = afwImage.fluxErrFromABMagErr(refMagErr, refMag)
matches = [self.setCatFlux(m, flux, fluxKey, fluxErr, fluxErrKey) for
m, flux, fluxErr in zip(matches, refFlux, refFluxErr) if flux == flux]
else:
Expand Down