Skip to content

Commit

Permalink
Enforce Astropy compatible units
Browse files Browse the repository at this point in the history
An optional (but default on) checkUnits is added to the constructors of:

- CharacterizeImageTask
- CalibrateTask
- MeasureMergedCoaddSourcesTask
  • Loading branch information
Pim Schellart authored and Pim Schellart committed May 9, 2016
1 parent f5dc404 commit 205f145
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions python/lsst/pipe/tasks/calibrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ class CalibrateConfig(pexConfig.Config):
default = 3,
doc = "Match radius for matching icSourceCat objects to sourceCat objects (pixels)",
)
checkUnitsParseStrict = pexConfig.Field(
doc = "Strictness of Astropy unit compatibility check, can be 'raise', 'warn' or 'silent'",
dtype = str,
default = "raise",
)

def setDefaults(self):
pexConfig.Config.setDefaults(self)
Expand Down Expand Up @@ -269,6 +274,7 @@ def __init__(self, icSourceSchema=None, **kwargs):
if self.schemaMapper is not None:
# finalize the schema
self.schema = self.schemaMapper.getOutputSchema()
self.schema.checkUnits(parse_strict=self.config.checkUnitsParseStrict)

@pipeBase.timeMethod
def run(self, dataRef, exposure=None, background=None, icSourceCat=None, doUnpersist=True):
Expand Down
6 changes: 6 additions & 0 deletions python/lsst/pipe/tasks/characterizeImage.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ class CharacterizeImageConfig(pexConfig.Config):
target = RepairTask,
doc = "Remove cosmic rays",
)
checkUnitsParseStrict = pexConfig.Field(
doc = "Strictness of Astropy unit compatibility check, can be 'raise', 'warn' or 'silent'",
dtype = str,
default = "raise",
)

def setDefaults(self):
pexConfig.Config.setDefaults(self)
Expand Down Expand Up @@ -253,6 +258,7 @@ def __init__(self, schema=None, **kwargs):
self.makeSubtask("detectAndMeasure", schema=self.schema)
self._initialFrame = getDebugFrame(self._display, "frame") or 1
self._frame = self._initialFrame
self.schema.checkUnits(parse_strict=self.config.checkUnitsParseStrict)

@pipeBase.timeMethod
def run(self, dataRef, exposure=None, background=None, doUnpersist=True):
Expand Down
6 changes: 6 additions & 0 deletions python/lsst/pipe/tasks/multiBand.py
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,11 @@ class MeasureMergedCoaddSourcesConfig(Config):
doMatchSources = Field(dtype=bool, default=True, doc="Match sources to reference catalog?")
astrometry = ConfigurableField(target=AstrometryTask, doc="Astrometric matching")
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'",
dtype = str,
default = "raise",
)

def setDefaults(self):
Config.setDefaults(self)
Expand Down Expand Up @@ -1017,6 +1022,7 @@ def __init__(self, butler=None, schema=None, peakSchema=None, **kwargs):
self.makeSubtask("astrometry", schema=self.schema)
if self.config.doPropagateFlags:
self.makeSubtask("propagateFlags", schema=self.schema)
self.schema.checkUnits(parse_strict=self.config.checkUnitsParseStrict)

def run(self, patchRef):
"""!
Expand Down

0 comments on commit 205f145

Please sign in to comment.