4 from .cameraGeomLib
import FOCAL_PLANE, PUPIL, PIXELS, TAN_PIXELS, ACTUAL_PIXELS, CameraSys, \
5 Detector, Orientation, CameraTransformMap
6 from .camera
import Camera
7 from .makePixelToTanPixel
import makePixelToTanPixel
9 __all__ = [
"makeCameraFromPath",
"makeCameraFromCatalogs",
"makeDetector"]
11 cameraSysList = [PUPIL, FOCAL_PLANE, PIXELS, TAN_PIXELS, ACTUAL_PIXELS]
12 cameraSysMap = dict((sys.getSysName(), sys)
for sys
in cameraSysList)
14 def makeDetector(detectorConfig, ampInfoCatalog, focalPlaneToPupil, plateScale):
15 """!Make a Detector instance from a detector config and amp info catalog
17 @param detectorConfig config for this detector (an lsst.pex.config.Config)
18 @param ampInfoCatalog amplifier information for this detector (an lsst.afw.table.AmpInfoCatalog)
19 @param focalPlaneToPupil FOCAL_PLANE to PUPIL XYTransform
20 @param plateScale nominal plate scale (arcsec/mm)
21 @return detector (an lsst.afw.cameraGeom.Detector)
24 pixelSizeMm =
afwGeom.Extent2D(detectorConfig.pixelSize_x, detectorConfig.pixelSize_y)
26 transforms[FOCAL_PLANE] = orientation.makePixelFpTransform(pixelSizeMm)
28 llPoint =
afwGeom.Point2I(detectorConfig.bbox_x0, detectorConfig.bbox_y0)
29 urPoint =
afwGeom.Point2I(detectorConfig.bbox_x1, detectorConfig.bbox_y1)
32 tanPixSys =
CameraSys(TAN_PIXELS, detectorConfig.name)
35 orientation = orientation,
36 focalPlaneToPupil = focalPlaneToPupil,
37 pixelSizeMm = pixelSizeMm,
38 plateScale = plateScale,
44 detectorConfig.detectorType,
45 detectorConfig.serial,
54 """!Make an Orientation instance from a detector config
56 @param detectorConfig config for this detector (an lsst.pex.config.Config)
57 @return orientation (an lsst.afw.cameraGeom.Orientation)
59 offset =
afwGeom.Point2D(detectorConfig.offset_x, detectorConfig.offset_y)
60 refPos =
afwGeom.Point2D(detectorConfig.refpos_x, detectorConfig.refpos_y)
62 pitch =
afwGeom.Angle(detectorConfig.pitchDeg, afwGeom.degrees)
64 return Orientation(offset, refPos, yaw, pitch, roll)
67 """!Make a dictionary of CameraSys: lsst.afw.geom.XYTransform from a config dict.
69 @param transformConfigDict an lsst.pex.config.ConfigDictField from an lsst.afw.geom.XYTransform
70 registry; keys are camera system names.
71 @return a dict of CameraSys or CameraSysPrefix: lsst.afw.geom.XYTransform
74 if transformConfigDict
is not None:
75 for key
in transformConfigDict:
76 transform = transformConfigDict[key].transform.apply()
81 """!Make a Camera instance from a directory of ampInfo files
83 The directory must contain one ampInfo fits file for each detector in cameraConfig.detectorList.
84 The name of each ampInfo file must be shortNameFunc(fullDetectorName) + ".fits".
86 @param[in] cameraConfig an instance of CameraConfig
87 @param[in] ampInfoPath path to ampInfo data files
88 @param[in] shortNameFunc a function that converts a long detector name to a short one
89 @return camera (an lsst.afw.cameraGeom.Camera)
91 ampInfoCatDict = dict()
92 for detectorConfig
in cameraConfig.detectorList.itervalues():
93 shortName = shortNameFunc(detectorConfig.name)
94 ampCatPath = os.path.join(ampInfoPath, shortName +
".fits")
95 ampInfoCatalog = AmpInfoCatalog.readFits(ampCatPath)
96 ampInfoCatDict[detectorConfig.name] = ampInfoCatalog
101 """!Construct a Camera instance from a dictionary of detector name: AmpInfoCatalog
103 @param[in] cameraConfig an instance of CameraConfig
104 @param[in] ampInfoCatDict a dictionary of detector name: AmpInfoCatalog
105 @return camera (an lsst.afw.cameraGeom.Camera)
107 nativeSys = cameraSysMap[cameraConfig.transformDict.nativeSys]
109 focalPlaneToPupil = transformDict[PUPIL]
113 for detectorConfig
in cameraConfig.detectorList.itervalues():
114 ampInfoCatalog = ampInfoCatDict[detectorConfig.name]
117 detectorConfig = detectorConfig,
118 ampInfoCatalog = ampInfoCatalog,
119 focalPlaneToPupil = focalPlaneToPupil,
120 plateScale = cameraConfig.plateScale,
123 return Camera(cameraConfig.name, detectorList, transformMap)
def makeTransformDict
Make a dictionary of CameraSys: lsst.afw.geom.XYTransform from a config dict.
An integer coordinate rectangle.
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.
def makeCameraFromCatalogs
Construct a Camera instance from a dictionary of detector name: AmpInfoCatalog.