LSST Applications 28.0.2,g0fba68d861+5b923b673a,g1fd858c14a+7a7b9dd5ed,g2c84ff76c0+5548bfee71,g30358e5240+f0e04ebe90,g35bb328faa+fcb1d3bbc8,g436fd98eb5+bdc6fcdd04,g4af146b050+742274f7cd,g4d2262a081+3efd3f8190,g4e0f332c67+cb09b8a5b6,g53246c7159+fcb1d3bbc8,g5a012ec0e7+477f9c599b,g5edb6fd927+826dfcb47f,g60b5630c4e+bdc6fcdd04,g67b6fd64d1+2218407a0c,g78460c75b0+2f9a1b4bcd,g786e29fd12+cf7ec2a62a,g7b71ed6315+fcb1d3bbc8,g87b7deb4dc+f9ac2ab1bd,g8852436030+ebf28f0d95,g89139ef638+2218407a0c,g9125e01d80+fcb1d3bbc8,g989de1cb63+2218407a0c,g9f33ca652e+42fb53f4c8,g9f7030ddb1+11b9b6f027,ga2b97cdc51+bdc6fcdd04,gab72ac2889+bdc6fcdd04,gabe3b4be73+1e0a283bba,gabf8522325+3210f02652,gb1101e3267+9c79701da9,gb58c049af0+f03b321e39,gb89ab40317+2218407a0c,gcf25f946ba+ebf28f0d95,gd6cbbdb0b4+e8f9c9c900,gd9a9a58781+fcb1d3bbc8,gde0f65d7ad+a08f294619,ge278dab8ac+3ef3db156b,ge410e46f29+2218407a0c,gf67bdafdda+2218407a0c
LSST Data Management Base Package
Loading...
Searching...
No Matches
lsst.skymap.dodecaSkyMap.DodecaSkyMap Class Reference
Inheritance diagram for lsst.skymap.dodecaSkyMap.DodecaSkyMap:
lsst.skymap.baseSkyMap.BaseSkyMap

Public Member Functions

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

Public Attributes

 config = config
 

Static Public Attributes

 ConfigClass = BaseSkyMapConfig
 
str SKYMAP_RUN_COLLECTION_NAME = "skymaps"
 
str SKYMAP_DATASET_TYPE_NAME = "skyMap"
 

Protected Attributes

 _dodecahedron = detail.Dodecahedron(withFacesOnPoles=self.config.withTractsOnPoles)
 
list _tractInfoList = []
 
 _wcsFactory
 
 _sha1 = None
 
 _tractBuilder = config.tractBuilder.apply()
 

Static Protected Attributes

tuple _version = (1, 0)
 

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__()

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

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
81 # will shift it as required.
82 wcs = self._wcsFactory.makeWcs(crPixPos=geom.Point2D(0, 0), crValCoord=tractCoord)
83
84 self._tractInfoList.append(
85 TractInfo(
86 id=id,
87 tractBuilder=self._tractBuilder,
88 ctrCoord=tractCoord,
89 vertexCoordList=[detail.coordFromVec(vec, defRA=tractRA) for vec in vertexVecList],
90 tractOverlap=tractOverlap,
91 wcs=wcs,
92 )
93 )
94
A class representing an angle.
Definition Angle.h:128

Member Function Documentation

◆ __eq__()

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

Definition at line 311 of file baseSkyMap.py.

311 def __eq__(self, other):
312 try:
313 return self.getSha1() == other.getSha1()
314 except AttributeError:
315 return NotImplemented
316

◆ __getitem__()

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

Definition at line 299 of file baseSkyMap.py.

299 def __getitem__(self, ind):
300 return self._tractInfoList[ind]
301

◆ __getstate__()

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__()

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

Definition at line 308 of file baseSkyMap.py.

308 def __hash__(self):
309 return hash(self.getSha1())
310

◆ __iter__()

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

Definition at line 302 of file baseSkyMap.py.

302 def __iter__(self):
303 return iter(self._tractInfoList)
304

◆ __len__()

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

Definition at line 305 of file baseSkyMap.py.

305 def __len__(self):
306 return len(self._tractInfoList)
307

◆ __ne__()

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

Definition at line 317 of file baseSkyMap.py.

317 def __ne__(self, other):
318 return not (self == other)
319

◆ __setstate__()

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()

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 276 of file baseSkyMap.py.

276 def findClosestTractPatchList(self, coordList):
277 """Find closest tract and patches that overlap coordinates.
278
279 Parameters
280 ----------
281 coordList : `lsst.geom.SpherePoint`
282 List of ICRS sky coordinates to search for.
283
284 Returns
285 -------
286 retList : `list`
287 list of (TractInfo, list of PatchInfo) for tracts and patches
288 that contain, or may contain, the specified region.
289 The list will be empty if there is no overlap.
290 """
291 retList = []
292 for coord in coordList:
293 tractInfo = self.findTract(coord)
294 patchList = tractInfo.findPatchList(coordList)
295 if patchList and not (tractInfo, patchList) in retList:
296 retList.append((tractInfo, patchList))
297 return retList
298

◆ findTract()

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

◆ findTractIdArray()

lsst.skymap.baseSkyMap.BaseSkyMap.findTractIdArray ( self,
ra,
dec,
degrees = False )
inherited
Find array of tract IDs with vectorized operations (where
supported).

If a given sky map does not support vectorized operations, then a loop
over findTract will be called.

Parameters
----------
ra : `numpy.ndarray`
    Array of Right Ascension.  Units are radians unless
    degrees=True.
dec : `numpy.ndarray`
    Array of Declination.  Units are radians unless
    degrees=True.
degrees : `bool`, optional
    Input ra, dec arrays are degrees if `True`.

Returns
-------
tractId : `numpy.ndarray`
    Array of tract IDs

Notes
-----
- If coord is equidistant between multiple sky tract centers then one
  is arbitrarily chosen.

.. warning::

   If tracts do not cover the whole sky then the returned tract may not
   include the given ra/dec.

Reimplemented in lsst.skymap.ringsSkyMap.RingsSkyMap.

Definition at line 206 of file baseSkyMap.py.

206 def findTractIdArray(self, ra, dec, degrees=False):
207 """Find array of tract IDs with vectorized operations (where
208 supported).
209
210 If a given sky map does not support vectorized operations, then a loop
211 over findTract will be called.
212
213 Parameters
214 ----------
215 ra : `numpy.ndarray`
216 Array of Right Ascension. Units are radians unless
217 degrees=True.
218 dec : `numpy.ndarray`
219 Array of Declination. Units are radians unless
220 degrees=True.
221 degrees : `bool`, optional
222 Input ra, dec arrays are degrees if `True`.
223
224 Returns
225 -------
226 tractId : `numpy.ndarray`
227 Array of tract IDs
228
229 Notes
230 -----
231 - If coord is equidistant between multiple sky tract centers then one
232 is arbitrarily chosen.
233
234 .. warning::
235
236 If tracts do not cover the whole sky then the returned tract may not
237 include the given ra/dec.
238 """
239 units = geom.degrees if degrees else geom.radians
240 coords = [geom.SpherePoint(r*units, d*units) for r, d in zip(np.atleast_1d(ra),
241 np.atleast_1d(dec))]
242
243 tractId = np.array([self.findTract(coord).getId() for coord in coords])
244
245 return tractId
246
Point in an unspecified spherical coordinate system.
Definition SpherePoint.h:57

◆ findTractPatchList()

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 247 of file baseSkyMap.py.

247 def findTractPatchList(self, coordList):
248 """Find tracts and patches that overlap a region.
249
250 Parameters
251 ----------
252 coordList : `list` of `lsst.geom.SpherePoint`
253 List of ICRS sky coordinates to search for.
254
255 Returns
256 -------
257 reList : `list` of (`TractInfo`, `list` of `PatchInfo`)
258 For tracts and patches that contain, or may contain, the specified
259 region. The list will be empty if there is no overlap.
260
261 Notes
262 -----
263 .. warning::
264
265 This uses a naive algorithm that may find some tracts and patches
266 that do not overlap the region (especially if the region is not a
267 rectangle aligned along patch x, y).
268 """
269 retList = []
270 for tractInfo in self:
271 patchList = tractInfo.findPatchList(coordList)
272 if patchList:
273 retList.append((tractInfo, patchList))
274 return retList
275

◆ getSha1()

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 344 of file baseSkyMap.py.

344 def getSha1(self):
345 """Return a SHA1 hash that uniquely identifies this SkyMap instance.
346
347 Returns
348 -------
349 sha1 : `bytes`
350 A 20-byte hash that uniquely identifies this SkyMap instance.
351
352 Notes
353 -----
354 Subclasses should almost always override ``updateSha1`` instead of
355 this function to add subclass-specific state to the hash.
356 """
357 if self._sha1 is None:
358 sha1 = hashlib.sha1()
359 sha1.update(type(self).__name__.encode('utf-8'))
360 configPacked = self._tractBuilder.getPackedConfig(self.config)
361 sha1.update(configPacked)
362 self.updateSha1(sha1)
363 self._sha1 = sha1.digest()
364 return self._sha1
365

◆ getVersion()

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()

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()

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

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

Definition at line 320 of file baseSkyMap.py.

320 def logSkyMapInfo(self, log):
321 """Write information about a sky map to supplied log
322
323 Parameters
324 ----------
325 log : `logging.Logger`
326 Log object that information about skymap will be written.
327 """
328 log.info("sky map has %s tracts" % (len(self),))
329 for tractInfo in self:
330 wcs = tractInfo.getWcs()
331 posBox = geom.Box2D(tractInfo.getBBox())
332 pixelPosList = (
333 posBox.getMin(),
334 geom.Point2D(posBox.getMaxX(), posBox.getMinY()),
335 posBox.getMax(),
336 geom.Point2D(posBox.getMinX(), posBox.getMaxY()),
337 )
338 skyPosList = [wcs.pixelToSky(pos).getPosition(geom.degrees) for pos in pixelPosList]
339 posStrList = ["(%0.3f, %0.3f)" % tuple(skyPos) for skyPos in skyPosList]
340 log.info("tract %s has corners %s (RA, Dec deg) and %s x %s patches" %
341 (tractInfo.getId(), ", ".join(posStrList),
342 tractInfo.getNumPatches()[0], tractInfo.getNumPatches()[1]))
343
A floating-point coordinate rectangle geometry.
Definition Box.h:413

◆ register()

lsst.skymap.baseSkyMap.BaseSkyMap.register ( self,
name,
butler )
inherited
Add skymap, tract, and patch Dimension entries to the given Gen3
Butler.

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

Raises
------
lsst.daf.butler.registry.ConflictingDefinitionError
    Raised if a different skymap exists with the same name.

Notes
-----
Registering the same skymap multiple times (with the exact same
definition) is safe, but inefficient; most of the work of computing
the rows to be inserted must be done first in order to check for
consistency between the new skymap and any existing one.

Re-registering a skymap with different tract and/or patch definitions
but the same summary information may not be detected as a conflict but
will never result in updating the skymap; there is intentionally no
way to modify a registered skymap (aside from manual administrative
operations on the database), as it is hard to guarantee that this can
be done without affecting reproducibility.

Definition at line 387 of file baseSkyMap.py.

387 def register(self, name, butler):
388 """Add skymap, tract, and patch Dimension entries to the given Gen3
389 Butler.
390
391 Parameters
392 ----------
393 name : `str`
394 The name of the skymap.
395 butler : `lsst.daf.butler.Butler`
396 The butler to add to.
397
398 Raises
399 ------
400 lsst.daf.butler.registry.ConflictingDefinitionError
401 Raised if a different skymap exists with the same name.
402
403 Notes
404 -----
405 Registering the same skymap multiple times (with the exact same
406 definition) is safe, but inefficient; most of the work of computing
407 the rows to be inserted must be done first in order to check for
408 consistency between the new skymap and any existing one.
409
410 Re-registering a skymap with different tract and/or patch definitions
411 but the same summary information may not be detected as a conflict but
412 will never result in updating the skymap; there is intentionally no
413 way to modify a registered skymap (aside from manual administrative
414 operations on the database), as it is hard to guarantee that this can
415 be done without affecting reproducibility.
416 """
417 numPatches = [tractInfo.getNumPatches() for tractInfo in self]
418 nxMax = max(nn[0] for nn in numPatches)
419 nyMax = max(nn[1] for nn in numPatches)
420
421 skyMapRecord = {
422 "skymap": name,
423 "hash": self.getSha1(),
424 "tract_max": len(self),
425 "patch_nx_max": nxMax,
426 "patch_ny_max": nyMax,
427 }
428 butler.registry.registerRun(self.SKYMAP_RUN_COLLECTION_NAME)
429 # Kind of crazy that we've got three different capitalizations of
430 # "skymap" here, but that's what the various conventions (or at least
431 # precedents) dictate.
432 from lsst.daf.butler import DatasetType
433 from lsst.daf.butler.registry import ConflictingDefinitionError
434 datasetType = DatasetType(
435 name=self.SKYMAP_DATASET_TYPE_NAME,
436 dimensions=["skymap"],
437 storageClass="SkyMap",
438 universe=butler.dimensions
439 )
440 butler.registry.registerDatasetType(datasetType)
441 with butler.transaction():
442 try:
443 inserted = butler.registry.syncDimensionData("skymap", skyMapRecord)
444 except ConflictingDefinitionError as err:
445 raise ConflictingDefinitionError(
446 f"SkyMap with hash {self.getSha1().hex()} is already registered with a different name."
447 ) from err
448 if inserted:
449 for tractInfo in self:
450 tractId = tractInfo.getId()
451 tractRegion = tractInfo.getOuterSkyPolygon()
452 tractWcs = tractInfo.getWcs()
453 tractRecord = dict(
454 skymap=name,
455 tract=tractId,
456 region=tractRegion,
457 )
458 butler.registry.insertDimensionData("tract", tractRecord)
459
460 patchRecords = []
461 for patchInfo in tractInfo:
462 xx, yy = patchInfo.getIndex()
463 patchRecords.append(
464 dict(
465 skymap=name,
466 tract=tractId,
467 patch=tractInfo.getSequentialPatchIndex(patchInfo),
468 cell_x=xx,
469 cell_y=yy,
470 region=patchInfo.getOuterSkyPolygon(tractWcs),
471 )
472 )
473 butler.registry.insertDimensionData("patch", *patchRecords)
474
475 butler.put(self, datasetType, {"skymap": name}, run=self.SKYMAP_RUN_COLLECTION_NAME)

◆ updateSha1()

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

◆ _dodecahedron

lsst.skymap.dodecaSkyMap.DodecaSkyMap._dodecahedron = detail.Dodecahedron(withFacesOnPoles=self.config.withTractsOnPoles)
protected

Definition at line 70 of file dodecaSkyMap.py.

◆ _sha1

lsst.skymap.baseSkyMap.BaseSkyMap._sha1 = None
protectedinherited

Definition at line 169 of file baseSkyMap.py.

◆ _tractBuilder

lsst.skymap.baseSkyMap.BaseSkyMap._tractBuilder = config.tractBuilder.apply()
protectedinherited

Definition at line 170 of file baseSkyMap.py.

◆ _tractInfoList

lsst.skymap.baseSkyMap.BaseSkyMap._tractInfoList = []
protectedinherited

Definition at line 163 of file baseSkyMap.py.

◆ _version

tuple lsst.skymap.dodecaSkyMap.DodecaSkyMap._version = (1, 0)
staticprotected

Definition at line 66 of file dodecaSkyMap.py.

◆ _wcsFactory

lsst.skymap.baseSkyMap.BaseSkyMap._wcsFactory
protectedinherited
Initial value:
= detail.WcsFactory(
pixelScale=Angle(self.config.pixelScale, arcseconds),
projection=self.config.projection,
rotation=Angle(self.config.rotation, degrees),
)

Definition at line 164 of file baseSkyMap.py.

◆ config

lsst.skymap.baseSkyMap.BaseSkyMap.config = config
inherited

Definition at line 162 of file baseSkyMap.py.

◆ ConfigClass

lsst.skymap.baseSkyMap.BaseSkyMap.ConfigClass = BaseSkyMapConfig
staticinherited

Definition at line 156 of file baseSkyMap.py.

◆ SKYMAP_DATASET_TYPE_NAME

str lsst.skymap.baseSkyMap.BaseSkyMap.SKYMAP_DATASET_TYPE_NAME = "skyMap"
staticinherited

Definition at line 385 of file baseSkyMap.py.

◆ SKYMAP_RUN_COLLECTION_NAME

lsst.skymap.baseSkyMap.BaseSkyMap.SKYMAP_RUN_COLLECTION_NAME = "skymaps"
staticinherited

Definition at line 383 of file baseSkyMap.py.


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