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
Public Member Functions | Static Public Attributes | Private Member Functions | Static Private Attributes | List of all members
lsst.pipe.tasks.exampleCmdLineTask.ExampleCmdLineTask Class Reference

Example command-line task that computes simple statistics on an image. More...

Inheritance diagram for lsst.pipe.tasks.exampleCmdLineTask.ExampleCmdLineTask:

Public Member Functions

def __init__
 
def run
 Compute a few statistics on the image plane of an exposure. More...
 

Static Public Attributes

 ConfigClass = ExampleCmdLineConfig
 

Private Member Functions

def _getConfigName
 Get the name prefix for the task config's dataset type, or None to prevent persisting the config. More...
 
def _getMetadataName
 Get the name prefix for the task metadata's dataset type, or None to prevent persisting metadata. More...
 

Static Private Attributes

string _DefaultName = "exampleTask"
 

Detailed Description

Example command-line task that computes simple statistics on an image.

Contents

Description

Example command-line task that computes simple statistics on an image.

This task was written as an example for the documents How to Write a Task and How to Write a Command-Line Task. The task reads in a "calexp" (a calibrated science exposure), computes statistics on the image plane, and logs and returns the statistics. In addition, if debugging is enabled, it displays the image in ds9.

The image statistics are computed using a subtask, in order to show how to call subtasks and how to retarget (replace) them with variant subtasks.

The main method is run.

Configuration parameters

See ExampleCmdLineConfig

Debug variables

This task supports the following debug variables:

display
If True then display the exposure in ds9

To enable debugging, see Using lsstDebug to control debugging output.

A complete example of using ExampleCmdLineTask

This code is in examples/exampleCmdLineTask.py, and can be run as follows:

1 examples/exampleCmdLineTask.py $OBS_TEST_DIR/data/input --id
2 # that will process all data; you can also try any combination of these flags:
3 --id filter=g
4 --config doFail=True --doraise
5 --show config data

Definition at line 51 of file exampleCmdLineTask.py.

Constructor & Destructor Documentation

def lsst.pipe.tasks.exampleCmdLineTask.ExampleCmdLineTask.__init__ (   self,
  args,
  kwargs 
)
Construct an ExampleCmdLineTask

Call the parent class constructor and make the "stats" subtask from the config field of the same name.

Definition at line 104 of file exampleCmdLineTask.py.

105  def __init__(self, *args, **kwargs):
106  """Construct an ExampleCmdLineTask
107 
108  Call the parent class constructor and make the "stats" subtask from the config field of the same name.
109  """
110  pipeBase.CmdLineTask.__init__(self, *args, **kwargs)
111  self.makeSubtask("stats")

Member Function Documentation

def lsst.pipe.tasks.exampleCmdLineTask.ExampleCmdLineTask._getConfigName (   self)
private

Get the name prefix for the task config's dataset type, or None to prevent persisting the config.

This override returns None to avoid persisting metadata for this trivial task.

However, if the method returns a name, then the full name of the dataset type will be <name>_config. The default CmdLineTask._getConfigName returns _DefaultName, which for this task would result in a dataset name of "exampleTask_config".

Normally you can use the default CmdLineTask._getConfigName, but here are two reasons why you might want to override it:

Normally if you override _getConfigName then you override _getMetadataName to match.

Definition at line 142 of file exampleCmdLineTask.py.

143  def _getConfigName(self):
144  """!Get the name prefix for the task config's dataset type, or None to prevent persisting the config
145 
146  This override returns None to avoid persisting metadata for this trivial task.
147 
148  However, if the method returns a name, then the full name of the dataset type will be <name>_config.
149  The default CmdLineTask._getConfigName returns _DefaultName,
150  which for this task would result in a dataset name of "exampleTask_config".
151 
152  Normally you can use the default CmdLineTask._getConfigName, but here are two reasons
153  why you might want to override it:
154  - If you do not want your task to write its config, then have the override return None.
155  That is done for this example task, because I didn't want to clutter up the
156  repository with config information for a trivial task.
157  - If the default name would not be unique. An example is
158  \ref lsst.pipe.tasks.makeSkyMap.MakeSkyMapTask "MakeSkyMapTask": it makes a
159  \ref lsst.skymap.SkyMap "sky map" (sky pixelization for a coadd)
160  for any of several different types of coadd, such as deep or goodSeeing.
161  As such, the name of the persisted config must include the coadd type in order to be unique.
162 
163  Normally if you override _getConfigName then you override _getMetadataName to match.
164  """
165  return None
def _getConfigName
Get the name prefix for the task config&#39;s dataset type, or None to prevent persisting the config...
def lsst.pipe.tasks.exampleCmdLineTask.ExampleCmdLineTask._getMetadataName (   self)
private

Get the name prefix for the task metadata's dataset type, or None to prevent persisting metadata.

This override returns None to avoid persisting metadata for this trivial task.

However, if the method returns a name, then the full name of the dataset type will be <name>_metadata. The default CmdLineTask._getConfigName returns _DefaultName, which for this task would result in a dataset name of "exampleTask_metadata".

See the description of _getConfigName for reasons to override this method.

Definition at line 166 of file exampleCmdLineTask.py.

167  def _getMetadataName(self):
168  """!Get the name prefix for the task metadata's dataset type, or None to prevent persisting metadata
169 
170  This override returns None to avoid persisting metadata for this trivial task.
171 
172  However, if the method returns a name, then the full name of the dataset type will be <name>_metadata.
173  The default CmdLineTask._getConfigName returns _DefaultName,
174  which for this task would result in a dataset name of "exampleTask_metadata".
175 
176  See the description of _getConfigName for reasons to override this method.
177  """
178  return None
def _getMetadataName
Get the name prefix for the task metadata&#39;s dataset type, or None to prevent persisting metadata...
def lsst.pipe.tasks.exampleCmdLineTask.ExampleCmdLineTask.run (   self,
  dataRef 
)

Compute a few statistics on the image plane of an exposure.

Parameters
dataRef:data reference for a calibrated science exposure ("calexp")
Returns
a pipeBase Struct containing:
  • mean: mean of image plane
  • meanErr: uncertainty in mean
  • stdDev: standard deviation of image plane
  • stdDevErr: uncertainty in standard deviation

Definition at line 113 of file exampleCmdLineTask.py.

114  def run(self, dataRef):
115  """!Compute a few statistics on the image plane of an exposure
116 
117  @param dataRef: data reference for a calibrated science exposure ("calexp")
118  @return a pipeBase Struct containing:
119  - mean: mean of image plane
120  - meanErr: uncertainty in mean
121  - stdDev: standard deviation of image plane
122  - stdDevErr: uncertainty in standard deviation
123  """
124  self.log.info("Processing data ID %s" % (dataRef.dataId,))
125  if self.config.doFail:
126  raise pipeBase.TaskError("Raising TaskError by request (config.doFail=True)")
127 
128  # Unpersist the raw exposure pointed to by the data reference
129  rawExp = dataRef.get("raw")
130  maskedImage = rawExp.getMaskedImage()
131 
132  # Support extra debug output.
133  # -
134  import lsstDebug
135  display = lsstDebug.Info(__name__).display
136  if display:
137  frame = 1
138  mtv(rawExp, frame=frame, title="exposure")
139 
140  # return the pipe_base Struct that is returned by self.stats.run
141  return self.stats.run(maskedImage)
def run
Compute a few statistics on the image plane of an exposure.

Member Data Documentation

string lsst.pipe.tasks.exampleCmdLineTask.ExampleCmdLineTask._DefaultName = "exampleTask"
staticprivate

Definition at line 102 of file exampleCmdLineTask.py.

lsst.pipe.tasks.exampleCmdLineTask.ExampleCmdLineTask.ConfigClass = ExampleCmdLineConfig
static

Definition at line 101 of file exampleCmdLineTask.py.


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