LSST Applications  21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
processCcdWithFakesDriver.py
Go to the documentation of this file.
1 from lsst.pipe.base import ArgumentParser
2 from lsst.pipe.tasks.processCcdWithFakes import ProcessCcdWithFakesTask
3 from lsst.pipe.tasks.postprocess import WriteSourceTableTask, TransformSourceTableTask
4 from lsst.pex.config import Config, Field, ConfigurableField, ListField
5 from lsst.ctrl.pool.parallel import BatchParallelTask, BatchTaskRunner
6 from lsst.meas.base import PerTractCcdDataIdContainer
7 
8 
10  processCcdWithFakes = ConfigurableField(
11  target=ProcessCcdWithFakesTask, doc="CCD with fakes processing task")
12  doMakeSourceTable = Field(dtype=bool, default=False,
13  doc="Do postprocessing tasks to write parquet Source Table?")
14  doSaveWideSourceTable = Field(dtype=bool, default=False,
15  doc=("Save the parquet version of the full src catalog?",
16  "Only respected if doMakeSourceTable"))
17  writeSourceTable = ConfigurableField(
18  target=WriteSourceTableTask, doc="Task to make parquet table for full src catalog")
19  transformSourceTable = ConfigurableField(
20  target=TransformSourceTableTask, doc="Transform Source Table to DPDD specification")
21  ignoreCcdList = ListField(dtype=int, default=[],
22  doc="List of CCDs to ignore when processing")
23  ccdKey = Field(dtype=str, default="ccd",
24  doc="DataId key corresponding to a single sensor")
25 
26 
28  """Run batches, and initialize Task"""
29  pass
30 
31 
32 class ProcessCcdWithFakesDriverTask(BatchParallelTask):
33  """Process CCDs in parallel for processCcdWithFakes
34  """
35  ConfigClass = ProcessCcdWithFakesDriverConfig
36  _DefaultName = "processCcdWithFakesDriver"
37  RunnerClass = ProcessCcdWithFakesTaskRunner
38 
39  def __init__(self, *args, **kwargs):
40  """
41  Parameters
42  ----------
43  kwargs : other keyword arguments for lsst.ctrl.pool.BatchParallelTask
44  """
45  BatchParallelTask.__init__(self, *args, **kwargs)
46  self.ignoreCcdsignoreCcds = set(self.config.ignoreCcdList)
47  self.makeSubtask("processCcdWithFakes")
48  if self.config.doMakeSourceTable:
49  self.makeSubtask("writeSourceTable")
50  self.makeSubtask("transformSourceTable")
51 
52  @classmethod
53  def _makeArgumentParser(cls, *args, **kwargs):
54  kwargs.pop("doBatch", False)
55  parser = ArgumentParser(name="processCcdWithFakesDriver", *args, **kwargs)
56  parser.add_id_argument("--id", "fakes_calexp",
57  help="data ID, e.g. --id visit=12345 ccd=67, tract=9813",
58  ContainerClass=PerTractCcdDataIdContainer)
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.ignoreCcdsignoreCcds:
65  self.log.warn("Ignoring %s: CCD in ignoreCcdList" %
66  (sensorRef.dataId))
67  return None
68 
69  with self.logOperationlogOperation("processing %s" % (sensorRef.dataId,)):
70  result = self.processCcdWithFakes.runDataRef(sensorRef)
71  if self.config.doMakeSourceTable:
72  parquet = self.writeSourceTable.run(result.outputCat,
73  ccdVisitId=sensorRef.get('ccdExposureId'))
74  if self.config.doSaveWideSourceTable:
75  sensorRef.put(parquet.table, 'fakes_source')
76 
77  df = self.transformSourceTable.run(parquet.table,
78  funcs=self.transformSourceTable.getFunctors(),
79  dataId=sensorRef.dataId)
80  self.transformSourceTable.write(df, sensorRef)
81 
82  return result
def logOperation(self, operation, catch=False, trace=True)
Provide a context manager for logging an operation.
Definition: parallel.py:502
daf::base::PropertySet * set
Definition: fits.cc:912
void write(OutputArchiveHandle &handle) const override
def run(self, coaddExposures, bbox, wcs)
Definition: getTemplate.py:603