summaryrefslogtreecommitdiff
path: root/fit.py
diff options
context:
space:
mode:
authorChristian Franke <nobody@nowhere.ws>2013-12-10 07:01:52 +0100
committerChristian Franke <nobody@nowhere.ws>2013-12-10 07:01:52 +0100
commit4265af272a962ce1df1f6a975fdc8210f889760a (patch)
tree5aa10060c5c76ad99d5ab6e36fd81413d72a24cb /fit.py
parentee3f9c98681127496101900d65d05c8520b16732 (diff)
Add some conversions from celsius to adc valuesHEADmaster
Luckily, this ATMega is grossly oversized, so we can just throw in floating point arithmetic.
Diffstat (limited to 'fit.py')
-rw-r--r--fit.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/fit.py b/fit.py
new file mode 100644
index 0000000..1ecee1f
--- /dev/null
+++ b/fit.py
@@ -0,0 +1,23 @@
+from scipy.optimize import curve_fit
+import numpy
+import matplotlib.pyplot as pyplot
+
+
+data_x = numpy.array([ 10, 13, 17, 21, 24, 31, 36, 41 ])
+data_y = numpy.array([ 1017, 898, 810, 715, 620, 547, 510, 500 ])
+
+def func(x, a, b, c):
+ return a * numpy.exp(-b*x)-c
+
+popt, pcov = curve_fit(func, data_x, data_y, maxfev=5000)
+trial_x = numpy.linspace(0, 50, 200)
+trial_y = func(trial_x, *popt)
+
+print popt
+
+pyplot.figure()
+pyplot.plot(data_x, data_y, 'ro', label='Data')
+pyplot.plot(trial_x, trial_y, 'b-', label="Exp Fit")
+pyplot.legend()
+pyplot.show()
+