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 from .ingestIndexReferenceTask
import IngestIndexedReferenceTask
30 import lsst.afw.table
as afwTable
31 import lsst.pex.config
as pexConfig
32 import lsst.pipe.base
as pipeBase
33 from .indexerRegistry
import IndexerRegistry
37 ref_dataset_name = pexConfig.Field(
39 default=
'cal_ref_cat',
40 doc=
'Name of the ingested reference dataset' 45 ConfigClass = LoadIndexedReferenceObjectsConfig
46 _DefaultName =
'LoadIndexedReferenceObjectsTask' 49 LoadReferenceObjectsTask.__init__(self, *args, **kwargs)
50 dataset_config = butler.get(
"ref_cat_config", name=self.config.ref_dataset_name, immediate=
True)
51 self.
indexer = IndexerRegistry[dataset_config.indexer.name](dataset_config.indexer.active)
59 """!Load reference objects that overlap a circular sky region 61 @param[in] ctrCoord center of search region (an lsst.afw.geom.Coord) 62 @param[in] radius radius of search region (an lsst.afw.geom.Angle) 63 @param[in] filterName name of filter, or None for the default filter; 64 used for flux values in case we have flux limits (which are not yet implemented) 66 @return an lsst.pipe.base.Struct containing: 67 - refCat a catalog of reference objects with the 68 \link meas_algorithms_loadReferenceObjects_Schema standard schema \endlink 69 as documented in LoadReferenceObjects, including photometric, resolved and variable; 70 hasCentroid is False for all objects. 71 - fluxField = name of flux field for specified filterName. None if refCat is None. 73 id_list, boundary_mask = self.
indexer.get_pixel_ids(ctrCoord, radius)
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:
119 shards.append(self.
butler.get(
'ref_cat',
123 def _trim_to_circle(self, catalog_shard, ctrCoord, radius):
124 """!Trim a catalog to a circular aperture. 126 @param[in] catalog_shard SourceCatalog to be trimmed 127 @param[in] ctrCoord afw.Coord to compare each record to 128 @param[in] radius afwGeom.Angle indicating maximume separation 129 @param[out] a SourceCatalog constructed from records that fall in the circular aperture 131 temp_cat = type(catalog_shard)(catalog_shard.schema)
132 for record
in catalog_shard:
133 if record.getCoord().angularSeparation(ctrCoord) < radius:
134 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.