24 __all__ = [
"LoadIndexedReferenceObjectsConfig",
"LoadIndexedReferenceObjectsTask"]
26 from lsst.meas.algorithms import getRefFluxField, LoadReferenceObjectsTask, LoadReferenceObjectsConfig
30 from .indexerRegistry
import IndexerRegistry
34 ref_dataset_name = pexConfig.Field(
36 default=
'cal_ref_cat',
37 doc=
'Name of the ingested reference dataset' 42 ConfigClass = LoadIndexedReferenceObjectsConfig
43 _DefaultName =
'LoadIndexedReferenceObjectsTask' 46 LoadReferenceObjectsTask.__init__(self, *args, **kwargs)
47 dataset_config = butler.get(
"ref_cat_config", name=self.config.ref_dataset_name, immediate=
True)
48 self.
indexer = IndexerRegistry[dataset_config.indexer.name](dataset_config.indexer.active)
56 """!Load reference objects that overlap a circular sky region 58 @param[in] ctrCoord center of search region (an lsst.afw.geom.Coord) 59 @param[in] radius radius of search region (an lsst.afw.geom.Angle) 60 @param[in] filterName name of filter, or None for the default filter; 61 used for flux values in case we have flux limits (which are not yet implemented) 63 @return an lsst.pipe.base.Struct containing: 64 - refCat a catalog of reference objects with the 65 @link meas_algorithms_loadReferenceObjects_Schema standard schema @endlink 66 as documented in LoadReferenceObjects, including photometric, resolved and variable; 67 hasCentroid is False for all objects. 68 - fluxField = name of flux field for specified filterName. None if refCat is None. 70 id_list, boundary_mask = self.
indexer.get_pixel_ids(ctrCoord, radius)
72 refCat = self.
butler.get(
'ref_cat',
76 fluxField =
getRefFluxField(schema=refCat.schema, filterName=filterName)
77 for shard, is_on_boundary
in zip(shards, boundary_mask):
89 mapper = afwTable.SchemaMapper(refCat.schema,
True)
90 mapper.addMinimalSchema(refCat.schema,
True)
91 mapper.editOutputSchema().addField(
"centroid_x", type=float)
92 mapper.editOutputSchema().addField(
"centroid_y", type=float)
93 mapper.editOutputSchema().addField(
"hasCentroid", type=
"Flag")
94 expandedCat = afwTable.SimpleCatalog(mapper.getOutputSchema())
95 expandedCat.extend(refCat, mapper=mapper)
99 if not expandedCat.isContiguous():
100 expandedCat = expandedCat.copy(deep=
True)
103 return pipeBase.Struct(
109 """!Get all shards that touch a circular aperture 111 @param[in] id_list A list of integer pixel ids 112 @param[out] a list of SourceCatalogs for each pixel, None if not data exists 115 for pixel_id
in id_list:
116 if self.
butler.datasetExists(
'ref_cat',
118 shards.append(self.
butler.get(
'ref_cat',
119 dataId=self.
indexer.make_data_id(pixel_id,
124 def _trim_to_circle(self, catalog_shard, ctrCoord, radius):
125 """!Trim a catalog to a circular aperture. 127 @param[in] catalog_shard SourceCatalog to be trimmed 128 @param[in] ctrCoord ICRS coord to compare each record to (an lsst.afw.geom.SpherePoint) 129 @param[in] radius afwGeom.Angle indicating maximume separation 130 @param[out] a SourceCatalog constructed from records that fall in the circular aperture 132 temp_cat = type(catalog_shard)(catalog_shard.schema)
133 for record
in catalog_shard:
134 if record.getCoord().separation(ctrCoord) < radius:
135 temp_cat.append(record)
def loadSkyCircle(self, ctrCoord, radius, filterName=None)
Load reference objects that overlap a circular sky region.
Fit spatial kernel using approximate fluxes for candidates, and solving a linear system of equations...
def getRefFluxField(schema, filterName=None)
Get name of flux field in schema.
def _addFluxAliases(self, schema)
def get_shards(self, id_list)
Get all shards that touch a circular aperture.
def __init__(self, butler, args, kwargs)
Abstract base class to load objects from reference catalogs.
def _trim_to_circle(self, catalog_shard, ctrCoord, radius)
Trim a catalog to a circular aperture.