Skip to content

Commit

Permalink
Cleanups to versioning in the metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
parejkoj committed Apr 5, 2019
1 parent e0ee27f commit 165f6c3
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions bin.src/convert_refcat_to_nJy.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import lsst.afw.table
from lsst.meas.algorithms import DatasetConfig
from lsst.meas.algorithms.loadReferenceObjects import convertToNanojansky, hasNanojanskyFluxUnits
from lsst.meas.algorithms.ingestIndexReferenceTask import addRefCatMetadata
import lsst.log


Expand Down Expand Up @@ -78,6 +79,7 @@ def process_one(filename, write=False, quiet=False):
output = convertToNanojansky(catalog, log, doConvert=write)

if write:
addRefCatMetadata(output)
output.writeFits(filename)
log.info(f"Wrote: {filename}")

Expand Down
6 changes: 4 additions & 2 deletions python/lsst/meas/algorithms/ingestIndexReferenceTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,13 @@ def addRefCatMetadata(catalog):
Parameters
----------
catalog - `~lsst.afw.table.SimpleCatalog`
catalog : `lsst.afw.table.SimpleCatalog`
Catalog to which metadata should be attached. Will be modified
in-place.
"""
md = PropertyList()
md = catalog.getMetadata()
if md is None:
md = PropertyList()
md.set("REFCAT_FORMAT_VERSION", LATEST_FORMAT_VERSION)
catalog.setMetadata(md)

Expand Down
4 changes: 2 additions & 2 deletions python/lsst/meas/algorithms/loadIndexedReferenceObjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ def loadSkyCircle(self, ctrCoord, radius, filterName=None, epoch=None):
# too, and should be consistent with the version in the config.
catVersion = getFormatVersionFromRefCat(refCat)
if catVersion != self.dataset_config.format_version:
raise RuntimeError(f"Format version in reference catalog ({catVersion}) does "
f"not match configuration ({self.dataset_config.format_version})")
raise RuntimeError(f"Format version in reference catalog ({catVersion}) does not match"
f" format_version field in config ({self.dataset_config.format_version})")

self._addFluxAliases(refCat.schema)
fluxField = getRefFluxField(schema=refCat.schema, filterName=filterName)
Expand Down
2 changes: 0 additions & 2 deletions python/lsst/meas/algorithms/loadReferenceObjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,8 @@ def convertToNanojansky(catalog, log, doConvert=True):
fluxFieldsStr = '; '.join("(%s, '%s')" % (field.getName(), field.getUnits()) for field in input_fields)

if doConvert:
from .ingestIndexReferenceTask import addRefCatMetadata # workaround for circular dependency
newSchema = mapper.getOutputSchema()
output = lsst.afw.table.SimpleCatalog(newSchema)
addRefCatMetadata(output)
output.extend(catalog, mapper=mapper)
for field in output_fields:
output[field.getName()] *= 1e9
Expand Down

0 comments on commit 165f6c3

Please sign in to comment.