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