24 from collections
import Iterable
26 from lsst.afw.table
import SourceCatalog
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()
54 noiseReplacerConf = NoiseReplacerConfig()
55 noiseReplacerConf.noiseSeedMultiplier = \
56 algMetadata.get(SFMT.NOISE_SEED_MULTIPLIER)
57 noiseReplacerConf.noiseSource = algMetadata.get(SFMT.NOISE_SOURCE)
58 noiseReplacerConf.noiseOffset = algMetadata.get(SFMT.NOISE_OFFSET)
60 footprints = {src.getId(): (src.getParent(), src.getFootprint())
64 exposureId = algMetadata.get(SFMT.NOISE_EXPOSURE_ID)
68 noiseReplacer = NoiseReplacer(noiseReplacerConf, exposure, footprints,
69 exposureId=exposureId)
74 """ Creates a catalog prepopulated with ids
76 This function is used to generate a SourceCatalog containing blank records
77 with Ids specified in the idList parameter
79 This function is primarily used when rerunning measurements on a footprint.
80 Specifying ids in a new measurement catalog which correspond to ids in an
81 old catalog makes comparing results much easier.
85 schema : lsst.afw.table.Schema
86 Schema used to describe the fields in the resulting SourceCatalog
88 oldCatalog : lsst.afw.table.SourceCatalog
89 Catalog containing previous measurements.
92 Python iterable whose values should be numbers corresponding to
93 measurement ids, ids must exist in the oldCatalog
96 Python iterable whose entries should be strings corresponding to schema
97 keys that exist in both the old catalog and input schema. Fields listed
98 will be copied from the old catalog into the new catalog.
102 measCat : lsst.afw.table.SourceCatalog
103 SourceCatalog prepopulated with entries corresponding to the ids
109 if not isinstance(fields, Iterable):
110 raise RuntimeError(
"fields list must be an iterable with string"
113 if entry
not in schema:
114 schema.addField(oldCatalog.schema.find(entry).field)
116 measCat = SourceCatalog(schema)
118 oldSrc = oldCatalog.find(srcId)
119 src = measCat.addNew()
121 src.setFootprint(oldSrc.getFootprint())
122 src.setParent(oldSrc.getParent())
123 src.setCoord(oldSrc.getCoord())
125 src[entry] = oldSrc[entry]