LSSTApplications  19.0.0-10-g920eed2,19.0.0-11-g48a0200+2,19.0.0-18-gfc4e62b+13,19.0.0-2-g3b2f90d+2,19.0.0-2-gd671419+5,19.0.0-20-g5a5a17ab+11,19.0.0-21-g2644856+13,19.0.0-23-g84eeccb+1,19.0.0-24-g878c510+1,19.0.0-25-g6c8df7140,19.0.0-25-gb330496+1,19.0.0-3-g2b32d65+5,19.0.0-3-g8227491+12,19.0.0-3-g9c54d0d+12,19.0.0-3-gca68e65+8,19.0.0-3-gcfc5f51+5,19.0.0-3-ge110943+11,19.0.0-3-ge74d124,19.0.0-3-gfe04aa6+13,19.0.0-30-g9c3fd16+1,19.0.0-4-g06f5963+5,19.0.0-4-g3d16501+13,19.0.0-4-g4a9c019+5,19.0.0-4-g5a8b323,19.0.0-4-g66397f0+1,19.0.0-4-g8278b9b+1,19.0.0-4-g8557e14,19.0.0-4-g8964aba+13,19.0.0-4-ge404a01+12,19.0.0-5-g40f3a5a,19.0.0-5-g4db63b3,19.0.0-5-gfb03ce7+13,19.0.0-6-gbaebbfb+12,19.0.0-61-gec4c6e08+1,19.0.0-7-g039c0b5+11,19.0.0-7-gbea9075+4,19.0.0-7-gc567de5+13,19.0.0-71-g41c0270,19.0.0-9-g2f02add+1,19.0.0-9-g463f923+12,w.2020.22
LSSTDataManagementBasePackage
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 
26 import lsst.utils
27 import lsst.afw.image.utils as afwImageUtils
28 import lsst.daf.persistence as dafPersist
29 from lsst.obs.base import CameraMapper
30 from .testCamera import TestCamera
31 from .makeTestRawVisitInfo import MakeTestRawVisitInfo
32 
33 
35  """Camera mapper for the Test camera.
36  """
37  packageName = 'obs_test'
38 
39  MakeRawVisitInfoClass = MakeTestRawVisitInfo
40 
41  def __init__(self, inputPolicy=None, **kwargs):
42  policyFilePath = dafPersist.Policy.defaultPolicyFile(self.packageName, "testMapper.yaml", "policy")
43  policy = dafPersist.Policy(policyFilePath)
44 
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)
52 
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}
56 
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
64 
65  def _extractDetectorName(self, dataId):
66  return "0"
67 
68  def _defectLookup(self, dataId):
69  """Find the defects for a given CCD.
70 
71  Parameters
72  ----------
73  dataId : `dict`
74  Dataset identifier
75 
76  Returns
77  -------
78  result : `str`
79  Path to the defects file.
80 
81  Raises
82  ------
83  RuntimeError
84  If ``obs_test`` is not setup.
85  """
86  obsTestDir = lsst.utils.getPackageDir('obs_test')
87 
88  return os.path.join(obsTestDir, "data", "input", "defects", "defects.fits")
89 
90  def _computeCcdExposureId(self, dataId):
91  """Compute the 64-bit (long) identifier for a CCD exposure.
92 
93  Parameters
94  ----------
95  dataId : `dict`
96  Data identifier with visit
97  """
98  visit = dataId['visit']
99  return int(visit)
100 
101  def bypass_ccdExposureId(self, datasetType, pythonType, location, dataId):
102  return self._computeCcdExposureId(dataId)
103 
104  def bypass_ccdExposureId_bits(self, datasetType, pythonType, location, dataId):
105  return 41
106 
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
112 
113  def _setCcdExposureId(self, propertyList, dataId):
114  propertyList.set("Computed_ccdExposureId", self._computeCcdExposureId(dataId))
115  return propertyList
116 
117  def _makeCamera(self, policy, repositoryDir):
118  """Make a camera describing the camera geometry.
119 
120  Returns
121  -------
122  testCamera : `TestCamera`
123  Test camera.
124  """
125  return TestCamera()
126 
127 
129  """Minimal mapper for testing calexp composite access, e.g. calexp_wcs.
130 
131  Used by test_metadataObjectAccess.py.
132  """
133  packageName = "obs_test"
134 
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
150 
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()
155 
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.
160 
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"
lsst.obs.test.testMapper.TestMapper.bypass_ccdExposureId
def bypass_ccdExposureId(self, datasetType, pythonType, location, dataId)
Definition: testMapper.py:101
lsst.obs.test.testMapper.TestMapper.doFootprints
doFootprints
Definition: testMapper.py:45
lsst.obs.test.testMapper.TestMapper
Definition: testMapper.py:34
lsst.obs.test.testMapper.TestMapper.validate
def validate(self, dataId)
Definition: testMapper.py:107
lsst::utils::getPackageDir
std::string getPackageDir(std::string const &packageName)
return the root directory of a setup package
Definition: packaging.cc:33
lsst.obs.base.cameraMapper.CameraMapper.packageName
packageName
Definition: cameraMapper.py:173
lsst.obs.test.testMapper.TestMapper.__init__
def __init__(self, inputPolicy=None, **kwargs)
Definition: testMapper.py:41
lsst.obs.test.testMapper.TestMapper.bypass_ccdExposureId_bits
def bypass_ccdExposureId_bits(self, datasetType, pythonType, location, dataId)
Definition: testMapper.py:104
lsst.obs.test.testMapper.TestMapper.filterIdMap
filterIdMap
Definition: testMapper.py:54
lsst.obs.test.testCamera.TestCamera
Definition: testCamera.py:31
lsst::utils
Definition: Backtrace.h:29
lsst.obs.test.testMapper.MapperForTestCalexpMetadataObjects.__init__
def __init__(self, root, parentRegistry=None, repositoryCfg=None)
Definition: testMapper.py:135
lsst::daf::persistence.policy.Policy
Definition: policy.py:49
lsst::daf::persistence
Definition: Utils.h:50
lsst.obs.test.testMapper.MapperForTestCalexpMetadataObjects
Definition: testMapper.py:128
lsst.obs.base.cameraMapper.CameraMapper._computeCcdExposureId
def _computeCcdExposureId(self, dataId)
Definition: cameraMapper.py:542
lsst.obs.base.cameraMapper.CameraMapper
Definition: cameraMapper.py:47
lsst.obs.test.testMapper.MapperForTestCalexpMetadataObjects.filterIdMap
filterIdMap
Definition: testMapper.py:141
lsst::afw::image.utils
Definition: utils.py:1
lsst.obs.base
Definition: __init__.py:1