Coverage for python/lsst/ap/association/diaPipe.py : 52%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# # LSST Data Management System # Copyright 2008-2016 AURA/LSST. # # This product includes software developed by the # LSST Project (http://www.lsst.org/). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the LSST License Statement and # the GNU General Public License along with this program. If not, # see <https://www.lsstcorp.org/LegalNotices/>. #
Additionally performs forced photometry on the calibrated and difference images at the updated locations of DiaObjects.
Currently loads directly from the Apdb rather than pre-loading. """
AssociationTask, DiaForcedSourceTask, LoadDiaCatalogsTask, MapDiaSourceTask, make_dia_object_schema, make_dia_source_schema)
"DiaPipelineTask", "DiaPipelineConnections")
dimensions=("instrument", "visit", "detector"), defaultTemplates={"coaddName": "deep"}): """Butler connections for DiaPipelineTask. """ doc="Schema of the DiaSource catalog produced during image " "differencing", name="{coaddName}Diff_diaSrc_schema", storageClass="SourceCatalog", multiple=True ) doc="Catalog of DiaSources produced during image differencing.", name="{coaddName}Diff_diaSrc", storageClass="SourceCatalog", dimensions=("instrument", "visit", "detector"), ) doc="Difference image on which the DiaSources were detected.", name="{coaddName}Diff_differenceExp", storageClass="ExposureF", dimensions=("instrument", "visit", "detector"), ) doc="Calibrated exposure differenced with a template image during " "image differencing.", name="calexp", storageClass="ExposureF", dimensions=("instrument", "visit", "detector"), ) doc="Marker dataset storing the configuration of the Apdb for each " "visit/detector. Used to signal the completion of the pipeline.", name="apdb_marker", storageClass="", dimensions=("instrument", "visit", "detector"), )
pipelineConnections=DiaPipelineConnections): """Config for DiaPipelineTask. """ target=daxApdb.Apdb, ConfigClass=daxApdb.ApdbConfig, doc="Database connection for storing associated DiaSources and " "DiaObjects. Must already be initialized.", ) target=MapDiaSourceTask, doc="Task for assigning columns from the raw output of ip_diffim into " "a schema that more closely resembles the DPDD.", ) target=LoadDiaCatalogsTask, doc="Task to load DiaObjects and DiaSources from the Apdb.", ) target=AssociationTask, doc="Task used to associate DiaSources with DiaObjects.", ) target=DiaForcedSourceTask, doc="Task used for force photometer DiaObject locations in direct and " "difference images.", )
self.apdb.dia_object_index = "baseline" self.apdb.dia_object_columns = [] self.apdb.extra_schema_file = os.path.join( getPackageDir("ap_association"), "data", "apdb-ap-pipe-schema-extra.yaml")
pexConfig.Config.validate(self) if self.diaCatalogLoader.htmLevel != \ self.associator.diaCalculation.plugins["ap_HTMIndex"].htmLevel: raise ValueError("HTM index level in LoadDiaCatalogsTask must be " "equal to HTMIndexDiaCalculationPlugin index " "level.")
"""Task for loading, associating and storing Difference Image Analysis (DIA) Objects and Sources. """
super().__init__(**kwargs) self.apdb = self.config.apdb.apply( afw_schemas=dict(DiaObject=make_dia_object_schema(), DiaSource=make_dia_source_schema())) self.makeSubtask("diaSourceDpddifier", inputSchema=initInputs["diaSourceSchema"]) self.makeSubtask("diaCatalogLoader") self.makeSubtask("associator") self.makeSubtask("diaForcedSource")
inputs = butlerQC.get(inputRefs) expId, expBits = butlerQC.quantum.dataId.pack("visit_detector", returnMaxBits=True) inputs["ccdExposureIdBits"] = expBits
outputs = self.run(**inputs)
butlerQC.put(outputs, outputRefs)
def run(self, diaSourceCat, diffIm, exposure, ccdExposureIdBits): """Process DiaSources and DiaObjects.
Load previous DiaObjects and their DiaSource history. Calibrate the values in the diaSourceCat. Associate new DiaSources with previous DiaObjects. Run forced photometry at the updated DiaObject locations. Store the results in the Alert Production Database (Apdb).
Parameters ---------- diaSourceCat : `lsst.afw.table.SourceCatalog` Newly detected DiaSources. diffIm : `lsst.afw.image.Exposure` Difference image exposure in which the sources in ``diaSourceCat`` were detected. exposure : `lsst.afw.image.Exposure` Calibrated exposure differenced with a template to create ``diffIm``. ccdExposureIdBits : `int` Number of bits used for a unique ``ccdVisitId``.
Returns ------- results : `lsst.pipe.base.Struct` Results struct with components.
- ``apdb_maker`` : Marker dataset to store in the Butler indicating that this ccdVisit has completed successfully. (`lsst.dax.apdb.ApdbConfig`) """ self.log.info("Running DiaPipeline...") # Put the SciencePipelines through a SDMification step and return # calibrated columns with the expect output database names. diaSources = self.diaSourceDpddifier.run(diaSourceCat, diffIm, return_pandas=True)
# Load the DiaObjects and DiaSource history. loaderResult = self.diaCatalogLoader.run(diffIm, self.apdb)
# Associate new DiaSources with existing DiaObjects and update # DiaObject summary statistics using the full DiaSource history. assocResults = self.associator.run(diaSources, loaderResult.diaObjects, loaderResult.diaSources)
# Force photometer on the Difference and Calibrated exposures using # the new and updated DiaObject locations. diaForcedSources = self.diaForcedSource.run( assocResults.diaObjects, ccdExposureIdBits, exposure, diffIm)
# Store DiaSources and updated DiaObjects in the Apdb. self.apdb.storeDiaSources(assocResults.diaSources) self.apdb.storeDiaObjects( assocResults.updatedDiaObjects, exposure.getInfo().getVisitInfo().getDate().toPython()) self.apdb.storeDiaForcedSources(diaForcedSources)
return pipeBase.Struct(apdb_maker=self.config.apdb.value) |