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 lsst.utils.timer
import timeMethod
32from .indexerRegistry
import IndexerRegistry
36 ref_dataset_name = pexConfig.Field(
38 default=
'cal_ref_cat',
39 doc=
'Name of the ingested reference dataset'
44 """Load reference objects from an indexed catalog ingested by
45 IngestIndexReferenceTask.
49 butler : `lsst.daf.persistence.Butler`
50 Data butler for reading catalogs
52 ConfigClass = LoadIndexedReferenceObjectsConfig
53 _DefaultName = 'LoadIndexedReferenceObjectsTask'
56 LoadReferenceObjectsTask.__init__(self, *args, **kwargs)
57 self.
dataset_configdataset_config = butler.get(
"ref_cat_config", name=self.config.ref_dataset_name, immediate=
True)
65 def loadSkyCircle(self, ctrCoord, radius, filterName, epoch=None, centroids=False):
66 shardIdList, isOnBoundaryList = self.
indexerindexer.getShardIds(ctrCoord, radius)
67 shards = self.
getShardsgetShards(shardIdList)
73 for shard, isOnBoundary
in zip(shards, isOnBoundaryList):
77 refCat.extend(self.
_trimToCircle_trimToCircle(shard, ctrCoord, radius))
82 if not refCat.isContiguous():
83 refCat = refCat.copy(
True)
90 self.log.warning(
"Found version 0 reference catalog with old style units in schema.")
91 self.log.warning(
"run `meas_algorithms/bin/convert_refcat_to_nJy.py` to convert fluxes to nJy.")
92 self.log.warning(
"See RFC-575 for more details.")
99 raise RuntimeError(f
"Format version in reference catalog ({catVersion}) does not match"
100 f
" format_version field in config ({self.dataset_config.format_version})")
110 mapper = afwTable.SchemaMapper(refCat.schema,
True)
111 mapper.addMinimalSchema(refCat.schema,
True)
112 mapper.editOutputSchema().addField(
"centroid_x", type=float)
113 mapper.editOutputSchema().addField(
"centroid_y", type=float)
114 mapper.editOutputSchema().addField(
"hasCentroid", type=
"Flag")
115 expandedCat = afwTable.SimpleCatalog(mapper.getOutputSchema())
116 expandedCat.extend(refCat, mapper=mapper)
120 return pipeBase.Struct(
130 shardIdList : `list` of `int`
131 A list of integer shard ids.
136 A list of reference catalogs, one for each entry
in shardIdList.
139 for shardId
in shardIdList:
147 def _trimToCircle(self, refCat, ctrCoord, radius):
148 """Trim a reference catalog to a circular aperture.
153 Reference catalog to be trimmed.
155 ICRS center of search region.
157 Radius of search region.
162 Catalog containing objects that fall in the circular aperture.
164 tempCat = type(refCat)(refCat.schema)
165 for record
in refCat:
166 if record.getCoord().separation(ctrCoord) < radius:
167 tempCat.append(record)
def _trimToCircle(self, refCat, ctrCoord, radius)
def getShards(self, shardIdList)
def loadSkyCircle(self, ctrCoord, radius, filterName, epoch=None, centroids=False)
def __init__(self, butler, *args, **kwargs)
def _addFluxAliases(self, schema)
def applyProperMotions(self, catalog, epoch)
def hasNanojanskyFluxUnits(schema)
def convertToNanojansky(catalog, log, doConvert=True)
def getRefFluxField(schema, filterName)
def getFormatVersionFromRefCat(refCat)
Fit spatial kernel using approximate fluxes for candidates, and solving a linear system of equations.