24 __all__ = [
"LoadIndexedReferenceObjectsConfig",
"LoadIndexedReferenceObjectsTask"]
26 from .loadReferenceObjects
import hasNanojanskyFluxUnits, convertToNanojansky, getFormatVersionFromRefCat
27 from lsst.meas.algorithms import getRefFluxField, LoadReferenceObjectsTask, LoadReferenceObjectsConfig
32 from .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_config = butler.get(
"ref_cat_config", name=self.config.ref_dataset_name, immediate=
True)
66 shardIdList, isOnBoundaryList = self.
indexer.getShardIds(ctrCoord, radius)
68 refCat = self.
butler.get(
'ref_cat',
73 for shard, isOnBoundary
in zip(shards, isOnBoundaryList):
82 if epoch
is not None and "pm_ra" in refCat.schema:
84 if isinstance(refCat.schema[
"pm_ra"].asKey(), lsst.afw.table.KeyAngle):
87 self.log.
warn(
"Catalog pm_ra field is not an Angle; not applying proper motion")
91 self.log.
warn(
"Found version 0 reference catalog with old style units in schema.")
92 self.log.
warn(
"run `meas_algorithms/bin/convert_refcat_to_nJy.py` to convert fluxes to nJy.")
93 self.log.
warn(
"See RFC-575 for more details.")
100 raise RuntimeError(f
"Format version in reference catalog ({catVersion}) does not match" 101 f
" format_version field in config ({self.dataset_config.format_version})")
104 fluxField =
getRefFluxField(schema=refCat.schema, filterName=filterName)
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")
116 expandedCat.extend(refCat, mapper=mapper)
120 if not expandedCat.isContiguous():
121 expandedCat = expandedCat.copy(
True)
124 return pipeBase.Struct(
134 shardIdList : `list` of `int` 135 A list of integer shard ids. 139 catalogs : `list` of `lsst.afw.table.SimpleCatalog` 140 A list of reference catalogs, one for each entry in shardIdList. 143 for shardId
in shardIdList:
144 if self.
butler.datasetExists(
'ref_cat',
146 shards.append(self.
butler.get(
'ref_cat',
151 def _trimToCircle(self, refCat, ctrCoord, radius):
152 """Trim a reference catalog to a circular aperture. 156 refCat : `lsst.afw.table.SimpleCatalog` 157 Reference catalog to be trimmed. 158 ctrCoord : `lsst.geom.SpherePoint` 159 ICRS center of search region. 160 radius : `lsst.geom.Angle` 161 Radius of search region. 165 catalog : `lsst.afw.table.SimpleCatalog` 166 Catalog containing objects that fall in the circular aperture. 168 tempCat =
type(refCat)(refCat.schema)
169 for record
in refCat:
170 if record.getCoord().separation(ctrCoord) < radius:
171 tempCat.append(record)
def hasNanojanskyFluxUnits(schema)
A mapping between the keys of two Schemas, used to copy data between them.
def getFormatVersionFromRefCat(refCat)
def getShards(self, shardIdList)
def loadSkyCircle(self, ctrCoord, radius, filterName=None, epoch=None)
def applyProperMotions(self, catalog, epoch)
Fit spatial kernel using approximate fluxes for candidates, and solving a linear system of equations...
def convertToNanojansky(catalog, log, doConvert=True)
def getRefFluxField(schema, filterName=None)
def _addFluxAliases(self, schema)
Custom catalog class for record/table subclasses that are guaranteed to have an ID, and should generally be sorted by that ID.
def _trimToCircle(self, refCat, ctrCoord, radius)
def __init__(self, butler, args, kwargs)
Abstract base class to load objects from reference catalogs.