LSSTApplications  10.0-2-g4f67435,11.0.rc2+1,11.0.rc2+12,11.0.rc2+3,11.0.rc2+4,11.0.rc2+5,11.0.rc2+6,11.0.rc2+7,11.0.rc2+8
LSSTDataManagementBasePackage
processCcd.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 #
3 # LSST Data Management System
4 # Copyright 2008, 2009, 2010 LSST Corporation.
5 #
6 # This product includes software developed by the
7 # LSST Project (http://www.lsst.org/).
8 #
9 # This program is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation, either version 3 of the License, or
12 # (at your option) any later version.
13 #
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the LSST License Statement and
20 # the GNU General Public License along with this program. If not,
21 # see <http://www.lsstcorp.org/LegalNotices/>.
22 #
23 from .processImage import ProcessImageTask
24 from lsst.ip.isr import IsrTask
25 import lsst.afw.table as afwTable
26 import lsst.pex.config as pexConfig
27 import lsst.pipe.base as pipeBase
28 
29 class ProcessCcdConfig(ProcessImageTask.ConfigClass):
30  """Config for ProcessCcd"""
31  doIsr = pexConfig.Field(dtype=bool, default=True, doc = "Perform ISR?")
32  isr = pexConfig.ConfigurableField(
33  target = IsrTask,
34  doc = "Instrumental Signature Removal",
35  )
36 
37 class ProcessCcdTask(ProcessImageTask):
38  """Process a CCD
39 
40  Available steps include:
41  - instrument signature removal (ISR)
42  - calibrate
43  - detect sources
44  - measure sources
45  """
46  ConfigClass = ProcessCcdConfig
47  _DefaultName = "processCcd"
48  dataPrefix = ""
49 
50  def __init__(self, **kwargs):
51  ProcessImageTask.__init__(self, **kwargs)
52  self.makeSubtask("isr")
53 
54  def makeIdFactory(self, sensorRef):
55  expBits = sensorRef.get("ccdExposureId_bits")
56  expId = long(sensorRef.get("ccdExposureId"))
57  return afwTable.IdFactory.makeSource(expId, 64 - expBits)
58 
59  def getExposureId(self, sensorRef):
60  return long(sensorRef.get("ccdExposureId"))
61 
62  @pipeBase.timeMethod
63  def run(self, sensorRef):
64  """Process one CCD
65 
66  @param sensorRef: sensor-level butler data reference
67  @return pipe_base Struct containing these fields:
68  - postIsrExposure: exposure after ISR performed if calib.doIsr or config.doCalibrate, else None
69  - exposure: calibrated exposure (calexp): as computed if config.doCalibrate,
70  else as upersisted and updated if config.doDetection, else None
71  - calib: object returned by calibration process if config.doCalibrate, else None
72  - sources: detected source if config.doPhotometry, else None
73  """
74  self.log.info("Processing %s" % (sensorRef.dataId))
75 
76  # initialize outputs
77  postIsrExposure = None
78 
79  if self.config.doIsr:
80  postIsrExposure = self.isr.runDataRef(sensorRef).exposure
81  elif self.config.doCalibrate:
82  postIsrExposure = sensorRef.get(self.dataPrefix + "postISRCCD")
83 
84  # delegate most of the work to ProcessImageTask
85  result = self.process(sensorRef, postIsrExposure)
86  result.postIsrExposure = postIsrExposure
87  return result