LoadReferenceObjectsTask

class lsst.meas.algorithms.LoadReferenceObjectsTask(butler=None, *args, **kwargs)

Bases: Task, ReferenceObjectLoaderBase

Abstract gen2 base class to load objects from reference catalogs.

Methods Summary

applyProperMotions(catalog, epoch)

Apply proper motion correction to a reference catalog.

emptyMetadata()

Empty (clear) the metadata for this Task and all sub-Tasks.

getAllSchemaCatalogs()

Get schema catalogs for all tasks in the hierarchy, combining the results into a single dict.

getFullMetadata()

Get metadata for all tasks.

getFullName()

Get the task name as a hierarchical name including parent task names.

getMetadataBox(bbox, wcs, filterName[, ...])

Return metadata about the load

getMetadataCircle(coord, radius, filterName)

Return metadata about the reference catalog being loaded.

getName()

Get the name of the task.

getSchemaCatalogs()

Get the schemas generated by this task.

getTaskDict()

Get a dictionary of all tasks as a shallow copy.

joinMatchListWithCatalog(matchCat, sourceCat)

Relink an unpersisted match list to sources and reference objects.

loadPixelBox(bbox, wcs, filterName[, ...])

Load reference objects that overlap a rectangular pixel region.

loadSkyCircle(ctrCoord, radius, filterName)

Load reference objects that overlap a circular sky region.

makeField(doc)

Make a lsst.pex.config.ConfigurableField for this task.

makeMinimalSchema(filterNameList, *[, ...])

Make a standard schema for reference object catalogs.

makeSubtask(name, **keyArgs)

Create a subtask as a new instance as the name attribute of this task.

timer(name[, logLevel])

Context manager to log performance data for an arbitrary block of code.

Methods Documentation

applyProperMotions(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:
cataloglsst.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_raProper motion in Right Ascension (rad/yr,

    East positive)

  • pm_raErr : Error in pm_ra (rad/yr), optional.

  • pm_decProper 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)

epochastropy.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.

emptyMetadata() None

Empty (clear) the metadata for this Task and all sub-Tasks.

getAllSchemaCatalogs() Dict[str, Any]

Get schema catalogs for all tasks in the hierarchy, combining the results into a single dict.

Returns:
schemacatalogsdict

Keys are butler dataset type, values are a empty catalog (an instance of the appropriate lsst.afw.table Catalog type) for all tasks in the hierarchy, from the top-level task down through all subtasks.

Notes

This method may be called on any task in the hierarchy; it will return the same answer, regardless.

The default implementation should always suffice. If your subtask uses schemas the override Task.getSchemaCatalogs, not this method.

getFullMetadata() TaskMetadata

Get metadata for all tasks.

Returns:
metadataTaskMetadata

The keys are the full task name. Values are metadata for the top-level task and all subtasks, sub-subtasks, etc.

Notes

The returned metadata includes timing information (if @timer.timeMethod is used) and any metadata set by the task. The name of each item consists of the full task name with . replaced by :, followed by . and the name of the item, e.g.:

topLevelTaskName:subtaskName:subsubtaskName.itemName

using : in the full task name disambiguates the rare situation that a task has a subtask and a metadata item with the same name.

getFullName() str

Get the task name as a hierarchical name including parent task names.

Returns:
fullNamestr

The full name consists of the name of the parent task and each subtask separated by periods. For example:

  • The full name of top-level task “top” is simply “top”.

  • The full name of subtask “sub” of top-level task “top” is “top.sub”.

  • The full name of subtask “sub2” of subtask “sub” of top-level task “top” is “top.sub.sub2”.

getMetadataBox(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:
bboxlsst.geom.Box2I or lsst.geom.Box2D

Bounding box for the pixels.

wcslsst.afw.geom.SkyWcs

The WCS object associated with bbox.

filterNamestr

Name of the camera filter.

epochastropy.time.Time or None, optional

Epoch to which to correct proper motion and parallax, or None to not apply such corrections.

bboxToSpherePaddingint, 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:
mdlsst.daf.base.PropertyList

The metadata detailing the search parameters used for this dataset.

static getMetadataCircle(coord, radius, filterName, epoch=None)

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:
coordlsst.geom.SpherePoint

ICRS center of the search region.

radiuslsst.geom.Angle

Radius of the search region.

filterNamestr

Name of the camera filter.

epochastropy.time.Time or None, optional

Epoch to which to correct proper motion and parallax, or None to not apply such corrections.

Returns:
mdlsst.daf.base.PropertyList

Metadata about the catalog.

getName() str

Get the name of the task.

Returns:
taskNamestr

Name of the task.

See also

getFullName
getSchemaCatalogs() Dict[str, Any]

Get the schemas generated by this task.

Returns:
schemaCatalogsdict

Keys are butler dataset type, values are an empty catalog (an instance of the appropriate lsst.afw.table Catalog type) for this task.

See also

Task.getAllSchemaCatalogs

Notes

Warning

Subclasses that use schemas must override this method. The default implementation returns an empty dict.

This method may be called at any time after the Task is constructed, which means that all task schemas should be computed at construction time, not when data is actually processed. This reflects the philosophy that the schema should not depend on the data.

Returning catalogs rather than just schemas allows us to save e.g. slots for SourceCatalog as well.

getTaskDict() Dict[str, ReferenceType[Task]]

Get a dictionary of all tasks as a shallow copy.

Returns:
taskDictdict

Dictionary containing full task name: task object for the top-level task and all subtasks, sub-subtasks, etc.

joinMatchListWithCatalog(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:
matchCatlsst.afw.table.BaseCatalog

Unpersisted packed match list. matchCat.table.getMetadata() must contain match metadata, as returned by the astrometry tasks.

sourceCatlsst.afw.table.SourceCatalog

Source catalog. As a side effect, the catalog will be sorted by ID.

Returns:
matchListlsst.afw.table.ReferenceMatchVector

Match list.

loadPixelBox(bbox, wcs, filterName, photoCalib=None, epoch=None)

Load reference objects that overlap a rectangular pixel region.

Parameters:
bboxlsst.geom.Box2I or lsst.geom.Box2D

Bounding box for pixels.

wcslsst.afw.geom.SkyWcs

WCS; used to convert pixel positions to sky coordinates and vice-versa.

filterNamestr

Name of filter. This can be used for flux limit comparisons.

photoCalibNone

Deprecated, only included for api compatibility.

epochastropy.time.Time or None, optional

Epoch to which to correct proper motion and parallax, or None to not apply such corrections.

Returns:
resultslsst.pipe.base.Struct

A Struct containing the following fields: refCat : lsst.afw.catalog.SimpleCatalog

A catalog of reference objects with the standard schema, as documented in the main doc string for LoadReferenceObjects. The catalog is guaranteed to be contiguous.

fluxFieldstr

Name of flux field for specified filterName.

Notes

The search algorithm works by searching in a region in sky coordinates whose center is the center of the bbox and radius is large enough to just include all 4 corners of the bbox. Stars that lie outside the bbox are then trimmed from the list.

abstract loadSkyCircle(ctrCoord, radius, filterName, epoch=None, centroids=False)

Load reference objects that overlap a circular sky region.

Parameters:
ctrCoordlsst.geom.SpherePoint

ICRS center of search region.

radiuslsst.geom.Angle

Radius of search region.

filterNamestr

Name of filter. This can be used for flux limit comparisons.

epochastropy.time.Time or None, optional

Epoch to which to correct proper motion and parallax, or None to not apply such corrections.

centroidsbool, optional

Add centroid fields to the loaded Schema. loadPixelBox expects these fields to exist.

Returns:
resultslsst.pipe.base.Struct

A Struct containing the following fields: refCat : lsst.afw.catalog.SimpleCatalog

A catalog of reference objects with the standard schema, as documented in the main doc string for LoadReferenceObjects. The catalog is guaranteed to be contiguous.

fluxFieldstr

Name of flux field for specified filterName.

Notes

Note that subclasses are responsible for performing the proper motion correction, since this is the lowest-level interface for retrieving the catalog.

classmethod makeField(doc: str) ConfigurableField

Make a lsst.pex.config.ConfigurableField for this task.

Parameters:
docstr

Help text for the field.

Returns:
configurableFieldlsst.pex.config.ConfigurableField

A ConfigurableField for this task.

Examples

Provides a convenient way to specify this task is a subtask of another task.

Here is an example of use:

class OtherTaskConfig(lsst.pex.config.Config):
    aSubtask = ATaskClass.makeField("brief description of task")
static makeMinimalSchema(filterNameList, *, addCentroid=False, addIsPhotometric=False, addIsResolved=False, addIsVariable=False, coordErrDim=2, addProperMotion=False, properMotionErrDim=2, addParallax=False)

Make a standard schema for reference object catalogs.

Parameters:
filterNameListlist of str

List of filter names. Used to create <filterName>_flux fields.

addIsPhotometricbool

If True then add field “photometric”.

addIsResolvedbool

If True then add field “resolved”.

addIsVariablebool

If True then add field “variable”.

coordErrDimint

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”.

addProperMotionbool

If True add fields “epoch”, “pm_ra”, “pm_dec” and “pm_flag”.

properMotionErrDimint

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”.

addParallaxbool

If True add fields “epoch”, “parallax”, “parallaxErr” and “parallax_flag”.

Returns:
schemalsst.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.

makeSubtask(name: str, **keyArgs: Any) None

Create a subtask as a new instance as the name attribute of this task.

Parameters:
namestr

Brief name of the subtask.

keyArgs

Extra keyword arguments used to construct the task. The following arguments are automatically provided and cannot be overridden:

  • “config”.

  • “parentTask”.

Notes

The subtask must be defined by Task.config.name, an instance of ConfigurableField or RegistryField.

timer(name: str, logLevel: int = 10) Iterator[None]

Context manager to log performance data for an arbitrary block of code.

Parameters:
namestr

Name of code being timed; data will be logged using item name: Start and End.

logLevel

A logging level constant.

See also

timer.logInfo

Examples

Creating a timer context:

with self.timer("someCodeToTime"):
    pass  # code to time