LSSTApplications  11.0-13-gbb96280,12.1+18,12.1+7,12.1-1-g14f38d3+72,12.1-1-g16c0db7+5,12.1-1-g5961e7a+84,12.1-1-ge22e12b+23,12.1-11-g06625e2+4,12.1-11-g0d7f63b+4,12.1-19-gd507bfc,12.1-2-g7dda0ab+38,12.1-2-gc0bc6ab+81,12.1-21-g6ffe579+2,12.1-21-gbdb6c2a+4,12.1-24-g941c398+5,12.1-3-g57f6835+7,12.1-3-gf0736f3,12.1-37-g3ddd237,12.1-4-gf46015e+5,12.1-5-g06c326c+20,12.1-5-g648ee80+3,12.1-5-gc2189d7+4,12.1-6-ga608fc0+1,12.1-7-g3349e2a+5,12.1-7-gfd75620+9,12.1-9-g577b946+5,12.1-9-gc4df26a+10
LSSTDataManagementBasePackage
equatSkyMap.py
Go to the documentation of this file.
1 from builtins import range
2 #
3 # LSST Data Management System
4 # Copyright 2008, 2009, 2010 LSST Corporation.
5 #
6 # This product includes software developed by the
7 # LSST Project (http://www.lsst.org/).
8 #
9 # This program is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation, either version 3 of the License, or
12 # (at your option) any later version.
13 #
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the LSST License Statement and
20 # the GNU General Public License along with this program. If not,
21 # see <http://www.lsstcorp.org/LegalNotices/>.
22 #
23 import lsst.pex.config as pexConfig
24 import lsst.afw.coord as afwCoord
25 import lsst.afw.geom as afwGeom
26 from .baseSkyMap import BaseSkyMap
27 from .tractInfo import TractInfo
28 
29 
30 class EquatSkyMapConfig(BaseSkyMap.ConfigClass):
31  numTracts = pexConfig.Field(
32  doc="number of tracts; warning: TAN projection requires at least 3",
33  dtype=int,
34  default=4,
35  )
36  decRange = pexConfig.ListField(
37  doc="range of declination (deg)",
38  dtype=float,
39  length=2,
40  default=(-1.25, 1.25),
41  )
42 
43  def setDefaults(self):
44  self.projection = "CEA"
45 
46 
47 class EquatSkyMap(BaseSkyMap):
48  """Equatorial sky map pixelization, e.g. for SDSS stripe 82 image data.
49 
50  EquatSkyMap represents an equatorial band of sky divided along declination into overlapping tracts.
51  """
52  ConfigClass = EquatSkyMapConfig
53  _version = (1, 0) # for pickle
54 
55  def __init__(self, config=None):
56  """Construct a EquatSkyMap
57 
58  @param[in] config: an instance of self.ConfigClass; if None the default config is used
59  """
60  BaseSkyMap.__init__(self, config)
61 
62  decRange = tuple(afwGeom.Angle(dr, afwGeom.degrees) for dr in self.config.decRange)
63  midDec = (decRange[0] + decRange[1]) / 2.0
64  tractWidthRA = afwGeom.Angle(360.0 / self.config.numTracts, afwGeom.degrees)
65  tractOverlap = afwGeom.Angle(self.config.tractOverlap, afwGeom.degrees)
66 
67  for id in range(self.config.numTracts):
68  begRA = tractWidthRA * id
69  endRA = begRA + tractWidthRA
70  vertexCoordList = (
71  afwCoord.IcrsCoord(begRA, decRange[0]),
72  afwCoord.IcrsCoord(endRA, decRange[0]),
73  afwCoord.IcrsCoord(endRA, decRange[1]),
74  afwCoord.IcrsCoord(begRA, decRange[1]),
75  )
76 
77  midRA = begRA + tractWidthRA / 2.0
78  ctrCoord = afwCoord.IcrsCoord(midRA, midDec)
79 
80  # CRVal must have Dec=0 for symmetry about the equator
81  crValCoord = afwCoord.IcrsCoord(midRA, afwGeom.Angle(0.0))
82 
83  # make initial WCS; don't worry about crPixPos because TractInfo will shift it as required
84  wcs = self._wcsFactory.makeWcs(crPixPos=afwGeom.Point2D(0, 0), crValCoord=crValCoord)
85 
86  self._tractInfoList.append(TractInfo(
87  id=id,
88  patchInnerDimensions=self.config.patchInnerDimensions,
89  patchBorder=self.config.patchBorder,
90  ctrCoord=ctrCoord,
91  vertexCoordList=vertexCoordList,
92  tractOverlap=tractOverlap,
93  wcs=wcs,
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 representing an Angle.
Definition: Angle.h:103
A class to handle Icrs coordinates (inherits from Coord)
Definition: Coord.h:156