Skip to content

Commit

Permalink
Merge pull request #47 from lsst/tickets/DM-5642
Browse files Browse the repository at this point in the history
Use and enforce Astropy compliant units
  • Loading branch information
Pim Schellart authored and Pim Schellart committed May 10, 2016
2 parents 45caa2e + 0fd9bee commit 8d87e0e
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 5 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
2 changes: 1 addition & 1 deletion python/lsst/pipe/tasks/mocks/mockObject.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def __init__(self, **kwds):
lsst.pipe.base.Task.__init__(self, **kwds)
self.schema = lsst.afw.table.SimpleTable.makeMinimalSchema()
self.center = lsst.afw.table.Point2DKey.addFields(self.schema, "center",
"center position in tract WCS", "pixels")
"center position in tract WCS", "pixel")
self.magKey = self.schema.addField("mag", type=float, doc="exact true magnitude")
self.rng = numpy.random.RandomState(self.config.seed)

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
4 changes: 2 additions & 2 deletions tests/data/v695833-e0-c000-a00.sci.fits

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/data/v695833-e0-c000.xy.fits

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/testRegister.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def create(self):

# Generate catalogues
schema = afwTable.SourceTable.makeMinimalSchema()
centroidKey = afwTable.Point2DKey.addFields(schema, "center", "center", "pixels")
centroidKey = afwTable.Point2DKey.addFields(schema, "center", "center", "pixel")

def newCatalog():
catalog = afwTable.SourceCatalog(schema)
Expand Down

0 comments on commit 8d87e0e

Please sign in to comment.