calib scripts

- put calibrange into calib files
- add recent calibrations
This commit is contained in:
l_samenv
2023-08-22 17:34:08 +02:00
parent f2d80a9425
commit 9adc313337
76 changed files with 8267 additions and 4 deletions

View File

@@ -25,13 +25,15 @@ class StdFilter(object):
def parse(self, line):
'''get numbers from a line and put them to self.output'''
if line.strip().startswith('#'):
return
values = []
row = line.split()
try:
for c in self.colnums:
values.append(float(row[c]))
except (IndexError, ValueError):
# print('SKIP: %s' % line.strip())
#print('SKIP: %s' % line.strip())
return
self.posttreat(values)
@@ -54,6 +56,8 @@ class Filter340(StdFilter):
def parse(self, line):
'''scan header for data format'''
if line.startswith('#'):
return
if self.header:
if line.startswith("Data Format"):
dataformat = line.split(":")[1].strip()[0]
@@ -137,7 +141,7 @@ def convert_res(res1, res2, resc1, log1=True, log2=True, smooth=0):
res2 = res2[::-1]
for r1,r2 in zip(res1[:-1], res1[1:]):
if r1 >= r2:
print(res1)
print(10 ** res1)
raise ValueError('not increasing X')
fun = splrep(res1, res2, s=smooth)
# extrapolation outside the range only linear!
@@ -238,6 +242,7 @@ Serial Number: %s\r
Data Format: %d (Log Ohms/Kelvin)\r
SetPoint Limit: %.1f (Kelvin)\r
Temperature coefficient: 1 (Negative)\r
calibrange : %g,%g\r
Number of Breakpoints: %d\r
\r
No. Units Temperature (K)\r
@@ -277,6 +282,7 @@ No. Units Temperature (K)\r
tstbest[i] = sum(meas.tst[j][i] for j in range(3)) / 3.0
print(dict(averaged=meas.n-m, selected=m))
self.rcal, self.tcal = make_calib(run.rref, run.tref, refbest, tstbest, run.t_points, smooth=smooth)
self.calibrange = convert_res(self.rcal, self.tcal, [tstbest[0], tstbest[-1]])
return (self.rcal, self.tcal)
def write(self, rc, tc, logR=True, logT=False, path='%s/%s.340', caldate=None):
@@ -313,7 +319,8 @@ No. Units Temperature (K)\r
continue
raise ValueError('ERROR: data for %s is not monotonic' % self.serialno)
with open(path, 'w') as f:
f.write(self.HEADER % (self.model, caldate, self.serialno, dataformat, tc[-1], len(tc)))
f.write(self.HEADER % (self.model, caldate, self.serialno, dataformat, tc[-1],
self.calibrange[0], self.calibrange[1], len(tc)))
for i,(r,t) in enumerate(sorted(zip(rc, tc))):
f.write("%3d %#10.7g %#10.7g\r\n" % (i+1,r,t))
@@ -347,4 +354,4 @@ class CalibRun(object):
try:
sensor.write(rc, tc, **self.outputoptions)
except ValueError as e:
print(e)
print(e)