31 __all__ = [
"makeCamera"]
35 """An imaging camera (e.g. the LSST 3Gpix camera) 40 Camera description YAML file. 44 camera : `lsst.afw.cameraGeom.Camera` 48 with open(cameraFile)
as fd:
49 cameraParams = yaml.load(fd, Loader=yaml.CLoader)
51 cameraName = cameraParams[
"name"]
56 plateScale =
geom.Angle(cameraParams[
"plateScale"], geom.arcseconds)
57 nativeSys = cameraGeom.CameraSys(cameraParams[
"transforms"].pop(
"nativeSys"))
60 ccdParams = cameraParams[
"CCDs"]
64 for ccdName, ccdValues
in ccdParams.items():
71 """Make a list of detector configs 75 detectorConfig : `list` of `lsst.afw.cameraGeom.DetectorConfig` 76 A list of detector configs. 79 for name, ccd
in ccdParams.items():
80 detectorConfig = cameraGeom.DetectorConfig()
81 detectorConfigs.append(detectorConfig)
83 detectorConfig.name = name
84 detectorConfig.id = ccd[
'id']
85 detectorConfig.serial = ccd[
'serial']
86 detectorConfig.detectorType = ccd[
'detectorType']
87 if 'physicalType' in ccd:
88 detectorConfig.physicalType = ccd[
'physicalType']
90 detectorConfig.bbox_x0, detectorConfig.bbox_y0 = ccd[
'bbox'][0]
91 detectorConfig.bbox_x1, detectorConfig.bbox_y1 = ccd[
'bbox'][1]
92 detectorConfig.pixelSize_x, detectorConfig.pixelSize_y = ccd[
'pixelSize']
93 detectorConfig.transformDict.nativeSys = ccd[
'transformDict'][
'nativeSys']
94 transforms = ccd[
'transformDict'][
'transforms']
95 detectorConfig.transformDict.transforms =
None if transforms ==
'None' else transforms
96 detectorConfig.refpos_x, detectorConfig.refpos_y = ccd[
'refpos']
97 detectorConfig.offset_x, detectorConfig.offset_y = ccd[
'offset']
98 detectorConfig.transposeDetector = ccd[
'transposeDetector']
99 detectorConfig.pitchDeg = ccd[
'pitch']
100 detectorConfig.yawDeg = ccd[
'yaw']
101 detectorConfig.rollDeg = ccd[
'roll']
102 if 'crosstalk' in ccd:
103 detectorConfig.crosstalk = ccd[
'crosstalk']
105 return detectorConfigs
109 """Construct an amplifier info catalog 112 assert len(ccd[
'amplifiers']) > 0
113 amp =
list(ccd[
'amplifiers'].values())[0]
116 xRawExtent, yRawExtent = rawBBox.getDimensions()
119 readCorners = dict(LL=LL, LR=LR, UL=UL, UR=UR)
121 schema = AmpInfoTable.makeMinimalSchema()
123 linThreshKey = schema.addField(
'linearityThreshold', type=float)
124 linMaxKey = schema.addField(
'linearityMaximum', type=float)
125 linUnitsKey = schema.addField(
'linearityUnits', type=str, size=9)
126 hduKey = schema.addField(
'hdu', type=np.int32)
130 for name, amp
in sorted(ccd[
'amplifiers'].
items(), key=
lambda x: x[1][
'hdu']):
131 record = ampCatalog.addNew()
133 record.set(hduKey, amp[
'hdu'])
136 perAmpData = amp[
'perAmpData']
140 x0, y0 = ix*xRawExtent, iy*yRawExtent
143 xDataExtent, yDataExtent = rawDataBBox.getDimensions()
145 afwGeom.PointI(ix*xDataExtent, iy*yDataExtent), rawDataBBox.getDimensions()))
149 record.setRawBBox(rawBBox)
153 record.setRawDataBBox(rawDataBBox)
157 record.setRawHorizontalOverscanBBox(rawSerialOverscanBBox)
161 record.setRawVerticalOverscanBBox(rawParallelOverscanBBox)
165 record.setRawPrescanBBox(rawSerialPrescanBBox)
172 record.setReadoutCorner(readCorners[amp[
'readCorner']])
173 record.setGain(amp[
'gain'])
174 record.setReadNoise(amp[
'readNoise'])
175 record.setSaturation(amp[
'saturation'])
176 record.setHasRawInfo(
True)
178 flipX, flipY = amp.get(
"flipXY")
180 record.setRawFlipX(flipX)
181 record.setRawFlipY(flipY)
183 record.setLinearityCoeffs([
float(val)
for val
in amp[
'linearityCoeffs']])
184 record.setLinearityType(amp[
'linearityType'])
185 record.set(linThreshKey,
float(amp[
'linearityThreshold']))
186 record.set(linMaxKey,
float(amp[
'linearityMax']))
187 record.set(linUnitsKey,
"DN")
192 """Given a list [(x0, y0), (xsize, ysize)], probably from a yaml file, 195 (x0, y0), (xsize, ysize) = ylist
200 """Make a dictionary of TransformPoint2ToPoint2s from yaml, mapping from nativeSys 204 nativeSys : `lsst.afw.cameraGeom.CameraSys` 205 transformDict : `dict` 206 A dict specifying parameters of transforms; keys are camera system names. 207 plateScale : `lsst.geom.Angle` 208 The size of a pixel in angular units/mm (e.g. 20 arcsec/mm for LSST) 213 A dict of `lsst.afw.cameraGeom.CameraSys` : `lsst.afw.geom.TransformPoint2ToPoint2` 215 The resulting dict's keys are `~lsst.afw.cameraGeom.CameraSys`, 216 and the values are Transforms *from* NativeSys *to* CameraSys 219 assert nativeSys == cameraGeom.FOCAL_PLANE,
"Cameras with nativeSys != FOCAL_PLANE are not supported." 223 for key, transform
in transformDict.items():
224 transformType = transform[
"transformType"]
225 knownTransformTypes = [
"affine",
"radial"]
226 if transformType
not in knownTransformTypes:
227 raise RuntimeError(
"Saw unknown transform type for %s: %s (known types are: [%s])" % (
228 key, transform[
"transformType"],
", ".join(knownTransformTypes)))
230 if transformType ==
"affine":
232 np.array(transform[
"translation"]))
235 elif transformType ==
"radial":
240 radialCoeffs = np.array(transform[
"coeffs"])
242 radialCoeffs *= plateScale.asRadians()
245 raise RuntimeError(
"Impossible condition \"%s\" is not in: [%s])" % (
246 transform[
"transformType"],
", ".join(knownTransformTypes)))
248 resMap[cameraGeom.CameraSys(key)] = transform
254 pupilFactoryClass=cameraGeom.pupil.PupilFactory):
255 """Construct a Camera instance from a dictionary of 256 detector name : `lsst.afw.table.ampInfo.AmpInfoCatalog` 261 The name of the camera 262 detectorConfig : `list` 263 A list of `lsst.afw.cameraGeom.cameraConfig.DetectorConfig` 264 nativeSys : `lsst.afw.cameraGeom.CameraSys` 265 The native transformation type; must be `lsst.afw.cameraGeom.FOCAL_PLANE` 266 transformDict : `dict` 267 A dict of lsst.afw.cameraGeom.CameraSys : `lsst.afw.geom.TransformPoint2ToPoint2` 268 ampInfoCatDict : `dict` 269 A dictionary of detector name : 270 `lsst.afw.table.ampInfo.AmpInfoCatalog` 271 pupilFactoryClass : `type`, optional 272 Class to attach to camera; 273 `lsst.default afw.cameraGeom.PupilFactory` 277 camera : `lsst.afw.cameraGeom.Camera` 282 Copied from `lsst.afw.cameraGeom.cameraFactory` with permission and encouragement 291 assert nativeSys == cameraGeom.FOCAL_PLANE,
"Cameras with nativeSys != FOCAL_PLANE are not supported." 293 focalPlaneToField = transformDict[cameraGeom.FIELD_ANGLE]
294 transformMapBuilder = cameraGeom.TransformMap.Builder(nativeSys)
295 transformMapBuilder.connect(transformDict)
300 for detectorConfig
in detectorConfigList:
306 detectorConfig=detectorConfig,
307 ampInfoCatalog=ampInfoCatDict[detectorConfig.name],
308 focalPlaneToField=focalPlaneToField,
313 thisDetectorTransforms = thisDetectorData.pop(
"transforms")
316 detectorData.append(thisDetectorData)
322 detectorNativeSys = detectorConfig.transformDict.nativeSys
323 detectorNativeSys = (cameraGeom.PIXELS
if detectorNativeSys
is None else 324 cameraGeom.CameraSysPrefix(detectorNativeSys))
333 assert detectorNativeSys == cameraGeom.PIXELS, \
334 "Detectors with nativeSys != PIXELS are not supported." 335 detectorNativeSys = cameraGeom.CameraSys(detectorNativeSys, detectorConfig.name)
338 transformMapBuilder.connect(detectorNativeSys, thisDetectorTransforms)
342 transformMap = transformMapBuilder.build()
345 detectorList = [cameraGeom.Detector(transformMap=transformMap, **kw)
for kw
in detectorData]
347 return cameraGeom.Camera(cameraName, detectorList, transformMap, pupilFactoryClass)
def makeBBoxFromList(ylist)
def makeDetectorData(detectorConfig, ampInfoCatalog, focalPlaneToField)
def makeCamera(cameraFile)
A class representing an angle.
def makeDetectorConfigList(ccdParams)
def makeTransformDict(nativeSys, transformDict, plateScale)
std::shared_ptr< TransformPoint2ToPoint2 > makeRadialTransform(std::vector< double > const &forwardCoeffs, std::vector< double > const &inverseCoeffs)
A purely radial polynomial distortion.
CatalogT< AmpInfoRecord > AmpInfoCatalog
def makeCameraFromCatalogs(cameraName, detectorConfigList, nativeSys, transformDict, ampInfoCatDict, pupilFactoryClass=cameraGeom.pupil.PupilFactory)
def makeAmpInfoCatalog(ccd)
std::vector< SchemaItem< Flag > > * items
An integer coordinate rectangle.
daf::base::PropertyList * list
std::shared_ptr< TransformPoint2ToPoint2 > makeTransform(lsst::geom::AffineTransform const &affine)
Wrap an lsst::geom::AffineTransform as a Transform.