Coverage for python/lsst/obs/sdss/convertOpECalib.py : 27%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1import os
3import numpy as np
5import lsst.utils
6from lsst.obs.sdss.yanny import yanny as Yanny # noqa N812
9class SdssCameraState(Yanny):
10 _filters = dict(u=1, g=2, r=3, i=4, z=5)
12 def __init__(self, opDir, opConfig, opECalib):
13 self._ECalib = Yanny(os.path.join(opDir, opECalib))["ECALIB"]
14 self._CcdConfig = Yanny(os.path.join(opDir, opConfig))["CCDCONFIG"]
16 def _splitCcd(self, ccdName):
17 filter, camCol = list(ccdName)
19 return filter, int(camCol)
21 def _getCamRow(self, filter):
22 return SdssCameraState._filters[filter]
24 def getCcdIndex(self, ECALIB, ccdName):
25 """Return the index for the given ccd (e.g. g1) into the arrays returned by a Yanny object"""
26 filter, camCol = self._splitCcd(ccdName)
27 camRow = self._getCamRow(filter)
29 me = np.where(np.logical_and(np.equal(ECALIB["camCol"], camCol), np.equal(ECALIB["camRow"], camRow)))
30 if len(me) != 1:
31 raise RuntimeError("Unable to lookup index for ccd %s" % ccdName)
33 return me[0]
35 def getEParams(self, ccdName):
36 """Return a pair of ampId dict of electronic params for both amps of a named CCD (e.g. z4)"""
37 ECALIB = self._ECalib
38 me = self.getCcdIndex(ECALIB, ccdName)
40 eparams = []
41 for i in range(4):
42 if int(self._CcdConfig["amp%d" % i][me]):
43 gain = ECALIB["gain%d" % i][me]
44 readNoise = ECALIB["readNoiseDN%d" % i][me]
45 fullWell = ECALIB["fullWellDN%d" % i][me]
47 eparams.append((i, {'gain': gain, 'readNoise': readNoise, 'fullWell': fullWell}))
49 if len(eparams) == 1:
50 eparams.append((1, eparams[0][1]))
52 return eparams
55if __name__ == "__main__": 55 ↛ 56line 55 didn't jump to line 56, because the condition on line 55 was never true
56 sc = SdssCameraState(os.path.join(lsst.utils.getPackageDir("obs_sdss"), "etc"), "opConfig-50000.par",
57 "opECalib-50000.par")
58 print([(i, ep['gain'], ep['readNoise'], ep['fullWell']) for i, ep in sc.getEParams("g2")])