Skip to content

Commit

Permalink
Fix for temp cal script.
Browse files Browse the repository at this point in the history
  • Loading branch information
jgoppert committed Feb 1, 2017
1 parent e4fb855 commit e16d996
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions Tools/process_sensor_caldata.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import matplotlib.pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages
import os
#import json
# import json

import pandas
from numpy.polynomial import Polynomial
Expand Down Expand Up @@ -160,7 +160,8 @@ def temperature_calibration(ulog_filename, do_plot):
y = data[field]
y -= config['offset'](y)
f_poly = Polynomial.fit(x, y, config['poly_deg'])
coeffs[topic][multi_id]['poly'][field] = list(f_poly.coef)
coeffs[topic][multi_id]['poly'][field] = list(np.array(
f_poly.coef, dtype=np.float))

if do_plot:
fitPlot(
Expand All @@ -177,7 +178,7 @@ def temperature_calibration(ulog_filename, do_plot):
# create param dict from coeff dict
params = {}
for topic in coeffs.keys():
for mult_id in coeffs[topic].keys():
for multi_id in coeffs[topic].keys():
data = coeffs[topic][multi_id]

# common params
Expand All @@ -195,16 +196,16 @@ def temperature_calibration(ulog_filename, do_plot):
for i_field, field in enumerate(data['poly'].keys()):
for i_c, c in enumerate(data['poly'][field]):
p['X{:d}_{:d}'.format(i_c, i_field)] = \
qgc_param(data['poly'][field][i_c], 'float')
qgc_param(float(data['poly'][field][i_c]), 'float')

# naming
if topic == 'sensor_gyro':
name = 'TC_G{:d}'.format(mult_id)
params[name + '_ID'] = qgc_param(mult_id, 'int')
name = 'TC_G{:d}'.format(multi_id)
params[name + '_ID'] = qgc_param(multi_id, 'int')
elif topic == 'sensor_baro':
name = 'TC_B{:d}'.format(mult_id)
name = 'TC_B{:d}'.format(multi_id)
elif topic == 'sensor_accel':
name = 'TC_A{:d}'.format(mult_id)
name = 'TC_A{:d}'.format(multi_id)

# prepend name to params and save in params dict
params.update({ '{:s}_{:s}'.format(name, key): val
Expand Down

0 comments on commit e16d996

Please sign in to comment.