1 from __future__
import absolute_import, division, print_function
2 from builtins
import zip
26 from lsst.meas.algorithms import getRefFluxField, LoadReferenceObjectsTask, LoadReferenceObjectsConfig
27 from .ingestIndexReferenceTask
import IngestIndexedReferenceTask
31 from .indexerRegistry
import IndexerRegistry
32 __all__ = [
"LoadIndexedReferenceObjectsConfig",
"LoadIndexedReferenceObjectsTask"]
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', dataId=self.indexer.make_data_id(
'master_schema', self.
ref_dataset_name),
76 self._addFluxAliases(refCat.schema)
77 fluxField =
getRefFluxField(schema=refCat.schema, filterName=filterName)
78 for shard, is_on_boundary
in zip(shards, boundary_mask):
87 if not refCat.isContiguous():
88 refCat = refCat.copy()
95 mapper.addMinimalSchema(refCat.schema,
True)
96 mapper.editOutputSchema().addField(
"centroid_x", type=float)
97 mapper.editOutputSchema().addField(
"centroid_y", type=float)
98 mapper.editOutputSchema().addField(
"hasCentroid", type=
"Flag")
100 expandedCat.extend(refCat, mapper=mapper)
104 return pipeBase.Struct(
110 """!Get all shards that touch a circular aperture
112 @param[in] id_list A list of integer pixel ids
113 @param[out] a list of SourceCatalogs for each pixel, None if not data exists
116 for pixel_id
in id_list:
117 if self.butler.datasetExists(
'ref_cat', dataId=self.indexer.make_data_id(pixel_id, self.
ref_dataset_name)):
118 shards.append(self.butler.get(
'ref_cat',
119 dataId=self.indexer.make_data_id(pixel_id, self.
ref_dataset_name), immediate=
True))
123 """!Trim a catalog to a circular aperture.
125 @param[in] catalog_shard SourceCatalog to be trimmed
126 @param[in] ctrCoord afw.Coord to compare each record to
127 @param[in] radius afwGeom.Angle indicating maximume separation
128 @param[out] a SourceCatalog constructed from records that fall in the circular aperture
130 temp_cat = type(catalog_shard)(catalog_shard.schema)
131 for record
in catalog_shard:
132 if record.getCoord().angularSeparation(ctrCoord) < radius:
133 temp_cat.append(record)
def get_shards
Get all shards that touch a circular aperture.
A mapping between the keys of two Schemas, used to copy data between them.
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.
Custom catalog class for record/table subclasses that are guaranteed to have an ID, and should generally be sorted by that ID.
def getRefFluxField
Get name of flux field in schema.