24__all__ = [
"LoadIndexedReferenceObjectsConfig",
"LoadIndexedReferenceObjectsTask"]
26from .loadReferenceObjects
import hasNanojanskyFluxUnits, convertToNanojansky, getFormatVersionFromRefCat
27from lsst.meas.algorithms import getRefFluxField, LoadReferenceObjectsTask, LoadReferenceObjectsConfig
30import lsst.pipe.base
as pipeBase
31from .indexerRegistry
import IndexerRegistry
35 ref_dataset_name = pexConfig.Field(
37 default=
'cal_ref_cat',
38 doc=
'Name of the ingested reference dataset'
43 """Load reference objects from an indexed catalog ingested by
44 IngestIndexReferenceTask.
48 butler : `lsst.daf.persistence.Butler`
49 Data butler for reading catalogs
51 ConfigClass = LoadIndexedReferenceObjectsConfig
52 _DefaultName = 'LoadIndexedReferenceObjectsTask'
55 LoadReferenceObjectsTask.__init__(self, *args, **kwargs)
56 self.
dataset_config = butler.get(
"ref_cat_config", name=self.config.ref_dataset_name, immediate=
True)
64 def loadSkyCircle(self, ctrCoord, radius, filterName=None, epoch=None, centroids=False):
65 shardIdList, isOnBoundaryList = self.
indexer.getShardIds(ctrCoord, radius)
72 for shard, isOnBoundary
in zip(shards, isOnBoundaryList):
81 if not refCat.isContiguous():
82 refCat = refCat.copy(
True)
88 if self.
dataset_config.format_version == 0
or not hasNanojanskyFluxUnits(refCat.schema):
89 self.log.warning(
"Found version 0 reference catalog with old style units in schema.")
90 self.log.warning(
"run `meas_algorithms/bin/convert_refcat_to_nJy.py` to convert fluxes to nJy.")
91 self.log.warning(
"See RFC-575 for more details.")
92 refCat = convertToNanojansky(refCat, self.log)
96 catVersion = getFormatVersionFromRefCat(refCat)
98 raise RuntimeError(f
"Format version in reference catalog ({catVersion}) does not match"
99 f
" format_version field in config ({self.dataset_config.format_version})")
102 fluxField = getRefFluxField(schema=refCat.schema, filterName=filterName)
109 mapper = afwTable.SchemaMapper(refCat.schema,
True)
110 mapper.addMinimalSchema(refCat.schema,
True)
111 mapper.editOutputSchema().addField(
"centroid_x", type=float)
112 mapper.editOutputSchema().addField(
"centroid_y", type=float)
113 mapper.editOutputSchema().addField(
"hasCentroid", type=
"Flag")
114 expandedCat = afwTable.SimpleCatalog(mapper.getOutputSchema())
115 expandedCat.extend(refCat, mapper=mapper)
119 return pipeBase.Struct(
129 shardIdList : `list` of `int`
130 A list of integer shard ids.
135 A list of reference catalogs, one for each entry
in shardIdList.
138 for shardId
in shardIdList:
146 def _trimToCircle(self, refCat, ctrCoord, radius):
147 """Trim a reference catalog to a circular aperture.
152 Reference catalog to be trimmed.
154 ICRS center of search region.
156 Radius of search region.
161 Catalog containing objects that fall in the circular aperture.
163 tempCat = type(refCat)(refCat.schema)
164 for record
in refCat:
165 if record.getCoord().separation(ctrCoord) < radius:
166 tempCat.append(record)
def _trimToCircle(self, refCat, ctrCoord, radius)
def loadSkyCircle(self, ctrCoord, radius, filterName=None, epoch=None, centroids=False)
def getShards(self, shardIdList)
def __init__(self, butler, *args, **kwargs)
def _addFluxAliases(self, schema)
def applyProperMotions(self, catalog, epoch)
Fit spatial kernel using approximate fluxes for candidates, and solving a linear system of equations.