1 from builtins
import zip
2 from builtins
import object
33 except Exception
as e:
35 """An object which blows up when we try to read it""" 38 raise RuntimeError(
"Was unable to import healpy: %s" % e)
41 from lsst.pex.config
import Field
42 from lsst.afw.coord
import IcrsCoord
43 import lsst.afw.geom
as afwGeom
44 from .cachingSkyMap
import CachingSkyMap
45 from .tractInfo
import TractInfo
47 __all__ = [
'HealpixSkyMapConfig',
'HealpixSkyMap']
50 """Convert healpy's ang to an afw Coord 52 The ang is provided as a single object, thetaphi, so the output 53 of healpy functions can be directed to this function without 54 additional translation. 56 return IcrsCoord(float(thetaphi[1])*afwGeom.radians, float(thetaphi[0] - 0.5*numpy.pi)*afwGeom.radians)
60 """Convert an afw Coord to a healpy ang (theta, phi) 62 The Healpix convention is that 0 <= theta <= pi, 0 <= phi < 2pi. 64 return (coord.getLatitude().asRadians() + 0.5*numpy.pi, coord.getLongitude().asRadians())
68 """Tract for the HealpixSkyMap""" 70 def __init__(self, nSide, ident, nest, patchInnerDimensions, patchBorder, ctrCoord, tractOverlap, wcs):
71 """Set vertices from nside, ident, nest""" 72 theta, phi = healpy.vec2ang(numpy.transpose(healpy.boundaries(nSide, ident, nest=nest)))
73 vertexList = [
angToCoord(thetaphi)
for thetaphi
in zip(theta, phi)]
74 super(HealpixTractInfo, self).
__init__(ident, patchInnerDimensions, patchBorder, ctrCoord,
75 vertexList, tractOverlap, wcs)
79 """Configuration for the HealpixSkyMap""" 80 log2NSide = Field(dtype=int, default=0, doc=
"Number of sides, expressed in powers of 2")
81 nest = Field(dtype=bool, default=
False, doc=
"Use NEST ordering instead of RING?")
88 """HEALPix-based sky map pixelization. 90 We put a Tract at the position of each HEALPixel. 92 ConfigClass = HealpixSkyMapConfig
99 @param[in] config: an instance of self.ConfigClass; if None the default config is used 100 @param[in] version: software version of this class, to retain compatibility with old instances 102 self.
_nside = 1 << config.log2NSide
103 numTracts = healpy.nside2npix(self.
_nside)
104 super(HealpixSkyMap, self).
__init__(numTracts, config, version)
107 """Find the tract whose inner region includes the coord.""" 109 index = healpy.ang2pix(self.
_nside, theta, phi, nest=self.
config.nest)
113 """Get the TractInfo for a particular index""" 115 wcs = self.
_wcsFactory.makeWcs(crPixPos=afwGeom.Point2D(0, 0), crValCoord=center)
117 self.
config.patchBorder, center, self.
config.tractOverlap*afwGeom.degrees,
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)
def __getattr__(self, name)