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