1 from __future__
import absolute_import, division, print_function
6 from .cameraGeomLib
import FOCAL_PLANE, FIELD_ANGLE, PIXELS, TAN_PIXELS, ACTUAL_PIXELS, CameraSys, \
7 Detector, DetectorType, Orientation, TransformMap
8 from .camera
import Camera
9 from .makePixelToTanPixel
import makePixelToTanPixel
10 from .pupil
import PupilFactory
12 __all__ = [
"makeCameraFromPath",
"makeCameraFromCatalogs",
13 "makeDetector",
"copyDetector"]
15 cameraSysList = [FIELD_ANGLE, FOCAL_PLANE, PIXELS, TAN_PIXELS, ACTUAL_PIXELS]
16 cameraSysMap = dict((sys.getSysName(), sys)
for sys
in cameraSysList)
19 def makeDetector(detectorConfig, ampInfoCatalog, focalPlaneToField):
20 """!Make a Detector instance from a detector config and amp info catalog
22 @param detectorConfig config for this detector (an lsst.pex.config.Config)
23 @param ampInfoCatalog amplifier information for this detector (an lsst.afw.table.AmpInfoCatalog)
24 @param focalPlaneToField FOCAL_PLANE to FIELD_ANGLE Transform
25 @return detector (an lsst.afw.cameraGeom.Detector)
29 detectorConfig.pixelSize_x, detectorConfig.pixelSize_y)
31 transforms[FOCAL_PLANE] = orientation.makePixelFpTransform(pixelSizeMm)
33 llPoint =
afwGeom.Point2I(detectorConfig.bbox_x0, detectorConfig.bbox_y0)
34 urPoint =
afwGeom.Point2I(detectorConfig.bbox_x1, detectorConfig.bbox_y1)
37 tanPixSys =
CameraSys(TAN_PIXELS, detectorConfig.name)
40 orientation = orientation,
41 focalPlaneToField = focalPlaneToField,
42 pixelSizeMm = pixelSizeMm,
48 DetectorType(detectorConfig.detectorType),
49 detectorConfig.serial,
59 """!Return a copy of a Detector
61 @param detector The Detector to clone
62 @param ampInfoCatalog The ampInfoCatalog to use; default use original
64 N.b. No deep copies are made; the input transformDict is used unmodified
66 if ampInfoCatalog
is None:
67 ampInfoCatalog = detector.getAmpInfoCatalog()
69 tm = detector.getTransformMap()
70 native = detector.getNativeCoordSys()
71 transformDict = dict()
74 transformDict[cs] = tm.getTransform(native, cs)
76 return Detector(detector.getName(), detector.getId(), detector.getType(),
77 detector.getSerial(), detector.getBBox(),
78 ampInfoCatalog, detector.getOrientation(), detector.getPixelSize(),
83 """!Make an Orientation instance from a detector config
85 @param detectorConfig config for this detector (an lsst.pex.config.Config)
86 @return orientation (an lsst.afw.cameraGeom.Orientation)
88 offset =
afwGeom.Point2D(detectorConfig.offset_x, detectorConfig.offset_y)
89 refPos =
afwGeom.Point2D(detectorConfig.refpos_x, detectorConfig.refpos_y)
91 pitch =
afwGeom.Angle(detectorConfig.pitchDeg, afwGeom.degrees)
93 return Orientation(offset, refPos, yaw, pitch, roll)
97 """!Make a dictionary of CameraSys: lsst.afw.geom.Transform from a config dict.
99 @param transformConfigDict an lsst.pex.config.ConfigDictField from an lsst.afw.geom.Transform
100 registry; keys are camera system names.
101 @return a dict of CameraSys or CameraSysPrefix: lsst.afw.geom.Transform
104 if transformConfigDict
is not None:
105 for key
in transformConfigDict:
106 transform = transformConfigDict[key].transform.apply()
112 pupilFactoryClass=PupilFactory):
113 """!Make a Camera instance from a directory of ampInfo files
115 The directory must contain one ampInfo fits file for each detector in cameraConfig.detectorList.
116 The name of each ampInfo file must be shortNameFunc(fullDetectorName) + ".fits".
118 @param[in] cameraConfig an instance of CameraConfig
119 @param[in] ampInfoPath path to ampInfo data files
120 @param[in] shortNameFunc a function that converts a long detector name to a short one
121 @param[in] pupilFactoryClass class to attach to camera; default afw.cameraGeom.PupilFactory
122 @return camera (an lsst.afw.cameraGeom.Camera)
124 ampInfoCatDict = dict()
125 for detectorConfig
in cameraConfig.detectorList.values():
126 shortName = shortNameFunc(detectorConfig.name)
127 ampCatPath = os.path.join(ampInfoPath, shortName +
".fits")
128 ampInfoCatalog = AmpInfoCatalog.readFits(ampCatPath)
129 ampInfoCatDict[detectorConfig.name] = ampInfoCatalog
135 pupilFactoryClass=PupilFactory):
136 """!Construct a Camera instance from a dictionary of detector name: AmpInfoCatalog
138 @param[in] cameraConfig an instance of CameraConfig
139 @param[in] ampInfoCatDict a dictionary of detector name: AmpInfoCatalog
140 @param[in] pupilFactoryClass class to attach to camera; default afw.cameraGeom.PupilFactory
141 @return camera (an lsst.afw.cameraGeom.Camera)
143 nativeSys = cameraSysMap[cameraConfig.transformDict.nativeSys]
145 focalPlaneToField = transformDict[FIELD_ANGLE]
149 for detectorConfig
in cameraConfig.detectorList.values():
150 ampInfoCatalog = ampInfoCatDict[detectorConfig.name]
153 detectorConfig = detectorConfig,
154 ampInfoCatalog = ampInfoCatalog,
155 focalPlaneToField = focalPlaneToField,
158 return Camera(cameraConfig.name, detectorList, transformMap, pupilFactoryClass)
Camera coordinate system; used as a key in in TransformMap.
def makeTransformDict
Make a dictionary of CameraSys: lsst.afw.geom.Transform from a config dict.
An integer coordinate rectangle.
Describe a detector's orientation in the focal plane.
def copyDetector
Return a copy of a Detector.
A class representing an angle.
def makeOrientation
Make an Orientation instance from a detector config.
def makeCameraFromPath
Make a Camera instance from a directory of ampInfo files.
def makePixelToTanPixel
Make a Transform whose forward direction converts PIXEL to TAN_PIXEL for one detector.
def makeDetector
Make a Detector instance from a detector config and amp info catalog.
Information about a CCD or other imaging detector.
def makeCameraFromCatalogs
Construct a Camera instance from a dictionary of detector name: AmpInfoCatalog.