lsst.skymap  14.0-4-g3609236+6
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.coord as afwCoord
28 import lsst.afw.geom as afwGeom
29 from .baseSkyMap import BaseSkyMap
30 from .tractInfo import TractInfo
31 
32 __all__ = ['EquatSkyMapConfig', 'EquatSkyMap']
33 
34 
35 class EquatSkyMapConfig(BaseSkyMap.ConfigClass):
36  numTracts = pexConfig.Field(
37  doc="number of tracts; warning: TAN projection requires at least 3",
38  dtype=int,
39  default=4,
40  )
41  decRange = pexConfig.ListField(
42  doc="range of declination (deg)",
43  dtype=float,
44  length=2,
45  default=(-1.25, 1.25),
46  )
47 
48  def setDefaults(self):
49  self.projection = "CEA"
50 
51 
53  """Equatorial sky map pixelization, e.g. for SDSS stripe 82 image data.
54 
55  EquatSkyMap represents an equatorial band of sky divided along declination into overlapping tracts.
56  """
57  ConfigClass = EquatSkyMapConfig
58  _version = (1, 0) # for pickle
59 
60  def __init__(self, config=None):
61  """Construct a EquatSkyMap
62 
63  @param[in] config: an instance of self.ConfigClass; if None the default config is used
64  """
65  BaseSkyMap.__init__(self, config)
66 
67  decRange = tuple(afwGeom.Angle(dr, afwGeom.degrees) for dr in self.config.decRange)
68  midDec = (decRange[0] + decRange[1]) / 2.0
69  tractWidthRA = afwGeom.Angle(360.0 / self.config.numTracts, afwGeom.degrees)
70  tractOverlap = afwGeom.Angle(self.config.tractOverlap, afwGeom.degrees)
71 
72  for id in range(self.config.numTracts):
73  begRA = tractWidthRA * id
74  endRA = begRA + tractWidthRA
75  vertexCoordList = (
76  afwCoord.IcrsCoord(begRA, decRange[0]),
77  afwCoord.IcrsCoord(endRA, decRange[0]),
78  afwCoord.IcrsCoord(endRA, decRange[1]),
79  afwCoord.IcrsCoord(begRA, decRange[1]),
80  )
81 
82  midRA = begRA + tractWidthRA / 2.0
83  ctrCoord = afwCoord.IcrsCoord(midRA, midDec)
84 
85  # CRVal must have Dec=0 for symmetry about the equator
86  crValCoord = afwCoord.IcrsCoord(midRA, afwGeom.Angle(0.0))
87 
88  # make initial WCS; don't worry about crPixPos because TractInfo will shift it as required
89  wcs = self._wcsFactory.makeWcs(crPixPos=afwGeom.Point2D(0, 0), crValCoord=crValCoord)
90 
91  self._tractInfoList.append(TractInfo(
92  id=id,
93  patchInnerDimensions=self.config.patchInnerDimensions,
94  patchBorder=self.config.patchBorder,
95  ctrCoord=ctrCoord,
96  vertexCoordList=vertexCoordList,
97  tractOverlap=tractOverlap,
98  wcs=wcs,
99  ))
100 
101  def __getstate__(self):
102  """Support pickle
103 
104  @return a dict containing:
105  - version: a pair of ints
106  - config: the config
107  """
108  return dict(
109  version=self._version,
110  config=self.config,
111  )
112 
113  def __setstate__(self, stateDict):
114  """Support unpickle
115 
116  @param[in] stateDict: a dict containing:
117  - version: a pair of ints
118  - config: the config
119  """
120  version = stateDict["version"]
121  if version >= (2, 0):
122  raise RuntimeError("Version = %s >= (2,0); cannot unpickle" % (version,))
123  self.__init__(stateDict["config"])
124 
125  def getVersion(self):
126  """Return version (e.g. for pickle)
127 
128  @return version as a pair of integers
129  """
130  return self._version
131 
132  def updateSha1(self, sha1):
133  """Add subclass-specific state or configuration options to the SHA1."""
134  sha1.update(struct.pack("<i2d", self.config.numTracts, *self.config.decRange))
def __init__(self, config=None)
Definition: equatSkyMap.py:60
def __setstate__(self, stateDict)
Definition: equatSkyMap.py:113
def __init__(self, config=None)
Definition: baseSkyMap.py:93