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