LSST Applications g0b6bd0c080+a72a5dd7e6,g1182afd7b4+2a019aa3bb,g17e5ecfddb+2b8207f7de,g1d67935e3f+06cf436103,g38293774b4+ac198e9f13,g396055baef+6a2097e274,g3b44f30a73+6611e0205b,g480783c3b1+98f8679e14,g48ccf36440+89c08d0516,g4b93dc025c+98f8679e14,g5c4744a4d9+a302e8c7f0,g613e996a0d+e1c447f2e0,g6c8d09e9e7+25247a063c,g7271f0639c+98f8679e14,g7a9cd813b8+124095ede6,g9d27549199+a302e8c7f0,ga1cf026fa3+ac198e9f13,ga32aa97882+7403ac30ac,ga786bb30fb+7a139211af,gaa63f70f4e+9994eb9896,gabf319e997+ade567573c,gba47b54d5d+94dc90c3ea,gbec6a3398f+06cf436103,gc6308e37c7+07dd123edb,gc655b1545f+ade567573c,gcc9029db3c+ab229f5caf,gd01420fc67+06cf436103,gd877ba84e5+06cf436103,gdb4cecd868+6f279b5b48,ge2d134c3d5+cc4dbb2e3f,ge448b5faa6+86d1ceac1d,gecc7e12556+98f8679e14,gf3ee170dca+25247a063c,gf4ac96e456+ade567573c,gf9f5ea5b4d+ac198e9f13,gff490e6085+8c2580be5c,w.2022.27
LSST Data Management Base Package
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
lsst.meas.algorithms.loadReferenceObjects.ReferenceObjectLoaderBase Class Reference
Inheritance diagram for lsst.meas.algorithms.loadReferenceObjects.ReferenceObjectLoaderBase:
lsst.meas.algorithms.loadReferenceObjects.LoadReferenceObjectsTask lsst.meas.algorithms.loadReferenceObjects.ReferenceObjectLoader lsst.meas.algorithms.loadIndexedReferenceObjects.LoadIndexedReferenceObjectsTask

Public Member Functions

def __init__ (self, config=None, *args, **kwargs)
 
def applyProperMotions (self, catalog, epoch)
 
def getMetadataBox (self, bbox, wcs, filterName, epoch=None, bboxToSpherePadding=100)
 
def joinMatchListWithCatalog (self, matchCat, sourceCat)
 

Static Public Member Functions

def makeMinimalSchema (filterNameList, *addCentroid=False, addIsPhotometric=False, addIsResolved=False, addIsVariable=False, coordErrDim=2, addProperMotion=False, properMotionErrDim=2, addParallax=False)
 
def getMetadataCircle (coord, radius, filterName, epoch=None)
 

Public Attributes

 config
 

Static Public Attributes

 ConfigClass = LoadReferenceObjectsConfig
 

Detailed Description

Base class for reference object loaders, to facilitate gen2/gen3 code
sharing.

Parameters
----------
config : `lsst.pex.config.Config`
    Configuration for the loader.

Definition at line 233 of file loadReferenceObjects.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.meas.algorithms.loadReferenceObjects.ReferenceObjectLoaderBase.__init__ (   self,
  config = None,
args,
**  kwargs 
)

Member Function Documentation

◆ applyProperMotions()

def lsst.meas.algorithms.loadReferenceObjects.ReferenceObjectLoaderBase.applyProperMotions (   self,
  catalog,
  epoch 
)
Apply proper motion correction to a reference catalog.

Adjust position and position error in the ``catalog``
for proper motion to the specified ``epoch``,
modifying the catalog in place.

Parameters
----------
catalog : `lsst.afw.table.SimpleCatalog`
    Catalog of positions, containing at least these fields:

    - Coordinates, retrieved by the table's coordinate key.
    - ``coord_raErr`` : Error in Right Ascension (rad).
    - ``coord_decErr`` : Error in Declination (rad).
    - ``pm_ra`` : Proper motion in Right Ascension (rad/yr,
        East positive)
    - ``pm_raErr`` : Error in ``pm_ra`` (rad/yr), optional.
    - ``pm_dec`` : Proper motion in Declination (rad/yr,
        North positive)
    - ``pm_decErr`` : Error in ``pm_dec`` (rad/yr), optional.
    - ``epoch`` : Mean epoch of object (an astropy.time.Time)
epoch : `astropy.time.Time`
    Epoch to which to correct proper motion.
    If None, do not apply PM corrections or raise if
    ``config.requireProperMotion`` is True.

Raises
------
RuntimeError
    Raised if ``config.requireProperMotion`` is set but we cannot
    apply the proper motion correction for some reason.

Definition at line 247 of file loadReferenceObjects.py.

247 def applyProperMotions(self, catalog, epoch):
248 """Apply proper motion correction to a reference catalog.
249
250 Adjust position and position error in the ``catalog``
251 for proper motion to the specified ``epoch``,
252 modifying the catalog in place.
253
254 Parameters
255 ----------
257 Catalog of positions, containing at least these fields:
258
259 - Coordinates, retrieved by the table's coordinate key.
260 - ``coord_raErr`` : Error in Right Ascension (rad).
261 - ``coord_decErr`` : Error in Declination (rad).
262 - ``pm_ra`` : Proper motion in Right Ascension (rad/yr,
263 East positive)
264 - ``pm_raErr`` : Error in ``pm_ra`` (rad/yr), optional.
265 - ``pm_dec`` : Proper motion in Declination (rad/yr,
266 North positive)
267 - ``pm_decErr`` : Error in ``pm_dec`` (rad/yr), optional.
268 - ``epoch`` : Mean epoch of object (an astropy.time.Time)
269 epoch : `astropy.time.Time`
270 Epoch to which to correct proper motion.
271 If None, do not apply PM corrections or raise if
272 ``config.requireProperMotion`` is True.
273
274 Raises
275 ------
276 RuntimeError
277 Raised if ``config.requireProperMotion`` is set but we cannot
278 apply the proper motion correction for some reason.
279 """
280 if epoch is None:
281 if self.config.requireProperMotion:
282 raise RuntimeError("requireProperMotion=True but epoch not provided to loader.")
283 else:
284 self.log.debug("No epoch provided: not applying proper motion corrections to refcat.")
285 return
286
287 # Warn/raise for a catalog in an incorrect format, if epoch was specified.
288 if ("pm_ra" in catalog.schema
289 and not isinstance(catalog.schema["pm_ra"].asKey(), afwTable.KeyAngle)):
290 if self.config.requireProperMotion:
291 raise RuntimeError("requireProperMotion=True but refcat pm_ra field is not an Angle.")
292 else:
293 self.log.warning("Reference catalog pm_ra field is not an Angle; cannot apply proper motion.")
294 return
295
296 if ("epoch" not in catalog.schema or "pm_ra" not in catalog.schema):
297 if self.config.requireProperMotion:
298 raise RuntimeError("requireProperMotion=True but PM data not available from catalog.")
299 else:
300 self.log.warning("Proper motion correction not available for this reference catalog.")
301 return
302
303 applyProperMotionsImpl(self.log, catalog, epoch)
304
Custom catalog class for record/table subclasses that are guaranteed to have an ID,...
Definition: SortedCatalog.h:42

◆ getMetadataBox()

def lsst.meas.algorithms.loadReferenceObjects.ReferenceObjectLoaderBase.getMetadataBox (   self,
  bbox,
  wcs,
  filterName,
  epoch = None,
  bboxToSpherePadding = 100 
)
Return metadata about the load

This metadata is used for reloading the catalog (e.g., for
reconstituting a normalised match list).

Parameters
----------
bbox : `lsst.geom.Box2I` or `lsst.geom.Box2D`
    Bounding box for the pixels.
wcs : `lsst.afw.geom.SkyWcs`
    The WCS object associated with ``bbox``.
filterName : `str`
    Name of the camera filter.
epoch : `astropy.time.Time` or `None`,  optional
    Epoch to which to correct proper motion and parallax, or `None` to
    not apply such corrections.
bboxToSpherePadding : `int`, optional
    Padding in pixels to account for translating a set of corners into
    a spherical (convex) boundary that is certain to encompass the
    enitre area covered by the box.

Returns
-------
md : `lsst.daf.base.PropertyList`
    The metadata detailing the search parameters used for this
    dataset.

Definition at line 679 of file loadReferenceObjects.py.

680 bboxToSpherePadding=100):
681 """Return metadata about the load
682
683 This metadata is used for reloading the catalog (e.g., for
684 reconstituting a normalised match list).
685
686 Parameters
687 ----------
688 bbox : `lsst.geom.Box2I` or `lsst.geom.Box2D`
689 Bounding box for the pixels.
691 The WCS object associated with ``bbox``.
692 filterName : `str`
693 Name of the camera filter.
694 epoch : `astropy.time.Time` or `None`, optional
695 Epoch to which to correct proper motion and parallax, or `None` to
696 not apply such corrections.
697 bboxToSpherePadding : `int`, optional
698 Padding in pixels to account for translating a set of corners into
699 a spherical (convex) boundary that is certain to encompass the
700 enitre area covered by the box.
701
702 Returns
703 -------
705 The metadata detailing the search parameters used for this
706 dataset.
707 """
708 circle = self._calculateCircle(bbox, wcs, self.config.pixelMargin)
709 md = self.getMetadataCircle(circle.coord, circle.radius, filterName, epoch=epoch)
710
711 paddedBbox = circle.bbox
712 _, _, innerCorners, outerCorners = self._makeBoxRegion(paddedBbox, wcs, bboxToSpherePadding)
713 for box, corners in zip(("INNER", "OUTER"), (innerCorners, outerCorners)):
714 for (name, corner) in zip(("UPPER_LEFT", "UPPER_RIGHT", "LOWER_LEFT", "LOWER_RIGHT"),
715 corners):
716 md.add(f"{box}_{name}_RA", geom.SpherePoint(corner).getRa().asDegrees(), f"{box}_corner")
717 md.add(f"{box}_{name}_DEC", geom.SpherePoint(corner).getDec().asDegrees(), f"{box}_corner")
718 return md
719
A 2-dimensional celestial WCS that transform pixels to ICRS RA/Dec, using the LSST standard for pixel...
Definition: SkyWcs.h:117
Class for storing ordered metadata with comments.
Definition: PropertyList.h:68
A floating-point coordinate rectangle geometry.
Definition: Box.h:413
An integer coordinate rectangle.
Definition: Box.h:55
Point in an unspecified spherical coordinate system.
Definition: SpherePoint.h:57

◆ getMetadataCircle()

def lsst.meas.algorithms.loadReferenceObjects.ReferenceObjectLoaderBase.getMetadataCircle (   coord,
  radius,
  filterName,
  epoch = None 
)
static
Return metadata about the reference catalog being loaded.

This metadata is used for reloading the catalog (e.g. for
reconstituting a normalized match list).

Parameters
----------
coord : `lsst.geom.SpherePoint`
    ICRS center of the search region.
radius : `lsst.geom.Angle`
    Radius of the search region.
filterName : `str`
    Name of the camera filter.
epoch : `astropy.time.Time` or `None`, optional
    Epoch to which to correct proper motion and parallax, or `None` to
    not apply such corrections.

Returns
-------
md : `lsst.daf.base.PropertyList`
    Metadata about the catalog.

Definition at line 647 of file loadReferenceObjects.py.

647 def getMetadataCircle(coord, radius, filterName, epoch=None):
648 """Return metadata about the reference catalog being loaded.
649
650 This metadata is used for reloading the catalog (e.g. for
651 reconstituting a normalized match list).
652
653 Parameters
654 ----------
655 coord : `lsst.geom.SpherePoint`
656 ICRS center of the search region.
657 radius : `lsst.geom.Angle`
658 Radius of the search region.
659 filterName : `str`
660 Name of the camera filter.
661 epoch : `astropy.time.Time` or `None`, optional
662 Epoch to which to correct proper motion and parallax, or `None` to
663 not apply such corrections.
664
665 Returns
666 -------
668 Metadata about the catalog.
669 """
670 md = PropertyList()
671 md.add('RA', coord.getRa().asDegrees(), 'field center in degrees')
672 md.add('DEC', coord.getDec().asDegrees(), 'field center in degrees')
673 md.add('RADIUS', radius.asDegrees(), 'field radius in degrees, minimum')
674 md.add('SMATCHV', 1, 'SourceMatchVector version number')
675 md.add('FILTER', filterName, 'filter name for photometric data')
676 md.add('EPOCH', "NONE" if epoch is None else epoch.mjd, 'Epoch (TAI MJD) for catalog')
677 return md
678
A class representing an angle.
Definition: Angle.h:128

◆ joinMatchListWithCatalog()

def lsst.meas.algorithms.loadReferenceObjects.ReferenceObjectLoaderBase.joinMatchListWithCatalog (   self,
  matchCat,
  sourceCat 
)
Relink an unpersisted match list to sources and reference objects.

A match list is persisted and unpersisted as a catalog of IDs
produced by afw.table.packMatches(), with match metadata
(as returned by the astrometry tasks) in the catalog's metadata
attribute. This method converts such a match catalog into a match
list, with links to source records and reference object records.

Parameters
----------
matchCat : `lsst.afw.table.BaseCatalog`
    Unpersisted packed match list.
    ``matchCat.table.getMetadata()`` must contain match metadata,
    as returned by the astrometry tasks.
sourceCat : `lsst.afw.table.SourceCatalog`
    Source catalog. As a side effect, the catalog will be sorted
    by ID.

Returns
-------
matchList : `lsst.afw.table.ReferenceMatchVector`
    Match list.

Definition at line 720 of file loadReferenceObjects.py.

720 def joinMatchListWithCatalog(self, matchCat, sourceCat):
721 """Relink an unpersisted match list to sources and reference objects.
722
723 A match list is persisted and unpersisted as a catalog of IDs
724 produced by afw.table.packMatches(), with match metadata
725 (as returned by the astrometry tasks) in the catalog's metadata
726 attribute. This method converts such a match catalog into a match
727 list, with links to source records and reference object records.
728
729 Parameters
730 ----------
731 matchCat : `lsst.afw.table.BaseCatalog`
732 Unpersisted packed match list.
733 ``matchCat.table.getMetadata()`` must contain match metadata,
734 as returned by the astrometry tasks.
735 sourceCat : `lsst.afw.table.SourceCatalog`
736 Source catalog. As a side effect, the catalog will be sorted
737 by ID.
738
739 Returns
740 -------
742 Match list.
743 """
744 return joinMatchListWithCatalogImpl(self, matchCat, sourceCat)
745
746
def joinMatchListWithCatalogImpl(refObjLoader, matchCat, sourceCat)

◆ makeMinimalSchema()

def lsst.meas.algorithms.loadReferenceObjects.ReferenceObjectLoaderBase.makeMinimalSchema (   filterNameList,
addCentroid = False,
  addIsPhotometric = False,
  addIsResolved = False,
  addIsVariable = False,
  coordErrDim = 2,
  addProperMotion = False,
  properMotionErrDim = 2,
  addParallax = False 
)
static
Make a standard schema for reference object catalogs.

Parameters
----------
filterNameList : `list` of `str`
    List of filter names. Used to create <filterName>_flux fields.
addIsPhotometric : `bool`
    If True then add field "photometric".
addIsResolved : `bool`
    If True then add field "resolved".
addIsVariable : `bool`
    If True then add field "variable".
coordErrDim : `int`
    Number of coord error fields; must be one of 0, 2, 3:

    - If 2 or 3: add fields "coord_raErr" and "coord_decErr".
    - If 3: also add field "coord_radecErr".
addProperMotion : `bool`
    If True add fields "epoch", "pm_ra", "pm_dec" and "pm_flag".
properMotionErrDim : `int`
    Number of proper motion error fields; must be one of 0, 2, 3;
    ignored if addProperMotion false:
    - If 2 or 3: add fields "pm_raErr" and "pm_decErr".
    - If 3: also add field "pm_radecErr".
addParallax : `bool`
    If True add fields "epoch", "parallax", "parallaxErr"
    and "parallax_flag".

Returns
-------
schema : `lsst.afw.table.Schema`
    Schema for reference catalog, an
    `lsst.afw.table.SimpleCatalog`.

Notes
-----
Reference catalogs support additional covariances, such as
covariance between RA and proper motion in declination,
that are not supported by this method, but can be added after
calling this method.

Definition at line 306 of file loadReferenceObjects.py.

310 addParallax=False):
311 """Make a standard schema for reference object catalogs.
312
313 Parameters
314 ----------
315 filterNameList : `list` of `str`
316 List of filter names. Used to create <filterName>_flux fields.
317 addIsPhotometric : `bool`
318 If True then add field "photometric".
319 addIsResolved : `bool`
320 If True then add field "resolved".
321 addIsVariable : `bool`
322 If True then add field "variable".
323 coordErrDim : `int`
324 Number of coord error fields; must be one of 0, 2, 3:
325
326 - If 2 or 3: add fields "coord_raErr" and "coord_decErr".
327 - If 3: also add field "coord_radecErr".
328 addProperMotion : `bool`
329 If True add fields "epoch", "pm_ra", "pm_dec" and "pm_flag".
330 properMotionErrDim : `int`
331 Number of proper motion error fields; must be one of 0, 2, 3;
332 ignored if addProperMotion false:
333 - If 2 or 3: add fields "pm_raErr" and "pm_decErr".
334 - If 3: also add field "pm_radecErr".
335 addParallax : `bool`
336 If True add fields "epoch", "parallax", "parallaxErr"
337 and "parallax_flag".
338
339 Returns
340 -------
341 schema : `lsst.afw.table.Schema`
342 Schema for reference catalog, an
344
345 Notes
346 -----
347 Reference catalogs support additional covariances, such as
348 covariance between RA and proper motion in declination,
349 that are not supported by this method, but can be added after
350 calling this method.
351 """
352 schema = afwTable.SimpleTable.makeMinimalSchema()
353 if addCentroid:
354 afwTable.Point2DKey.addFields(
355 schema,
356 "centroid",
357 "centroid on an exposure, if relevant",
358 "pixel",
359 )
360 schema.addField(
361 field="hasCentroid",
362 type="Flag",
363 doc="is position known?",
364 )
365 for filterName in filterNameList:
366 schema.addField(
367 field="%s_flux" % (filterName,),
368 type=numpy.float64,
369 doc="flux in filter %s" % (filterName,),
370 units="nJy",
371 )
372 for filterName in filterNameList:
373 schema.addField(
374 field="%s_fluxErr" % (filterName,),
375 type=numpy.float64,
376 doc="flux uncertainty in filter %s" % (filterName,),
377 units="nJy",
378 )
379 if addIsPhotometric:
380 schema.addField(
381 field="photometric",
382 type="Flag",
383 doc="set if the object can be used for photometric calibration",
384 )
385 if addIsResolved:
386 schema.addField(
387 field="resolved",
388 type="Flag",
389 doc="set if the object is spatially resolved",
390 )
391 if addIsVariable:
392 schema.addField(
393 field="variable",
394 type="Flag",
395 doc="set if the object has variable brightness",
396 )
397 if coordErrDim not in (0, 2, 3):
398 raise ValueError("coordErrDim={}; must be (0, 2, 3)".format(coordErrDim))
399 if coordErrDim > 0:
400 afwTable.CovarianceMatrix2fKey.addFields(
401 schema=schema,
402 prefix="coord",
403 names=["ra", "dec"],
404 units=["rad", "rad"],
405 diagonalOnly=(coordErrDim == 2),
406 )
407
408 if addProperMotion or addParallax:
409 schema.addField(
410 field="epoch",
411 type=numpy.float64,
412 doc="date of observation (TAI, MJD)",
413 units="day",
414 )
415
416 if addProperMotion:
417 schema.addField(
418 field="pm_ra",
419 type="Angle",
420 doc="proper motion in the right ascension direction = dra/dt * cos(dec)",
421 units="rad/year",
422 )
423 schema.addField(
424 field="pm_dec",
425 type="Angle",
426 doc="proper motion in the declination direction",
427 units="rad/year",
428 )
429 if properMotionErrDim not in (0, 2, 3):
430 raise ValueError("properMotionErrDim={}; must be (0, 2, 3)".format(properMotionErrDim))
431 if properMotionErrDim > 0:
432 afwTable.CovarianceMatrix2fKey.addFields(
433 schema=schema,
434 prefix="pm",
435 names=["ra", "dec"],
436 units=["rad/year", "rad/year"],
437 diagonalOnly=(properMotionErrDim == 2),
438 )
439 schema.addField(
440 field="pm_flag",
441 type="Flag",
442 doc="Set if proper motion or proper motion error is bad",
443 )
444
445 if addParallax:
446 schema.addField(
447 field="parallax",
448 type="Angle",
449 doc="parallax",
450 units="rad",
451 )
452 schema.addField(
453 field="parallaxErr",
454 type="Angle",
455 doc="uncertainty in parallax",
456 units="rad",
457 )
458 schema.addField(
459 field="parallax_flag",
460 type="Flag",
461 doc="Set if parallax or parallax error is bad",
462 )
463 return schema
464
Defines the fields and offsets for a table.
Definition: Schema.h:51
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:174

Member Data Documentation

◆ config

lsst.meas.algorithms.loadReferenceObjects.ReferenceObjectLoaderBase.config

Definition at line 245 of file loadReferenceObjects.py.

◆ ConfigClass

lsst.meas.algorithms.loadReferenceObjects.ReferenceObjectLoaderBase.ConfigClass = LoadReferenceObjectsConfig
static

Definition at line 242 of file loadReferenceObjects.py.


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