24 __all__ = [
"LoadIndexedReferenceObjectsConfig",
"LoadIndexedReferenceObjectsTask"]
26 from .loadReferenceObjects
import hasNanojanskyFluxUnits, convertToNanojansky, getFormatVersionFromRefCat
27 from lsst.meas.algorithms import getRefFluxField, LoadReferenceObjectsTask, LoadReferenceObjectsConfig
31 from .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_configdataset_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.
indexerindexer.getShardIds(ctrCoord, radius)
66 shards = self.
getShardsgetShards(shardIdList)
72 for shard, isOnBoundary
in zip(shards, isOnBoundaryList):
76 refCat.extend(self.
_trimToCircle_trimToCircle(shard, ctrCoord, radius))
81 if not refCat.isContiguous():
82 refCat = refCat.copy(
True)
89 self.log.warn(
"Found version 0 reference catalog with old style units in schema.")
90 self.log.warn(
"run `meas_algorithms/bin/convert_refcat_to_nJy.py` to convert fluxes to nJy.")
91 self.log.warn(
"See RFC-575 for more details.")
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.
134 catalogs : `list` of `lsst.afw.table.SimpleCatalog`
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.
151 refCat : `lsst.afw.table.SimpleCatalog`
152 Reference catalog to be trimmed.
153 ctrCoord : `lsst.geom.SpherePoint`
154 ICRS center of search region.
155 radius : `lsst.geom.Angle`
156 Radius of search region.
160 catalog : `lsst.afw.table.SimpleCatalog`
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)
def hasNanojanskyFluxUnits(schema)
def getRefFluxField(schema, filterName=None)
def convertToNanojansky(catalog, log, doConvert=True)
def getFormatVersionFromRefCat(refCat)
Fit spatial kernel using approximate fluxes for candidates, and solving a linear system of equations.