LSST Applications  21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
testMapper.py
Go to the documentation of this file.
1 # This file is part of obs_test.
2 #
3 # Developed for the LSST Data Management System.
4 # This product includes software developed by the LSST Project
5 # (http://www.lsst.org).
6 # See the COPYRIGHT file at the top-level directory of this distribution
7 # for details of code ownership.
8 #
9 # This program is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation, either version 3 of the License, or
12 # (at your option) any later version.
13 #
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #
22 __all__ = ["TestMapper", "MapperForTestCalexpMetadataObjects"]
23 
24 import os
25 import warnings
26 
27 import lsst.utils
28 import lsst.afw.image.utils as afwImageUtils
29 import lsst.daf.persistence as dafPersist
30 from lsst.obs.base import CameraMapper
31 from .testCamera import TestCamera
32 from .makeTestRawVisitInfo import MakeTestRawVisitInfo
33 
34 
35 class TestMapper(CameraMapper):
36  """Camera mapper for the Test camera.
37  """
38  packageName = 'obs_test'
39 
40  MakeRawVisitInfoClass = MakeTestRawVisitInfo
41 
42  def __init__(self, inputPolicy=None, **kwargs):
43  policyFilePath = dafPersist.Policy.defaultPolicyFile(self.packageNamepackageName, "testMapper.yaml", "policy")
44  policy = dafPersist.Policy(policyFilePath)
45 
46  self.doFootprintsdoFootprints = False
47  if inputPolicy is not None:
48  for kw in inputPolicy.paramNames(True):
49  if kw == "doFootprints":
50  self.doFootprintsdoFootprints = True
51  else:
52  kwargs[kw] = inputPolicy.get(kw)
53 
54  CameraMapper.__init__(self, policy, policyFilePath, **kwargs)
55  self.filterIdMapfilterIdMap = {
56  'u': 0, 'g': 1, 'r': 2, 'i': 3, 'z': 4, 'y': 5, 'i2': 5}
57 
58  with warnings.catch_warnings():
59  # surpress Filter warnings; we already know this is deprecated
60  warnings.simplefilter('ignore', category=FutureWarning)
61 
62  # The LSST Filters from L. Jones 04/07/10
63  afwImageUtils.defineFilter('u', 364.59)
64  afwImageUtils.defineFilter('g', 476.31)
65  afwImageUtils.defineFilter('r', 619.42)
66  afwImageUtils.defineFilter('i', 752.06)
67  afwImageUtils.defineFilter('z', 866.85)
68  afwImageUtils.defineFilter('y', 971.68, alias=['y4']) # official y filter
69 
70  def _extractDetectorName(self, dataId):
71  return "0"
72 
73  def _defectLookup(self, dataId):
74  """Find the defects for a given CCD.
75 
76  Parameters
77  ----------
78  dataId : `dict`
79  Dataset identifier
80 
81  Returns
82  -------
83  result : `str`
84  Path to the defects file.
85 
86  Raises
87  ------
88  RuntimeError
89  If ``obs_test`` is not setup.
90  """
91  obsTestDir = lsst.utils.getPackageDir('obs_test')
92 
93  return os.path.join(obsTestDir, "data", "input", "defects", "defects.fits")
94 
95  def _computeCcdExposureId(self, dataId):
96  """Compute the 64-bit (long) identifier for a CCD exposure.
97 
98  Parameters
99  ----------
100  dataId : `dict`
101  Data identifier with visit
102  """
103  visit = dataId['visit']
104  return int(visit)
105 
106  def bypass_ccdExposureId(self, datasetType, pythonType, location, dataId):
107  return self._computeCcdExposureId_computeCcdExposureId(dataId)
108 
109  def bypass_ccdExposureId_bits(self, datasetType, pythonType, location, dataId):
110  return 41
111 
112  def validate(self, dataId):
113  visit = dataId.get("visit")
114  if visit is not None and not isinstance(visit, int):
115  dataId["visit"] = int(visit)
116  return dataId
117 
118  def _setCcdExposureId(self, propertyList, dataId):
119  propertyList.set("Computed_ccdExposureId", self._computeCcdExposureId_computeCcdExposureId(dataId))
120  return propertyList
121 
122  def _makeCamera(self, policy, repositoryDir):
123  """Make a camera describing the camera geometry.
124 
125  Returns
126  -------
127  testCamera : `TestCamera`
128  Test camera.
129  """
130  return TestCamera()
131 
132 
133 class MapperForTestCalexpMetadataObjects(lsst.obs.base.CameraMapper):
134  """Minimal mapper for testing calexp composite access, e.g. calexp_wcs.
135 
136  Used by test_metadataObjectAccess.py.
137  """
138  packageName = "obs_test"
139 
140  def __init__(self, root, parentRegistry=None, repositoryCfg=None):
141  policyFilePath = dafPersist.Policy.defaultPolicyFile(
142  self.packageNamepackageName, "testCalexpMetadataObjects.yaml", "policy")
143  policy = dafPersist.Policy(policyFilePath)
144  super(MapperForTestCalexpMetadataObjects, self).__init__(
145  policy, repositoryDir=root, root=root, parentRegistry=None, repositoryCfg=None)
146  self.filterIdMapfilterIdMap = {
147  'u': 0, 'g': 1, 'r': 2, 'i': 3, 'z': 4, 'y': 5, 'i2': 5}
148 
149  with warnings.catch_warnings():
150  # surpress Filter warnings; we already know this is deprecated
151  warnings.simplefilter('ignore', category=FutureWarning)
152 
153  # The LSST Filters from L. Jones 04/07/10
154  afwImageUtils.defineFilter('u', 364.59)
155  afwImageUtils.defineFilter('g', 476.31)
156  afwImageUtils.defineFilter('r', 619.42)
157  afwImageUtils.defineFilter('i', 752.06)
158  afwImageUtils.defineFilter('z', 866.85)
159  afwImageUtils.defineFilter('y', 971.68, alias=['y4']) # official y filter
160 
161  def _makeCamera(self, policy, repositoryDir):
162  """Normally this makes a camera. For composite testing, we don't need a camera.
163  """
164  return TestCamera()
165 
166  def _extractDetectorName(self, dataId):
167  """Normally this extracts the detector (CCD) name from the dataset
168  identifier. The name in question is the detector name used by
169  lsst.afw.cameraGeom.
170 
171  We don't need anything meaninful here, so just override so as not to
172  throw (in the base class impl)
173  """
174  return "0"
def __init__(self, root, parentRegistry=None, repositoryCfg=None)
Definition: testMapper.py:140
def _computeCcdExposureId(self, dataId)
Definition: testMapper.py:95
def bypass_ccdExposureId(self, datasetType, pythonType, location, dataId)
Definition: testMapper.py:106
def bypass_ccdExposureId_bits(self, datasetType, pythonType, location, dataId)
Definition: testMapper.py:109
def __init__(self, inputPolicy=None, **kwargs)
Definition: testMapper.py:42