Tools: Change sign convention used by thermal calibrator

The flight code assumes corrections have the same sign as the sensor bias error and are subtracted from the raw reading
This commit is contained in:
Paul Riseborough
2017-01-27 08:42:36 +11:00
committed by Lorenz Meier
parent c829e27a02
commit f9b75e68c9
+3 -4
View File
@@ -71,8 +71,7 @@ def temp_calibration(data, topic, fields, units, label):
'type': 'FLOAT', 'type': 'FLOAT',
} }
# curve fit the data for corrections - note # curve fit the data for corrections - note corrections have same sign as sensor bias and will need to be subtracted from the raw reading to remove the bias
# corrections have oppsite sign to sensor bias
try: try:
params['ID']['val'] = int(np.median(data['device_id'])) params['ID']['val'] = int(np.median(data['device_id']))
except: except:
@@ -90,7 +89,7 @@ def temp_calibration(data, topic, fields, units, label):
temp_resample = temp_rel_resample + params['TREF']['val'] temp_resample = temp_rel_resample + params['TREF']['val']
for i, field in enumerate(fields): for i, field in enumerate(fields):
coef = np.polyfit(temp_rel, -data[field], 3) coef = np.polyfit(temp_rel, data[field], 3)
for j in range(3): for j in range(3):
params['X{:d}_{:d}'.format(3-j, i)]['val'] = float(coef[j]) params['X{:d}_{:d}'.format(3-j, i)]['val'] = float(coef[j])
fit_coef = np.poly1d(coef) fit_coef = np.poly1d(coef)
@@ -99,7 +98,7 @@ def temp_calibration(data, topic, fields, units, label):
# draw plots # draw plots
plt.subplot(len(fields), 1, i + 1) plt.subplot(len(fields), 1, i + 1)
plt.plot(data['temperature'], data[field], 'b') plt.plot(data['temperature'], data[field], 'b')
plt.plot(temp_resample, -resample, 'r') plt.plot(temp_resample, resample, 'r')
plt.title('{:s} Bias vs Temperature'.format(topic)) plt.title('{:s} Bias vs Temperature'.format(topic))
plt.ylabel('{:s} bias {:s}'.format(field, units)) plt.ylabel('{:s} bias {:s}'.format(field, units))
plt.xlabel('temperature (degC)') plt.xlabel('temperature (degC)')