LSSTApplications  11.0-13-gbb96280,12.1.rc1,12.1.rc1+1,12.1.rc1+2,12.1.rc1+5,12.1.rc1+8,12.1.rc1-1-g06d7636+1,12.1.rc1-1-g253890b+5,12.1.rc1-1-g3d31b68+7,12.1.rc1-1-g3db6b75+1,12.1.rc1-1-g5c1385a+3,12.1.rc1-1-g83b2247,12.1.rc1-1-g90cb4cf+6,12.1.rc1-1-g91da24b+3,12.1.rc1-2-g3521f8a,12.1.rc1-2-g39433dd+4,12.1.rc1-2-g486411b+2,12.1.rc1-2-g4c2be76,12.1.rc1-2-gc9c0491,12.1.rc1-2-gda2cd4f+6,12.1.rc1-3-g3391c73+2,12.1.rc1-3-g8c1bd6c+1,12.1.rc1-3-gcf4b6cb+2,12.1.rc1-4-g057223e+1,12.1.rc1-4-g19ed13b+2,12.1.rc1-4-g30492a7
LSSTDataManagementBasePackage
processCcd.py
Go to the documentation of this file.
1 #
2 # LSST Data Management System
3 # Copyright 2008-2015 AURA/LSST.
4 #
5 # This product includes software developed by the
6 # LSST Project (http://www.lsst.org/).
7 #
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
12 #
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the LSST License Statement and
19 # the GNU General Public License along with this program. If not,
20 # see <https://www.lsstcorp.org/LegalNotices/>.
21 #
22 from lsst.ip.isr import IsrTask
23 import lsst.pex.config as pexConfig
24 import lsst.pipe.base as pipeBase
25 from .calibrate import CalibrateTask
26 from .characterizeImage import CharacterizeImageTask
27 
28 __all__ = ["ProcessCcdConfig", "ProcessCcdTask"]
29 
30 class ProcessCcdConfig(pexConfig.Config):
31  """Config for ProcessCcd"""
32  isr = pexConfig.ConfigurableField(
33  target = IsrTask,
34  doc = """Task to perform instrumental signature removal or load a post-ISR image; ISR consists of:
35  - assemble raw amplifier images into an exposure with image, variance and mask planes
36  - perform bias subtraction, flat fielding, etc.
37  - mask known bad pixels
38  - provide a preliminary WCS
39  """,
40  )
41  charImage = pexConfig.ConfigurableField(
42  target = CharacterizeImageTask,
43  doc = """Task to characterize a science exposure:
44  - detect sources, usually at high S/N
45  - estimate the background, which is subtracted from the image and returned as field "background"
46  - estimate a PSF model, which is added to the exposure
47  - interpolate over defects and cosmic rays, updating the image, variance and mask planes
48  """,
49  )
50  doCalibrate = pexConfig.Field(
51  dtype = bool,
52  default = True,
53  doc = "Perform calibration?",
54  )
55  calibrate = pexConfig.ConfigurableField(
56  target = CalibrateTask,
57  doc = """Task to perform astrometric and photometric calibration:
58  - refine the WCS in the exposure
59  - refine the Calib photometric calibration object in the exposure
60  - detect sources, usually at low S/N
61  """,
62  )
63 
64 
65 ## \addtogroup LSST_task_documentation
66 ## \{
67 ## \page ProcessCcdTask
68 ## \ref ProcessCcdTask_ "ProcessCcdTask"
69 ## \copybrief ProcessCcdTask
70 ## \}
71 
72 class ProcessCcdTask(pipeBase.CmdLineTask):
73  """!Assemble raw data, fit the PSF, detect and measure, and fit WCS and zero-point
74 
75  @anchor ProcessCcdTask_
76 
77  @section pipe_tasks_processCcd_Contents Contents
78 
79  - @ref pipe_tasks_processCcd_Purpose
80  - @ref pipe_tasks_processCcd_Initialize
81  - @ref pipe_tasks_processCcd_IO
82  - @ref pipe_tasks_processCcd_Config
83  - @ref pipe_tasks_processCcd_Debug
84  - @ref pipe_tasks_processCcd_Example
85 
86  @section pipe_tasks_processCcd_Purpose Description
87 
88  Perform the following operations:
89  - Call isr to unpersist raw data and assemble it into a post-ISR exposure
90  - Call charImage subtract background, fit a PSF model, repair cosmic rays,
91  detect and measure bright sources, and measure aperture correction
92  - Call calibrate to perform deep detection, deblending and single-frame measurement,
93  refine the WCS and fit the photometric zero-point
94 
95  @section pipe_tasks_processCcd_Initialize Task initialisation
96 
97  @copydoc \_\_init\_\_
98 
99  @section pipe_tasks_processCcd_IO Invoking the Task
100 
101  This task is primarily designed to be run from the command line.
102 
103  The main method is `run`, which takes a single butler data reference for the raw input data.
104 
105  @section pipe_tasks_processCcd_Config Configuration parameters
106 
107  See @ref ProcessCcdConfig
108 
109  @section pipe_tasks_processCcd_Debug Debug variables
110 
111  ProcessCcdTask has no debug output, but its subtasks do.
112 
113  @section pipe_tasks_processCcd_Example A complete example of using ProcessCcdTask
114 
115  The following commands will process all raw data in obs_test's data repository.
116  Note: be sure to specify an `--output` that does not already exist:
117 
118  setup obs_test
119  setup pipe_tasks
120  processCcd.py $OBS_TEST_DIR/data/input --output processCcdOut --id
121 
122  The data is read from the small repository in the `obs_test` package and written `./processCcdOut`
123  (or whatever output you specified). Specifying `--id` with no values processes all data.
124  Add the option `--help` to see more options.
125  """
126  ConfigClass = ProcessCcdConfig
127  RunnerClass = pipeBase.ButlerInitializedTaskRunner
128  _DefaultName = "processCcd"
129 
130  def __init__(self, butler=None, refObjLoader=None, **kwargs):
131  """!
132  @param[in] butler The butler is passed to the refObjLoader constructor in case it is
133  needed. Ignored if the refObjLoader argument provides a loader directly.
134  @param[in] refObjLoader An instance of LoadReferenceObjectsTasks that supplies an
135  external reference catalog. May be None if the desired loader can be constructed
136  from the butler argument or all steps requiring a reference catalog are disabled.
137  @param[in,out] kwargs other keyword arguments for lsst.pipe.base.CmdLineTask
138  """
139  pipeBase.CmdLineTask.__init__(self, **kwargs)
140  self.makeSubtask("isr")
141  self.makeSubtask("charImage", butler=butler, refObjLoader=refObjLoader)
142  self.makeSubtask("calibrate", butler=butler, icSourceSchema=self.charImage.schema,
143  refObjLoader=refObjLoader)
144 
145  @pipeBase.timeMethod
146  def run(self, sensorRef):
147  """Process one CCD
148 
149  The sequence of operations is:
150  - remove instrument signature
151  - characterize image to estimate PSF and background
152  - calibrate astrometry and photometry
153 
154  @param sensorRef: butler data reference for raw data
155 
156  @return pipe_base Struct containing these fields:
157  - charRes: object returned by image characterization task; an lsst.pipe.base.Struct
158  that will include "background" and "sourceCat" fields
159  - calibRes: object returned by calibration task: an lsst.pipe.base.Struct
160  that will include "background" and "sourceCat" fields
161  - exposure: final exposure (an lsst.afw.image.ExposureF)
162  - background: final background model (an lsst.afw.math.BackgroundList)
163  """
164  self.log.info("Processing %s" % (sensorRef.dataId))
165 
166  exposure = self.isr.runDataRef(sensorRef).exposure
167 
168  charRes = self.charImage.run(
169  dataRef = sensorRef,
170  exposure = exposure,
171  doUnpersist = False,
172  )
173  exposure = charRes.exposure
174 
175  if self.config.doCalibrate:
176  calibRes = self.calibrate.run(
177  dataRef = sensorRef,
178  exposure = charRes.exposure,
179  background = charRes.background,
180  doUnpersist = False,
181  icSourceCat = charRes.sourceCat,
182  )
183 
184  return pipeBase.Struct(
185  charRes = charRes,
186  calibRes = calibRes if self.config.doCalibrate else None,
187  exposure = exposure,
188  background = calibRes.background if self.config.doCalibrate else charRes.background,
189  )
190 
191  @classmethod
193  """!Create and return an argument parser
194 
195  @param[in] cls the class object
196  @return the argument parser for this task.
197 
198  This override is used to delay making the data ref list until the daset type is known;
199  this is done in @ref parseAndRun.
200  """
201  parser = pipeBase.ArgumentParser(name=cls._DefaultName)
202  parser.add_id_argument(name="--id",
203  datasetType=pipeBase.ConfigDatasetType(name="isr.datasetType"),
204  help="data IDs, e.g. --id visit=12345 ccd=1,2^0,3")
205  return parser
206 
Assemble raw data, fit the PSF, detect and measure, and fit WCS and zero-point.
Definition: processCcd.py:72
def _makeArgumentParser
Create and return an argument parser.
Definition: processCcd.py:192