lsst.skymap  16.0-5-gef99c9f+12
dodecaSkyMap.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 """
23 @todo
24 - Consider tweaking pixel scale so the average scale is as specified, rather than the scale at the center
25 """
26 import struct
27 
28 import lsst.pex.config as pexConfig
29 import lsst.afw.geom as afwGeom
30 from . import detail
31 from .baseSkyMap import BaseSkyMap
32 from .tractInfo import TractInfo
33 
34 __all__ = ['DodecaSkyMapConfig', 'DodecaSkyMap']
35 
36 
37 class DodecaSkyMapConfig(BaseSkyMap.ConfigClass):
38  withTractsOnPoles = pexConfig.Field(
39  doc="if True center a tract on each pole, else put a vertex on each pole",
40  dtype=bool,
41  default=False,
42  )
43 
44  def setDefaults(self):
45  self.tractOverlap = 3.5
46  self.patchBorder = 250
47  self.pixelScale = 10.0 / 50.0 # LSST plate scale is 50 um/arcsec and pixel size is 10 um
48  self.patchInnerDimensions = (4000, 4000)
49  self.projection = "STG"
50 
51 
53  """Dodecahedron-based sky map pixelization.
54 
55  DodecaSkyMap divides the sky into 12 overlapping Tracts arranged as the faces of a dodecahedron.
56  """
57  ConfigClass = DodecaSkyMapConfig
58  _version = (1, 0) # for pickle
59 
60  def __init__(self, config=None):
61  """Construct a DodecaSkyMap
62 
63  @param[in] config: an instance of self.ConfigClass; if None the default config is used
64  """
65  BaseSkyMap.__init__(self, config)
66  self._dodecahedron = detail.Dodecahedron(withFacesOnPoles=self.config.withTractsOnPoles)
67 
68  tractOverlap = afwGeom.Angle(self.config.tractOverlap, afwGeom.degrees)
69 
70  for id in range(12):
71  tractVec = self._dodecahedron.getFaceCtr(id)
72  tractCoord = detail.coordFromVec(tractVec, defRA=afwGeom.Angle(0))
73  tractRA = tractCoord.getLongitude()
74  vertexVecList = self._dodecahedron.getVertices(id)
75 
76  # make initial WCS; don't worry about crPixPos because TractInfo will shift it as required
77  wcs = self._wcsFactory.makeWcs(crPixPos=afwGeom.Point2D(0, 0), crValCoord=tractCoord)
78 
79  self._tractInfoList.append(
80  TractInfo(
81  id=id,
82  patchInnerDimensions=self.config.patchInnerDimensions,
83  patchBorder=self.config.patchBorder,
84  ctrCoord=tractCoord,
85  vertexCoordList=[detail.coordFromVec(vec, defRA=tractRA) for vec in vertexVecList],
86  tractOverlap=tractOverlap,
87  wcs=wcs,
88  )
89  )
90 
91  def __getstate__(self):
92  """Support pickle
93 
94  @return a dict containing:
95  - version: a pair of ints
96  - config: the config
97  """
98  return dict(
99  version=self._version,
100  config=self.config,
101  )
102 
103  def __setstate__(self, stateDict):
104  """Support unpickle
105 
106  @param[in] stateDict: a dict containing:
107  - version: a pair of ints
108  - config: the config
109  """
110  version = stateDict["version"]
111  if version >= (2, 0):
112  raise RuntimeError("Version = %s >= (2,0); cannot unpickle" % (version,))
113  self.__init__(stateDict["config"])
114 
115  def findTract(self, coord):
116  """Find the tract whose inner region includes the coord.
117 
118  @param[in] coord: ICRS sky coordinate (lsst.afw.geom.SpherePoint)
119  @return TractInfo for tract whose inner region includes the coord.
120 
121  @note This routine will be more efficient if coord is ICRS.
122  """
123  return self[self._dodecahedron.getFaceInd(coord.getVector())]
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 
133  """Return withTractsOnPoles parameter
134 
135  @return withTractsOnPoles as a bool
136  """
137  return self._dodecahedron.getWithFacesOnPoles()
138 
139  def updateSha1(self, sha1):
140  """Add subclass-specific state or configuration options to the SHA1."""
141  sha1.update(struct.pack("<?", self.config.withTractsOnPoles))
def __init__(self, config=None)
Definition: baseSkyMap.py:92
def __init__(self, config=None)
Definition: dodecaSkyMap.py:60