LSSTApplications  20.0.0
LSSTDataManagementBasePackage
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
lsst.skymap.dodecaSkyMap.DodecaSkyMap Class Reference
Inheritance diagram for lsst.skymap.dodecaSkyMap.DodecaSkyMap:
lsst.skymap.baseSkyMap.BaseSkyMap

Public Member Functions

def __init__ (self, config=None)
 
def __getstate__ (self)
 
def __setstate__ (self, stateDict)
 
def findTract (self, coord)
 
def getVersion (self)
 
def getWithTractsOnPoles (self)
 
def updateSha1 (self, sha1)
 
def findTractPatchList (self, coordList)
 
def findClosestTractPatchList (self, coordList)
 
def __getitem__ (self, ind)
 
def __iter__ (self)
 
def __len__ (self)
 
def __hash__ (self)
 
def __eq__ (self, other)
 
def __ne__ (self, other)
 
def logSkyMapInfo (self, log)
 
def getSha1 (self)
 
def register (self, name, registry)
 

Public Attributes

 config
 

Static Public Attributes

 ConfigClass
 

Detailed Description

Dodecahedron-based sky map pixelization.

DodecaSkyMap divides the sky into 12 overlapping Tracts arranged as the
faces of a dodecahedron.

Parameters
----------
config : `lsst.skymap.BaseSkyMapConfig` (optional)
    The configuration for this SkyMap; if None use the default config.

Definition at line 54 of file dodecaSkyMap.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.skymap.dodecaSkyMap.DodecaSkyMap.__init__ (   self,
  config = None 
)

Reimplemented from lsst.skymap.baseSkyMap.BaseSkyMap.

Definition at line 68 of file dodecaSkyMap.py.

68  def __init__(self, config=None):
69  BaseSkyMap.__init__(self, config)
70  self._dodecahedron = detail.Dodecahedron(withFacesOnPoles=self.config.withTractsOnPoles)
71 
72  tractOverlap = geom.Angle(self.config.tractOverlap, geom.degrees)
73 
74  for id in range(12):
75  tractVec = self._dodecahedron.getFaceCtr(id)
76  tractCoord = detail.coordFromVec(tractVec, defRA=geom.Angle(0))
77  tractRA = tractCoord.getLongitude()
78  vertexVecList = self._dodecahedron.getVertices(id)
79 
80  # make initial WCS; don't worry about crPixPos because TractInfo will shift it as required
81  wcs = self._wcsFactory.makeWcs(crPixPos=geom.Point2D(0, 0), crValCoord=tractCoord)
82 
83  self._tractInfoList.append(
84  TractInfo(
85  id=id,
86  patchInnerDimensions=self.config.patchInnerDimensions,
87  patchBorder=self.config.patchBorder,
88  ctrCoord=tractCoord,
89  vertexCoordList=[detail.coordFromVec(vec, defRA=tractRA) for vec in vertexVecList],
90  tractOverlap=tractOverlap,
91  wcs=wcs,
92  )
93  )
94 

Member Function Documentation

◆ __eq__()

def lsst.skymap.baseSkyMap.BaseSkyMap.__eq__ (   self,
  other 
)
inherited

Definition at line 212 of file baseSkyMap.py.

212  def __eq__(self, other):
213  try:
214  return self.getSha1() == other.getSha1()
215  except AttributeError:
216  return NotImplemented
217 

◆ __getitem__()

def lsst.skymap.baseSkyMap.BaseSkyMap.__getitem__ (   self,
  ind 
)
inherited

Reimplemented in lsst.skymap.cachingSkyMap.CachingSkyMap.

Definition at line 200 of file baseSkyMap.py.

200  def __getitem__(self, ind):
201  return self._tractInfoList[ind]
202 

◆ __getstate__()

def lsst.skymap.dodecaSkyMap.DodecaSkyMap.__getstate__ (   self)
Support pickle.

Returns
-------
result : `dict`
    A dict containing:
    - version: a pair of ints
    - config: the config

Definition at line 95 of file dodecaSkyMap.py.

95  def __getstate__(self):
96  """Support pickle.
97 
98  Returns
99  -------
100  result : `dict`
101  A dict containing:
102  - version: a pair of ints
103  - config: the config
104  """
105  return dict(
106  version=self._version,
107  config=self.config,
108  )
109 

◆ __hash__()

def lsst.skymap.baseSkyMap.BaseSkyMap.__hash__ (   self)
inherited

Definition at line 209 of file baseSkyMap.py.

209  def __hash__(self):
210  return hash(self.getSha1())
211 

◆ __iter__()

def lsst.skymap.baseSkyMap.BaseSkyMap.__iter__ (   self)
inherited

Reimplemented in lsst.skymap.cachingSkyMap.CachingSkyMap.

Definition at line 203 of file baseSkyMap.py.

203  def __iter__(self):
204  return iter(self._tractInfoList)
205 

◆ __len__()

def lsst.skymap.baseSkyMap.BaseSkyMap.__len__ (   self)
inherited

Reimplemented in lsst.skymap.cachingSkyMap.CachingSkyMap.

Definition at line 206 of file baseSkyMap.py.

206  def __len__(self):
207  return len(self._tractInfoList)
208 

◆ __ne__()

def lsst.skymap.baseSkyMap.BaseSkyMap.__ne__ (   self,
  other 
)
inherited

Definition at line 218 of file baseSkyMap.py.

218  def __ne__(self, other):
219  return not (self == other)
220 

◆ __setstate__()

def lsst.skymap.dodecaSkyMap.DodecaSkyMap.__setstate__ (   self,
  stateDict 
)
Support unpickle

Parameters
----------
stateDict : `dict`
    - version: a pair of ints
    - config: the config

Definition at line 110 of file dodecaSkyMap.py.

110  def __setstate__(self, stateDict):
111  """Support unpickle
112 
113  Parameters
114  ----------
115  stateDict : `dict`
116  - version: a pair of ints
117  - config: the config
118  """
119  version = stateDict["version"]
120  if version >= (2, 0):
121  raise RuntimeError("Version = %s >= (2,0); cannot unpickle" % (version,))
122  self.__init__(stateDict["config"])
123 

◆ findClosestTractPatchList()

def lsst.skymap.baseSkyMap.BaseSkyMap.findClosestTractPatchList (   self,
  coordList 
)
inherited
Find closest tract and patches that overlap coordinates.

Parameters
----------
coordList : `lsst.geom.SpherePoint`
    List of ICRS sky coordinates to search for.

Returns
-------
retList : `list`
    list of (TractInfo, list of PatchInfo) for tracts and patches
    that contain, or may contain, the specified region.
    The list will be empty if there is no overlap.

Definition at line 177 of file baseSkyMap.py.

177  def findClosestTractPatchList(self, coordList):
178  """Find closest tract and patches that overlap coordinates.
179 
180  Parameters
181  ----------
182  coordList : `lsst.geom.SpherePoint`
183  List of ICRS sky coordinates to search for.
184 
185  Returns
186  -------
187  retList : `list`
188  list of (TractInfo, list of PatchInfo) for tracts and patches
189  that contain, or may contain, the specified region.
190  The list will be empty if there is no overlap.
191  """
192  retList = []
193  for coord in coordList:
194  tractInfo = self.findTract(coord)
195  patchList = tractInfo.findPatchList(coordList)
196  if patchList and not (tractInfo, patchList) in retList:
197  retList.append((tractInfo, patchList))
198  return retList
199 

◆ findTract()

def lsst.skymap.dodecaSkyMap.DodecaSkyMap.findTract (   self,
  coord 
)
Find the tract whose inner region includes the coord.

Parameters
----------
coord : `lsst.geom.SpherePoint`
    ICRS sky coordinate to search for.

Returns
-------
tractInfo : `TractInfo`
    Info for tract whose inner region includes the coord.

Reimplemented from lsst.skymap.baseSkyMap.BaseSkyMap.

Definition at line 124 of file dodecaSkyMap.py.

124  def findTract(self, coord):
125  """Find the tract whose inner region includes the coord.
126 
127  Parameters
128  ----------
129  coord : `lsst.geom.SpherePoint`
130  ICRS sky coordinate to search for.
131 
132  Returns
133  -------
134  tractInfo : `TractInfo`
135  Info for tract whose inner region includes the coord.
136  """
137  return self[self._dodecahedron.getFaceInd(coord.getVector())]
138 

◆ findTractPatchList()

def lsst.skymap.baseSkyMap.BaseSkyMap.findTractPatchList (   self,
  coordList 
)
inherited
Find tracts and patches that overlap a region.

Parameters
----------
coordList : `list` of `lsst.geom.SpherePoint`
    List of ICRS sky coordinates to search for.

Returns
-------
reList : `list` of (`TractInfo`, `list` of `PatchInfo`)
    For tracts and patches that contain, or may contain, the specified
    region. The list will be empty if there is no overlap.

Notes
-----
**warning:**
    This uses a naive algorithm that may find some tracts and patches
    that do not overlap the region (especially if the region is not a
    rectangle aligned along patch x, y).

Reimplemented in lsst.skymap.ringsSkyMap.RingsSkyMap.

Definition at line 149 of file baseSkyMap.py.

149  def findTractPatchList(self, coordList):
150  """Find tracts and patches that overlap a region.
151 
152  Parameters
153  ----------
154  coordList : `list` of `lsst.geom.SpherePoint`
155  List of ICRS sky coordinates to search for.
156 
157  Returns
158  -------
159  reList : `list` of (`TractInfo`, `list` of `PatchInfo`)
160  For tracts and patches that contain, or may contain, the specified
161  region. The list will be empty if there is no overlap.
162 
163  Notes
164  -----
165  **warning:**
166  This uses a naive algorithm that may find some tracts and patches
167  that do not overlap the region (especially if the region is not a
168  rectangle aligned along patch x, y).
169  """
170  retList = []
171  for tractInfo in self:
172  patchList = tractInfo.findPatchList(coordList)
173  if patchList:
174  retList.append((tractInfo, patchList))
175  return retList
176 

◆ getSha1()

def lsst.skymap.baseSkyMap.BaseSkyMap.getSha1 (   self)
inherited
Return a SHA1 hash that uniquely identifies this SkyMap instance.

Returns
-------
sha1 : `bytes`
    A 20-byte hash that uniquely identifies this SkyMap instance.

Notes
-----
Subclasses should almost always override ``updateSha1`` instead of
this function to add subclass-specific state to the hash.

Definition at line 245 of file baseSkyMap.py.

245  def getSha1(self):
246  """Return a SHA1 hash that uniquely identifies this SkyMap instance.
247 
248  Returns
249  -------
250  sha1 : `bytes`
251  A 20-byte hash that uniquely identifies this SkyMap instance.
252 
253  Notes
254  -----
255  Subclasses should almost always override ``updateSha1`` instead of
256  this function to add subclass-specific state to the hash.
257  """
258  if self._sha1 is None:
259  sha1 = hashlib.sha1()
260  sha1.update(type(self).__name__.encode('utf-8'))
261  configPacked = struct.pack(
262  "<iiidd3sd",
263  self.config.patchInnerDimensions[0],
264  self.config.patchInnerDimensions[1],
265  self.config.patchBorder,
266  self.config.tractOverlap,
267  self.config.pixelScale,
268  self.config.projection.encode('ascii'),
269  self.config.rotation
270  )
271  sha1.update(configPacked)
272  self.updateSha1(sha1)
273  self._sha1 = sha1.digest()
274  return self._sha1
275 

◆ getVersion()

def lsst.skymap.dodecaSkyMap.DodecaSkyMap.getVersion (   self)
Return version (e.g. for pickle).

Returns
-------
version : `tuple` of `int`
    Version as a pair of integers.

Definition at line 139 of file dodecaSkyMap.py.

139  def getVersion(self):
140  """Return version (e.g. for pickle).
141 
142  Returns
143  -------
144  version : `tuple` of `int`
145  Version as a pair of integers.
146  """
147  return self._version
148 

◆ getWithTractsOnPoles()

def lsst.skymap.dodecaSkyMap.DodecaSkyMap.getWithTractsOnPoles (   self)
Return True if there are tracts centered on the poles.

Definition at line 149 of file dodecaSkyMap.py.

149  def getWithTractsOnPoles(self):
150  """Return True if there are tracts centered on the poles.
151  """
152  return self._dodecahedron.getWithFacesOnPoles()
153 

◆ logSkyMapInfo()

def lsst.skymap.baseSkyMap.BaseSkyMap.logSkyMapInfo (   self,
  log 
)
inherited
Write information about a sky map to supplied log

Parameters
----------
log : `lsst.log.Log`
    Log object that information about skymap will be written

Definition at line 221 of file baseSkyMap.py.

221  def logSkyMapInfo(self, log):
222  """Write information about a sky map to supplied log
223 
224  Parameters
225  ----------
226  log : `lsst.log.Log`
227  Log object that information about skymap will be written
228  """
229  log.info("sky map has %s tracts" % (len(self),))
230  for tractInfo in self:
231  wcs = tractInfo.getWcs()
232  posBox = geom.Box2D(tractInfo.getBBox())
233  pixelPosList = (
234  posBox.getMin(),
235  geom.Point2D(posBox.getMaxX(), posBox.getMinY()),
236  posBox.getMax(),
237  geom.Point2D(posBox.getMinX(), posBox.getMaxY()),
238  )
239  skyPosList = [wcs.pixelToSky(pos).getPosition(geom.degrees) for pos in pixelPosList]
240  posStrList = ["(%0.3f, %0.3f)" % tuple(skyPos) for skyPos in skyPosList]
241  log.info("tract %s has corners %s (RA, Dec deg) and %s x %s patches" %
242  (tractInfo.getId(), ", ".join(posStrList),
243  tractInfo.getNumPatches()[0], tractInfo.getNumPatches()[1]))
244 

◆ register()

def lsst.skymap.baseSkyMap.BaseSkyMap.register (   self,
  name,
  registry 
)
inherited
Add SkyMap, Tract, and Patch Dimension entries to the given Gen3
Butler Registry.

Parameters
----------
name : `str`
    The name of the skymap.
registry : `lsst.daf.butler.Registry`
    The registry to add to.

Definition at line 293 of file baseSkyMap.py.

293  def register(self, name, registry):
294  """Add SkyMap, Tract, and Patch Dimension entries to the given Gen3
295  Butler Registry.
296 
297  Parameters
298  ----------
299  name : `str`
300  The name of the skymap.
301  registry : `lsst.daf.butler.Registry`
302  The registry to add to.
303  """
304  nxMax = 0
305  nyMax = 0
306  records = {
307  "skymap": [],
308  "tract": [],
309  "patch": [],
310  }
311  for tractInfo in self:
312  nx, ny = tractInfo.getNumPatches()
313  nxMax = max(nxMax, nx)
314  nyMax = max(nyMax, ny)
315  region = tractInfo.getOuterSkyPolygon()
316  centroid = SpherePoint(region.getCentroid())
317  records["tract"].append({
318  "skymap": name,
319  "tract": tractInfo.getId(),
320  "region": region,
321  "ra": centroid.getRa().asDegrees(),
322  "dec": centroid.getDec().asDegrees(),
323  })
324  for patchInfo in tractInfo:
325  cellX, cellY = patchInfo.getIndex()
326  records["patch"].append({
327  "skymap": name,
328  "tract": tractInfo.getId(),
329  "patch": tractInfo.getSequentialPatchIndex(patchInfo),
330  "cell_x": cellX,
331  "cell_y": cellY,
332  "region": patchInfo.getOuterSkyPolygon(tractInfo.getWcs()),
333  })
334  records["skymap"].append({
335  "skymap": name,
336  "hash": self.getSha1(),
337  "tract_max": len(self),
338  "patch_nx_max": nxMax,
339  "patch_ny_max": nyMax,
340  })
341  with registry.transaction():
342  for dimension, recordsForDimension in records.items():
343  registry.insertDimensionData(dimension, *recordsForDimension)

◆ updateSha1()

def lsst.skymap.dodecaSkyMap.DodecaSkyMap.updateSha1 (   self,
  sha1 
)
Add subclass-specific state or configuration options to the SHA1.

Reimplemented from lsst.skymap.baseSkyMap.BaseSkyMap.

Definition at line 154 of file dodecaSkyMap.py.

154  def updateSha1(self, sha1):
155  """Add subclass-specific state or configuration options to the SHA1."""
156  sha1.update(struct.pack("<?", self.config.withTractsOnPoles))

Member Data Documentation

◆ config

lsst.skymap.baseSkyMap.BaseSkyMap.config
inherited

Definition at line 107 of file baseSkyMap.py.

◆ ConfigClass

lsst.skymap.dodecaSkyMap.DodecaSkyMap.ConfigClass
static

Definition at line 65 of file dodecaSkyMap.py.


The documentation for this class was generated from the following file:
lsst::afw::table::SpherePoint
lsst::geom::SpherePoint SpherePoint
Definition: misc.h:35
ast::append
std::shared_ptr< FrameSet > append(FrameSet const &first, FrameSet const &second)
Construct a FrameSet that performs two transformations in series.
Definition: functional.cc:33
max
int max
Definition: BoundedField.cc:104
lsst::meas::astrom::makeWcs
std::shared_ptr< afw::geom::SkyWcs > makeWcs(SipForwardTransform const &sipForward, SipReverseTransform const &sipReverse, geom::SpherePoint const &skyOrigin)
Create a new TAN SIP Wcs from a pair of SIP transforms and the sky origin.
Definition: SipTransform.cc:148
lsst.gdb.ip.diffim.printers.register
def register(obj)
Definition: printers.py:20
type
table::Key< int > type
Definition: Detector.cc:163
lsst::geom::Point< double, 2 >
lsst::geom::Angle
A class representing an angle.
Definition: Angle.h:127
lsst::geom::Box2D
A floating-point coordinate rectangle geometry.
Definition: Box.h:413
astshim.fitsChanContinued.iter
def iter(self)
Definition: fitsChanContinued.py:88