lsst.pipe.tasks  16.0+1
dcrMultiBand.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # This file is part of pipe_tasks.
3 #
4 # LSST Data Management System
5 # This product includes software developed by the
6 # LSST Project (http://www.lsst.org/).
7 # See COPYRIGHT file at the top of the source tree.
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 <https://www.lsstcorp.org/LegalNotices/>.
22 #
23 
24 from lsst.coadd.utils.coaddDataIdContainer import ExistingCoaddDataIdContainer
25 from lsst.pipe.base import ArgumentParser
26 from lsst.pipe.tasks.multiBand import MergeDetectionsTask
27 from lsst.pipe.tasks.multiBand import DetectCoaddSourcesTask
28 from lsst.pipe.tasks.multiBand import MergeSourcesRunner
29 from lsst.pipe.tasks.multiBand import MeasureMergedCoaddSourcesTask
30 from lsst.pipe.tasks.multiBand import MergeMeasurementsTask
31 
32 __all__ = ["DetectDcrCoaddSources", "MergeDcrDetectionsTask",
33  "MeasureMergedDcrCoaddSourcesTask", "MergeDcrMeasurementsTask"]
34 
35 """Measure sources and their sub-filter spectrum from a DCR model."""
36 
37 
39  """Task runner for the MergeSourcesTask.
40 
41  Required because the run method requires a list of dataRefs
42  rather than a single dataRef.
43  """
44 
45  @staticmethod
46  def getTargetList(parsedCmd, **kwargs):
47  """Provide a list of patch and filter references for each tract.
48 
49  The filter references within the list will have different subfilters.
50 
51  Parameters
52  ----------
53  parsedCmd : `dict`
54  The parsed command
55  **kwargs
56  Key word arguments (unused)
57 
58  Returns
59  -------
60  list of `patchRef`
61  List of all matching data references for a given patch.
62 
63  Raises
64  ------
65  RuntimeError
66  if multiple references are provided for the same combination of
67  tract, patch, filter, and subfilter
68  """
69  refList = {} # Will index this as refList[tract][patch][filter][subfilter] = ref
70  for ref in parsedCmd.id.refList:
71  tract = ref.dataId["tract"]
72  patch = ref.dataId["patch"]
73  filter = ref.dataId["filter"]
74  subfilter = ref.dataId["subfilter"]
75  if tract not in refList:
76  refList[tract] = {}
77  if patch not in refList[tract]:
78  refList[tract][patch] = {}
79  if filter not in refList[tract][patch]:
80  refList[tract][patch][filter] = {}
81  if subfilter in refList[tract][patch][filter]:
82  raise RuntimeError("Multiple versions of %s" % (ref.dataId,))
83  refList[tract][patch][filter][subfilter] = ref
84  return [(list(f.values()), kwargs)
85  for t in list(refList.values())
86  for p in list(t.values())
87  for f in list(p.values())]
88 
89 
91  """Detect sources on a DCR coadd."""
92 
93  @classmethod
94  def _makeArgumentParser(cls):
95  parser = ArgumentParser(name=cls._DefaultName)
96  parser.add_id_argument(name="--id",
97  datasetType="dcrCoadd",
98  help="data ID, e.g. --id tract=12345 patch=1,2 filter=g, subfilter=0",
99  ContainerClass=ExistingCoaddDataIdContainer)
100  return parser
101 
102 
104  """Merge dcrCoadd detections from multiple subfilters."""
105 
106  RunnerClass = MergeDcrSourcesRunner
107 
108  @classmethod
109  def _makeArgumentParser(cls):
110  """Create a suitable ArgumentParser.
111 
112  We will use the ArgumentParser to get a provide a list of data
113  references for patches; the RunnerClass will sort them into lists
114  of data references for the same patch
115  """
116  parser = ArgumentParser(name=cls._DefaultName)
117  parser.add_id_argument(name="--id",
118  datasetType="dcrCoadd_" + cls.inputDataset,
119  ContainerClass=ExistingCoaddDataIdContainer,
120  help="data ID, e.g. --id tract=12345 patch=1,2 filter=g, subfilter=0^1^2")
121  return parser
122 
123 
125  """Deblend sources from master catalog in each coadd seperately and measure."""
126 
127  @classmethod
128  def _makeArgumentParser(cls):
129  parser = ArgumentParser(name=cls._DefaultName)
130  parser.add_id_argument(name="--id",
131  datasetType="dcrCoadd_calexp",
132  help="data ID, e.g. --id tract=12345 patch=1,2 filter=g, subfilter=0",
133  ContainerClass=ExistingCoaddDataIdContainer)
134  return parser
135 
136 
138  """Merge measurements from multiple subfilters."""
139 
140  RunnerClass = MergeDcrSourcesRunner
141 
142  @classmethod
143  def _makeArgumentParser(cls):
144  """Create a suitable ArgumentParser.
145 
146  We will use the ArgumentParser to get a provide a list of data
147  references for patches; the RunnerClass will sort them into lists
148  of data references for the same patch
149  """
150  parser = ArgumentParser(name=cls._DefaultName)
151  parser.add_id_argument(name="--id",
152  datasetType="dcrCoadd_" + cls.inputDataset,
153  ContainerClass=ExistingCoaddDataIdContainer,
154  help="data ID, e.g. --id tract=12345 patch=1,2 filter=g, subfilter=0^1^2")
155  return parser
Merge coadd detections from multiple bands.
Definition: multiBand.py:592
Task runner for the MergeSourcesTask. Required because the run method requires a list of dataRefs rat...
Definition: multiBand.py:327
Merge measurements from multiple bands.
Definition: multiBand.py:1200
Deblend sources from master catalog in each coadd seperately and measure.
Definition: multiBand.py:893