LSSTApplications  16.0-10-g0ee56ad+5,16.0-11-ga33d1f2+5,16.0-12-g3ef5c14+3,16.0-12-g71e5ef5+18,16.0-12-gbdf3636+3,16.0-13-g118c103+3,16.0-13-g8f68b0a+3,16.0-15-gbf5c1cb+4,16.0-16-gfd17674+3,16.0-17-g7c01f5c+3,16.0-18-g0a50484+1,16.0-20-ga20f992+8,16.0-21-g0e05fd4+6,16.0-21-g15e2d33+4,16.0-22-g62d8060+4,16.0-22-g847a80f+4,16.0-25-gf00d9b8+1,16.0-28-g3990c221+4,16.0-3-gf928089+3,16.0-32-g88a4f23+5,16.0-34-gd7987ad+3,16.0-37-gc7333cb+2,16.0-4-g10fc685+2,16.0-4-g18f3627+26,16.0-4-g5f3a788+26,16.0-5-gaf5c3d7+4,16.0-5-gcc1f4bb+1,16.0-6-g3b92700+4,16.0-6-g4412fcd+3,16.0-6-g7235603+4,16.0-69-g2562ce1b+2,16.0-8-g14ebd58+4,16.0-8-g2df868b+1,16.0-8-g4cec79c+6,16.0-8-gadf6c7a+1,16.0-8-gfc7ad86,16.0-82-g59ec2a54a+1,16.0-9-g5400cdc+2,16.0-9-ge6233d7+5,master-g2880f2d8cf+3,v17.0.rc1
LSSTDataManagementBasePackage
singleFrameDriver.py
Go to the documentation of this file.
1 from __future__ import absolute_import, division, print_function
2 
3 from lsst.pipe.base import ArgumentParser, ButlerInitializedTaskRunner, ConfigDatasetType
4 from lsst.pipe.tasks.processCcd import ProcessCcdTask
5 from lsst.pex.config import Config, Field, ConfigurableField, ListField
6 from lsst.ctrl.pool.parallel import BatchParallelTask, BatchTaskRunner
7 
8 
10  processCcd = ConfigurableField(
11  target=ProcessCcdTask, doc="CCD processing task")
12  ignoreCcdList = ListField(dtype=int, default=[],
13  doc="List of CCDs to ignore when processing")
14  ccdKey = Field(dtype=str, default="ccd",
15  doc="DataId key corresponding to a single sensor")
16 
17 
19  """Run batches, and initialize Task using a butler"""
20  pass
21 
22 
23 class SingleFrameDriverTask(BatchParallelTask):
24  """Process CCDs in parallel
25  """
26  ConfigClass = SingleFrameDriverConfig
27  _DefaultName = "singleFrameDriver"
28  RunnerClass = SingleFrameTaskRunner
29 
30  def __init__(self, butler=None, psfRefObjLoader=None, astromRefObjLoader=None, photoRefObjLoader=None,
31  *args, **kwargs):
32  """!
33  Constructor
34 
35  The psfRefObjLoader, astromRefObjLoader, photoRefObjLoader should
36  be an instance of LoadReferenceObjectsTasks that supplies an external
37  reference catalog. They may be None if the butler argument is
38  provided or the particular reference catalog is not required.
39 
40  @param[in] butler The butler is passed to the refObjLoader constructor in case it is
41  needed. Ignored if the refObjLoader argument provides a loader directly.
42  @param[in] psfRefObjLoader Reference catalog loader for PSF determination.
43  @param[in] astromRefObjLoader Reference catalog loader for astrometric calibration.
44  @param[in] photoRefObjLoader Reference catalog loader for photometric calibration.
45  @param[in,out] kwargs other keyword arguments for lsst.ctrl.pool.BatchParallelTask
46  """
47  BatchParallelTask.__init__(self, *args, **kwargs)
48  self.ignoreCcds = set(self.config.ignoreCcdList)
49  self.makeSubtask("processCcd", butler=butler, psfRefObjLoader=psfRefObjLoader,
50  astromRefObjLoader=astromRefObjLoader, photoRefObjLoader=photoRefObjLoader)
51 
52  @classmethod
53  def _makeArgumentParser(cls, *args, **kwargs):
54  kwargs.pop("doBatch", False)
55  parser = ArgumentParser(name="singleFrameDriver", *args, **kwargs)
56  parser.add_id_argument("--id",
57  datasetType=ConfigDatasetType(
58  name="processCcd.isr.datasetType"),
59  level="sensor",
60  help="data ID, e.g. --id visit=12345 ccd=67")
61  return parser
62 
63  def runDataRef(self, sensorRef):
64  """Process a single CCD, with scatter-gather-scatter using MPI.
65  """
66  if sensorRef.dataId[self.config.ccdKey] in self.ignoreCcds:
67  self.log.warn("Ignoring %s: CCD in ignoreCcdList" %
68  (sensorRef.dataId))
69  return None
70 
71  with self.logOperation("processing %s" % (sensorRef.dataId,)):
72  return self.processCcd.runDataRef(sensorRef)
def makeSubtask(self, name, keyArgs)
Definition: task.py:275
daf::base::PropertySet * set
Definition: fits.cc:832
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