LSST Applications g0265f82a02+0e5473021a,g02d81e74bb+f5613e8b4f,g1470d8bcf6+190ad2ba91,g14a832a312+311607e4ab,g2079a07aa2+86d27d4dc4,g2305ad1205+a8e3196225,g295015adf3+b67ee847e5,g2bbee38e9b+0e5473021a,g337abbeb29+0e5473021a,g3ddfee87b4+a761f810f3,g487adcacf7+17c8fdbcbd,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+65b5bd823e,g5a732f18d5+53520f316c,g64a986408d+f5613e8b4f,g6c1bc301e9+51106c2951,g858d7b2824+f5613e8b4f,g8a8a8dda67+585e252eca,g99cad8db69+6729933424,g9ddcbc5298+9a081db1e4,ga1e77700b3+15fc3df1f7,ga8c6da7877+ef4e3a5875,gb0e22166c9+60f28cb32d,gb6a65358fc+0e5473021a,gba4ed39666+c2a2e4ac27,gbb8dafda3b+e9bba80f27,gc120e1dc64+eee469a5e5,gc28159a63d+0e5473021a,gcf0d15dbbd+a761f810f3,gdaeeff99f8+f9a426f77a,ge6526c86ff+d4c1d4bfef,ge79ae78c31+0e5473021a,gee10cc3b42+585e252eca,gf1cff7945b+f5613e8b4f,w.2024.16
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Protected Attributes | List of all members
lsst.afw.cameraGeom.testUtils.CameraWrapper Class Reference

Public Member Functions

 __init__ (self, plateScale=20.0, radialDistortion=0.925, isLsstLike=False)
 
 nDetectors (self)
 
 makeDetectorConfigs (self, detFile)
 
 makeAmpLists (self, ampFile, isLsstLike=False)
 
 makeTestRepositoryItems (self, isLsstLike=False)
 

Public Attributes

 plateScale
 
 radialDistortion
 
 detectorNameList
 
 detectorIdList
 
 ampDataDict
 
 camConfig
 
 ampListDict
 
 camera
 

Protected Attributes

 _afwTestDataDir
 

Detailed Description

A simple Camera and the data used to construct it

Intended for use with unit tests, thus saves some interesting information.

Parameters
----------
plateScale : `float`
    Plate scale in arcsec/mm; 20.0 is for LSST.
radialDistortion : `float`
    Radial distortion, in mm/rad^2.
    The r^3 coefficient of the radial distortion polynomial
    that converts FIELD_ANGLE in radians to FOCAL_PLANE in mm;
    0.925 is the value Dave Monet measured for lsstSim data.
isLsstLike : `bool`.
    Make repository products with one raw image per amplifier (True)
    or with one raw image per detector (False).

Definition at line 170 of file testUtils.py.

Constructor & Destructor Documentation

◆ __init__()

lsst.afw.cameraGeom.testUtils.CameraWrapper.__init__ ( self,
plateScale = 20.0,
radialDistortion = 0.925,
isLsstLike = False )

Definition at line 189 of file testUtils.py.

189 def __init__(self, plateScale=20.0, radialDistortion=0.925, isLsstLike=False):
190 afwDir = lsst.utils.getPackageDir("afw")
191 self._afwTestDataDir = os.path.join(afwDir, "python", "lsst", "afw",
192 "cameraGeom", "testData")
193
194 # Info to store for unit tests
195 self.plateScale = float(plateScale)
196 self.radialDistortion = float(radialDistortion)
197 self.detectorNameList = []
198 self.detectorIdList = []
199 self.ampDataDict = {} # ampData[Dict]: raw dictionaries of test data fields
200
201 # ampList[Dict]: actual cameraGeom.Amplifier objects
202 self.camConfig, self.ampListDict = self.makeTestRepositoryItems(
203 isLsstLike)
204 self.camera = makeCameraFromAmpLists(
205 self.camConfig, self.ampListDict)
206

Member Function Documentation

◆ makeAmpLists()

lsst.afw.cameraGeom.testUtils.CameraWrapper.makeAmpLists ( self,
ampFile,
isLsstLike = False )
Construct a dict of list of Amplifer, one list per detector.

Parameters
----------
ampFile : `str`
    Path to amplifier data file.
isLsstLike : `bool`
    If True then there is one raw image per amplifier;
    if False then there is one raw image per detector.

Definition at line 255 of file testUtils.py.

255 def makeAmpLists(self, ampFile, isLsstLike=False):
256 """Construct a dict of list of Amplifer, one list per detector.
257
258 Parameters
259 ----------
260 ampFile : `str`
261 Path to amplifier data file.
262 isLsstLike : `bool`
263 If True then there is one raw image per amplifier;
264 if False then there is one raw image per detector.
265 """
266 readoutMap = {
267 'LL': ReadoutCorner.LL,
268 'LR': ReadoutCorner.LR,
269 'UR': ReadoutCorner.UR,
270 'UL': ReadoutCorner.UL,
271 }
272 ampDataList = []
273 with open(ampFile) as fh:
274 names = fh.readline().rstrip().lstrip("#").split("|")
275 for line in fh:
276 els = line.rstrip().split("|")
277 ampProps = dict([(name, el) for name, el in zip(names, els)])
278 ampDataList.append(ampProps)
279 ampListDict = {}
280 self.ampDataDict = {}
281 for ampData in ampDataList:
282 if ampData['ccd_name'] in ampListDict:
283 ampList = ampListDict[ampData['ccd_name']]
284 self.ampDataDict[ampData['ccd_name']]['namps'] += 1
285 else:
286 ampList = []
287 ampListDict[ampData['ccd_name']] = ampList
288 self.ampDataDict[ampData['ccd_name']] = {'namps': 1, 'linInfo': {}}
289 builder = Amplifier.Builder()
290 bbox = lsst.geom.Box2I(lsst.geom.Point2I(int(ampData['trimmed_xmin']),
291 int(ampData['trimmed_ymin'])),
292 lsst.geom.Point2I(int(ampData['trimmed_xmax']),
293 int(ampData['trimmed_ymax'])))
294 rawBbox = lsst.geom.Box2I(lsst.geom.Point2I(int(ampData['raw_xmin']),
295 int(ampData['raw_ymin'])),
296 lsst.geom.Point2I(int(ampData['raw_xmax']),
297 int(ampData['raw_ymax'])))
298 rawDataBbox = lsst.geom.Box2I(
299 lsst.geom.Point2I(int(ampData['raw_data_xmin']),
300 int(ampData['raw_data_ymin'])),
301 lsst.geom.Point2I(int(ampData['raw_data_xmax']),
302 int(ampData['raw_data_ymax'])))
303 rawHOverscanBbox = lsst.geom.Box2I(
304 lsst.geom.Point2I(int(ampData['hoscan_xmin']),
305 int(ampData['hoscan_ymin'])),
306 lsst.geom.Point2I(int(ampData['hoscan_xmax']),
307 int(ampData['hoscan_ymax'])))
308 rawVOverscanBbox = lsst.geom.Box2I(
309 lsst.geom.Point2I(int(ampData['voscan_xmin']),
310 int(ampData['voscan_ymin'])),
311 lsst.geom.Point2I(int(ampData['voscan_xmax']),
312 int(ampData['voscan_ymax'])))
313 rawPrescanBbox = lsst.geom.Box2I(
314 lsst.geom.Point2I(int(ampData['pscan_xmin']),
315 int(ampData['pscan_ymin'])),
316 lsst.geom.Point2I(int(ampData['pscan_xmax']),
317 int(ampData['pscan_ymax'])))
318 xoffset = int(ampData['x_offset'])
319 yoffset = int(ampData['y_offset'])
320 flipx = bool(int(ampData['flipx']))
321 flipy = bool(int(ampData['flipy']))
322 readcorner = 'LL'
323 if not isLsstLike:
324 offext = lsst.geom.Extent2I(xoffset, yoffset)
325 if flipx:
326 xExt = rawBbox.getDimensions().getX()
327 rawBbox.flipLR(xExt)
328 rawDataBbox.flipLR(xExt)
329 rawHOverscanBbox.flipLR(xExt)
330 rawVOverscanBbox.flipLR(xExt)
331 rawPrescanBbox.flipLR(xExt)
332 if flipy:
333 yExt = rawBbox.getDimensions().getY()
334 rawBbox.flipTB(yExt)
335 rawDataBbox.flipTB(yExt)
336 rawHOverscanBbox.flipTB(yExt)
337 rawVOverscanBbox.flipTB(yExt)
338 rawPrescanBbox.flipTB(yExt)
339 if not flipx and not flipy:
340 readcorner = 'LL'
341 elif flipx and not flipy:
342 readcorner = 'LR'
343 elif flipx and flipy:
344 readcorner = 'UR'
345 elif not flipx and flipy:
346 readcorner = 'UL'
347 else:
348 raise RuntimeError("Couldn't find read corner")
349
350 flipx = False
351 flipy = False
352 rawBbox.shift(offext)
353 rawDataBbox.shift(offext)
354 rawHOverscanBbox.shift(offext)
355 rawVOverscanBbox.shift(offext)
356 rawPrescanBbox.shift(offext)
357 xoffset = 0
358 yoffset = 0
359 offset = lsst.geom.Extent2I(xoffset, yoffset)
360 builder.setBBox(bbox)
361 builder.setRawXYOffset(offset)
362 builder.setName(str(ampData['name']))
363 builder.setReadoutCorner(readoutMap[readcorner])
364 builder.setGain(float(ampData['gain']))
365 builder.setReadNoise(float(ampData['readnoise']))
366 linCoeffs = np.array([float(ampData['lin_coeffs']), ], dtype=float)
367 builder.setLinearityCoeffs(linCoeffs)
368 builder.setLinearityType(str(ampData['lin_type']))
369 builder.setRawFlipX(flipx)
370 builder.setRawFlipY(flipy)
371 builder.setRawBBox(rawBbox)
372 builder.setRawDataBBox(rawDataBbox)
373 builder.setRawHorizontalOverscanBBox(rawHOverscanBbox)
374 builder.setRawVerticalOverscanBBox(rawVOverscanBbox)
375 builder.setRawPrescanBBox(rawPrescanBbox)
376 builder.setLinearityThreshold(float(ampData['lin_thresh']))
377 builder.setLinearityMaximum(float(ampData['lin_max']))
378 builder.setLinearityUnits(str(ampData['lin_units']))
379 self.ampDataDict[ampData['ccd_name']]['linInfo'][ampData['name']] = \
380 {'lincoeffs': linCoeffs, 'lintype': str(ampData['lin_type']),
381 'linthresh': float(ampData['lin_thresh']), 'linmax': float(ampData['lin_max']),
382 'linunits': str(ampData['lin_units'])}
383 ampList.append(builder)
384 return ampListDict
385
An integer coordinate rectangle.
Definition Box.h:55

◆ makeDetectorConfigs()

lsst.afw.cameraGeom.testUtils.CameraWrapper.makeDetectorConfigs ( self,
detFile )
Construct a list of DetectorConfig, one per detector

Definition at line 212 of file testUtils.py.

212 def makeDetectorConfigs(self, detFile):
213 """Construct a list of DetectorConfig, one per detector
214 """
215 detectors = []
216 self.detectorNameList = []
217 self.detectorIdList = []
218 with open(detFile) as fh:
219 names = fh.readline().rstrip().lstrip("#").split("|")
220 for line in fh:
221 els = line.rstrip().split("|")
222 detectorProps = dict([(name, el)
223 for name, el in zip(names, els)])
224 detectors.append(detectorProps)
225 detectorConfigs = []
226 for i, detector in enumerate(detectors):
227 detectorId = (i + 1) * 10 # to avoid simple 0, 1, 2...
228 detectorName = detector['name']
229 detConfig = DetectorConfig()
230 detConfig.name = detectorName
231 detConfig.id = detectorId
232 detConfig.bbox_x0 = 0
233 detConfig.bbox_y0 = 0
234 detConfig.bbox_x1 = int(detector['npix_x']) - 1
235 detConfig.bbox_y1 = int(detector['npix_y']) - 1
236 detConfig.serial = str(detector['serial'])
237 detConfig.detectorType = int(detector['detectorType'])
238 detConfig.offset_x = float(detector['x'])
239 detConfig.offset_y = float(detector['y'])
240 detConfig.offset_z = float(detector['z'])
241 detConfig.refpos_x = float(detector['refPixPos_x'])
242 detConfig.refpos_y = float(detector['refPixPos_y'])
243 detConfig.yawDeg = float(detector['yaw'])
244 detConfig.pitchDeg = float(detector['pitch'])
245 detConfig.rollDeg = float(detector['roll'])
246 detConfig.pixelSize_x = float(detector['pixelSize'])
247 detConfig.pixelSize_y = float(detector['pixelSize'])
248 detConfig.transposeDetector = False
249 detConfig.transformDict.nativeSys = PIXELS.getSysName()
250 detectorConfigs.append(detConfig)
251 self.detectorNameList.append(detectorName)
252 self.detectorIdList.append(detectorId)
253 return detectorConfigs
254

◆ makeTestRepositoryItems()

lsst.afw.cameraGeom.testUtils.CameraWrapper.makeTestRepositoryItems ( self,
isLsstLike = False )
Make camera config and amp catalog dictionary, using default
detector and amp files.

Parameters
----------
isLsstLike : `bool`
    If True then there is one raw image per amplifier;
    if False then there is one raw image per detector.

Definition at line 386 of file testUtils.py.

386 def makeTestRepositoryItems(self, isLsstLike=False):
387 """Make camera config and amp catalog dictionary, using default
388 detector and amp files.
389
390 Parameters
391 ----------
392 isLsstLike : `bool`
393 If True then there is one raw image per amplifier;
394 if False then there is one raw image per detector.
395 """
396 detFile = os.path.join(self._afwTestDataDir, "testCameraDetectors.dat")
397 detectorConfigs = self.makeDetectorConfigs(detFile)
398 ampFile = os.path.join(self._afwTestDataDir, "testCameraAmps.dat")
399 ampListDict = self.makeAmpLists(ampFile, isLsstLike=isLsstLike)
400 camConfig = CameraConfig()
401 camConfig.name = "testCamera%s"%('LSST' if isLsstLike else 'SC')
402 camConfig.detectorList = dict((i, detConfig)
403 for i, detConfig in enumerate(detectorConfigs))
404 camConfig.plateScale = self.plateScale
405 pScaleRad = lsst.geom.arcsecToRad(self.plateScale)
406 radialDistortCoeffs = [0.0, 1.0/pScaleRad,
407 0.0, self.radialDistortion/pScaleRad]
408 tConfig = afwGeom.TransformConfig()
409 tConfig.transform.name = 'inverted'
410 radialClass = afwGeom.transformRegistry['radial']
411 tConfig.transform.active.transform.retarget(radialClass)
412 tConfig.transform.active.transform.coeffs = radialDistortCoeffs
413 tmc = TransformMapConfig()
414 tmc.nativeSys = FOCAL_PLANE.getSysName()
415 tmc.transforms = {FIELD_ANGLE.getSysName(): tConfig}
416 camConfig.transformDict = tmc
417 return camConfig, ampListDict
418
419
420@inTestCase
constexpr double arcsecToRad(double x) noexcept
Definition Angle.h:56

◆ nDetectors()

lsst.afw.cameraGeom.testUtils.CameraWrapper.nDetectors ( self)
Return the number of detectors

Definition at line 208 of file testUtils.py.

208 def nDetectors(self):
209 """Return the number of detectors"""
210 return len(self.detectorNameList)
211

Member Data Documentation

◆ _afwTestDataDir

lsst.afw.cameraGeom.testUtils.CameraWrapper._afwTestDataDir
protected

Definition at line 191 of file testUtils.py.

◆ ampDataDict

lsst.afw.cameraGeom.testUtils.CameraWrapper.ampDataDict

Definition at line 199 of file testUtils.py.

◆ ampListDict

lsst.afw.cameraGeom.testUtils.CameraWrapper.ampListDict

Definition at line 202 of file testUtils.py.

◆ camConfig

lsst.afw.cameraGeom.testUtils.CameraWrapper.camConfig

Definition at line 202 of file testUtils.py.

◆ camera

lsst.afw.cameraGeom.testUtils.CameraWrapper.camera

Definition at line 204 of file testUtils.py.

◆ detectorIdList

lsst.afw.cameraGeom.testUtils.CameraWrapper.detectorIdList

Definition at line 198 of file testUtils.py.

◆ detectorNameList

lsst.afw.cameraGeom.testUtils.CameraWrapper.detectorNameList

Definition at line 197 of file testUtils.py.

◆ plateScale

lsst.afw.cameraGeom.testUtils.CameraWrapper.plateScale

Definition at line 195 of file testUtils.py.

◆ radialDistortion

lsst.afw.cameraGeom.testUtils.CameraWrapper.radialDistortion

Definition at line 196 of file testUtils.py.


The documentation for this class was generated from the following file: