LSSTApplications  11.0-13-gbb96280,12.1.rc1,12.1.rc1+1,12.1.rc1+2,12.1.rc1+5,12.1.rc1+8,12.1.rc1-1-g06d7636+1,12.1.rc1-1-g253890b+5,12.1.rc1-1-g3d31b68+7,12.1.rc1-1-g3db6b75+1,12.1.rc1-1-g5c1385a+3,12.1.rc1-1-g83b2247,12.1.rc1-1-g90cb4cf+6,12.1.rc1-1-g91da24b+3,12.1.rc1-2-g3521f8a,12.1.rc1-2-g39433dd+4,12.1.rc1-2-g486411b+2,12.1.rc1-2-g4c2be76,12.1.rc1-2-gc9c0491,12.1.rc1-2-gda2cd4f+6,12.1.rc1-3-g3391c73+2,12.1.rc1-3-g8c1bd6c+1,12.1.rc1-3-gcf4b6cb+2,12.1.rc1-4-g057223e+1,12.1.rc1-4-g19ed13b+2,12.1.rc1-4-g30492a7
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 to handle Icrs coordinates (inherits from Coord)
Definition: Coord.h:156