26 import lsst.pex.config 
as pexConfig
 
   32     """Config for MakeSkyMapTask 
   34     coaddName = pexConfig.Field(
 
   35         doc=
"coadd name, e.g. deep, goodSeeing, chiSquared",
 
   39     skyMap = skyMapRegistry.makeField(
 
   43     doWrite = pexConfig.Field(
 
   44         doc=
"persist the skyMap? If False then run generates the sky map and returns it, " 
   45             "but does not save it to the data repository",
 
   52     """Only need a single butler instance to run on.""" 
   55         return [parsedCmd.butler]
 
   58         task = self.TaskClass(config=self.config, log=self.log)
 
   62             results = task.runDataRef(butler)
 
   65                 results = task.runDataRef(butler)
 
   66             except Exception 
as e:
 
   67                 task.log.fatal(
"Failed: %s" % e)
 
   69                 if not isinstance(e, pipeBase.TaskError):
 
   70                     traceback.print_exc(file=sys.stderr)
 
   71         task.writeMetadata(butler)
 
   72         if self.doReturnResults:
 
   73             return pipeBase.Struct(
 
   74                 exitStatus=exitStatus,
 
   78             return pipeBase.Struct(
 
   79                 exitStatus=exitStatus,
 
   84     """!Make a sky map in a repository 
   86     Making a sky map in a repository is a prerequisite for making a coadd, 
   87     since the sky map is used as the pixelization for the coadd. 
   89     ConfigClass = MakeSkyMapConfig
 
   90     _DefaultName = 
"makeSkyMap" 
   91     RunnerClass = MakeSkyMapRunner
 
   94         pipeBase.CmdLineTask.__init__(self, **kwargs)
 
   98         """!Make a skymap, persist it (optionally) and log some information about it 
  100         @param[in]   butler  data butler 
  101         @return      a pipeBase Struct containing: 
  102                      - skyMap: the constructed SkyMap 
  104         skyMap = self.config.skyMap.apply()
 
  106         if self.config.doWrite:
 
  107             butler.put(skyMap, self.config.coaddName + 
"Coadd_skyMap")
 
  108         return pipeBase.Struct(
 
  113         """!Log information about a sky map 
  115         @param[in] skyMap  sky map (an lsst.skyMap.SkyMap) 
  117         self.log.
info(
"sky map has %s tracts" % (len(skyMap),))
 
  118         for tractInfo 
in skyMap:
 
  119             wcs = tractInfo.getWcs()
 
  127             skyPosList = [wcs.pixelToSky(pos).getPosition(geom.degrees) 
for pos 
in pixelPosList]
 
  128             posStrList = [
"(%0.3f, %0.3f)" % tuple(skyPos) 
for skyPos 
in skyPosList]
 
  129             self.log.
info(
"tract %s has corners %s (RA, Dec deg) and %s x %s patches" %
 
  130                           (tractInfo.getId(), 
", ".join(posStrList),
 
  131                            tractInfo.getNumPatches()[0], tractInfo.getNumPatches()[1]))
 
  134     def _makeArgumentParser(cls):
 
  135         """Create an argument parser 
  137         No identifiers are added because none are used. 
  141     def _getConfigName(self):
 
  142         """Disable persistence of config 
  144         There's only one SkyMap per rerun anyway, so the config is redundant, 
  145         and checking it means we can't overwrite or append to one once we've 
  150     def _getMetadataName(self):
 
  151         """Disable persistence of metadata 
  153         There's nothing worth persisting.