lsst.skymap  14.0-2-g8373656+19
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 lsst.pex.config as pexConfig
25 import lsst.afw.coord as afwCoord
26 import lsst.afw.geom as afwGeom
27 from .baseSkyMap import BaseSkyMap
28 from .tractInfo import TractInfo
29 
30 __all__ = ['EquatSkyMapConfig', 'EquatSkyMap']
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  afwCoord.IcrsCoord(begRA, decRange[0]),
74  afwCoord.IcrsCoord(endRA, decRange[0]),
75  afwCoord.IcrsCoord(endRA, decRange[1]),
76  afwCoord.IcrsCoord(begRA, decRange[1]),
77  )
78 
79  midRA = begRA + tractWidthRA / 2.0
80  ctrCoord = afwCoord.IcrsCoord(midRA, midDec)
81 
82  # CRVal must have Dec=0 for symmetry about the equator
83  crValCoord = afwCoord.IcrsCoord(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
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:85