lsst.skymap  15.0-4-g5589a47+4
equatSkyMap.py
Go to the documentation of this file.
1 #
2 # LSST Data Management System
3 # Copyright 2008, 2009, 2010 LSST Corporation.
4 #
5 # This product includes software developed by the
6 # LSST Project (http://www.lsst.org/).
7 #
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
12 #
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the LSST License Statement and
19 # the GNU General Public License along with this program. If not,
20 # see <http://www.lsstcorp.org/LegalNotices/>.
21 #
22 import struct
23 
24 import lsst.pex.config as pexConfig
25 import lsst.afw.geom as afwGeom
26 from .baseSkyMap import BaseSkyMap
27 from .tractInfo import TractInfo
28 
29 __all__ = ['EquatSkyMapConfig', 'EquatSkyMap']
30 
31 
32 class EquatSkyMapConfig(BaseSkyMap.ConfigClass):
33  numTracts = pexConfig.Field(
34  doc="number of tracts; warning: TAN projection requires at least 3",
35  dtype=int,
36  default=4,
37  )
38  decRange = pexConfig.ListField(
39  doc="range of declination (deg)",
40  dtype=float,
41  length=2,
42  default=(-1.25, 1.25),
43  )
44 
45  def setDefaults(self):
46  self.projection = "CEA"
47 
48 
50  """Equatorial sky map pixelization, e.g. for SDSS stripe 82 image data.
51 
52  EquatSkyMap represents an equatorial band of sky divided along declination into overlapping tracts.
53  """
54  ConfigClass = EquatSkyMapConfig
55  _version = (1, 0) # for pickle
56 
57  def __init__(self, config=None):
58  """Construct a EquatSkyMap
59 
60  @param[in] config: an instance of self.ConfigClass; if None the default config is used
61  """
62  BaseSkyMap.__init__(self, config)
63 
64  decRange = tuple(afwGeom.Angle(dr, afwGeom.degrees) for dr in self.config.decRange)
65  midDec = (decRange[0] + decRange[1]) / 2.0
66  tractWidthRA = afwGeom.Angle(360.0 / self.config.numTracts, afwGeom.degrees)
67  tractOverlap = afwGeom.Angle(self.config.tractOverlap, afwGeom.degrees)
68 
69  for id in range(self.config.numTracts):
70  begRA = tractWidthRA * id
71  endRA = begRA + tractWidthRA
72  vertexCoordList = (
73  afwGeom.SpherePoint(begRA, decRange[0]),
74  afwGeom.SpherePoint(endRA, decRange[0]),
75  afwGeom.SpherePoint(endRA, decRange[1]),
76  afwGeom.SpherePoint(begRA, decRange[1]),
77  )
78 
79  midRA = begRA + tractWidthRA / 2.0
80  ctrCoord = afwGeom.SpherePoint(midRA, midDec)
81 
82  # CRVal must have Dec=0 for symmetry about the equator
83  crValCoord = afwGeom.SpherePoint(midRA, afwGeom.Angle(0.0))
84 
85  # make initial WCS; don't worry about crPixPos because TractInfo will shift it as required
86  wcs = self._wcsFactory.makeWcs(crPixPos=afwGeom.Point2D(0, 0), crValCoord=crValCoord)
87 
88  self._tractInfoList.append(TractInfo(
89  id=id,
90  patchInnerDimensions=self.config.patchInnerDimensions,
91  patchBorder=self.config.patchBorder,
92  ctrCoord=ctrCoord,
93  vertexCoordList=vertexCoordList,
94  tractOverlap=tractOverlap,
95  wcs=wcs,
96  ))
97 
98  def __getstate__(self):
99  """Support pickle
100 
101  @return a dict containing:
102  - version: a pair of ints
103  - config: the config
104  """
105  return dict(
106  version=self._version,
107  config=self.config,
108  )
109 
110  def __setstate__(self, stateDict):
111  """Support unpickle
112 
113  @param[in] stateDict: a dict containing:
114  - version: a pair of ints
115  - config: the config
116  """
117  version = stateDict["version"]
118  if version >= (2, 0):
119  raise RuntimeError("Version = %s >= (2,0); cannot unpickle" % (version,))
120  self.__init__(stateDict["config"])
121 
122  def getVersion(self):
123  """Return version (e.g. for pickle)
124 
125  @return version as a pair of integers
126  """
127  return self._version
128 
129  def updateSha1(self, sha1):
130  """Add subclass-specific state or configuration options to the SHA1."""
131  sha1.update(struct.pack("<i2d", self.config.numTracts, *self.config.decRange))
def __init__(self, config=None)
Definition: equatSkyMap.py:57
def __setstate__(self, stateDict)
Definition: equatSkyMap.py:110
def __init__(self, config=None)
Definition: baseSkyMap.py:92