Skip to content

Commit

Permalink
calibrate, measureCoaddSources: add option to write denormalized matches
Browse files Browse the repository at this point in the history
This writes the matches in a format that uses more disk space but
is much more convenient to read.
  • Loading branch information
PaulPrice committed Mar 21, 2017
1 parent a178704 commit ffbfd72
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
12 changes: 11 additions & 1 deletion python/lsst/pipe/tasks/calibrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from lsst.afw.math import BackgroundList
from lsst.afw.table import IdFactory, SourceTable
from lsst.meas.algorithms import SourceDetectionTask
from lsst.meas.astrom import AstrometryTask, displayAstrometry, createMatchMetadata
from lsst.meas.astrom import AstrometryTask, displayAstrometry, createMatchMetadata, denormalizedMatches
from lsst.meas.base import SingleFrameMeasurementTask, ApplyApCorrTask, CatalogCalculationTask
from lsst.meas.deblender import SourceDeblendTask
from .photoCal import PhotoCalTask
Expand All @@ -59,6 +59,13 @@ class CalibrateConfig(pexConfig.Config):
default=True,
doc="Write reference matches (ignored if doWrite false)?",
)
doWriteMatchesDenormalized = pexConfig.Field(
dtype=bool,
default=False,
doc=("Write reference matches in denormalized format? "
"This format uses more disk space, but is more convenient to read. "
"Ignored if doWriteMatches=False or doWrite=False."),
)
doAstrometry = pexConfig.Field(
dtype=bool,
default=True,
Expand Down Expand Up @@ -508,6 +515,9 @@ def writeOutputs(self, dataRef, exposure, background, sourceCat, astromMatches,
normalizedMatches = afwTable.packMatches(astromMatches)
normalizedMatches.table.setMetadata(matchMeta)
dataRef.put(normalizedMatches, "srcMatch")
if self.config.doWriteMatchesDenormalized:
denormMatches = denormalizedMatches(astromMatches, matchMeta)
dataRef.put(denormMatches, "srcMatchFull")
dataRef.put(exposure, "calexp")
dataRef.put(background, "calexpBackground")

Expand Down
12 changes: 11 additions & 1 deletion python/lsst/pipe/tasks/multiBand.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from lsst.meas.base import SingleFrameMeasurementTask, ApplyApCorrTask, CatalogCalculationTask
from lsst.meas.deblender import SourceDeblendTask
from lsst.pipe.tasks.coaddBase import getSkyInfo, scaleVariance
from lsst.meas.astrom import DirectMatchTask
from lsst.meas.astrom import DirectMatchTask, denormalizedMatches
from lsst.pipe.tasks.setPrimaryFlags import SetPrimaryFlagsTask
from lsst.pipe.tasks.propagateVisitFlags import PropagateVisitFlagsTask
import lsst.afw.image as afwImage
Expand Down Expand Up @@ -858,6 +858,12 @@ class MeasureMergedCoaddSourcesConfig(Config):
propagateFlags = ConfigurableField(target=PropagateVisitFlagsTask, doc="Propagate visit flags to coadd")
doMatchSources = Field(dtype=bool, default=True, doc="Match sources to reference catalog?")
match = ConfigurableField(target=DirectMatchTask, doc="Matching to reference catalog")
doWriteMatchesDenormalized = Field(
dtype=bool,
default=False,
doc=("Write reference matches in denormalized format? "
"This format uses more disk space, but is more convenient to read."),
)
coaddName = Field(dtype=str, default="deep", doc="Name of coadd")
checkUnitsParseStrict = Field(
doc="Strictness of Astropy unit compatibility check, can be 'raise', 'warn' or 'silent'",
Expand Down Expand Up @@ -1146,6 +1152,10 @@ def writeMatches(self, dataRef, exposure, sources):
matches = afwTable.packMatches(result.matches)
matches.table.setMetadata(result.matchMeta)
dataRef.put(matches, self.config.coaddName + "Coadd_srcMatch")
if self.config.doWriteMatchesDenormalized:
denormMatches = denormalizedMatches(result.matches, result.matchMeta)
dataRef.put(denormMatches, self.config.coaddName + "Coadd_srcMatchFull")


def write(self, dataRef, sources):
"""!
Expand Down

0 comments on commit ffbfd72

Please sign in to comment.