LSSTApplications  11.0-13-gbb96280,12.1+18,12.1+7,12.1-1-g14f38d3+72,12.1-1-g16c0db7+5,12.1-1-g5961e7a+84,12.1-1-ge22e12b+23,12.1-11-g06625e2+4,12.1-11-g0d7f63b+4,12.1-19-gd507bfc,12.1-2-g7dda0ab+38,12.1-2-gc0bc6ab+81,12.1-21-g6ffe579+2,12.1-21-gbdb6c2a+4,12.1-24-g941c398+5,12.1-3-g57f6835+7,12.1-3-gf0736f3,12.1-37-g3ddd237,12.1-4-gf46015e+5,12.1-5-g06c326c+20,12.1-5-g648ee80+3,12.1-5-gc2189d7+4,12.1-6-ga608fc0+1,12.1-7-g3349e2a+5,12.1-7-gfd75620+9,12.1-9-g577b946+5,12.1-9-gc4df26a+10
LSSTDataManagementBasePackage
testMapper.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 import os
24 
25 import lsst.utils
26 import lsst.afw.image.utils as afwImageUtils
27 import lsst.daf.persistence as dafPersist
28 from lsst.obs.base import CameraMapper
29 from .testCamera import TestCamera
30 from .makeTestRawVisitInfo import MakeTestRawVisitInfo
31 
32 __all__ = ["TestMapper", "MapperForTestCalexpMetadataObjects"]
33 
34 
35 class TestMapper(CameraMapper):
36  packageName = 'obs_test'
37 
38  MakeRawVisitInfoClass = MakeTestRawVisitInfo
39 
40  def __init__(self, inputPolicy=None, **kwargs):
41  policyFilePath = dafPersist.Policy.defaultPolicyFile(self.packageName, "testMapper.paf", "policy")
42  policy = dafPersist.Policy(policyFilePath)
43 
44  self.doFootprints = False
45  if inputPolicy is not None:
46  for kw in inputPolicy.paramNames(True):
47  if kw == "doFootprints":
48  self.doFootprints = True
49  else:
50  kwargs[kw] = inputPolicy.get(kw)
51 
52  CameraMapper.__init__(self, policy, policyFilePath, **kwargs)
53  self.filterIdMap = {
54  'u': 0, 'g': 1, 'r': 2, 'i': 3, 'z': 4, 'y': 5, 'i2': 5}
55 
56  # The LSST Filters from L. Jones 04/07/10
57  afwImageUtils.defineFilter('u', 364.59)
58  afwImageUtils.defineFilter('g', 476.31)
59  afwImageUtils.defineFilter('r', 619.42)
60  afwImageUtils.defineFilter('i', 752.06)
61  afwImageUtils.defineFilter('z', 866.85)
62  afwImageUtils.defineFilter('y', 971.68, alias=['y4']) # official y filter
63 
64  def _extractDetectorName(self, dataId):
65  return "0"
66 
67  def _defectLookup(self, dataId):
68  """Find the defects for a given CCD.
69  @param dataId (dict) Dataset identifier
70  @return (string) path to the defects file or None if not available
71  """
72  obsTestDir = lsst.utils.getPackageDir('obs_test')
73 
74  return os.path.join(obsTestDir, "data", "input", "defects", "defects.fits")
75 
76  def _computeCcdExposureId(self, dataId):
77  """Compute the 64-bit (long) identifier for a CCD exposure.
78 
79  @param dataId (dict) Data identifier with visit
80  """
81  visit = dataId['visit']
82  return int(visit)
83 
84  def bypass_ccdExposureId(self, datasetType, pythonType, location, dataId):
85  return self._computeCcdExposureId(dataId)
86 
87  def bypass_ccdExposureId_bits(self, datasetType, pythonType, location, dataId):
88  return 41
89 
90  def validate(self, dataId):
91  visit = dataId.get("visit")
92  if visit is not None and not isinstance(visit, int):
93  dataId["visit"] = int(visit)
94  return dataId
95 
96  def _setCcdExposureId(self, propertyList, dataId):
97  propertyList.set("Computed_ccdExposureId", self._computeCcdExposureId(dataId))
98  return propertyList
99 
100  def _makeCamera(self, policy, repositoryDir):
101  """Make a camera (instance of lsst.afw.cameraGeom.Camera) describing the camera geometry
102  """
103  return TestCamera()
104 
105 
106 class MapperForTestCalexpMetadataObjects(lsst.obs.base.CameraMapper):
107  packageName = "obs_test"
108 
109  def __init__(self, root):
110  policyFilePath = dafPersist.Policy.defaultPolicyFile(
111  self.packageName, "testCalexpMetadataObjects.yaml", "policy")
112  policy = dafPersist.Policy(policyFilePath)
113  super(MapperForTestCalexpMetadataObjects, self).__init__(
114  policy, repositoryDir=root, root=root)
115  self.filterIdMap = {
116  'u': 0, 'g': 1, 'r': 2, 'i': 3, 'z': 4, 'y': 5, 'i2': 5}
117  # The LSST Filters from L. Jones 04/07/10
118  afwImageUtils.defineFilter('u', 364.59)
119  afwImageUtils.defineFilter('g', 476.31)
120  afwImageUtils.defineFilter('r', 619.42)
121  afwImageUtils.defineFilter('i', 752.06)
122  afwImageUtils.defineFilter('z', 866.85)
123  afwImageUtils.defineFilter('y', 971.68, alias=['y4']) # official y filter
124 
125  def _makeCamera(self, policy, repositoryDir):
126  """Normally this makes a camera. For composite testing, we don't need a camera.
127  """
128  return TestCamera()
129 
130  def _extractDetectorName(self, dataId):
131  """Normally this extracts the detector (CCD) name from the dataset
132  identifier. The name in question is the detector name used by
133  lsst.afw.cameraGeom.
134 
135  We don't need anything meaninful here, so just override so as not to
136  throw (in the base class impl)
137  """
138  return "0"
139 
140 
141 
std::string getPackageDir(std::string const &packageName)
return the root directory of a setup package
Definition: Utils.cc:34