lsst.cp.pipe  17.0.1-1-g6dd7d69+3
utils.py
Go to the documentation of this file.
1 # This file is part of cp_pipe.
2 #
3 # Developed for the LSST Data Management System.
4 # This product includes software developed by the LSST Project
5 # (https://www.lsst.org).
6 # See the COPYRIGHT file at the top-level directory of this distribution
7 # for details of code ownership.
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 GNU General Public License
20 # along with this program. If not, see <https://www.gnu.org/licenses/>.
21 #
22 
23 __all__ = ['PairedVisitTaskRunner', ]
24 
25 import lsst.pipe.base as pipeBase
26 
27 
28 class PairedVisitTaskRunner(pipeBase.TaskRunner):
29  """Subclass of TaskRunner for handling intrinsically paired visits.
30 
31  This transforms the processed arguments generated by the ArgumentParser
32  into the arguments expected by tasks which take visit pairs for their
33  run() methods.
34 
35  Such tasks' run() methods tend to take two arguments,
36  one of which is the dataRef (as usual), and the other is the list
37  of visit-pairs, in the form of a list of tuples.
38  This list is supplied on the command line as documented,
39  and this class parses that, and passes the parsed version
40  to the run() method.
41 
42  See pipeBase.TaskRunner for more information.
43  """
44 
45  @staticmethod
46  def getTargetList(parsedCmd, **kwargs):
47  """Parse the visit list and pass through explicitly."""
48  visitPairs = []
49  for visitStringPair in parsedCmd.visitPairs:
50  visitStrings = visitStringPair.split(",")
51  if len(visitStrings) != 2:
52  raise RuntimeError("Found {} visits in {} instead of 2".format(len(visitStrings),
53  visitStringPair))
54  try:
55  visits = [int(visit) for visit in visitStrings]
56  except Exception:
57  raise RuntimeError("Could not parse {} as two integer visit numbers".format(visitStringPair))
58  visitPairs.append(visits)
59 
60  return pipeBase.TaskRunner.getTargetList(parsedCmd, visitPairs=visitPairs, **kwargs)
def getTargetList(parsedCmd, kwargs)
Definition: utils.py:46