Skip to content

Commit

Permalink
Only handle coord errors if coord_err_unit is set
Browse files Browse the repository at this point in the history
  • Loading branch information
jdswinbank committed Jul 16, 2020
1 parent e497c0a commit 800a7a0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
14 changes: 8 additions & 6 deletions python/lsst/meas/algorithms/ingestIndexManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@ def __init__(self, filenames, config, file_reader, indexer,
self.htmRange = htmRange
self.addRefCatMetadata = addRefCatMetadata
self.log = log
# cache this to speed up coordinate conversions
self.coord_err_unit = u.Unit(self.config.coord_err_unit)
if self.config.coord_err_unit is not None:
# cache this to speed up coordinate conversions
self.coord_err_unit = u.Unit(self.config.coord_err_unit)

def run(self, inputFiles):
"""Index a set of input files from a reference catalog, and write the
Expand Down Expand Up @@ -270,10 +271,11 @@ def _getCoordErr(self, inputData, ):
may be more complicated in external catalogs.
"""
result = {}
result['coord_raErr'] = u.Quantity(inputData[self.config.ra_err_name],
self.coord_err_unit).to_value(u.radian)
result['coord_decErr'] = u.Quantity(inputData[self.config.dec_err_name],
self.coord_err_unit).to_value(u.radian)
if hasattr(self, "coord_err_unit"):
result['coord_raErr'] = u.Quantity(inputData[self.config.ra_err_name],
self.coord_err_unit).to_value(u.radian)
result['coord_decErr'] = u.Quantity(inputData[self.config.dec_err_name],
self.coord_err_unit).to_value(u.radian)
return result

def _setFlags(self, record, row):
Expand Down
17 changes: 9 additions & 8 deletions tests/ingestIndexTestBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,14 +269,15 @@ def checkAllRowsInRefcat(self, refObjLoader, skyCatalog, config):
rtol=1e-14, msg=msg)
self.assertFloatsAlmostEqual(row['dec_icrs'], cat[0]['coord_dec'].asDegrees(),
rtol=1e-14, msg=msg)
# coordinate errors are not lsst.geom.Angle, so we have to use the
# `units` field to convert them, and they are float32, so the tolerance is wider.
raErr = cat[0]['coord_raErr']*u.Unit(cat.schema['coord_raErr'].asField().getUnits())
decErr = cat[0]['coord_decErr']*u.Unit(cat.schema['coord_decErr'].asField().getUnits())
self.assertFloatsAlmostEqual(row['ra_err'], raErr.to_value(config.coord_err_unit),
rtol=1e-7, msg=msg)
self.assertFloatsAlmostEqual(row['dec_err'], decErr.to_value(config.coord_err_unit),
rtol=1e-7, msg=msg)
if config.coord_err_unit is not None:
# coordinate errors are not lsst.geom.Angle, so we have to use the
# `units` field to convert them, and they are float32, so the tolerance is wider.
raErr = cat[0]['coord_raErr']*u.Unit(cat.schema['coord_raErr'].asField().getUnits())
decErr = cat[0]['coord_decErr']*u.Unit(cat.schema['coord_decErr'].asField().getUnits())
self.assertFloatsAlmostEqual(row['ra_err'], raErr.to_value(config.coord_err_unit),
rtol=1e-7, msg=msg)
self.assertFloatsAlmostEqual(row['dec_err'], decErr.to_value(config.coord_err_unit),
rtol=1e-7, msg=msg)

if config.parallax_name is not None:
self.assertFloatsAlmostEqual(row['parallax'], cat[0]['parallax'].asArcseconds())
Expand Down

0 comments on commit 800a7a0

Please sign in to comment.