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-12909: fix bug in test code and linting errors #24

Merged
merged 2 commits into from
Dec 2, 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
35 changes: 20 additions & 15 deletions python/lsst/meas/mosaic/updateExposure.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@
import numpy

from . import getFCorImg, FluxFitParams, getJImg, calculateJacobian
from lsst.pipe.base import Struct
import lsst.afw.geom as afwGeom
import lsst.afw.table as afwTable
import lsst.afw.image as afwImage
import lsst.afw.math as afwMath
from lsst.afw.fits import FitsError
from lsst.pipe.base import Struct, TaskError
from . import utils as mosaicUtils

__all__ = ("applyMosaicResults", "getMosaicResults", "applyMosaicResultsExposure", "applyMosaicResultsCatalog",
"applyCalib")
__all__ = ("applyMosaicResults", "getMosaicResults", "applyMosaicResultsExposure",
"applyMosaicResultsCatalog", "applyCalib")


def applyMosaicResults(dataRef, calexp=None):
"""Deprecated function to apply the results to an exposure
Expand All @@ -42,6 +42,7 @@ def applyMosaicResults(dataRef, calexp=None):
"""
return applyMosaicResultsExposure(dataRef, calexp).exposure


def applyMosaicResultsExposure(dataRef, calexp=None):
"""Update an Exposure with the Wcs, Calib, and flux scaling from meas_mosaic.

Expand Down Expand Up @@ -84,6 +85,7 @@ def applyMosaicResultsExposure(dataRef, calexp=None):

return Struct(exposure=calexp, mosaic=mosaic)


def getFluxFitParams(dataRef):
"""Retrieve the flux correction parameters determined by meas_mosaic

Expand All @@ -104,15 +106,16 @@ def getFluxFitParams(dataRef):
wcs = getWcs(dataRef)

if hscRun is None:
detector = dataRef.get("camera")[dataRef.dataId["ccd"]]
nQuarter = detector.getOrientation().getNQuarter()
if nQuarter%4 != 0:
# Have to put this import here due to circular dependence in forcedPhotCcd.py in meas_base
import lsst.meas.astrom as measAstrom
dimensions = dataRef.get("calexp_bbox").getDimensions()
wcs = measAstrom.rotateWcsPixelsBy90(wcs, nQuarter, dimensions)
detector = dataRef.get("camera")[dataRef.dataId["ccd"]]
nQuarter = detector.getOrientation().getNQuarter()
if nQuarter%4 != 0:
# Have to put this import here due to circular dependence in forcedPhotCcd.py in meas_base
import lsst.meas.astrom as measAstrom
dimensions = dataRef.get("calexp_bbox").getDimensions()
wcs = measAstrom.rotateWcsPixelsBy90(wcs, nQuarter, dimensions)
return Struct(ffp=ffp, calib=calib, wcs=wcs)


def getWcs(dataRef):
"""Retrieve the Wcs determined by meas_mosaic

Expand All @@ -126,6 +129,7 @@ def getWcs(dataRef):
wcsHeader = dataRef.get("wcs_md", immediate=True)
return afwImage.makeWcs(wcsHeader)


def getMosaicResults(dataRef, dims=None):
"""Retrieve the results of meas_mosaic

Expand Down Expand Up @@ -248,14 +252,15 @@ def applyCalib(catalog, calib, hscRun=None):
if name in newErrKeys:
fluxErr = newCatalog[newErrKeys[name]]
magArray = numpy.array([calib.getMagnitude(f, e) for f, e in zip(flux, fluxErr)])
mag = magArray[:,0]
fluxErr[:] = magArray[:,1]
mag = magArray[:, 0]
fluxErr[:] = magArray[:, 1]
else:
mag = numpy.array([calib.getMagnitude(f) for f in flux])
flux[:] = mag

return newCatalog


def getFluxKeys(schema, hscRun=None):
"""Retrieve the flux and flux error keys from a schema

Expand All @@ -270,8 +275,8 @@ def getFluxKeys(schema, hscRun=None):
name + "Sigma" in schemaKeys)
else:
fluxKeys = dict((name, key) for name, key in schemaKeys.items() if
re.search(r"^(flux\_\w+|\w+\_flux)$", name)
and not re.search(r"^(\w+\_apcorr)$", name) and name + "_err" in schemaKeys)
re.search(r"^(flux\_\w+|\w+\_flux)$", name) and not
re.search(r"^(\w+\_apcorr)$", name) and name + "_err" in schemaKeys)
errKeys = dict((name + "_err" , schemaKeys[name + "_err"]) for name in fluxKeys if
name + "_err" in schemaKeys)

Expand Down
3 changes: 1 addition & 2 deletions tests/test_fluxFitBoundedField.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,6 @@ def setUp(self):
camera = {} # all we need from our mock camera is dict-like
# access to (Mock)Detectors.
calexpMetadata = lsst.daf.base.PropertyList()
calexpMetadata.set("NAXIS1", self.bbox.getWidth())
calexpMetadata.set("NAXIS2", self.bbox.getHeight())
for nQuarter, ccd in self.ccds.items():
fcrFilename = os.path.join(
DATA_DIR,
Expand All @@ -155,6 +153,7 @@ def setUp(self):
self.dataRefs[ccd].put(wcsMetadata, "wcs_md")
self.dataRefs[ccd].put(calexpMetadata, "calexp_md")
self.dataRefs[ccd].put(camera, "camera")
self.dataRefs[ccd].put(self.bbox, "calexp_bbox")

def tearDown(self):
del self.ffp
Expand Down