33 """An object which blows up when we try to read it"""
35 raise RuntimeError(
"Was unable to import healpy: %s" % e)
41 from .cachingSkyMap
import CachingSkyMap
42 from .tractInfo
import TractInfo
46 """Convert healpy's ang to an afw Coord
48 The ang is provided as a single object, thetaphi, so the output
49 of healpy functions can be directed to this function without
50 additional translation.
52 return IcrsCoord(float(thetaphi[1])*afwGeom.radians, float(thetaphi[0] - 0.5*numpy.pi)*afwGeom.radians)
55 """Convert an afw Coord to a healpy ang (theta, phi)"""
56 return (coord.getLatitude().asRadians() - 0.5*numpy.pi, coord.getLongitude().asRadians())
59 """Tract for the HealpixSkyMap"""
60 def __init__(self, nSide, ident, nest, patchInnerDimensions, patchBorder, ctrCoord, tractOverlap, wcs):
61 """Set vertices from nside, ident, nest"""
62 theta, phi = healpy.vec2ang(numpy.transpose(healpy.boundaries(nSide, ident, nest=nest)))
63 vertexList = [
angToCoord(thetaphi)
for thetaphi
in zip(theta,phi)]
64 super(HealpixTractInfo, self).
__init__(ident, patchInnerDimensions, patchBorder, ctrCoord,
65 vertexList, tractOverlap, wcs)
69 """Configuration for the HealpixSkyMap"""
70 log2NSide = Field(dtype=int, default=0, doc=
"Number of sides, expressed in powers of 2")
71 nest = Field(dtype=bool, default=
False, doc=
"Use NEST ordering instead of RING?")
76 """HEALPix-based sky map pixelization.
78 We put a Tract at the position of each HEALPixel.
80 ConfigClass = HealpixSkyMapConfig
87 @param[in] config: an instance of self.ConfigClass; if None the default config is used
88 @param[in] version: software version of this class, to retain compatibility with old instances
91 numTracts = healpy.nside2npix(self.
_nside)
92 super(HealpixSkyMap, self).
__init__(numTracts, config, version)
95 """Find the tract whose inner region includes the coord."""
97 index = healpy.ang2pix(self.
_nside, theta, phi, nest=self.config.nest)
101 """Get the TractInfo for a particular index"""
102 center =
angToCoord(healpy.pix2ang(self.
_nside, index, nest=self.config.nest))
103 wcs = self._wcsFactory.makeWcs(crPixPos=
afwGeom.Point2D(0,0), crValCoord=center)
105 self.config.patchBorder, center, self.config.tractOverlap*afwGeom.degrees,
A class to handle Icrs coordinates (inherits from Coord)