LSST Applications g02d81e74bb+86cf3d8bc9,g180d380827+7a4e862ed4,g2079a07aa2+86d27d4dc4,g2305ad1205+e1ca1c66fa,g29320951ab+012e1474a1,g295015adf3+341ea1ce94,g2bbee38e9b+0e5473021a,g337abbeb29+0e5473021a,g33d1c0ed96+0e5473021a,g3a166c0a6a+0e5473021a,g3ddfee87b4+c429d67c83,g48712c4677+f88676dd22,g487adcacf7+27e1e21933,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+b41db86c35,g5a732f18d5+53520f316c,g64a986408d+86cf3d8bc9,g858d7b2824+86cf3d8bc9,g8a8a8dda67+585e252eca,g99cad8db69+84912a7fdc,g9ddcbc5298+9a081db1e4,ga1e77700b3+15fc3df1f7,ga8c6da7877+a2b54eae19,gb0e22166c9+60f28cb32d,gba4ed39666+c2a2e4ac27,gbb8dafda3b+6681f309db,gc120e1dc64+f0fcc2f6d8,gc28159a63d+0e5473021a,gcf0d15dbbd+c429d67c83,gdaeeff99f8+f9a426f77a,ge6526c86ff+0433e6603d,ge79ae78c31+0e5473021a,gee10cc3b42+585e252eca,gff1a9f87cc+86cf3d8bc9,w.2024.17
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
lsst.pipe.tasks.loadReferenceCatalog.LoadReferenceCatalogTask Class Reference
Inheritance diagram for lsst.pipe.tasks.loadReferenceCatalog.LoadReferenceCatalogTask:

Public Member Functions

 __init__ (self, *dataIds, refCats, name, **kwargs)
 
 getPixelBoxCatalog (self, bbox, wcs, filterList, epoch=None, bboxToSpherePadding=None)
 
 getSkyCircleCatalog (self, center, radius, filterList, epoch=None, catalogFormat='numpy')
 

Public Attributes

 refObjLoader
 

Static Public Attributes

 ConfigClass = LoadReferenceCatalogConfig
 

Protected Member Functions

 _formatCatalog (self, refCat, filterList)
 
 _determineFluxFields (self, center, filterList)
 

Protected Attributes

 _fluxFilters
 
 _fluxFields
 
 _referenceFilter
 

Static Protected Attributes

str _DefaultName = "loadReferenceCatalog"
 

Detailed Description

Load multi-band reference objects from a reference catalog.

Parameters
----------
dataIds : iterable of `lsst.daf.butler.dataId`
    An iterable object of dataIds which point to reference catalogs
    in a Gen3 repository.  Required for Gen3.
refCats : iterable of `lsst.daf.butler.DeferredDatasetHandle`
    An iterable object of dataset refs for reference catalogs in
    a Gen3 repository.
name : `str`
    The name of the refcat that this object will load. This name is used
    for applying colorterms, for example.

Raises
------
RuntimeError if dataIds or refCats is None.

Definition at line 77 of file loadReferenceCatalog.py.

Constructor & Destructor Documentation

◆ __init__()

lsst.pipe.tasks.loadReferenceCatalog.LoadReferenceCatalogTask.__init__ ( self,
* dataIds,
refCats,
name,
** kwargs )

Definition at line 99 of file loadReferenceCatalog.py.

99 def __init__(self, *, dataIds, refCats, name, **kwargs):
100 pipeBase.Task.__init__(self, **kwargs)
101 refConfig = self.config.refObjLoader
102 self.refObjLoader = ReferenceObjectLoader(dataIds=dataIds,
103 refCats=refCats,
104 name=name,
105 config=refConfig,
106 log=self.log)
107
108 if self.config.doReferenceSelection:
109 self.makeSubtask('referenceSelector')
110 self._fluxFilters = None
111 self._fluxFields = None
112 self._referenceFilter = None
113

Member Function Documentation

◆ _determineFluxFields()

lsst.pipe.tasks.loadReferenceCatalog.LoadReferenceCatalogTask._determineFluxFields ( self,
center,
filterList )
protected
Determine the flux field names for a reference catalog.

This method sets self._fluxFields, self._referenceFilter.

Parameters
----------
center : `lsst.geom.SpherePoint`
    The center around which to load test sources.
filterList : `list` [`str`]
    List of camera physicalFilter names.

Definition at line 306 of file loadReferenceCatalog.py.

306 def _determineFluxFields(self, center, filterList):
307 """Determine the flux field names for a reference catalog.
308
309 This method sets self._fluxFields, self._referenceFilter.
310
311 Parameters
312 ----------
313 center : `lsst.geom.SpherePoint`
314 The center around which to load test sources.
315 filterList : `list` [`str`]
316 List of camera physicalFilter names.
317 """
318 # Search for a good filter to use to load the reference catalog
319 # via the refObjLoader task which requires a valid filterName
320 foundReferenceFilter = False
321
322 # Store the original config
323 _config = self.refObjLoader.config
324
325 configTemp = LoadReferenceObjectsConfig()
326 configIntersection = {k: getattr(self.refObjLoader.config, k)
327 for k, v in self.refObjLoader.config.toDict().items()
328 if (k in configTemp.keys() and k != "connections")}
329 # We must turn off the proper motion checking to find the refFilter.
330 configIntersection['requireProperMotion'] = False
331 configTemp.update(**configIntersection)
332
333 self.refObjLoader.config = configTemp
334
335 for filterName in filterList:
336 if self.config.refObjLoader.anyFilterMapsToThis is not None:
337 refFilterName = self.config.refObjLoader.anyFilterMapsToThis
338 else:
339 refFilterName = self.config.refObjLoader.filterMap.get(filterName)
340 if refFilterName is None:
341 continue
342 try:
343 results = self.refObjLoader.loadSkyCircle(center,
344 0.05*lsst.geom.degrees,
345 refFilterName)
346 foundReferenceFilter = True
347 self._referenceFilter = refFilterName
348 break
349 except RuntimeError as err:
350 # This just means that the filterName wasn't listed
351 # in the reference catalog. This is okay.
352 if 'not find flux' in err.args[0]:
353 # The filterName wasn't listed in the reference catalog.
354 # This is not a fatal failure (yet)
355 pass
356 else:
357 raise err
358
359 self.refObjLoader.config = _config
360
361 if not foundReferenceFilter:
362 raise RuntimeError("Could not find any valid flux field(s) %s" %
363 (", ".join(filterList)))
364
365 # Record self._fluxFilters for checks on subsequent calls
366 self._fluxFilters = filterList
367
368 # Retrieve all the fluxField names
369 self._fluxFields = []
370 for filterName in filterList:
371 fluxField = None
372
373 if self.config.refObjLoader.anyFilterMapsToThis is not None:
374 refFilterName = self.config.refObjLoader.anyFilterMapsToThis
375 else:
376 refFilterName = self.config.refObjLoader.filterMap.get(filterName)
377
378 if refFilterName is not None:
379 try:
380 fluxField = getRefFluxField(results.refCat.schema, filterName=refFilterName)
381 except RuntimeError:
382 # This flux field isn't available. Set to None
383 fluxField = None
384
385 if fluxField is None:
386 self.log.warning('No reference flux field for camera filter %s', filterName)
387
388 self._fluxFields.append(fluxField)
std::vector< SchemaItem< Flag > > * items

◆ _formatCatalog()

lsst.pipe.tasks.loadReferenceCatalog.LoadReferenceCatalogTask._formatCatalog ( self,
refCat,
filterList )
protected
Format a reference afw table into the final format.

This method applies reference selections and color terms as specified
by the config.

Parameters
----------
refCat : `lsst.afw.table.SourceCatalog`
    Reference catalog in afw format.
filterList : `list` [`str`]
    List of camera physicalFilter names to apply color terms.

Returns
-------
refCat : `numpy.ndarray`
    Reference catalog.

Definition at line 224 of file loadReferenceCatalog.py.

224 def _formatCatalog(self, refCat, filterList):
225 """Format a reference afw table into the final format.
226
227 This method applies reference selections and color terms as specified
228 by the config.
229
230 Parameters
231 ----------
232 refCat : `lsst.afw.table.SourceCatalog`
233 Reference catalog in afw format.
234 filterList : `list` [`str`]
235 List of camera physicalFilter names to apply color terms.
236
237 Returns
238 -------
239 refCat : `numpy.ndarray`
240 Reference catalog.
241 """
242 if self.config.doReferenceSelection:
243 goodSources = self.referenceSelector.selectSources(refCat)
244 selected = goodSources.selected
245 else:
246 selected = np.ones(len(refCat), dtype=bool)
247
248 npRefCat = np.zeros(np.sum(selected), dtype=[('ra', 'f8'),
249 ('dec', 'f8'),
250 ('refMag', 'f4', (len(filterList), )),
251 ('refMagErr', 'f4', (len(filterList), ))])
252
253 if npRefCat.size == 0:
254 # Return an empty catalog if we don't have any selected sources.
255 return npRefCat
256
257 # Natively "coord_ra" and "coord_dec" are stored in radians.
258 # Doing this as an array rather than by row with the coord access is
259 # approximately 600x faster.
260 npRefCat['ra'] = np.rad2deg(refCat['coord_ra'][selected])
261 npRefCat['dec'] = np.rad2deg(refCat['coord_dec'][selected])
262
263 # Default (unset) values are 99.0
264 npRefCat['refMag'][:, :] = 99.0
265 npRefCat['refMagErr'][:, :] = 99.0
266
267 if self.config.doApplyColorTerms:
268 refCatName = self.refObjLoader.name
269
270 for i, (filterName, fluxField) in enumerate(zip(self._fluxFilters, self._fluxFields)):
271 if fluxField is None:
272 # There is no matching reference band.
273 # This will leave the column filled with 99s
274 continue
275 self.log.debug("Applying color terms for filterName='%s'", filterName)
276
277 colorterm = self.config.colorterms.getColorterm(filterName, refCatName, doRaise=True)
278
279 refMag, refMagErr = colorterm.getCorrectedMagnitudes(refCat)
280
281 # nan_to_num replaces nans with zeros, and this ensures
282 # that we select magnitudes that both filter out nans and are
283 # not very large (corresponding to very small fluxes), as "99"
284 # is a commen sentinel for illegal magnitudes.
285 good, = np.where((np.nan_to_num(refMag[selected], nan=99.0) < 90.0)
286 & (np.nan_to_num(refMagErr[selected], nan=99.0) < 90.0)
287 & (np.nan_to_num(refMagErr[selected]) > 0.0))
288
289 npRefCat['refMag'][good, i] = refMag[selected][good]
290 npRefCat['refMagErr'][good, i] = refMagErr[selected][good]
291 else:
292 # No color terms to apply
293 for i, (filterName, fluxField) in enumerate(zip(self._fluxFilters, self._fluxFields)):
294 # nan_to_num replaces nans with zeros, and this ensures that
295 # we select fluxes that both filter out nans and are positive.
296 good, = np.where((np.nan_to_num(refCat[fluxField][selected]) > 0.0)
297 & (np.nan_to_num(refCat[fluxField+'Err'][selected]) > 0.0))
298 refMag = (refCat[fluxField][selected][good]*units.nJy).to_value(units.ABmag)
299 refMagErr = abMagErrFromFluxErr(refCat[fluxField+'Err'][selected][good],
300 refCat[fluxField][selected][good])
301 npRefCat['refMag'][good, i] = refMag
302 npRefCat['refMagErr'][good, i] = refMagErr
303
304 return npRefCat
305

◆ getPixelBoxCatalog()

lsst.pipe.tasks.loadReferenceCatalog.LoadReferenceCatalogTask.getPixelBoxCatalog ( self,
bbox,
wcs,
filterList,
epoch = None,
bboxToSpherePadding = None )
Get a multi-band reference catalog by specifying a bounding box and WCS.

The catalog will be in `numpy.ndarray`, with positions proper-motion
corrected to "epoch" (if specified, and if the reference catalog has
proper motions); sources cut on a reference selector (if
"config.doReferenceSelection = True"); and color-terms applied (if
"config.doApplyColorTerms = True").

The format of the reference catalog will be of the format:

dtype = [('ra', 'np.float64'),
         ('dec', 'np.float64'),
         ('refMag', 'np.float32', (len(filterList), )),
         ('refMagErr', 'np.float32', (len(filterList), ))]

Reference magnitudes (AB) and errors will be 99 for non-detections
in a given band.

Parameters
----------
bbox : `lsst.geom.Box2I`
    Box which bounds a region in pixel space.
wcs : `lsst.afw.geom.SkyWcs`
    Wcs object defining the pixel to sky (and reverse) transform for
    the supplied bbox.
filterList : `List` [ `str` ]
    List of camera physicalFilter names to retrieve magnitudes.
epoch : `astropy.time.Time`, optional
    Epoch to which to correct proper motion and parallax
    (if available), or `None` to not apply such corrections.
bboxToSpherePadding : `int`, optional
    Padding to account for translating a set of corners into a
    spherical (convex) boundary that is certain to encompass the
    entire area covered by the bbox.

Returns
-------
refCat : `numpy.ndarray`
    Reference catalog.

Definition at line 114 of file loadReferenceCatalog.py.

115 bboxToSpherePadding=None):
116 """Get a multi-band reference catalog by specifying a bounding box and WCS.
117
118 The catalog will be in `numpy.ndarray`, with positions proper-motion
119 corrected to "epoch" (if specified, and if the reference catalog has
120 proper motions); sources cut on a reference selector (if
121 "config.doReferenceSelection = True"); and color-terms applied (if
122 "config.doApplyColorTerms = True").
123
124 The format of the reference catalog will be of the format:
125
126 dtype = [('ra', 'np.float64'),
127 ('dec', 'np.float64'),
128 ('refMag', 'np.float32', (len(filterList), )),
129 ('refMagErr', 'np.float32', (len(filterList), ))]
130
131 Reference magnitudes (AB) and errors will be 99 for non-detections
132 in a given band.
133
134 Parameters
135 ----------
136 bbox : `lsst.geom.Box2I`
137 Box which bounds a region in pixel space.
138 wcs : `lsst.afw.geom.SkyWcs`
139 Wcs object defining the pixel to sky (and reverse) transform for
140 the supplied bbox.
141 filterList : `List` [ `str` ]
142 List of camera physicalFilter names to retrieve magnitudes.
143 epoch : `astropy.time.Time`, optional
144 Epoch to which to correct proper motion and parallax
145 (if available), or `None` to not apply such corrections.
146 bboxToSpherePadding : `int`, optional
147 Padding to account for translating a set of corners into a
148 spherical (convex) boundary that is certain to encompass the
149 entire area covered by the bbox.
150
151 Returns
152 -------
153 refCat : `numpy.ndarray`
154 Reference catalog.
155 """
156 # Check if we have previously cached values for the fluxFields
157 if self._fluxFilters is None or self._fluxFilters != filterList:
158 center = wcs.pixelToSky(bbox.getCenter())
159 self._determineFluxFields(center, filterList)
160
161 skyBox = self.refObjLoader.loadPixelBox(bbox, wcs, self._referenceFilter,
162 epoch=epoch,
163 bboxToSpherePadding=bboxToSpherePadding)
164
165 if not skyBox.refCat.isContiguous():
166 refCat = skyBox.refCat.copy(deep=True)
167 else:
168 refCat = skyBox.refCat
169
170 return self._formatCatalog(refCat, filterList)
171

◆ getSkyCircleCatalog()

lsst.pipe.tasks.loadReferenceCatalog.LoadReferenceCatalogTask.getSkyCircleCatalog ( self,
center,
radius,
filterList,
epoch = None,
catalogFormat = 'numpy' )
Get a multi-band reference catalog by specifying a center and radius.

The catalog will be in `numpy.ndarray`, with positions proper-motion
corrected to "epoch" (if specified, and if the reference catalog has
proper motions); sources cut on a reference selector (if
"config.doReferenceSelection = True"); and color-terms applied (if
"config.doApplyColorTerms = True").

The format of the reference catalog will be of the format:

dtype = [('ra', 'np.float64'),
         ('dec', 'np.float64'),
         ('refMag', 'np.float32', (len(filterList), )),
         ('refMagErr', 'np.float32', (len(filterList), ))]

Reference magnitudes (AB) and errors will be 99 for non-detections
in a given band.

Parameters
----------
center : `lsst.geom.SpherePoint`
    Point defining the center of the circular region.
radius : `lsst.geom.Angle`
    Defines the angular radius of the circular region.
filterList : `List` [ `str` ]
    List of camera physicalFilter names to retrieve magnitudes.
epoch : `astropy.time.Time`, optional
    Epoch to which to correct proper motion and parallax
    (if available), or `None` to not apply such corrections.

Returns
-------
refCat : `numpy.ndarray`
    Reference catalog.

Definition at line 172 of file loadReferenceCatalog.py.

173 catalogFormat='numpy'):
174 """Get a multi-band reference catalog by specifying a center and radius.
175
176 The catalog will be in `numpy.ndarray`, with positions proper-motion
177 corrected to "epoch" (if specified, and if the reference catalog has
178 proper motions); sources cut on a reference selector (if
179 "config.doReferenceSelection = True"); and color-terms applied (if
180 "config.doApplyColorTerms = True").
181
182 The format of the reference catalog will be of the format:
183
184 dtype = [('ra', 'np.float64'),
185 ('dec', 'np.float64'),
186 ('refMag', 'np.float32', (len(filterList), )),
187 ('refMagErr', 'np.float32', (len(filterList), ))]
188
189 Reference magnitudes (AB) and errors will be 99 for non-detections
190 in a given band.
191
192 Parameters
193 ----------
194 center : `lsst.geom.SpherePoint`
195 Point defining the center of the circular region.
196 radius : `lsst.geom.Angle`
197 Defines the angular radius of the circular region.
198 filterList : `List` [ `str` ]
199 List of camera physicalFilter names to retrieve magnitudes.
200 epoch : `astropy.time.Time`, optional
201 Epoch to which to correct proper motion and parallax
202 (if available), or `None` to not apply such corrections.
203
204 Returns
205 -------
206 refCat : `numpy.ndarray`
207 Reference catalog.
208 """
209 # Check if we have previously cached values for the fluxFields
210 if self._fluxFilters is None or self._fluxFilters != filterList:
211 self._determineFluxFields(center, filterList)
212
213 skyCircle = self.refObjLoader.loadSkyCircle(center, radius,
214 self._referenceFilter,
215 epoch=epoch)
216
217 if not skyCircle.refCat.isContiguous():
218 refCat = skyCircle.refCat.copy(deep=True)
219 else:
220 refCat = skyCircle.refCat
221
222 return self._formatCatalog(refCat, filterList)
223

Member Data Documentation

◆ _DefaultName

str lsst.pipe.tasks.loadReferenceCatalog.LoadReferenceCatalogTask._DefaultName = "loadReferenceCatalog"
staticprotected

Definition at line 97 of file loadReferenceCatalog.py.

◆ _fluxFields

lsst.pipe.tasks.loadReferenceCatalog.LoadReferenceCatalogTask._fluxFields
protected

Definition at line 111 of file loadReferenceCatalog.py.

◆ _fluxFilters

lsst.pipe.tasks.loadReferenceCatalog.LoadReferenceCatalogTask._fluxFilters
protected

Definition at line 110 of file loadReferenceCatalog.py.

◆ _referenceFilter

lsst.pipe.tasks.loadReferenceCatalog.LoadReferenceCatalogTask._referenceFilter
protected

Definition at line 112 of file loadReferenceCatalog.py.

◆ ConfigClass

lsst.pipe.tasks.loadReferenceCatalog.LoadReferenceCatalogTask.ConfigClass = LoadReferenceCatalogConfig
static

Definition at line 96 of file loadReferenceCatalog.py.

◆ refObjLoader

lsst.pipe.tasks.loadReferenceCatalog.LoadReferenceCatalogTask.refObjLoader

Definition at line 102 of file loadReferenceCatalog.py.


The documentation for this class was generated from the following file: