LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Public Member Functions | Static Public Attributes | Private Member Functions | Static Private Attributes | List of all members
lsst.pipe.tasks.makeDiscreteSkyMap.MakeDiscreteSkyMapTask Class Reference

Make a DiscreteSkyMap in a repository, using the bounding box of a set of calexps. More...

Inheritance diagram for lsst.pipe.tasks.makeDiscreteSkyMap.MakeDiscreteSkyMapTask:

Public Member Functions

def __init__
 
def run
 Make a skymap from the bounds of the given set of calexps. More...
 

Static Public Attributes

 ConfigClass = MakeDiscreteSkyMapConfig
 
 RunnerClass = MakeDiscreteSkyMapRunner
 

Private Member Functions

def _getConfigName
 
def _getMetadataName
 

Static Private Attributes

string _DefaultName = "makeDiscreteSkyMap"
 

Detailed Description

Make a DiscreteSkyMap in a repository, using the bounding box of a set of calexps.

The command-line and run signatures and config are sufficiently different from MakeSkyMapTask that we don't inherit from it, but it is a replacement, so we use the same config/metadata names.

Definition at line 108 of file makeDiscreteSkyMap.py.

Constructor & Destructor Documentation

def lsst.pipe.tasks.makeDiscreteSkyMap.MakeDiscreteSkyMapTask.__init__ (   self,
  kwargs 
)

Definition at line 118 of file makeDiscreteSkyMap.py.

119  def __init__(self, **kwargs):
120  pipeBase.CmdLineTask.__init__(self, **kwargs)

Member Function Documentation

def lsst.pipe.tasks.makeDiscreteSkyMap.MakeDiscreteSkyMapTask._getConfigName (   self)
private
Return None to disable saving config

There's only one SkyMap per repository, so the config is redundant, and checking it means we can't
easily overwrite or append to an existing repository.

Definition at line 192 of file makeDiscreteSkyMap.py.

193  def _getConfigName(self):
194  """Return None to disable saving config
195 
196  There's only one SkyMap per repository, so the config is redundant, and checking it means we can't
197  easily overwrite or append to an existing repository.
198  """
199  return None
def lsst.pipe.tasks.makeDiscreteSkyMap.MakeDiscreteSkyMapTask._getMetadataName (   self)
private
Return None to disable saving metadata

The metadata is not interesting, and by not saving it we can eliminate a dataset type.

Definition at line 200 of file makeDiscreteSkyMap.py.

201  def _getMetadataName(self):
202  """Return None to disable saving metadata
203 
204  The metadata is not interesting, and by not saving it we can eliminate a dataset type.
205  """
206  return None
207 
def lsst.pipe.tasks.makeDiscreteSkyMap.MakeDiscreteSkyMapTask.run (   self,
  butler,
  dataRefList 
)

Make a skymap from the bounds of the given set of calexps.

Parameters
[in]butlerdata butler used to save the SkyMap
[in]dataRefListdataRefs of calexps used to determine the size and pointing of the SkyMap
Returns
a pipeBase Struct containing:
  • skyMap: the constructed SkyMap

Definition at line 122 of file makeDiscreteSkyMap.py.

123  def run(self, butler, dataRefList):
124  """!Make a skymap from the bounds of the given set of calexps.
125 
126  @param[in] butler data butler used to save the SkyMap
127  @param[in] dataRefList dataRefs of calexps used to determine the size and pointing of the SkyMap
128  @return a pipeBase Struct containing:
129  - skyMap: the constructed SkyMap
130  """
131  self.log.info("Extracting bounding boxes of %d images" % len(dataRefList))
132  points = []
133  for dataRef in dataRefList:
134  if not dataRef.datasetExists("calexp"):
135  self.log.warn("CalExp for %s does not exist: ignoring" % (dataRef.dataId,))
136  continue
137  md = dataRef.get("calexp_md", immediate=True)
138  wcs = afwImage.makeWcs(md)
139  # nb: don't need to worry about xy0 because Exposure saves Wcs with CRPIX shifted by (-x0, -y0).
140  boxI = afwGeom.Box2I(afwGeom.Point2I(0,0), afwGeom.Extent2I(md.get("NAXIS1"), md.get("NAXIS2")))
141  boxD = afwGeom.Box2D(boxI)
142  points.extend(tuple(wcs.pixelToSky(corner).getVector()) for corner in boxD.getCorners())
143  if len(points) == 0:
144  raise RuntimeError("No data found from which to compute convex hull")
145  self.log.info("Computing spherical convex hull")
146  polygon = lsst.geom.convexHull(points)
147  if polygon is None:
148  raise RuntimeError(
149  "Failed to compute convex hull of the vertices of all calexp bounding boxes; "
150  "they may not be hemispherical."
151  )
152  circle = polygon.getBoundingCircle()
153 
154  datasetName = self.config.coaddName + "Coadd_skyMap"
155 
156  skyMapConfig = DiscreteSkyMap.ConfigClass()
157  if self.config.doAppend and butler.datasetExists(datasetName):
158  oldSkyMap = butler.get(datasetName, immediate=True)
159  if not isinstance(oldSkyMap.config, DiscreteSkyMap.ConfigClass):
160  raise TypeError("Cannot append to existing non-discrete skymap")
161  compareLog = []
162  if not self.config.skyMap.compare(oldSkyMap.config, output=compareLog.append):
163  raise ValueError("Cannot append to existing skymap - configurations differ:", *compareLog)
164  skyMapConfig.raList.extend(oldSkyMap.config.raList)
165  skyMapConfig.decList.extend(oldSkyMap.config.decList)
166  skyMapConfig.radiusList.extend(oldSkyMap.config.radiusList)
167  skyMapConfig.update(**self.config.skyMap.toDict())
168  skyMapConfig.raList.append(circle.center[0])
169  skyMapConfig.decList.append(circle.center[1])
170  skyMapConfig.radiusList.append(circle.radius + self.config.borderSize)
171  skyMap = DiscreteSkyMap(skyMapConfig)
172 
173  for tractInfo in skyMap:
174  wcs = tractInfo.getWcs()
175  posBox = afwGeom.Box2D(tractInfo.getBBox())
176  pixelPosList = (
177  posBox.getMin(),
178  afwGeom.Point2D(posBox.getMaxX(), posBox.getMinY()),
179  posBox.getMax(),
180  afwGeom.Point2D(posBox.getMinX(), posBox.getMaxY()),
181  )
182  skyPosList = [wcs.pixelToSky(pos).getPosition(afwGeom.degrees) for pos in pixelPosList]
183  posStrList = ["(%0.3f, %0.3f)" % tuple(skyPos) for skyPos in skyPosList]
184  self.log.info("tract %s has corners %s (RA, Dec deg) and %s x %s patches" % \
185  (tractInfo.getId(), ", ".join(posStrList), \
186  tractInfo.getNumPatches()[0], tractInfo.getNumPatches()[1]))
187  if self.config.doWrite:
188  butler.put(skyMap, datasetName)
189  return pipeBase.Struct(
190  skyMap = skyMap
191  )
An integer coordinate rectangle.
Definition: Box.h:53
Wcs::Ptr makeWcs(coord::Coord const &crval, geom::Point2D const &crpix, double CD11, double CD12, double CD21, double CD22)
Create a Wcs object from crval, crpix, CD, using CD elements (useful from python) ...
Definition: makeWcs.cc:141
def run
Make a skymap from the bounds of the given set of calexps.
A floating-point coordinate rectangle geometry.
Definition: Box.h:271

Member Data Documentation

string lsst.pipe.tasks.makeDiscreteSkyMap.MakeDiscreteSkyMapTask._DefaultName = "makeDiscreteSkyMap"
staticprivate

Definition at line 115 of file makeDiscreteSkyMap.py.

lsst.pipe.tasks.makeDiscreteSkyMap.MakeDiscreteSkyMapTask.ConfigClass = MakeDiscreteSkyMapConfig
static

Definition at line 114 of file makeDiscreteSkyMap.py.

lsst.pipe.tasks.makeDiscreteSkyMap.MakeDiscreteSkyMapTask.RunnerClass = MakeDiscreteSkyMapRunner
static

Definition at line 116 of file makeDiscreteSkyMap.py.


The documentation for this class was generated from the following file: