Coverage for python/lsst/skymap/healpixSkyMap.py : 60%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# # LSST Data Management System # Copyright 2008, 2009, 2010, 2012 LSST Corporation. # # This product includes software developed by the # LSST Project (http://www.lsst.org/). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the LSST License Statement and # the GNU General Public License along with this program. If not, # see <http://www.lsstcorp.org/LegalNotices/>. #
# We want to register the HealpixSkyMap, but want "healpy" to be an # optional dependency. However, the HealpixSkyMap requires the use # of healpy. Therefore, we'll only raise an exception on the healpy # import when it comes time to using it. """An object which blows up when we try to read it"""
raise RuntimeError("Was unable to import healpy: %s" % e)
"""Convert healpy's ang to an lsst.geom.SpherePoint
The ang is provided as a single object, thetaphi, so the output of healpy functions can be directed to this function without additional translation. """ return afwGeom.SpherePoint(float(thetaphi[1]), float(thetaphi[0] - 0.5*numpy.pi), afwGeom.radians)
"""Convert an lsst.geom.SpherePoint to a healpy ang (theta, phi)
The Healpix convention is that 0 <= theta <= pi, 0 <= phi < 2pi. """ return (coord.getLatitude().asRadians() + 0.5*numpy.pi, coord.getLongitude().asRadians())
"""Tract for the HealpixSkyMap"""
"""Set vertices from nside, ident, nest""" theta, phi = healpy.vec2ang(numpy.transpose(healpy.boundaries(nSide, ident, nest=nest))) vertexList = [angToCoord(thetaphi) for thetaphi in zip(theta, phi)] super(HealpixTractInfo, self).__init__(ident, patchInnerDimensions, patchBorder, ctrCoord, vertexList, tractOverlap, wcs)
"""Configuration for the HealpixSkyMap"""
self.rotation = 45 # HEALPixels are oriented at 45 degrees
"""HEALPix-based sky map pixelization.
We put a Tract at the position of each HEALPixel.
Parameters ---------- config : `lsst.skymap.BaseSkyMapConfig` The configuration for this SkyMap. version : `int` or `tuple` of `int` (optional) Software version of this class, to retain compatibility with old instances. """
self._nside = 1 << config.log2NSide numTracts = healpy.nside2npix(self._nside) super(HealpixSkyMap, self).__init__(numTracts, config, version)
"""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. """ theta, phi = coordToAng(coord) index = healpy.ang2pix(self._nside, theta, phi, nest=self.config.nest) return self[index]
"""Generate TractInfo for the specified tract index.""" center = angToCoord(healpy.pix2ang(self._nside, index, nest=self.config.nest)) wcs = self._wcsFactory.makeWcs(crPixPos=afwGeom.Point2D(0, 0), crValCoord=center) return HealpixTractInfo(self._nside, index, self.config.nest, self.config.patchInnerDimensions, self.config.patchBorder, center, self.config.tractOverlap*afwGeom.degrees, wcs)
"""Add subclass-specific state or configuration options to the SHA1.""" sha1.update(struct.pack("<i?", self.config.log2NSide, self.config.nest)) |