1 from __future__
import absolute_import, division, print_function
6 from .cameraGeomLib
import FOCAL_PLANE, PUPIL, PIXELS, TAN_PIXELS, ACTUAL_PIXELS, CameraSys, \
7 Detector, DetectorType, Orientation, CameraTransformMap
8 from .camera
import Camera
9 from .makePixelToTanPixel
import makePixelToTanPixel
10 from .pupil
import PupilFactory
12 __all__ = [
"makeCameraFromPath",
"makeCameraFromCatalogs",
13 "makeDetector",
"copyDetector"]
15 cameraSysList = [PUPIL, FOCAL_PLANE, PIXELS, TAN_PIXELS, ACTUAL_PIXELS]
16 cameraSysMap = dict((sys.getSysName(), sys)
for sys
in cameraSysList)
19 def makeDetector(detectorConfig, ampInfoCatalog, focalPlaneToPupil):
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 focalPlaneToPupil FOCAL_PLANE to PUPIL XYTransform
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 focalPlaneToPupil = focalPlaneToPupil,
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 transformDict = dict()
71 for cs
in tm.getCoordSysList():
72 if cs != tm.getNativeCoordSys():
73 transformDict[cs] = tm.get(cs)
75 return Detector(detector.getName(), detector.getId(), detector.getType(),
76 detector.getSerial(), detector.getBBox(),
77 ampInfoCatalog, detector.getOrientation(), detector.getPixelSize(),
82 """!Make an Orientation instance from a detector config
84 @param detectorConfig config for this detector (an lsst.pex.config.Config)
85 @return orientation (an lsst.afw.cameraGeom.Orientation)
87 offset =
afwGeom.Point2D(detectorConfig.offset_x, detectorConfig.offset_y)
88 refPos =
afwGeom.Point2D(detectorConfig.refpos_x, detectorConfig.refpos_y)
90 pitch =
afwGeom.Angle(detectorConfig.pitchDeg, afwGeom.degrees)
92 return Orientation(offset, refPos, yaw, pitch, roll)
96 """!Make a dictionary of CameraSys: lsst.afw.geom.XYTransform from a config dict.
98 @param transformConfigDict an lsst.pex.config.ConfigDictField from an lsst.afw.geom.XYTransform
99 registry; keys are camera system names.
100 @return a dict of CameraSys or CameraSysPrefix: lsst.afw.geom.XYTransform
103 if transformConfigDict
is not None:
104 for key
in transformConfigDict:
105 transform = transformConfigDict[key].transform.apply()
111 pupilFactoryClass=PupilFactory):
112 """!Make a Camera instance from a directory of ampInfo files
114 The directory must contain one ampInfo fits file for each detector in cameraConfig.detectorList.
115 The name of each ampInfo file must be shortNameFunc(fullDetectorName) + ".fits".
117 @param[in] cameraConfig an instance of CameraConfig
118 @param[in] ampInfoPath path to ampInfo data files
119 @param[in] shortNameFunc a function that converts a long detector name to a short one
120 @param[in] pupilFactoryClass class to attach to camera; default afw.cameraGeom.PupilFactory
121 @return camera (an lsst.afw.cameraGeom.Camera)
123 ampInfoCatDict = dict()
124 for detectorConfig
in cameraConfig.detectorList.values():
125 shortName = shortNameFunc(detectorConfig.name)
126 ampCatPath = os.path.join(ampInfoPath, shortName +
".fits")
127 ampInfoCatalog = AmpInfoCatalog.readFits(ampCatPath)
128 ampInfoCatDict[detectorConfig.name] = ampInfoCatalog
134 pupilFactoryClass=PupilFactory):
135 """!Construct a Camera instance from a dictionary of detector name: AmpInfoCatalog
137 @param[in] cameraConfig an instance of CameraConfig
138 @param[in] ampInfoCatDict a dictionary of detector name: AmpInfoCatalog
139 @param[in] pupilFactoryClass class to attach to camera; default afw.cameraGeom.PupilFactory
140 @return camera (an lsst.afw.cameraGeom.Camera)
142 nativeSys = cameraSysMap[cameraConfig.transformDict.nativeSys]
144 focalPlaneToPupil = transformDict[PUPIL]
148 for detectorConfig
in cameraConfig.detectorList.values():
149 ampInfoCatalog = ampInfoCatDict[detectorConfig.name]
152 detectorConfig = detectorConfig,
153 ampInfoCatalog = ampInfoCatalog,
154 focalPlaneToPupil = focalPlaneToPupil,
157 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.XYTransform 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 an XYTransform 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.