23 from __future__
import absolute_import, division, print_function
25 __all__ = [
"LoadIndexedReferenceObjectsConfig",
"LoadIndexedReferenceObjectsTask"]
27 from builtins
import zip
28 from lsst.meas.algorithms import getRefFluxField, LoadReferenceObjectsTask, LoadReferenceObjectsConfig
29 import lsst.afw.table
as afwTable
30 import lsst.pex.config
as pexConfig
31 import lsst.pipe.base
as pipeBase
32 from .indexerRegistry
import IndexerRegistry
36 ref_dataset_name = pexConfig.Field(
38 default=
'cal_ref_cat',
39 doc=
'Name of the ingested reference dataset'
44 ConfigClass = LoadIndexedReferenceObjectsConfig
45 _DefaultName =
'LoadIndexedReferenceObjectsTask'
48 LoadReferenceObjectsTask.__init__(self, *args, **kwargs)
49 dataset_config = butler.get(
"ref_cat_config", name=self.config.ref_dataset_name, immediate=
True)
50 self.
indexer = IndexerRegistry[dataset_config.indexer.name](dataset_config.indexer.active)
58 """!Load reference objects that overlap a circular sky region
60 @param[in] ctrCoord center of search region (an lsst.afw.geom.Coord)
61 @param[in] radius radius of search region (an lsst.afw.geom.Angle)
62 @param[in] filterName name of filter, or None for the default filter;
63 used for flux values in case we have flux limits (which are not yet implemented)
65 @return an lsst.pipe.base.Struct containing:
66 - refCat a catalog of reference objects with the
67 \link meas_algorithms_loadReferenceObjects_Schema standard schema \endlink
68 as documented in LoadReferenceObjects, including photometric, resolved and variable;
69 hasCentroid is False for all objects.
70 - fluxField = name of flux field for specified filterName. None if refCat is None.
72 id_list, boundary_mask = self.indexer.get_pixel_ids(ctrCoord, radius)
74 refCat = self.butler.get(
'ref_cat',
77 self._addFluxAliases(refCat.schema)
78 fluxField =
getRefFluxField(schema=refCat.schema, filterName=filterName)
79 for shard, is_on_boundary
in zip(shards, boundary_mask):
88 if not refCat.isContiguous():
89 refCat = refCat.copy()
95 mapper = afwTable.SchemaMapper(refCat.schema,
True)
96 mapper.addMinimalSchema(refCat.schema,
True)
97 mapper.editOutputSchema().addField(
"centroid_x", type=float)
98 mapper.editOutputSchema().addField(
"centroid_y", type=float)
99 mapper.editOutputSchema().addField(
"hasCentroid", type=
"Flag")
100 expandedCat = afwTable.SimpleCatalog(mapper.getOutputSchema())
101 expandedCat.extend(refCat, mapper=mapper)
105 return pipeBase.Struct(
111 """!Get all shards that touch a circular aperture
113 @param[in] id_list A list of integer pixel ids
114 @param[out] a list of SourceCatalogs for each pixel, None if not data exists
117 for pixel_id
in id_list:
118 if self.butler.datasetExists(
'ref_cat',
120 shards.append(self.butler.get(
'ref_cat',
121 dataId=self.indexer.make_data_id(pixel_id,
126 def _trim_to_circle(self, catalog_shard, ctrCoord, radius):
127 """!Trim a catalog to a circular aperture.
129 @param[in] catalog_shard SourceCatalog to be trimmed
130 @param[in] ctrCoord afw.Coord to compare each record to
131 @param[in] radius afwGeom.Angle indicating maximume separation
132 @param[out] a SourceCatalog constructed from records that fall in the circular aperture
134 temp_cat = type(catalog_shard)(catalog_shard.schema)
135 for record
in catalog_shard:
136 if record.getCoord().angularSeparation(ctrCoord) < radius:
137 temp_cat.append(record)
def get_shards
Get all shards that touch a circular aperture.
def loadSkyCircle
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 _trim_to_circle
Trim a catalog to a circular aperture.
def getRefFluxField
Get name of flux field in schema.