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