LSST Applications 27.0.0,g0265f82a02+469cd937ee,g02d81e74bb+21ad69e7e1,g1470d8bcf6+cbe83ee85a,g2079a07aa2+e67c6346a6,g212a7c68fe+04a9158687,g2305ad1205+94392ce272,g295015adf3+81dd352a9d,g2bbee38e9b+469cd937ee,g337abbeb29+469cd937ee,g3939d97d7f+72a9f7b576,g487adcacf7+71499e7cba,g50ff169b8f+5929b3527e,g52b1c1532d+a6fc98d2e7,g591dd9f2cf+df404f777f,g5a732f18d5+be83d3ecdb,g64a986408d+21ad69e7e1,g858d7b2824+21ad69e7e1,g8a8a8dda67+a6fc98d2e7,g99cad8db69+f62e5b0af5,g9ddcbc5298+d4bad12328,ga1e77700b3+9c366c4306,ga8c6da7877+71e4819109,gb0e22166c9+25ba2f69a1,gb6a65358fc+469cd937ee,gbb8dafda3b+69d3c0e320,gc07e1c2157+a98bf949bb,gc120e1dc64+615ec43309,gc28159a63d+469cd937ee,gcf0d15dbbd+72a9f7b576,gdaeeff99f8+a38ce5ea23,ge6526c86ff+3a7c1ac5f1,ge79ae78c31+469cd937ee,gee10cc3b42+a6fc98d2e7,gf1cff7945b+21ad69e7e1,gfbcc870c63+9a11dc8c8f
LSST Data Management Base Package
|
Classes | |
class | docstring |
class | ProcessCcdWithFakesConnections |
Variables | |
exposure : `lsst.afw.image.exposure.exposure.ExposureF` | |
skyMap : `lsst.skymap.SkyMap` | |
wcs : `lsst.afw.geom.SkyWcs`, optional | |
photoCalib : `lsst.afw.image.photoCalib.PhotoCalib`, optional | |
icSourceCat : `lsst.afw.table.SourceCatalog`, optional | |
sfdSourceCat : `lsst.afw.table.SourceCatalog`, optional | |
externalSkyWcsGlobalCatalog | |
externalSkyWcsTractCatalog : `lsst.afw.table.ExposureCatalog`, optional | |
externalPhotoCalibGlobalCatalog | |
externalPhotoCalibTractCatalog | |
idGenerator : `lsst.meas.base.IdGenerator`, optional | |
resultStruct : `lsst.pipe.base.struct.Struct` | |
radius | |
fakeCats : `list` of `lsst.daf.butler.DeferredDatasetHandle` | |
combinedFakeCat : `pandas.DataFrame` | |
fakeCat : `pandas.core.frame.DataFrame` | |
movingFakeCat : `pandas.DataFrame` | |
calibCat : `lsst.afw.table.SourceCatalog` | |
sourceCat : `lsst.afw.table.SourceCatalog` | |
fieldsToCopy : `lsst.pex.config.listField.List` | |
newCat : `lsst.afw.table.SourceCatalog` | |
band : `str` | |
rngSeed : `int` | |
dataFrame : `pandas.DataFrame` | |
Insert fake sources into calexps
lsst.pipe.tasks.processCcdWithFakes.band : `str` |
Definition at line 755 of file processCcdWithFakes.py.
lsst.pipe.tasks.processCcdWithFakes.calibCat : `lsst.afw.table.SourceCatalog` |
selected = exposure.getInfo().getVisitInfo().getId() == fakeCat["visit"] return fakeCat[selected] def copyCalibrationFields(self, calibCat, sourceCat, fieldsToCopy):
Definition at line 538 of file processCcdWithFakes.py.
lsst.pipe.tasks.processCcdWithFakes.combinedFakeCat : `pandas.DataFrame` |
Definition at line 495 of file processCcdWithFakes.py.
lsst.pipe.tasks.processCcdWithFakes.dataFrame : `pandas.DataFrame` |
Definition at line 766 of file processCcdWithFakes.py.
lsst.pipe.tasks.processCcdWithFakes.exposure : `lsst.afw.image.exposure.exposure.ExposureF` |
Definition at line 406 of file processCcdWithFakes.py.
lsst.pipe.tasks.processCcdWithFakes.externalPhotoCalibGlobalCatalog |
Definition at line 425 of file processCcdWithFakes.py.
lsst.pipe.tasks.processCcdWithFakes.externalPhotoCalibTractCatalog |
Definition at line 428 of file processCcdWithFakes.py.
lsst.pipe.tasks.processCcdWithFakes.externalSkyWcsGlobalCatalog |
Definition at line 420 of file processCcdWithFakes.py.
lsst.pipe.tasks.processCcdWithFakes.externalSkyWcsTractCatalog : `lsst.afw.table.ExposureCatalog`, optional |
Definition at line 423 of file processCcdWithFakes.py.
lsst.pipe.tasks.processCcdWithFakes.fakeCat : `pandas.core.frame.DataFrame` |
if len(fakeCats) == 1: return fakeCats[0].get() outputCat = [] for fakeCatRef in fakeCats: cat = fakeCatRef.get() tractId = fakeCatRef.dataId["tract"] # Make sure all data is within the inner part of the tract. outputCat.append(cat[ skyMap.findTractIdArray(cat[self.config.insertFakes.ra_col], cat[self.config.insertFakes.dec_col], degrees=False) == tractId]) return pd.concat(outputCat) def getVisitMatchedFakeCat(self, fakeCat, exposure):
# Make a new SourceCatalog with the data from sourceCat so that we can add the new columns to it sourceSchemaMapper = afwTable.SchemaMapper(sourceCat.schema) sourceSchemaMapper.addMinimalSchema(sourceCat.schema, True) calibSchemaMapper = afwTable.SchemaMapper(calibCat.schema, sourceCat.schema) # Add the desired columns from the option fieldsToCopy missingFieldNames = [] for fieldName in fieldsToCopy: if fieldName in calibCat.schema: schemaItem = calibCat.schema.find(fieldName) calibSchemaMapper.editOutputSchema().addField(schemaItem.getField()) schema = calibSchemaMapper.editOutputSchema() calibSchemaMapper.addMapping(schemaItem.getKey(), schema.find(fieldName).getField()) else: missingFieldNames.append(fieldName) if missingFieldNames: raise RuntimeError(f"calibCat is missing fields {missingFieldNames} specified in " "fieldsToCopy") if "calib_detected" not in calibSchemaMapper.getOutputSchema(): self.calibSourceKey = calibSchemaMapper.addOutputField(afwTable.Field["Flag"]("calib_detected", "Source was detected as an icSource")) else: self.calibSourceKey = None schema = calibSchemaMapper.getOutputSchema() newCat = afwTable.SourceCatalog(schema) newCat.reserve(len(sourceCat)) newCat.extend(sourceCat, sourceSchemaMapper) # Set the aliases so it doesn't complain. for k, v in sourceCat.schema.getAliasMap().items(): newCat.schema.getAliasMap().set(k, v) select = newCat["deblend_nChild"] == 0 matches = afwTable.matchXy(newCat[select], calibCat, self.config.matchRadiusPix) # Check that no sourceCat sources are listed twice (we already know # that each match has a unique calibCat source ID, due to using # that ID as the key in bestMatches) numMatches = len(matches) numUniqueSources = len(set(m[1].getId() for m in matches)) if numUniqueSources != numMatches: self.log.warning("%d calibCat sources matched only %d sourceCat sources", numMatches, numUniqueSources) self.log.info("Copying flags from calibCat to sourceCat for %s sources", numMatches) # For each match: set the calibSourceKey flag and copy the desired # fields for src, calibSrc, d in matches: if self.calibSourceKey: src.setFlag(self.calibSourceKey, True) # src.assign copies the footprint from calibSrc, which we don't want # (DM-407) # so set calibSrc's footprint to src's footprint before src.assign, # then restore it calibSrcFootprint = calibSrc.getFootprint() try: calibSrc.setFootprint(src.getFootprint()) src.assign(calibSrc, calibSchemaMapper) finally: calibSrc.setFootprint(calibSrcFootprint) return newCat class ProcessCcdWithVariableFakesConnections(ProcessCcdWithFakesConnections): ccdVisitFakeMagnitudes = cT.Output( doc="Catalog of fakes with magnitudes scattered for this ccdVisit.", name="{fakesType}ccdVisitFakeMagnitudes", storageClass="DataFrame", dimensions=("instrument", "visit", "detector"), ) class ProcessCcdWithVariableFakesConfig(ProcessCcdWithFakesConfig, pipelineConnections=ProcessCcdWithVariableFakesConnections): scatterSize = pexConfig.RangeField( dtype=float, default=0.4, min=0, max=100, doc="Amount of scatter to add to the visit magnitude for variable " "sources." ) class ProcessCcdWithVariableFakesTask(ProcessCcdWithFakesTask):
_DefaultName = "processCcdWithVariableFakes" ConfigClass = ProcessCcdWithVariableFakesConfig def run(self, fakeCats, exposure, skyMap, wcs=None, photoCalib=None, icSourceCat=None, sfdSourceCat=None, idGenerator=None):
fakeCat = self.composeFakeCat(fakeCats, skyMap) if wcs is None: wcs = exposure.getWcs() if photoCalib is None: photoCalib = exposure.getPhotoCalib() if idGenerator is None: idGenerator = IdGenerator() band = exposure.getFilter().bandLabel ccdVisitMagnitudes = self.addVariability( fakeCat, band, exposure, photoCalib, idGenerator.catalog_id, ) self.insertFakes.run(fakeCat, exposure, wcs, photoCalib) # detect, deblend and measure sources returnedStruct = self.calibrate.run(exposure, idGenerator=idGenerator) sourceCat = returnedStruct.sourceCat sourceCat = self.copyCalibrationFields(sfdSourceCat, sourceCat, self.config.srcFieldsToCopy) resultStruct = pipeBase.Struct(outputExposure=exposure, outputCat=sourceCat, ccdVisitFakeMagnitudes=ccdVisitMagnitudes) return resultStruct def addVariability(self, fakeCat, band, exposure, photoCalib, rngSeed):
Definition at line 519 of file processCcdWithFakes.py.
lsst.pipe.tasks.processCcdWithFakes.fakeCats : `list` of `lsst.daf.butler.DeferredDatasetHandle` |
fakeCat = self.composeFakeCat(fakeCats, skyMap) if wcs is None: wcs = exposure.getWcs() if photoCalib is None: photoCalib = exposure.getPhotoCalib() if self.config.doMatchVisit: fakeCat = self.getVisitMatchedFakeCat(fakeCat, exposure) self.insertFakes.run(fakeCat, exposure, wcs, photoCalib) # detect, deblend and measure sources if idGenerator is None: idGenerator = IdGenerator() returnedStruct = self.calibrate.run(exposure, idGenerator=idGenerator) sourceCat = returnedStruct.sourceCat sourceCat = self.copyCalibrationFields(sfdSourceCat, sourceCat, self.config.srcFieldsToCopy) resultStruct = pipeBase.Struct(outputExposure=exposure, outputCat=sourceCat) return resultStruct def composeFakeCat(self, fakeCats, skyMap):
Definition at line 488 of file processCcdWithFakes.py.
lsst.pipe.tasks.processCcdWithFakes.fieldsToCopy : `lsst.pex.config.listField.List` |
Definition at line 542 of file processCcdWithFakes.py.
lsst.pipe.tasks.processCcdWithFakes.icSourceCat : `lsst.afw.table.SourceCatalog`, optional |
Definition at line 414 of file processCcdWithFakes.py.
lsst.pipe.tasks.processCcdWithFakes.idGenerator : `lsst.meas.base.IdGenerator`, optional |
Definition at line 431 of file processCcdWithFakes.py.
lsst.pipe.tasks.processCcdWithFakes.movingFakeCat : `pandas.DataFrame` |
Definition at line 526 of file processCcdWithFakes.py.
lsst.pipe.tasks.processCcdWithFakes.newCat : `lsst.afw.table.SourceCatalog` |
Definition at line 547 of file processCcdWithFakes.py.
lsst.pipe.tasks.processCcdWithFakes.photoCalib : `lsst.afw.image.photoCalib.PhotoCalib`, optional |
Definition at line 412 of file processCcdWithFakes.py.
lsst.pipe.tasks.processCcdWithFakes.radius |
Definition at line 445 of file processCcdWithFakes.py.
lsst.pipe.tasks.processCcdWithFakes.resultStruct : `lsst.pipe.base.struct.Struct` |
Definition at line 436 of file processCcdWithFakes.py.
lsst.pipe.tasks.processCcdWithFakes.rngSeed : `int` |
Definition at line 761 of file processCcdWithFakes.py.
lsst.pipe.tasks.processCcdWithFakes.sfdSourceCat : `lsst.afw.table.SourceCatalog`, optional |
Definition at line 417 of file processCcdWithFakes.py.
lsst.pipe.tasks.processCcdWithFakes.skyMap : `lsst.skymap.SkyMap` |
Definition at line 408 of file processCcdWithFakes.py.
lsst.pipe.tasks.processCcdWithFakes.sourceCat : `lsst.afw.table.SourceCatalog` |
Definition at line 540 of file processCcdWithFakes.py.
lsst.pipe.tasks.processCcdWithFakes.wcs : `lsst.afw.geom.SkyWcs`, optional |
Definition at line 410 of file processCcdWithFakes.py.