Coverage for python/lsst/obs/test/testMapper.py : 33%

Hot-keys 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
26import lsst.utils
27import lsst.afw.image.utils as afwImageUtils
28import lsst.daf.persistence as dafPersist
29from lsst.obs.base import CameraMapper
30from .testCamera import TestCamera
31from .makeTestRawVisitInfo import MakeTestRawVisitInfo
34class TestMapper(CameraMapper):
35 """Camera mapper for the Test camera.
36 """
37 packageName = 'obs_test'
39 MakeRawVisitInfoClass = MakeTestRawVisitInfo
41 def __init__(self, inputPolicy=None, **kwargs):
42 policyFilePath = dafPersist.Policy.defaultPolicyFile(self.packageName, "testMapper.yaml", "policy")
43 policy = dafPersist.Policy(policyFilePath)
45 self.doFootprints = False
46 if inputPolicy is not None:
47 for kw in inputPolicy.paramNames(True):
48 if kw == "doFootprints":
49 self.doFootprints = True
50 else:
51 kwargs[kw] = inputPolicy.get(kw)
53 CameraMapper.__init__(self, policy, policyFilePath, **kwargs)
54 self.filterIdMap = {
55 'u': 0, 'g': 1, 'r': 2, 'i': 3, 'z': 4, 'y': 5, 'i2': 5}
57 # The LSST Filters from L. Jones 04/07/10
58 afwImageUtils.defineFilter('u', 364.59)
59 afwImageUtils.defineFilter('g', 476.31)
60 afwImageUtils.defineFilter('r', 619.42)
61 afwImageUtils.defineFilter('i', 752.06)
62 afwImageUtils.defineFilter('z', 866.85)
63 afwImageUtils.defineFilter('y', 971.68, alias=['y4']) # official y filter
65 def _extractDetectorName(self, dataId):
66 return "0"
68 def _defectLookup(self, dataId):
69 """Find the defects for a given CCD.
71 Parameters
72 ----------
73 dataId : `dict`
74 Dataset identifier
76 Returns
77 -------
78 result : `str`
79 Path to the defects file.
81 Raises
82 ------
83 RuntimeError
84 If ``obs_test`` is not setup.
85 """
86 obsTestDir = lsst.utils.getPackageDir('obs_test')
88 return os.path.join(obsTestDir, "data", "input", "defects", "defects.fits")
90 def _computeCcdExposureId(self, dataId):
91 """Compute the 64-bit (long) identifier for a CCD exposure.
93 Parameters
94 ----------
95 dataId : `dict`
96 Data identifier with visit
97 """
98 visit = dataId['visit']
99 return int(visit)
101 def bypass_ccdExposureId(self, datasetType, pythonType, location, dataId):
102 return self._computeCcdExposureId(dataId)
104 def bypass_ccdExposureId_bits(self, datasetType, pythonType, location, dataId):
105 return 41
107 def validate(self, dataId):
108 visit = dataId.get("visit")
109 if visit is not None and not isinstance(visit, int):
110 dataId["visit"] = int(visit)
111 return dataId
113 def _setCcdExposureId(self, propertyList, dataId):
114 propertyList.set("Computed_ccdExposureId", self._computeCcdExposureId(dataId))
115 return propertyList
117 def _makeCamera(self, policy, repositoryDir):
118 """Make a camera describing the camera geometry.
120 Returns
121 -------
122 testCamera : `TestCamera`
123 Test camera.
124 """
125 return TestCamera()
128class MapperForTestCalexpMetadataObjects(lsst.obs.base.CameraMapper):
129 """Minimal mapper for testing calexp composite access, e.g. calexp_wcs.
131 Used by test_metadataObjectAccess.py.
132 """
133 packageName = "obs_test"
135 def __init__(self, root, parentRegistry=None, repositoryCfg=None):
136 policyFilePath = dafPersist.Policy.defaultPolicyFile(
137 self.packageName, "testCalexpMetadataObjects.yaml", "policy")
138 policy = dafPersist.Policy(policyFilePath)
139 super(MapperForTestCalexpMetadataObjects, self).__init__(
140 policy, repositoryDir=root, root=root, parentRegistry=None, repositoryCfg=None)
141 self.filterIdMap = {
142 'u': 0, 'g': 1, 'r': 2, 'i': 3, 'z': 4, 'y': 5, 'i2': 5}
143 # The LSST Filters from L. Jones 04/07/10
144 afwImageUtils.defineFilter('u', 364.59)
145 afwImageUtils.defineFilter('g', 476.31)
146 afwImageUtils.defineFilter('r', 619.42)
147 afwImageUtils.defineFilter('i', 752.06)
148 afwImageUtils.defineFilter('z', 866.85)
149 afwImageUtils.defineFilter('y', 971.68, alias=['y4']) # official y filter
151 def _makeCamera(self, policy, repositoryDir):
152 """Normally this makes a camera. For composite testing, we don't need a camera.
153 """
154 return TestCamera()
156 def _extractDetectorName(self, dataId):
157 """Normally this extracts the detector (CCD) name from the dataset
158 identifier. The name in question is the detector name used by
159 lsst.afw.cameraGeom.
161 We don't need anything meaninful here, so just override so as not to
162 throw (in the base class impl)
163 """
164 return "0"