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-15916: Make meas_mosaic backwards compatible with *_flux --> *_instFlux rename #47

Merged
merged 4 commits into from
Oct 22, 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
17 changes: 15 additions & 2 deletions python/lsst/meas/mosaic/mosaicTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,12 @@ class MosaicConfig(pexConfig.Config):
default=None,
optional=True)
allowMixedFilters = pexConfig.Field(dtype=bool, default=False, doc="Allow multiple filters in input?")
flagsToAlias = pexConfig.DictField(
doc="List of flags to alias to old, pre-RFC-498, names for backwards compatibility",
keytype=str,
itemtype=str,
default={"calib_psf_used": "calib_psfUsed", "calib_psf_candidate": "calib_psfCandidate",
"calib_astrometry_used": "calib_astrometryUsed"})

def setDefaults(self):
self.loadAstrom.ref_dataset_name = "ps1_pv3_3pi_20170110"
Expand Down Expand Up @@ -329,11 +335,16 @@ def readSrc(self, dataRef):
sources = mosaicUtils.rotatePixelCoords(sources, dims.getX(), dims.getY(),
nQuarter)

# Set the aliap map for the source catalog
if self.config.srcSchemaMap is not None and hscRun is not None:
# Set some alias maps for the source catalog where needed for
# backwards compatibility
if self.config.srcSchemaMap and hscRun:
aliasMap = sources.schema.getAliasMap()
for lsstName, otherName in self.config.srcSchemaMap.items():
aliasMap.set(lsstName, otherName)
if self.config.flagsToAlias and "calib_psfUsed" in sources.schema:
aliasMap = sources.schema.getAliasMap()
for lsstName, otherName in self.config.flagsToAlias.items():
aliasMap.set(lsstName, otherName)

refObjLoader = self.config.loadAstrom.apply(butler=dataRef.getButler())
srcMatch = dataRef.get("srcMatch", immediate=True)
Expand Down Expand Up @@ -869,6 +880,8 @@ def run(self, dataRefList, tractInfo, ct=None, debug=False, diagDir=".",

sourceSet, matchList, dataRefListUsed = self.readCatalog(dataRefListToUse, ct, numCoresForReadSource,
readTimeout, verbose)
if not matchList:
raise RuntimeError("No reference source matches found")

dataRefListToOutput = list(set(dataRefListUsed) & set(dataRefListOverlapWithTract))

Expand Down
22 changes: 13 additions & 9 deletions python/lsst/meas/mosaic/updateExposure.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,11 @@ def applyMosaicResultsCatalog(dataRef, catalog, addCorrection=True):
catalog = outCatalog

fluxKeys, errKeys = getFluxKeys(catalog.schema, hscRun=hscRun)
for name, key in fluxKeys.items():
for name, key in list(fluxKeys.items()) + list(errKeys.items()):
# Note this skips correcting the aperture fluxes in HSC processed data, but that's ok because
# we are using the flux_sinc as our comparison to base_CircularApertureFlux_12_0_flux
if key.subfields is None:
catalog[key][:] *= corr
if name in errKeys:
catalog[errKeys[name]][:] *= corr

# Now rotate them back to the LSST coord system
if hscRun is None:
Expand Down Expand Up @@ -269,14 +267,20 @@ def getFluxKeys(schema, hscRun=None):

Both are returned as dicts indexed on the flux name (e.g. "base_PsfFlux" or "base_CmodelFlux").
"""
schemaKeys = dict((s.field.getName(), s.key) for s in schema)

if hscRun is None:
fluxKeys = dict((name, key) for name, key in schemaKeys.items() if
re.search(r"^(\w+_instFlux)$", name) and key.getTypeString() != "Flag")
errKeys = dict((name + "Err", schemaKeys[name + "Err"]) for name in fluxKeys if
name + "Err" in schemaKeys)
fluxTypeStr = "_instFlux"
fluxSchemaItems = schema.extract("*" + fluxTypeStr)
# Do not include any flag fields (as determined by their type). Also exclude
# slot fields, as these would effectively duplicate whatever they point to.
fluxKeys = dict((name, schemaItem.key) for name, schemaItem in list(fluxSchemaItems.items()) if
schemaItem.field.getTypeString() != "Flag" and
not name.startswith("slot"))

errSchemaItems = schema.extract("*" + fluxTypeStr + "Err")
errKeys = dict((name, schemaItem.key) for name, schemaItem in list(errSchemaItems.items()) if
name[:-len("Err")] in fluxKeys)
else:
schemaKeys = dict((s.field.getName(), s.key) for s in schema)
fluxKeys = dict((name, key) for name, key in schemaKeys.items() if
re.search(r"^(flux\_\w+|\w+\_instFlux)$", name) and not
re.search(r"^(\w+\_apcorr)$", name) and name + "_err" in schemaKeys)
Expand Down