Skip to content

Commit

Permalink
calibrate: make astrometry failures non-fatal
Browse files Browse the repository at this point in the history
In many cases, we can limp along without astrometry succeeding, so
there's no need to give up completely.  In some cases, we want to
ensure that we succeed, so added config variable 'requireAstrometry'
to allow a RumtimeError in astrometry to be fatal.
  • Loading branch information
PaulPrice committed Jul 8, 2013
1 parent 886d41a commit e9db5c0
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions python/lsst/pipe/tasks/calibrate.py
Expand Up @@ -78,6 +78,11 @@ class CalibrateConfig(pexConfig.Config):
doc = "Compute photometric zeropoint?",
default = True,
)
requireAstrometry = pexConfig.Field(
dtype = bool,
doc = "Require astrometry to succeed, if activated?",
default = False,
)
background = pexConfig.ConfigField(
dtype = measAlg.estimateBackground.ConfigClass,
doc = "Background estimation configuration"
Expand Down Expand Up @@ -201,13 +206,17 @@ def run(self, exposure, defects=None, idFactory=None):
if self.config.doPsf:
self.initialMeasurement.measure(exposure, sources)

matches = None
if self.config.doAstrometry:
astromRet = self.astrometry.run(exposure, sources)
matches = astromRet.matches
else:
# If doAstrometry is False, we force the Star Selector to either make them itself
# or hope it doesn't need them.
matches = None
try:
astromRet = self.astrometry.run(exposure, sources)
matches = astromRet.matches
except RuntimeError as e:
if self.config.requireAstrometry:
raise
self.log.warn("Unable to perform astrometry (%s): attempting to proceed", e)
psfRet = self.measurePsf.run(exposure, sources, matches=matches)
cellSet = psfRet.cellSet
psf = psfRet.psf
Expand Down Expand Up @@ -240,12 +249,16 @@ def run(self, exposure, defects=None, idFactory=None):
if self.config.doAstrometry or self.config.doPhotoCal:
self.measurement.run(exposure, sources)

matches, matchMeta = None, None
if self.config.doAstrometry:
astromRet = self.astrometry.run(exposure, sources)
matches = astromRet.matches
matchMeta = astromRet.matchMeta
else:
matches, matchMeta = None, None
try:
astromRet = self.astrometry.run(exposure, sources)
matches = astromRet.matches
matchMeta = astromRet.matchMeta
except RuntimeError as e:
if self.config.requireAstrometry:
raise
self.log.warn("Unable to perform astrometry (%s): attempting to proceed", e)

if self.config.doPhotoCal:
assert(matches is not None)
Expand Down

0 comments on commit e9db5c0

Please sign in to comment.