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