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]
59 task = self.TaskClass(config=self.config, log=self.log)
63 results = task.run(butler)
66 results = task.run(butler)
67 except Exception
as e:
68 task.log.fatal(
"Failed: %s" % e)
70 if not isinstance(e, pipeBase.TaskError):
71 traceback.print_exc(file=sys.stderr)
72 task.writeMetadata(butler)
73 if self.doReturnResults:
74 return pipeBase.Struct(
75 exitStatus=exitStatus,
79 return pipeBase.Struct(
80 exitStatus=exitStatus,
85 """!Make a sky map in a repository 87 Making a sky map in a repository is a prerequisite for making a coadd, 88 since the sky map is used as the pixelization for the coadd. 90 ConfigClass = MakeSkyMapConfig
91 _DefaultName =
"makeSkyMap" 92 RunnerClass = MakeSkyMapRunner
95 pipeBase.CmdLineTask.__init__(self, **kwargs)
98 def run(self, butler):
99 """!Make a skymap, persist it (optionally) and log some information about it 101 @param[in] butler data butler 102 @return a pipeBase Struct containing: 103 - skyMap: the constructed SkyMap 105 skyMap = self.config.skyMap.apply()
107 if self.config.doWrite:
108 butler.put(skyMap, self.config.coaddName +
"Coadd_skyMap")
109 return pipeBase.Struct(
114 """!Log information about a sky map 116 @param[in] skyMap sky map (an lsst.skyMap.SkyMap) 118 self.log.info(
"sky map has %s tracts" % (len(skyMap),))
119 for tractInfo
in skyMap:
120 wcs = tractInfo.getWcs()
121 posBox = afwGeom.Box2D(tractInfo.getBBox())
124 afwGeom.Point2D(posBox.getMaxX(), posBox.getMinY()),
126 afwGeom.Point2D(posBox.getMinX(), posBox.getMaxY()),
128 skyPosList = [wcs.pixelToSky(pos).getPosition(afwGeom.degrees)
for pos
in pixelPosList]
129 posStrList = [
"(%0.3f, %0.3f)" % tuple(skyPos)
for skyPos
in skyPosList]
130 self.log.info(
"tract %s has corners %s (RA, Dec deg) and %s x %s patches" %
131 (tractInfo.getId(),
", ".join(posStrList),
132 tractInfo.getNumPatches()[0], tractInfo.getNumPatches()[1]))
135 def _makeArgumentParser(cls):
136 """Create an argument parser 138 No identifiers are added because none are used. 142 def _getConfigName(self):
143 """Disable persistence of config 145 There's only one SkyMap per rerun anyway, so the config is redundant, 146 and checking it means we can't overwrite or append to one once we've 151 def _getMetadataName(self):
152 """Disable persistence of metadata 154 There's nothing worth persisting.
def logSkyMapInfo(self, skyMap)
Log information about a sky map.
def __init__(self, kwargs)
def getTargetList(parsedCmd)
def __call__(self, butler)
def run(self, butler)
Make a skymap, persist it (optionally) and log some information about it.
Make a sky map in a repository.