LSSTApplications  18.0.0+106,18.0.0+50,19.0.0,19.0.0+1,19.0.0+10,19.0.0+11,19.0.0+13,19.0.0+17,19.0.0+2,19.0.0-1-g20d9b18+6,19.0.0-1-g425ff20,19.0.0-1-g5549ca4,19.0.0-1-g580fafe+6,19.0.0-1-g6fe20d0+1,19.0.0-1-g7011481+9,19.0.0-1-g8c57eb9+6,19.0.0-1-gb5175dc+11,19.0.0-1-gdc0e4a7+9,19.0.0-1-ge272bc4+6,19.0.0-1-ge3aa853,19.0.0-10-g448f008b,19.0.0-12-g6990b2c,19.0.0-2-g0d9f9cd+11,19.0.0-2-g3d9e4fb2+11,19.0.0-2-g5037de4,19.0.0-2-gb96a1c4+3,19.0.0-2-gd955cfd+15,19.0.0-3-g2d13df8,19.0.0-3-g6f3c7dc,19.0.0-4-g725f80e+11,19.0.0-4-ga671dab3b+1,19.0.0-4-gad373c5+3,19.0.0-5-ga2acb9c+2,19.0.0-5-gfe96e6c+2,w.2020.01
LSSTDataManagementBasePackage
singleFrameDriver.py
Go to the documentation of this file.
1 from lsst.pipe.base import ArgumentParser, ButlerInitializedTaskRunner, ConfigDatasetType
2 from lsst.pipe.tasks.processCcd import ProcessCcdTask
3 from lsst.pex.config import Config, Field, ConfigurableField, ListField
4 from lsst.ctrl.pool.parallel import BatchParallelTask, BatchTaskRunner
5 
6 
7 class SingleFrameDriverConfig(Config):
8  processCcd = ConfigurableField(
9  target=ProcessCcdTask, doc="CCD processing task")
10  ignoreCcdList = ListField(dtype=int, default=[],
11  doc="List of CCDs to ignore when processing")
12  ccdKey = Field(dtype=str, default="ccd",
13  doc="DataId key corresponding to a single sensor")
14 
15 
17  """Run batches, and initialize Task using a butler"""
18  pass
19 
20 
21 class SingleFrameDriverTask(BatchParallelTask):
22  """Process CCDs in parallel
23  """
24  ConfigClass = SingleFrameDriverConfig
25  _DefaultName = "singleFrameDriver"
26  RunnerClass = SingleFrameTaskRunner
27 
28  def __init__(self, butler=None, psfRefObjLoader=None, astromRefObjLoader=None, photoRefObjLoader=None,
29  *args, **kwargs):
30  """!
31  Constructor
32 
33  The psfRefObjLoader, astromRefObjLoader, photoRefObjLoader should
34  be an instance of LoadReferenceObjectsTasks that supplies an external
35  reference catalog. They may be None if the butler argument is
36  provided or the particular reference catalog is not required.
37 
38  @param[in] butler The butler is passed to the refObjLoader constructor in case it is
39  needed. Ignored if the refObjLoader argument provides a loader directly.
40  @param[in] psfRefObjLoader Reference catalog loader for PSF determination.
41  @param[in] astromRefObjLoader Reference catalog loader for astrometric calibration.
42  @param[in] photoRefObjLoader Reference catalog loader for photometric calibration.
43  @param[in,out] kwargs other keyword arguments for lsst.ctrl.pool.BatchParallelTask
44  """
45  BatchParallelTask.__init__(self, *args, **kwargs)
46  self.ignoreCcds = set(self.config.ignoreCcdList)
47  self.makeSubtask("processCcd", butler=butler, psfRefObjLoader=psfRefObjLoader,
48  astromRefObjLoader=astromRefObjLoader, photoRefObjLoader=photoRefObjLoader)
49 
50  @classmethod
51  def _makeArgumentParser(cls, *args, **kwargs):
52  kwargs.pop("doBatch", False)
53  parser = ArgumentParser(name="singleFrameDriver", *args, **kwargs)
54  parser.add_id_argument("--id",
55  datasetType=ConfigDatasetType(
56  name="processCcd.isr.datasetType"),
57  level="sensor",
58  help="data ID, e.g. --id visit=12345 ccd=67")
59  return parser
60 
61  def runDataRef(self, sensorRef):
62  """Process a single CCD, with scatter-gather-scatter using MPI.
63  """
64  if sensorRef.dataId[self.config.ccdKey] in self.ignoreCcds:
65  self.log.warn("Ignoring %s: CCD in ignoreCcdList" %
66  (sensorRef.dataId))
67  return None
68 
69  with self.logOperation("processing %s" % (sensorRef.dataId,)):
70  return self.processCcd.runDataRef(sensorRef)
def makeSubtask(self, name, keyArgs)
Definition: task.py:275
daf::base::PropertySet * set
Definition: fits.cc:902
def __init__(self, butler=None, psfRefObjLoader=None, astromRefObjLoader=None, photoRefObjLoader=None, args, kwargs)
Constructor.
def logOperation(self, operation, catch=False, trace=True)
Provide a context manager for logging an operation.
Definition: parallel.py:497