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