LSSTApplications  1.1.2+25,10.0+13,10.0+132,10.0+133,10.0+224,10.0+41,10.0+8,10.0-1-g0f53050+14,10.0-1-g4b7b172+19,10.0-1-g61a5bae+98,10.0-1-g7408a83+3,10.0-1-gc1e0f5a+19,10.0-1-gdb4482e+14,10.0-11-g3947115+2,10.0-12-g8719d8b+2,10.0-15-ga3f480f+1,10.0-2-g4f67435,10.0-2-gcb4bc6c+26,10.0-28-gf7f57a9+1,10.0-3-g1bbe32c+14,10.0-3-g5b46d21,10.0-4-g027f45f+5,10.0-4-g86f66b5+2,10.0-4-gc4fccf3+24,10.0-40-g4349866+2,10.0-5-g766159b,10.0-5-gca2295e+25,10.0-6-g462a451+1
LSSTDataManagementBasePackage
forcedPhotCoadd.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 #
3 # LSST Data Management System
4 # Copyright 2008, 2009, 2010, 2014 LSST Corporation.
5 #
6 # This product includes software developed by the
7 # LSST Project (http://www.lsst.org/).
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 <http://www.lsstcorp.org/LegalNotices/>.
22 #
23 
24 import lsst.pex.config
25 import lsst.pipe.base
26 import lsst.coadd.utils
27 import lsst.afw.table
28 
29 from .forcedPhotImage import *
30 from .base import *
31 from .references import CoaddSrcReferencesTask
32 
33 __all__ = ("ForcedPhotCoaddConfig", "ForcedPhotCoaddTask")
34 
35 class ForcedPhotCoaddConfig(ProcessImageForcedConfig):
36  pass
37 
38 ## @addtogroup LSST_task_documentation
39 ## @{
40 ## @page processForcedCoaddTask
41 ## ForcedPhotCoaddTask
42 ## @copybrief ForcedPhotCoaddTask
43 ## @}
44 
45 class ForcedPhotCoaddTask(ProcessImageForcedTask):
46  """!
47  A command-line driver for performing forced measurement on coadd images
48 
49  This task is a subclass of ForcedPhotImageTask which is specifically for doing forced
50  measurement on a coadd, using as a reference catalog detections which were made on overlapping
51  coadds (i.e. in other bands).
52 
53  The run method (inherited from ForcedPhotImageTask) takes a lsst.daf.persistence.ButlerDataRef
54  argument that corresponds to a coadd image. This is used to provide all the inputs and outputs
55  for the task:
56  - A "*Coadd_src" (e.g. "deepCoadd_src") dataset is used as the reference catalog. This not loaded
57  directly from the passed dataRef, however; only the patch and tract are used, while the filter
58  is set by the configuration for the references subtask (see CoaddSrcReferencesTask).
59  - A "*Coadd_calexp" (e.g. "deepCoadd_calexp") dataset is used as the measurement image. Note that
60  this means that ProcessCoaddTask must be run on an image before ForcedPhotCoaddTask, in order
61  to generate the "*Coadd_calexp" dataset.
62  - A "*Coadd_forced_src" (e.g. "deepCoadd_forced_src") dataset will be written with the output
63  measurement catalog.
64 
65  In addition to the run method, ForcedPhotCcdTask overrides several methods of ForcedPhotImageTask
66  to specialize it for coadd processing, including makeIdFactory() and fetchReferences(). None of these
67  should be called directly by the user, though it may be useful to override them further in subclasses.
68  """
69 
70  ConfigClass = ForcedPhotCoaddConfig
71  RunnerClass = lsst.pipe.base.ButlerInitializedTaskRunner
72  _DefaultName = "forcedPhotCoaddTask"
73  dataPrefix = "deepCoadd_"
74 
75  def makeIdFactory(self, dataRef):
76  """Create an object that generates globally unique source IDs from per-CCD IDs and the CCD ID.
77 
78  @param dataRef Data reference from butler. The "CoaddId_bits" and "CoaddId"
79  datasets are accessed. The data ID must have tract and patch keys.
80  """
81  expBits = dataRef.get(self.config.coaddName + "CoaddId_bits")
82  expId = long(dataRef.get(self.config.coaddName + "CoaddId"))
83  return lsst.afw.table.IdFactory.makeSource(expId, 64 - expBits)
84 
85  def fetchReferences(self, dataRef, exposure):
86  """Return an iterable of reference sources which overlap the exposure
87 
88  @param dataRef Data reference from butler corresponding to the image to be measured;
89  should have tract, patch, and filter keys.
90  @param exposure lsst.afw.image.Exposure to be measured (not used by this implementation)
91 
92  All work is delegated to the references subtask; see CoaddSrcReferencesTask for information
93  about the default behavior.
94  """
95  skyMap = dataRef.get(self.dataPrefix + "skyMap", immediate=True)
96  tractInfo = skyMap[dataRef.dataId["tract"]]
97  patch = tuple(int(v) for v in dataRef.dataId["patch"].split(","))
98  patchInfo = tractInfo.getPatchInfo(patch)
99  return self.references.fetchInPatches(dataRef, patchList=[patchInfo])
100 
101  @classmethod
103  parser = lsst.pipe.base.ArgumentParser(name=cls._DefaultName)
104  parser.add_id_argument("--id", "deepCoadd_forced_src", help="data ID, with raw CCD keys + tract",
105  ContainerClass=lsst.coadd.utils.CoaddDataIdContainer)
106  return parser
107 
108 
static boost::shared_ptr< IdFactory > makeSource(RecordId expId, int reserved)
Return an IdFactory that includes another, fixed ID in the higher-order bits.
A command-line driver for performing forced measurement on coadd images.