[tools] calibrate.py: exit with meaningfull error if optimization fails

This commit is contained in:
Felix Ruess
2013-12-27 20:05:07 +01:00
parent 0166f097ad
commit 4e2dc86ed7
+6 -1
View File
@@ -119,7 +119,12 @@ def main():
err = y*scipy.ones(len(meas)) - np
return err
p1, success = optimize.leastsq(err_func, p0[:], args=(flt_meas, sensor_ref))
p1, cov, info, msg, success = optimize.leastsq(err_func, p0[:], args=(flt_meas, sensor_ref), full_output=1)
if not success in [1, 2, 3, 4]:
print("Optimization error: ", msg)
print("Please try to provide a clean logfile.")
sys.exit(1)
cp1, np1 = calibration_utils.scale_measurements(flt_meas, p1)
print("optimized guess : avg "+str(np1.mean())+" std "+str(np1.std()))