22 from __future__
import absolute_import, division, print_function
26 import lsst.afw.geom
as afwGeom
27 import lsst.pex.config
as pexConfig
28 import lsst.pipe.base
as pipeBase
29 from lsst.skymap
import skyMapRegistry
33 """Config for MakeSkyMapTask
35 coaddName = pexConfig.Field(
36 doc=
"coadd name, e.g. deep, goodSeeing, chiSquared",
40 skyMap = skyMapRegistry.makeField(
44 doWrite = pexConfig.Field(
45 doc=
"persist the skyMap? If False then run generates the sky map and returns it, "
46 +
"but does not save it to the data repository",
53 """Only need a single butler instance to run on."""
56 return [parsedCmd.butler]
66 task = self.TaskClass(config=self.config, log=self.log)
68 results = task.run(butler)
71 results = task.run(butler)
72 except Exception
as e:
73 task.log.fatal(
"Failed: %s" % e)
74 if not isinstance(e, pipeBase.TaskError):
75 traceback.print_exc(file=sys.stderr)
76 task.writeMetadata(butler)
77 if self.doReturnResults:
82 """!Make a sky map in a repository
84 Making a sky map in a repository is a prerequisite for making a coadd,
85 since the sky map is used as the pixelization for the coadd.
87 ConfigClass = MakeSkyMapConfig
88 _DefaultName =
"makeSkyMap"
89 RunnerClass = MakeSkyMapRunner
92 pipeBase.CmdLineTask.__init__(self, **kwargs)
95 def run(self, butler):
96 """!Make a skymap, persist it (optionally) and log some information about it
98 @param[in] butler data butler
99 @return a pipeBase Struct containing:
100 - skyMap: the constructed SkyMap
102 skyMap = self.config.skyMap.apply()
104 if self.config.doWrite:
105 butler.put(skyMap, self.config.coaddName +
"Coadd_skyMap")
106 return pipeBase.Struct(
111 """!Log information about a sky map
113 @param[in] skyMap sky map (an lsst.skyMap.SkyMap)
115 self.log.info(
"sky map has %s tracts" % (len(skyMap),))
116 for tractInfo
in skyMap:
117 wcs = tractInfo.getWcs()
118 posBox = afwGeom.Box2D(tractInfo.getBBox())
121 afwGeom.Point2D(posBox.getMaxX(), posBox.getMinY()),
123 afwGeom.Point2D(posBox.getMinX(), posBox.getMaxY()),
125 skyPosList = [wcs.pixelToSky(pos).getPosition(afwGeom.degrees)
for pos
in pixelPosList]
126 posStrList = [
"(%0.3f, %0.3f)" % tuple(skyPos)
for skyPos
in skyPosList]
127 self.log.info(
"tract %s has corners %s (RA, Dec deg) and %s x %s patches" %
128 (tractInfo.getId(),
", ".join(posStrList),
129 tractInfo.getNumPatches()[0], tractInfo.getNumPatches()[1]))
132 def _makeArgumentParser(cls):
133 """Create an argument parser
135 No identifiers are added because none are used.
137 return pipeBase.ArgumentParser(name=cls._DefaultName)
139 def _getConfigName(self):
140 """Return the name of the config dataset
142 return "%s_makeSkyMap_config" % (self.config.coaddName,)
144 def _getMetadataName(self):
145 """Return the name of the metadata dataset
147 return "%s_makeSkyMap_metadata" % (self.config.coaddName,)
def run
Make a skymap, persist it (optionally) and log some information about it.
def logSkyMapInfo
Log information about a sky map.
Make a sky map in a repository.