Coverage for python/lsst/skymap/baseSkyMap.py : 83%

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 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/>. # @todo - Consider tweaking pixel scale so the average scale is as specified, rather than the scale at the center """
doc="dimensions of inner region of patches (x,y pixels)", dtype=int, length=2, default=(4000, 4000), ) doc="border between patch inner and outer bbox (pixels)", dtype=int, default=100, ) doc="minimum overlap between adjacent sky tracts, on the sky (deg)", dtype=float, default=1.0, ) doc="nominal pixel scale (arcsec/pixel)", dtype=float, default=0.333 ) doc="""one of the FITS WCS projection codes, such as: - STG: stereographic projection - MOL: Molleweide's projection - TAN: tangent-plane projection """, dtype=str, default="STG", ) doc="Rotation for WCS (deg)", dtype=float, default=0, )
"""A collection of overlapping Tracts that map part or all of the sky.
See TractInfo for more information.
BaseSkyMap is an abstract base class. Subclasses must do the following: @li define __init__ and have it construct the TractInfo objects and put them in _tractInfoList @li define __getstate__ and __setstate__ to allow pickling (the butler saves sky maps using pickle); see DodecaSkyMap for an example of how to do this. (Most of that code could be moved into this base class, but that would make it harder to handle older versions of pickle data.) @li define updateSha1 to add any subclass-specific state to the hash.
All SkyMap subclasses must be conceptually immutable; they must always refer to the same set of mathematical tracts and patches even if the in- memory representation of those objects changes. """
"""Construct a BaseSkyMap
@param[in] config: an instance of self.ConfigClass; if None the default config is used """ pixelScale=Angle(self.config.pixelScale, arcseconds), projection=self.config.projection, rotation=Angle(self.config.rotation, degrees), )
"""Find the tract whose center is nearest the specified coord.
@param[in] coord: ICRS sky coordinate (lsst.afw.geom.SpherePoint) @return TractInfo of tract whose center is nearest the specified coord
@warning: - if tracts do not cover the whole sky then the returned tract may not include the coord
@note - This routine will be more efficient if coord is ICRS. - If coord is equidistant between multiple sky tract centers then one is arbitrarily chosen. - The default implementation is not very efficient; subclasses may wish to override. """ # include index in order to disambiguate identical angSep values
"""Find tracts and patches that overlap a region
@param[in] coordList: list of ICRS sky coordinates (lsst.afw.geom.SpherePoint) @return 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.
@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). """
"""Find closest tract and patches that overlap coordinates
@param[in] coordList: list of ICRS sky coordinates (lsst.afw.geom.SpherePoint) @return 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. """
return hash(self.getSha1())
except AttributeError: return NotImplemented
"""Return a SHA1 hash that uniquely identifies this SkyMap instance.
Returns ------- sha1 : bytes A 20-byte hash that uniquely identifies this SkyMap instance.
Subclasses should almost always override `updateSha1()` instead of this function to add subclass-specific state to the hash. """ "<iiidd3sd", self.config.patchInnerDimensions[0], self.config.patchInnerDimensions[1], self.config.patchBorder, self.config.tractOverlap, self.config.pixelScale, self.config.projection.encode('ascii'), self.config.rotation )
"""Add subclass-specific state or configuration options to the SHA1.
Parameters ---------- sha1 : hashlib.sha1 A hashlib object on which `update()` can be called to add additional state to the hash.
This method is conceptually "protected": it should be reimplemented by all subclasses, but called only by the base class implementation of `getSha1()`. """ raise NotImplementedError()
"""Add SkyMap, Tract, and Patch DataUnits to the given Gen3 Butler Registry. """ registry.addDataUnitEntry("SkyMap", {"skymap": name, "hash": self.getSha1()}) for tractInfo in self: region = tractInfo.getOuterSkyPolygon() centroid = SpherePoint(region.getCentroid()) registry.addDataUnitEntry( "Tract", {"skymap": name, "tract": tractInfo.getId(), "region": region, "ra": centroid.getRa().asDegrees(), "dec": centroid.getDec().asDegrees()} ) for patchInfo in tractInfo: cellX, cellY = patchInfo.getIndex() registry.addDataUnitEntry( "Patch", {"skymap": name, "tract": tractInfo.getId(), "patch": tractInfo.getSequentialPatchIndex(patchInfo), "cell_x": cellX, "cell_y": cellY, "region": patchInfo.getOuterSkyPolygon(tractInfo.getWcs())} ) |