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']
88 detectorConfig.bbox_x0, detectorConfig.bbox_y0 = ccd[
'bbox'][0]
89 detectorConfig.bbox_x1, detectorConfig.bbox_y1 = ccd[
'bbox'][1]
90 detectorConfig.pixelSize_x, detectorConfig.pixelSize_y = ccd[
'pixelSize']
91 detectorConfig.transformDict.nativeSys = ccd[
'transformDict'][
'nativeSys']
92 transforms = ccd[
'transformDict'][
'transforms']
93 detectorConfig.transformDict.transforms =
None if transforms ==
'None' else transforms
94 detectorConfig.refpos_x, detectorConfig.refpos_y = ccd[
'refpos']
95 detectorConfig.offset_x, detectorConfig.offset_y = ccd[
'offset']
96 detectorConfig.transposeDetector = ccd[
'transposeDetector']
97 detectorConfig.pitchDeg = ccd[
'pitch']
98 detectorConfig.yawDeg = ccd[
'yaw']
99 detectorConfig.rollDeg = ccd[
'roll']
100 if 'crosstalk' in ccd:
101 detectorConfig.crosstalk = ccd[
'crosstalk']
103 return detectorConfigs
107 """Construct an amplifier info catalog 110 assert len(ccd[
'amplifiers']) > 0
111 amp =
list(ccd[
'amplifiers'].values())[0]
114 xRawExtent, yRawExtent = rawBBox.getDimensions()
117 readCorners = dict(LL=LL, LR=LR, UL=UL, UR=UR)
119 schema = AmpInfoTable.makeMinimalSchema()
121 linThreshKey = schema.addField(
'linearityThreshold', type=float)
122 linMaxKey = schema.addField(
'linearityMaximum', type=float)
123 linUnitsKey = schema.addField(
'linearityUnits', type=str, size=9)
124 hduKey = schema.addField(
'hdu', type=np.int32)
128 for name, amp
in sorted(ccd[
'amplifiers'].
items(), key=
lambda x: x[1][
'hdu']):
129 record = ampCatalog.addNew()
131 record.set(hduKey, amp[
'hdu'])
134 perAmpData = amp[
'perAmpData']
138 x0, y0 = ix*xRawExtent, iy*yRawExtent
141 xDataExtent, yDataExtent = rawDataBBox.getDimensions()
143 afwGeom.PointI(ix*xDataExtent, iy*yDataExtent), rawDataBBox.getDimensions()))
147 record.setRawBBox(rawBBox)
151 record.setRawDataBBox(rawDataBBox)
155 record.setRawHorizontalOverscanBBox(rawSerialOverscanBBox)
159 record.setRawVerticalOverscanBBox(rawParallelOverscanBBox)
163 record.setRawPrescanBBox(rawSerialPrescanBBox)
170 record.setReadoutCorner(readCorners[amp[
'readCorner']])
171 record.setGain(amp[
'gain'])
172 record.setReadNoise(amp[
'readNoise'])
173 record.setSaturation(amp[
'saturation'])
174 record.setHasRawInfo(
True)
176 flipX, flipY = amp.get(
"flipXY")
178 record.setRawFlipX(flipX)
179 record.setRawFlipY(flipY)
181 record.setLinearityCoeffs([
float(val)
for val
in amp[
'linearityCoeffs']])
182 record.setLinearityType(amp[
'linearityType'])
183 record.set(linThreshKey,
float(amp[
'linearityThreshold']))
184 record.set(linMaxKey,
float(amp[
'linearityMax']))
185 record.set(linUnitsKey,
"DN")
190 """Given a list [(x0, y0), (xsize, ysize)], probably from a yaml file, 193 (x0, y0), (xsize, ysize) = ylist
198 """Make a dictionary of TransformPoint2ToPoint2s from yaml, mapping from nativeSys 202 nativeSys : `lsst.afw.cameraGeom.CameraSys` 203 transformDict : `dict` 204 A dict specifying parameters of transforms; keys are camera system names. 205 plateScale : `lsst.geom.Angle` 206 The size of a pixel in angular units/mm (e.g. 20 arcsec/mm for LSST) 211 A dict of `lsst.afw.cameraGeom.CameraSys` : `lsst.afw.geom.TransformPoint2ToPoint2` 213 The resulting dict's keys are `~lsst.afw.cameraGeom.CameraSys`, 214 and the values are Transforms *from* NativeSys *to* CameraSys 217 assert nativeSys == cameraGeom.FOCAL_PLANE,
"Cameras with nativeSys != FOCAL_PLANE are not supported." 221 for key, transform
in transformDict.items():
222 transformType = transform[
"transformType"]
223 knownTransformTypes = [
"affine",
"radial"]
224 if transformType
not in knownTransformTypes:
225 raise RuntimeError(
"Saw unknown transform type for %s: %s (known types are: [%s])" % (
226 key, transform[
"transformType"],
", ".join(knownTransformTypes)))
228 if transformType ==
"affine":
230 np.array(transform[
"translation"]))
233 elif transformType ==
"radial":
238 radialCoeffs = np.array(transform[
"coeffs"])
240 radialCoeffs *= plateScale.asRadians()
243 raise RuntimeError(
"Impossible condition \"%s\" is not in: [%s])" % (
244 transform[
"transformType"],
", ".join(knownTransformTypes)))
246 resMap[cameraGeom.CameraSys(key)] = transform
252 pupilFactoryClass=cameraGeom.pupil.PupilFactory):
253 """Construct a Camera instance from a dictionary of 254 detector name : `lsst.afw.table.ampInfo.AmpInfoCatalog` 259 The name of the camera 260 detectorConfig : `list` 261 A list of `lsst.afw.cameraGeom.cameraConfig.DetectorConfig` 262 nativeSys : `lsst.afw.cameraGeom.CameraSys` 263 The native transformation type; must be `lsst.afw.cameraGeom.FOCAL_PLANE` 264 transformDict : `dict` 265 A dict of lsst.afw.cameraGeom.CameraSys : `lsst.afw.geom.TransformPoint2ToPoint2` 266 ampInfoCatDict : `dict` 267 A dictionary of detector name : 268 `lsst.afw.table.ampInfo.AmpInfoCatalog` 269 pupilFactoryClass : `type`, optional 270 Class to attach to camera; 271 `lsst.default afw.cameraGeom.PupilFactory` 275 camera : `lsst.afw.cameraGeom.Camera` 280 Copied from `lsst.afw.cameraGeom.cameraFactory` with permission and encouragement 289 assert nativeSys == cameraGeom.FOCAL_PLANE,
"Cameras with nativeSys != FOCAL_PLANE are not supported." 291 focalPlaneToField = transformDict[cameraGeom.FIELD_ANGLE]
292 transformMapBuilder = cameraGeom.TransformMap.Builder(nativeSys)
293 transformMapBuilder.connect(transformDict)
298 for detectorConfig
in detectorConfigList:
304 detectorConfig=detectorConfig,
305 ampInfoCatalog=ampInfoCatDict[detectorConfig.name],
306 focalPlaneToField=focalPlaneToField,
311 thisDetectorTransforms = thisDetectorData.pop(
"transforms")
314 detectorData.append(thisDetectorData)
320 detectorNativeSys = detectorConfig.transformDict.nativeSys
321 detectorNativeSys = (cameraGeom.PIXELS
if detectorNativeSys
is None else 322 cameraGeom.CameraSysPrefix(detectorNativeSys))
331 assert detectorNativeSys == cameraGeom.PIXELS, \
332 "Detectors with nativeSys != PIXELS are not supported." 333 detectorNativeSys = cameraGeom.CameraSys(detectorNativeSys, detectorConfig.name)
336 transformMapBuilder.connect(detectorNativeSys, thisDetectorTransforms)
340 transformMap = transformMapBuilder.build()
343 detectorList = [cameraGeom.Detector(transformMap=transformMap, **kw)
for kw
in detectorData]
345 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.