lsst.meas.base g67924a670a+6e23f27fc3
|
Classes | |
class | for |
class | ForcedPhotCcdConnections |
class | may |
Functions | |
runQuantum (self, butlerQC, inputRefs, outputRefs) | |
df2RefCat (self, dfList, exposureBBox, exposureWcs) | |
df2SourceCat (self, df) | |
Variables | |
footprintSource | |
refSchema : `lsst.afw.table.Schema`, optional | |
initInputs : `dict` | |
exposure : `lsst.afw.image.exposure.Exposure` | |
skyCorr : `lsst.afw.math.backgroundList`, optional | |
doApplySkyCorr | |
externalSkyWcsCatalog : `lsst.afw.table.ExposureCatalog`, optional | |
doApplyExternalSkyWcs | |
externalPhotoCalibCatalog : `lsst.afw.table.ExposureCatalog`, optional | |
doApplyExternalPhotoCalib | |
finalizedPsfApCorrCatalog : `lsst.afw.table.ExposureCatalog`, optional | |
doApplyFinalizedPsf | |
visitSummary : `lsst.afw.table.ExposureCatalog`, optional | |
sequence | refCats of `lsst.daf.butler.DeferredDatasetHandle` |
refWcs : `lsst.afw.image.SkyWcs` | |
refSources : `lsst.afw.table.SourceCatalog` | |
dataId : `lsst.daf.butler.DataCoordinate` | |
refCat : `lsst.afw.table.SourceCatalog` | |
measCat : `lsst.afw.table.SourceCatalog` | |
expId : `int` | |
exposureId : `int` | |
result : `lsst.pipe.base.Struct` | |
schema | |
outputSchema | |
lsst.meas.base.forcedPhotCcd.df2RefCat | ( | self, | |
dfList, | |||
exposureBBox, | |||
exposureWcs | |||
) |
Convert list of DataFrames to reference catalog Concatenate list of DataFrames presumably from multiple patches and downselect rows that overlap the exposureBBox using the exposureWcs. Parameters ---------- dfList : `list` of `pandas.DataFrame` Each element containst diaObjects with ra/dec position in degrees Columns 'diaObjectId', 'ra', 'dec' are expected exposureBBox : `lsst.geom.Box2I` Bounding box on which to select rows that overlap exposureWcs : `lsst.afw.geom.SkyWcs` World coordinate system to convert sky coords in ref cat to pixel coords with which to compare with exposureBBox Returns ------- refCat : `lsst.afw.table.SourceTable` Source Catalog with minimal schema that overlaps exposureBBox
Definition at line 871 of file forcedPhotCcd.py.
lsst.meas.base.forcedPhotCcd.df2SourceCat | ( | self, | |
df | |||
) |
Create minimal schema SourceCatalog from a pandas DataFrame. The forced measurement subtask expects this as input. Parameters ---------- df : `pandas.DataFrame` DiaObjects with locations and ids. Returns ------- outputCatalog : `lsst.afw.table.SourceTable` Output catalog with minimal schema.
Definition at line 902 of file forcedPhotCcd.py.
lsst.meas.base.forcedPhotCcd.runQuantum | ( | self, | |
butlerQC, | |||
inputRefs, | |||
outputRefs | |||
) |
Definition at line 824 of file forcedPhotCcd.py.
lsst.meas.base.forcedPhotCcd.dataId : `lsst.daf.butler.DataCoordinate` |
mergedRefCat = None # Step 1: Determine bounds of the exposure photometry will # be performed on. expWcs = exposure.getWcs() if expWcs is None: self.log.info("Exposure has no WCS. Returning None for mergedRefCat.") else: expRegion = exposure.getBBox(lsst.afw.image.PARENT) expBBox = lsst.geom.Box2D(expRegion) expBoxCorners = expBBox.getCorners() expSkyCorners = [expWcs.pixelToSky(corner).getVector() for corner in expBoxCorners] expPolygon = lsst.sphgeom.ConvexPolygon(expSkyCorners) # Step 2: Filter out reference catalog sources that are # not contained within the exposure boundaries, or whose # parents are not within the exposure boundaries. Note # that within a single input refCat, the parents always # appear before the children. for refCat in refCats: refCat = refCat.get() if mergedRefCat is None: mergedRefCat = lsst.afw.table.SourceCatalog(refCat.table) containedIds = {0} # zero as a parent ID means "this is a parent" for record in refCat: if (expPolygon.contains(record.getCoord().getVector()) and record.getParent() in containedIds): record.setFootprint(record.getFootprint()) mergedRefCat.append(record) containedIds.add(record.getId()) if mergedRefCat is None: raise RuntimeError("No reference objects for forced photometry.") mergedRefCat.sort(lsst.afw.table.SourceTable.getParentKey()) return mergedRefCat def generateMeasCat(self, dataId, exposure, refCat, refWcs):
Definition at line 565 of file forcedPhotCcd.py.
lsst.meas.base.forcedPhotCcd.doApplyExternalPhotoCalib |
Definition at line 398 of file forcedPhotCcd.py.
lsst.meas.base.forcedPhotCcd.doApplyExternalSkyWcs |
Definition at line 393 of file forcedPhotCcd.py.
lsst.meas.base.forcedPhotCcd.doApplyFinalizedPsf |
Definition at line 403 of file forcedPhotCcd.py.
lsst.meas.base.forcedPhotCcd.doApplySkyCorr |
Definition at line 390 of file forcedPhotCcd.py.
lsst.meas.base.forcedPhotCcd.expId : `int` |
Definition at line 579 of file forcedPhotCcd.py.
lsst.meas.base.forcedPhotCcd.exposure : `lsst.afw.image.exposure.Exposure` |
ConfigClass = ForcedPhotCcdConfig _DefaultName = "forcedPhotCcd" dataPrefix = "" def __init__(self, refSchema=None, initInputs=None, **kwargs): super().__init__(**kwargs) if initInputs is not None: refSchema = initInputs['inputSchema'].schema if refSchema is None: raise ValueError("No reference schema provided.") self.makeSubtask("measurement", refSchema=refSchema) # It is necessary to get the schema internal to the forced measurement # task until such a time that the schema is not owned by the # measurement task, but is passed in by an external caller. if self.config.doApCorr: self.makeSubtask("applyApCorr", schema=self.measurement.schema) self.makeSubtask('catalogCalculation', schema=self.measurement.schema) self.outputSchema = lsst.afw.table.SourceCatalog(self.measurement.schema) def runQuantum(self, butlerQC, inputRefs, outputRefs): inputs = butlerQC.get(inputRefs) tract = butlerQC.quantum.dataId['tract'] skyMap = inputs.pop('skyMap') inputs['refWcs'] = skyMap[tract].getWcs() # Connections only exist if they are configured to be used. skyCorr = inputs.pop('skyCorr', None) if self.config.useGlobalExternalSkyWcs: externalSkyWcsCatalog = inputs.pop('externalSkyWcsGlobalCatalog', None) else: externalSkyWcsCatalog = inputs.pop('externalSkyWcsTractCatalog', None) if self.config.useGlobalExternalPhotoCalib: externalPhotoCalibCatalog = inputs.pop('externalPhotoCalibGlobalCatalog', None) else: externalPhotoCalibCatalog = inputs.pop('externalPhotoCalibTractCatalog', None) finalizedPsfApCorrCatalog = inputs.pop('finalizedPsfApCorrCatalog', None) inputs['exposure'] = self.prepareCalibratedExposure( inputs['exposure'], skyCorr=skyCorr, externalSkyWcsCatalog=externalSkyWcsCatalog, externalPhotoCalibCatalog=externalPhotoCalibCatalog, finalizedPsfApCorrCatalog=finalizedPsfApCorrCatalog, visitSummary=inputs.pop("visitSummary"), ) inputs['refCat'] = self.mergeAndFilterReferences(inputs['exposure'], inputs['refCat'], inputs['refWcs']) if inputs['refCat'] is None: self.log.info("No WCS for exposure %s. No %s catalog will be written.", butlerQC.quantum.dataId, outputRefs.measCat.datasetType.name) else: inputs['measCat'], inputs['exposureId'] = self.generateMeasCat(inputRefs.exposure.dataId, inputs['exposure'], inputs['refCat'], inputs['refWcs']) self.attachFootprints(inputs['measCat'], inputs['refCat'], inputs['exposure'], inputs['refWcs']) outputs = self.run(**inputs) butlerQC.put(outputs, outputRefs) def prepareCalibratedExposure(self, exposure, skyCorr=None, externalSkyWcsCatalog=None, externalPhotoCalibCatalog=None, finalizedPsfApCorrCatalog=None, visitSummary=None):
detectorId = exposure.getInfo().getDetector().getId() if visitSummary is not None: row = visitSummary.find(detectorId) if row is None: raise RuntimeError(f"Detector id {detectorId} not found in visitSummary.") if (photoCalib := row.getPhotoCalib()) is not None: exposure.setPhotoCalib(photoCalib) if (skyWcs := row.getWcs()) is not None: exposure.setWcs(skyWcs) if (psf := row.getPsf()) is not None: exposure.setPsf(psf) if (apCorrMap := row.getApCorrMap()) is not None: exposure.info.setApCorrMap(apCorrMap) if externalPhotoCalibCatalog is not None: # TODO: remove on DM-39854 warnings.warn( "The 'externalPhotoCalibCatalog' argument is deprecated in favor of 'visitSummary' and will " "be removed after v26.", FutureWarning, stacklevel=find_outside_stacklevel("lsst.meas.base"), ) row = externalPhotoCalibCatalog.find(detectorId) if row is None: self.log.warning("Detector id %s not found in externalPhotoCalibCatalog; " "Using original photoCalib.", detectorId) else: photoCalib = row.getPhotoCalib() if photoCalib is None: self.log.warning("Detector id %s has None for photoCalib in externalPhotoCalibCatalog; " "Using original photoCalib.", detectorId) else: exposure.setPhotoCalib(photoCalib) if externalSkyWcsCatalog is not None: # TODO: remove on DM-39854 warnings.warn( "The 'externalSkyWcsCatalog' argument is deprecated in favor of 'visitSummary' and will " "be removed after v26.", FutureWarning, stacklevel=find_outside_stacklevel("lsst.meas.base"), ) row = externalSkyWcsCatalog.find(detectorId) if row is None: self.log.warning("Detector id %s not found in externalSkyWcsCatalog; " "Using original skyWcs.", detectorId) else: skyWcs = row.getWcs() if skyWcs is None: self.log.warning("Detector id %s has None for skyWcs in externalSkyWcsCatalog; " "Using original skyWcs.", detectorId) else: exposure.setWcs(skyWcs) if finalizedPsfApCorrCatalog is not None: # TODO: remove on DM-39854 warnings.warn( "The 'finalizedPsfApCorrCatalog' argument is deprecated in favor of 'visitSummary' and will " "be removed after v26.", FutureWarning, stacklevel=find_outside_stacklevel("lsst.meas.base"), ) row = finalizedPsfApCorrCatalog.find(detectorId) if row is None: self.log.warning("Detector id %s not found in finalizedPsfApCorrCatalog; " "Using original psf.", detectorId) else: psf = row.getPsf() apCorrMap = row.getApCorrMap() if psf is None or apCorrMap is None: self.log.warning("Detector id %s has None for psf/apCorrMap in " "finalizedPsfApCorrCatalog; Using original psf.", detectorId) else: exposure.setPsf(psf) exposure.setApCorrMap(apCorrMap) if skyCorr is not None: exposure.maskedImage -= skyCorr.getImage() return exposure def mergeAndFilterReferences(self, exposure, refCats, refWcs):
Definition at line 387 of file forcedPhotCcd.py.
lsst.meas.base.forcedPhotCcd.exposureId : `int` |
Definition at line 601 of file forcedPhotCcd.py.
lsst.meas.base.forcedPhotCcd.externalPhotoCalibCatalog : `lsst.afw.table.ExposureCatalog`, optional |
Definition at line 396 of file forcedPhotCcd.py.
lsst.meas.base.forcedPhotCcd.externalSkyWcsCatalog : `lsst.afw.table.ExposureCatalog`, optional |
Definition at line 391 of file forcedPhotCcd.py.
lsst.meas.base.forcedPhotCcd.finalizedPsfApCorrCatalog : `lsst.afw.table.ExposureCatalog`, optional |
Definition at line 401 of file forcedPhotCcd.py.
lsst.meas.base.forcedPhotCcd.footprintSource |
Definition at line 273 of file forcedPhotCcd.py.
lsst.meas.base.forcedPhotCcd.initInputs : `dict` |
Definition at line 308 of file forcedPhotCcd.py.
lsst.meas.base.forcedPhotCcd.measCat : `lsst.afw.table.SourceCatalog` |
id_generator = self.config.idGenerator.apply(dataId) measCat = self.measurement.generateMeasCat(exposure, refCat, refWcs, idFactory=id_generator.make_table_id_factory()) return measCat, id_generator.catalog_id def run(self, measCat, exposure, refCat, refWcs, exposureId=None):
Definition at line 577 of file forcedPhotCcd.py.
lsst.meas.base.forcedPhotCcd.outputSchema |
Definition at line 822 of file forcedPhotCcd.py.
lsst.meas.base.forcedPhotCcd.refCat : `lsst.afw.table.SourceCatalog` |
Definition at line 569 of file forcedPhotCcd.py.
sequence lsst.meas.base.forcedPhotCcd.refCats of `lsst.daf.butler.DeferredDatasetHandle` |
Definition at line 507 of file forcedPhotCcd.py.
lsst.meas.base.forcedPhotCcd.refSchema : `lsst.afw.table.Schema`, optional |
Definition at line 304 of file forcedPhotCcd.py.
lsst.meas.base.forcedPhotCcd.refSources : `lsst.afw.table.SourceCatalog` |
Definition at line 515 of file forcedPhotCcd.py.
lsst.meas.base.forcedPhotCcd.refWcs : `lsst.afw.image.SkyWcs` |
Definition at line 510 of file forcedPhotCcd.py.
lsst.meas.base.forcedPhotCcd.result : `lsst.pipe.base.Struct` |
Definition at line 607 of file forcedPhotCcd.py.
lsst.meas.base.forcedPhotCcd.schema |
Definition at line 821 of file forcedPhotCcd.py.
lsst.meas.base.forcedPhotCcd.skyCorr : `lsst.afw.math.backgroundList`, optional |
Definition at line 389 of file forcedPhotCcd.py.
lsst.meas.base.forcedPhotCcd.visitSummary : `lsst.afw.table.ExposureCatalog`, optional |
Definition at line 407 of file forcedPhotCcd.py.