24 from collections
import Iterable
32 """ Recreate NoiseReplacer used in measurement 34 Given a measurement catalog and the exposure on which the measurements were 35 made, reconstruct the NoiseReplacer object that was used to mask out 36 sources during measurement. 40 exposure : lsst.awf.exposure.Exposure 41 The exposure on which measurements were made 43 meaCat : lsst.afw.table.SourceCatalog 44 Catalog containing the outputs of measurements on each source 48 noiseReplacer : lsst.meas.base.NoiseReplacer 49 Object used to replace and or restore sources in the exposure with 53 algMetadata = measCat.getMetadata()
55 noiseReplacerConf.noiseSeedMultiplier = \
56 algMetadata.getScalar(SFMT.NOISE_SEED_MULTIPLIER)
57 noiseReplacerConf.noiseSource = algMetadata.getScalar(SFMT.NOISE_SOURCE)
58 noiseReplacerConf.noiseOffset = algMetadata.getScalar(SFMT.NOISE_OFFSET)
60 footprints = {src.getId(): (src.getParent(), src.getFootprint())
64 exposureId = algMetadata.getScalar(SFMT.NOISE_EXPOSURE_ID)
68 noiseReplacer =
NoiseReplacer(noiseReplacerConf, exposure, footprints,
69 exposureId=exposureId)
74 resetParents=True, addParents=False):
75 """ Creates a catalog prepopulated with ids 77 This function is used to generate a SourceCatalog containing blank records 78 with Ids specified in the idList parameter 80 This function is primarily used when rerunning measurements on a footprint. 81 Specifying ids in a new measurement catalog which correspond to ids in an 82 old catalog makes comparing results much easier. 84 The resetParents and addParents options are needed because 85 lsst.meas.base.SingleFrameMeasurementTask.runPlugins() will skip child 86 objects whose parents are not in the catalog. 90 schema : lsst.afw.table.Schema 91 Schema used to describe the fields in the resulting SourceCatalog 93 oldCatalog : lsst.afw.table.SourceCatalog 94 Catalog containing previous measurements. 97 Python iterable whose values should be numbers corresponding to 98 measurement ids, ids must exist in the oldCatalog 101 Python iterable whose entries should be strings corresponding to schema 102 keys that exist in both the old catalog and input schema. Fields listed 103 will be copied from the old catalog into the new catalog. 105 resetParents: boolean 106 Flag to toggle whether child objects whose parents are not in the 107 idList should have their parents reset to zero. 110 Flag to toggle whether parents of child objects will be added to the 111 idList (if not already present). 115 measCat : lsst.afw.table.SourceCatalog 116 SourceCatalog prepopulated with entries corresponding to the ids 120 if not isinstance(schema, Schema):
121 raise RuntimeError(
"schema must be an instance of " 122 "lsst.afw.table.Schema")
124 if not isinstance(oldCatalog, SourceCatalog):
125 raise RuntimeError(
"oldCatalog must be an instance of " 126 "lsst.afw.table.SourceCatalogiterable")
130 if not isinstance(fields, Iterable):
131 raise RuntimeError(
"fields list must be an iterable with string" 134 if entry
not in schema:
135 schema.addField(oldCatalog.schema.find(entry).field)
141 parentId = oldCatalog.find(srcId).getParent()
143 newIdList.add(parentId)
145 idList = sorted(idList)
147 measCat = SourceCatalog(schema)
149 oldSrc = oldCatalog.find(srcId)
150 src = measCat.addNew()
152 src.setFootprint(oldSrc.getFootprint())
153 parent = oldSrc.getParent()
154 if resetParents
and parent
and parent
not in idList:
156 src.setParent(parent)
157 src.setCoord(oldSrc.getCoord())
159 src[entry] = oldSrc[entry]
def rebuildNoiseReplacer(exposure, measCat)
def makeRerunCatalog(schema, oldCatalog, idList, fields=None, resetParents=True, addParents=False)
Class that handles replacing sources with noise during measurement.