LSSTApplications  11.0-13-gbb96280,12.1.rc1,12.1.rc1+1,12.1.rc1+2,12.1.rc1+5,12.1.rc1+8,12.1.rc1-1-g06d7636+1,12.1.rc1-1-g253890b+5,12.1.rc1-1-g3d31b68+7,12.1.rc1-1-g3db6b75+1,12.1.rc1-1-g5c1385a+3,12.1.rc1-1-g83b2247,12.1.rc1-1-g90cb4cf+6,12.1.rc1-1-g91da24b+3,12.1.rc1-2-g3521f8a,12.1.rc1-2-g39433dd+4,12.1.rc1-2-g486411b+2,12.1.rc1-2-g4c2be76,12.1.rc1-2-gc9c0491,12.1.rc1-2-gda2cd4f+6,12.1.rc1-3-g3391c73+2,12.1.rc1-3-g8c1bd6c+1,12.1.rc1-3-gcf4b6cb+2,12.1.rc1-4-g057223e+1,12.1.rc1-4-g19ed13b+2,12.1.rc1-4-g30492a7
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.daf.butlerUtils import CameraMapper
29 from .testCamera import TestCamera
30 
31 __all__ = ["TestMapper"]
32 
33 
34 class TestMapper(CameraMapper):
35  packageName = 'obs_test'
36 
37  def __init__(self, inputPolicy=None, **kwargs):
38  policyFilePath = dafPersist.Policy.defaultPolicyFile(self.packageName, "testMapper.paf", "policy")
39  policy = dafPersist.Policy(policyFilePath)
40 
41  self.doFootprints = False
42  if inputPolicy is not None:
43  for kw in inputPolicy.paramNames(True):
44  if kw == "doFootprints":
45  self.doFootprints = True
46  else:
47  kwargs[kw] = inputPolicy.get(kw)
48 
49  CameraMapper.__init__(self, policy, policyFilePath, **kwargs)
50  self.filterIdMap = {
51  'u': 0, 'g': 1, 'r': 2, 'i': 3, 'z': 4, 'y': 5, 'i2': 5}
52 
53  # The LSST Filters from L. Jones 04/07/10
54  afwImageUtils.defineFilter('u', 364.59)
55  afwImageUtils.defineFilter('g', 476.31)
56  afwImageUtils.defineFilter('r', 619.42)
57  afwImageUtils.defineFilter('i', 752.06)
58  afwImageUtils.defineFilter('z', 866.85)
59  afwImageUtils.defineFilter('y', 971.68, alias=['y4']) # official y filter
60 
61  def _extractDetectorName(self, dataId):
62  return "0"
63 
64  def _defectLookup(self, dataId):
65  """Find the defects for a given CCD.
66  @param dataId (dict) Dataset identifier
67  @return (string) path to the defects file or None if not available
68  """
69  obsTestDir = lsst.utils.getPackageDir('obs_test')
70 
71  return os.path.join(obsTestDir, "data", "input", "defects", "defects.fits")
72 
73  def _computeCcdExposureId(self, dataId):
74  """Compute the 64-bit (long) identifier for a CCD exposure.
75 
76  @param dataId (dict) Data identifier with visit
77  """
78  visit = dataId['visit']
79  return int(visit)
80 
81  def bypass_ccdExposureId(self, datasetType, pythonType, location, dataId):
82  return self._computeCcdExposureId(dataId)
83 
84  def bypass_ccdExposureId_bits(self, datasetType, pythonType, location, dataId):
85  return 41
86 
87  def validate(self, dataId):
88  visit = dataId.get("visit")
89  if visit is not None and not isinstance(visit, int):
90  dataId["visit"] = int(visit)
91  return dataId
92 
93  def _setCcdExposureId(self, propertyList, dataId):
94  propertyList.set("Computed_ccdExposureId", self._computeCcdExposureId(dataId))
95  return propertyList
96 
97  def _makeCamera(self, policy, repositoryDir):
98  """Make a camera (instance of lsst.afw.cameraGeom.Camera) describing the camera geometry
99  """
100  return TestCamera()
std::string getPackageDir(std::string const &packageName)
return the root directory of a setup package
Definition: Utils.cc:34