LSSTApplications
10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
|
Base class for data processing tasks. More...
Public Member Functions | |
def | __init__ |
Create a Task. More... | |
def | emptyMetadata |
Empty (clear) the metadata for this Task and all sub-Tasks. More... | |
def | getSchemaCatalogs |
Return the schemas generated by this task. More... | |
def | getAllSchemaCatalogs |
Call getSchemaCatalogs() on all tasks in the hiearchy, combining the results into a single dict. More... | |
def | getFullMetadata |
Get metadata for all tasks. More... | |
def | getFullName |
Return the task name as a hierarchical name including parent task names. More... | |
def | getName |
Return the name of the task. More... | |
def | getTaskDict |
Return a dictionary of all tasks as a shallow copy. More... | |
def | makeSubtask |
Create a subtask as a new instance self. More... | |
def | timer |
Context manager to log performance data for an arbitrary block of code. More... | |
def | display |
Display an exposure and/or sources. More... | |
def | makeField |
Make an lsst.pex.config.ConfigurableField for this task. More... | |
Public Attributes | |
metadata | |
config | |
log | |
Private Member Functions | |
def | _computeFullName |
Compute the full name of a subtask or metadata item, given its brief name. More... | |
Private Attributes | |
_name | |
_fullName | |
_taskDict | |
_display | |
Base class for data processing tasks.
See pipe_base introduction to learn what tasks are, and how to write a task for more information about writing tasks. If the second link is broken (as it will be before the documentation is cross-linked) then look at the main page of pipe_tasks documentation for a link.
Useful attributes include:
Subclasses typically have a method named "run" to perform the main data processing. Details:
Subclasses must also have an attribute ConfigClass that is a subclass of lsst.pex.config.Config which configures the task. Subclasses should also have an attribute _DefaultName: the default name if there is no parent task. _DefaultName is required for subclasses of CmdLineTask and recommended for subclasses of Task because it simplifies construction (e.g. for unit tests).
Tasks intended to be run from the command line should be subclasses of CmdLineTask, not Task.
def lsst.pipe.base.task.Task.__init__ | ( | self, | |
config = None , |
|||
name = None , |
|||
parentTask = None , |
|||
log = None |
|||
) |
Create a Task.
[in] | config | configuration for this task (an instance of self.ConfigClass, which is a task-specific subclass of lsst.pex.config.Config), or None. If None:
|
[in] | name | brief name of task, or None; if None then defaults to self._DefaultName |
[in] | parentTask | the parent task of this subtask, if any.
|
[in] | log | pexLog log; if None then the default is used; in either case a copy is made using the full task name. |
RuntimeError | if parentTask is None and config is None. |
RuntimeError | if parentTask is not None and name is None. |
RuntimeError | if name is None and _DefaultName does not exist. |
Definition at line 110 of file task.py.
|
private |
Compute the full name of a subtask or metadata item, given its brief name.
For example: if the full name of this task is "top.sub.sub2" then _computeFullName("subname") returns "top.sub.sub2.subname".
[in] | name | brief name of subtask or metadata item |
Definition at line 410 of file task.py.
def lsst.pipe.base.task.Task.display | ( | self, | |
name, | |||
exposure = None , |
|||
sources = () , |
|||
matches = None , |
|||
ctypes = _DefaultDS9CTypes , |
|||
ptypes = _DefaultDS9PTypes , |
|||
sizes = (4, , |
|||
pause = None , |
|||
prompt = None |
|||
) |
Display an exposure and/or sources.
[in] | name | name of product to display |
[in] | exposure | exposure to display (instance of lsst::afw::image::Exposure), or None |
[in] | sources | list of Sources to display, as a single lsst.afw.table.SourceCatalog or a list of lsst.afw.table.SourceCatalog, or an empty list to not display sources |
[in] | matches | list of source matches to display (instances of lsst.afw.table.ReferenceMatch), or None; if any matches are specified then exposure must be provided and have a lsst.afw.image.Wcs. |
[in] | ctypes | array of colors to use on ds9 for displaying sources and matches (in that order). ctypes is indexed as follows, where ctypes is repeatedly cycled through, if necessary:
|
[in] | ptypes | array of ptypes to use on ds9 for displaying sources and matches; indexed like ctypes |
[in] | sizes | array of sizes to use on ds9 for displaying sources and matches; indexed like ctypes |
[in] | pause | pause execution? |
[in] | prompt | prompt for user while paused (ignored if pause is False) |
Exception | if matches specified and exposure is None |
def lsst.pipe.base.task.Task.emptyMetadata | ( | self | ) |
Empty (clear) the metadata for this Task and all sub-Tasks.
Definition at line 157 of file task.py.
def lsst.pipe.base.task.Task.getAllSchemaCatalogs | ( | self | ) |
Call getSchemaCatalogs() on all tasks in the hiearchy, combining the results into a single dict.
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.
Definition at line 181 of file task.py.
def lsst.pipe.base.task.Task.getFullMetadata | ( | self | ) |
Get metadata for all tasks.
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.: topLeveltTaskName: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.
Definition at line 198 of file task.py.
def lsst.pipe.base.task.Task.getFullName | ( | self | ) |
Return the task name as a hierarchical name including parent task names.
The full name consists of the name of the parent task and each subtask separated by periods. For example:
Definition at line 216 of file task.py.
def lsst.pipe.base.task.Task.getName | ( | self | ) |
def lsst.pipe.base.task.Task.getSchemaCatalogs | ( | self | ) |
Return the schemas generated by this task.
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.
See also Task.getAllSchemaCatalogs
Definition at line 162 of file task.py.
def lsst.pipe.base.task.Task.getTaskDict | ( | self | ) |
Return a dictionary of all tasks as a shallow copy.
Definition at line 234 of file task.py.
def lsst.pipe.base.task.Task.makeField | ( | cls, | |
doc | |||
) |
Make an lsst.pex.config.ConfigurableField for this task.
Provides a convenient way to specify this task is a subtask of another task. Here is an example of use:
[in] | cls | this class |
[in] | doc | help text for the field |
Definition at line 394 of file task.py.
def lsst.pipe.base.task.Task.makeSubtask | ( | self, | |
name, | |||
keyArgs | |||
) |
Create a subtask as a new instance self.
<name>
The subtask must be defined by self.config.<name>, an instance of pex_config ConfigurableField.
name | brief name of subtask |
**keyArgs | extra keyword arguments used to construct the task. The following arguments are automatically provided and cannot be overridden: "config" and "parentTask". |
Definition at line 242 of file task.py.
def lsst.pipe.base.task.Task.timer | ( | self, | |
name, | |||
logLevel = pexLog.Log.DEBUG |
|||
) |
Context manager to log performance data for an arbitrary block of code.
[in] | name | name of code being timed; data will be logged using item name: <name>Start<item> and <name>End<item> |
[in] | logLevel | one of the lsst.pex.logging.Log level constants |
Example of use:
See timer.logInfo for the information logged
Definition at line 259 of file task.py.