24 - Consider tweaking pixel scale so the average scale is as specified, rather than the scale at the center 29 from builtins
import object
34 __all__ = [
"BaseSkyMap"]
38 patchInnerDimensions = pexConfig.ListField(
39 doc=
"dimensions of inner region of patches (x,y pixels)",
44 patchBorder = pexConfig.Field(
45 doc=
"border between patch inner and outer bbox (pixels)",
49 tractOverlap = pexConfig.Field(
50 doc=
"minimum overlap between adjacent sky tracts, on the sky (deg)",
54 pixelScale = pexConfig.Field(
55 doc=
"nominal pixel scale (arcsec/pixel)",
59 projection = pexConfig.Field(
60 doc=
"""one of the FITS WCS projection codes, such as: 61 - STG: stereographic projection 62 - MOL: Molleweide's projection 63 - TAN: tangent-plane projection 68 rotation = pexConfig.Field(
69 doc=
"Rotation for WCS (deg)",
76 """A collection of overlapping Tracts that map part or all of the sky. 78 See TractInfo for more information. 80 BaseSkyMap is an abstract base class. Subclasses must do the following: 81 @li define __init__ and have it construct the TractInfo objects and put them in _tractInfoList 82 @li define __getstate__ and __setstate__ to allow pickling (the butler saves sky maps using pickle); 83 see DodecaSkyMap for an example of how to do this. (Most of that code could be moved 84 into this base class, but that would make it harder to handle older versions of pickle data.) 85 @li define updateSha1 to add any subclass-specific state to the hash. 87 All SkyMap subclasses must be conceptually immutable; they must always 88 refer to the same set of mathematical tracts and patches even if the in- 89 memory representation of those objects changes. 91 ConfigClass = BaseSkyMapConfig
94 """Construct a BaseSkyMap 96 @param[in] config: an instance of self.ConfigClass; if None the default config is used 104 pixelScale=afwGeom.Angle(self.
config.pixelScale, afwGeom.arcseconds),
105 projection=self.
config.projection,
106 rotation=afwGeom.Angle(self.
config.rotation, afwGeom.degrees),
111 """Find the tract whose center is nearest the specified coord. 113 @param[in] coord: sky coordinate (afwCoord.Coord) 114 @return TractInfo of tract whose center is nearest the specified coord 117 - if tracts do not cover the whole sky then the returned tract may not include the coord 120 - This routine will be more efficient if coord is ICRS. 121 - If coord is equidistant between multiple sky tract centers then one is arbitrarily chosen. 122 - The default implementation is not very efficient; subclasses may wish to override. 124 icrsCoord = coord.toIcrs()
125 distTractInfoList = []
126 for tractInfo
in self:
127 angSep = icrsCoord.angularSeparation(tractInfo.getCtrCoord()).asDegrees()
128 distTractInfoList.append((angSep, tractInfo))
129 distTractInfoList.sort()
130 return distTractInfoList[0][1]
133 """Find tracts and patches that overlap a region 135 @param[in] coordList: list of sky coordinates (afwCoord.Coord) 136 @return list of (TractInfo, list of PatchInfo) for tracts and patches that contain, 137 or may contain, the specified region. The list will be empty if there is no overlap. 139 @warning this uses a naive algorithm that may find some tracts and patches that do not overlap 140 the region (especially if the region is not a rectangle aligned along patch x,y). 143 for tractInfo
in self:
144 patchList = tractInfo.findPatchList(coordList)
146 retList.append((tractInfo, patchList))
150 """Find closest tract and patches that overlap coordinates 152 @param[in] coordList: list of sky coordinates (afwCoord.Coord) 153 @return list of (TractInfo, list of PatchInfo) for tracts and patches that contain, 154 or may contain, the specified region. The list will be empty if there is no overlap. 157 for coord
in coordList:
159 patchList = tractInfo.findPatchList(coordList)
160 if patchList
and not (tractInfo, patchList)
in retList:
161 retList.append((tractInfo, patchList))
178 return self.
getSha1() == other.getSha1()
179 except AttributeError:
180 return NotImplemented
183 return not (self == other)
186 """Return a SHA1 hash that uniquely identifies this SkyMap instance. 191 A 20-byte hash that uniquely identifies this SkyMap instance. 193 Subclasses should almost always override `updateSha1()` instead of 194 this function to add subclass-specific state to the hash. 196 if self.
_sha1 is None:
197 sha1 = hashlib.sha1()
198 sha1.update(type(self).__name__.encode(
'utf-8'))
199 configPacked = struct.pack(
201 self.
config.patchInnerDimensions[0],
202 self.
config.patchInnerDimensions[1],
206 self.
config.projection.encode(
'ascii'),
209 sha1.update(configPacked)
211 self.
_sha1 = sha1.digest()
215 """Add subclass-specific state or configuration options to the SHA1. 220 A hashlib object on which `update()` can be called to add 221 additional state to the hash. 223 This method is conceptually "protected": it should be reimplemented by 224 all subclasses, but called only by the base class implementation of 227 raise NotImplementedError()
def updateSha1(self, sha1)
def findTractPatchList(self, coordList)
def findClosestTractPatchList(self, coordList)
def __getitem__(self, ind)
def findTract(self, coord)
def __init__(self, config=None)