Coverage for python/lsst/obs/test/testMapper.py: 32%
Shortcuts on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
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"]
24import os
25import warnings
27import lsst.utils
28import lsst.afw.image.utils as afwImageUtils
29import lsst.daf.persistence as dafPersist
30from lsst.obs.base import CameraMapper
31from .testCamera import TestCamera
32from .makeTestRawVisitInfo import MakeTestRawVisitInfo
35class TestMapper(CameraMapper):
36 """Camera mapper for the Test camera.
37 """
38 packageName = 'obs_test'
40 MakeRawVisitInfoClass = MakeTestRawVisitInfo
42 def __init__(self, inputPolicy=None, **kwargs):
43 policyFilePath = dafPersist.Policy.defaultPolicyFile(self.packageName, "testMapper.yaml", "policy")
44 policy = dafPersist.Policy(policyFilePath)
46 self.doFootprints = False
47 if inputPolicy is not None:
48 for kw in inputPolicy.paramNames(True):
49 if kw == "doFootprints":
50 self.doFootprints = True
51 else:
52 kwargs[kw] = inputPolicy.get(kw)
54 CameraMapper.__init__(self, policy, policyFilePath, **kwargs)
55 self.filterIdMap = {
56 'u': 0, 'g': 1, 'r': 2, 'i': 3, 'z': 4, 'y': 5, 'i2': 5}
58 with warnings.catch_warnings():
59 # surpress Filter warnings; we already know this is deprecated
60 warnings.simplefilter('ignore', category=FutureWarning)
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
70 def _extractDetectorName(self, dataId):
71 return "0"
73 def _defectLookup(self, dataId):
74 """Find the defects for a given CCD.
76 Parameters
77 ----------
78 dataId : `dict`
79 Dataset identifier
81 Returns
82 -------
83 result : `str`
84 Path to the defects file.
86 Raises
87 ------
88 RuntimeError
89 If ``obs_test`` is not setup.
90 """
91 obsTestDir = lsst.utils.getPackageDir('obs_test')
93 return os.path.join(obsTestDir, "data", "input", "defects", "defects.fits")
95 def _computeCcdExposureId(self, dataId):
96 """Compute the 64-bit (long) identifier for a CCD exposure.
98 Parameters
99 ----------
100 dataId : `dict`
101 Data identifier with visit
102 """
103 visit = dataId['visit']
104 return int(visit)
106 def bypass_ccdExposureId(self, datasetType, pythonType, location, dataId):
107 return self._computeCcdExposureId(dataId)
109 def bypass_ccdExposureId_bits(self, datasetType, pythonType, location, dataId):
110 return 41
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
118 def _setCcdExposureId(self, propertyList, dataId):
119 propertyList.set("Computed_ccdExposureId", self._computeCcdExposureId(dataId))
120 return propertyList
122 def _makeCamera(self, policy, repositoryDir):
123 """Make a camera describing the camera geometry.
125 Returns
126 -------
127 testCamera : `TestCamera`
128 Test camera.
129 """
130 return TestCamera()
133class MapperForTestCalexpMetadataObjects(lsst.obs.base.CameraMapper):
134 """Minimal mapper for testing calexp composite access, e.g. calexp_wcs.
136 Used by test_metadataObjectAccess.py.
137 """
138 packageName = "obs_test"
140 def __init__(self, root, parentRegistry=None, repositoryCfg=None):
141 policyFilePath = dafPersist.Policy.defaultPolicyFile(
142 self.packageName, "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.filterIdMap = {
147 'u': 0, 'g': 1, 'r': 2, 'i': 3, 'z': 4, 'y': 5, 'i2': 5}
149 with warnings.catch_warnings():
150 # surpress Filter warnings; we already know this is deprecated
151 warnings.simplefilter('ignore', category=FutureWarning)
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
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()
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.
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"