31 except Exception
as e:
33 """An object which blows up when we try to read it""" 36 raise RuntimeError(
"Was unable to import healpy: %s" % e)
41 from .cachingSkyMap
import CachingSkyMap
42 from .tractInfo
import TractInfo
44 __all__ = [
'HealpixSkyMapConfig',
'HealpixSkyMap']
48 """Convert healpy's ang to an lsst.afw.geom.SpherePoint 50 The ang is provided as a single object, thetaphi, so the output 51 of healpy functions can be directed to this function without 52 additional translation. 54 return afwGeom.SpherePoint(float(thetaphi[1]), float(thetaphi[0] - 0.5*numpy.pi), afwGeom.radians)
58 """Convert an lsst.afw.geom.SpherePoint to a healpy ang (theta, phi) 60 The Healpix convention is that 0 <= theta <= pi, 0 <= phi < 2pi. 62 return (coord.getLatitude().asRadians() + 0.5*numpy.pi, coord.getLongitude().asRadians())
66 """Tract for the HealpixSkyMap""" 68 def __init__(self, nSide, ident, nest, patchInnerDimensions, patchBorder, ctrCoord, tractOverlap, wcs):
69 """Set vertices from nside, ident, nest""" 70 theta, phi = healpy.vec2ang(numpy.transpose(healpy.boundaries(nSide, ident, nest=nest)))
71 vertexList = [
angToCoord(thetaphi)
for thetaphi
in zip(theta, phi)]
72 super(HealpixTractInfo, self).
__init__(ident, patchInnerDimensions, patchBorder, ctrCoord,
73 vertexList, tractOverlap, wcs)
77 """Configuration for the HealpixSkyMap""" 78 log2NSide = Field(dtype=int, default=0, doc=
"Number of sides, expressed in powers of 2")
79 nest = Field(dtype=bool, default=
False, doc=
"Use NEST ordering instead of RING?")
86 """HEALPix-based sky map pixelization. 88 We put a Tract at the position of each HEALPixel. 90 ConfigClass = HealpixSkyMapConfig
97 @param[in] config: an instance of self.ConfigClass; if None the default config is used 98 @param[in] version: software version of this class, to retain compatibility with old instances 100 self.
_nside = 1 << config.log2NSide
101 numTracts = healpy.nside2npix(self.
_nside)
102 super(HealpixSkyMap, self).
__init__(numTracts, config, version)
105 """Find the tract whose inner region includes the coord.""" 107 index = healpy.ang2pix(self.
_nside, theta, phi, nest=self.
config.nest)
111 """Get the TractInfo for a particular index""" 113 wcs = self.
_wcsFactory.makeWcs(crPixPos=afwGeom.Point2D(0, 0), crValCoord=center)
115 self.
config.patchBorder, center, self.
config.tractOverlap*afwGeom.degrees,
119 """Add subclass-specific state or configuration options to the SHA1.""" 120 sha1.update(struct.pack(
"<i?", self.
config.log2NSide, self.
config.nest))
def __getattr__(self, name, e=e)
def updateSha1(self, sha1)
def __init__(self, config, version=0)
def __init__(self, nSide, ident, nest, patchInnerDimensions, patchBorder, ctrCoord, tractOverlap, wcs)
def findTract(self, coord)
def generateTract(self, index)