Esempio n. 1
0
 def testForcedMeasurementTransform(self):
     """Test applying a transform task to the results of forced measurement."""
     schema = afwTable.SourceTable.makeMinimalSchema()
     forcedConfig = measBase.ForcedMeasurementConfig(plugins=[PLUGIN_NAME])
     # We don't use slots in this test
     for key in forcedConfig.slots:
         setattr(forcedConfig.slots, key, None)
     forcedConfig.copyColumns = {"id": "objectId", "parent": "parentObjectId"}
     forcedTask = measBase.ForcedMeasurementTask(schema, config=forcedConfig)
     transformConfig = TransformConfig(copyFields=("objectId", "coord_ra", "coord_dec"))
     transformTask = TransformTask(measConfig=forcedConfig,
                                   inputSchema=forcedTask.schema, outputDataset="forced_src",
                                   config=transformConfig)
     self._transformAndCheck(forcedConfig, forcedTask.schema, transformTask)
Esempio n. 2
0
def measureForced(exposure, source, refWcs, msConfig):
    """Forced measurement"""
    refCat = afwTable.SourceCatalog(source.table)
    refCat.append(source)
    schema = afwTable.SourceTable.makeMinimalSchema()
    algMeta = PropertyList()
    source.getTable().setMetadata(algMeta)
    task = measBase.ForcedMeasurementTask(schema,
                                          config=msConfig,
                                          algMetadata=algMeta)
    measCat = task.generateMeasCat(exposure, refCat, refWcs)
    task.attachTransformedFootprints(measCat, refCat, exposure, refWcs)
    task.run(measCat, exposure, refCat, refWcs)
    return measCat[0]
Esempio n. 3
0
def doForcedPhotometry(centroids, exposure, transientsOnly=False, asDF=False):
    expWcs = exposure.getWcs()
    if type(centroids) is afwTable.SourceCatalog:
        sources = centroids
    else:
        sources = centroidsToCatalog(centroids,
                                     expWcs,
                                     transientsOnly=transientsOnly)
    config = measBase.ForcedMeasurementTask.ConfigClass()
    config.plugins.names = ['base_TransformedCentroid', 'base_PsfFlux']
    config.slots.shape = None
    config.slots.centroid = 'base_TransformedCentroid'
    config.slots.modelFlux = 'base_PsfFlux'
    measurement = measBase.ForcedMeasurementTask(sources.getSchema(),
                                                 config=config)
    measCat = measurement.generateMeasCat(exposure, sources, expWcs)
    measurement.attachTransformedFootprints(measCat, sources, exposure, expWcs)
    measurement.run(measCat, exposure, sources, expWcs)

    if asDF:
        measCat = catalogToDF(
            measCat
        )  #pd.DataFrame({col: measCat.columns[col] for col in measCat.schema.getNames()})
    return measCat, sources