Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Plot, heating curve fit and libraries needed
import csv
import numpy as np
from scipy.optimize import curve_fit
from sys import argv
csvfile = open(argv[1], 'r')
linhas = csv.DictReader(csvfile)
Y, t = [], []
for linha in linhas:
t.append(float(linha['tempo']))
Y.append(float(linha['temperatura']))
Y, t = np.array(Y), np.array(t)
temperatura_aquecimento = lambda t, T_0, T_F, alpha : T_0 + (T_F - T_0) * (1 - np.exp(-alpha * t))
T_0, T_F, alpha = curve_fit(temperatura_aquecimento, t, Y)[0]
print(str(round(T_0, 2)) + ' + ' + str(round(T_F - T_0, 2)) + ' * (1 - e^(-' + str(round(alpha,4)) + 't))')
import csv
from matplotlib import pyplot as plot
from sys import argv
filename = argv[1]
csvfile = open(filename, 'r')
linhas = csv.DictReader(csvfile)
tempo = []
temperatura = []
for linha in linhas:
tempo.append(float(linha['tempo']))
temperatura.append(float(linha['temperatura']))
csvfile.close()
plot.plot(tempo, temperatura)
if len(argv) == 3:
filename = argv[2]
csvfile = open(filename, 'r')
linhas = csv.DictReader(csvfile)
tempo = []
temperatura = []
for linha in linhas:
tempo.append(float(linha['tempo']))
temperatura.append(float(linha['temperatura']))
csvfile.close()
plot.plot(tempo, temperatura)
backcall==0.1.0
cycler==0.10.0
decorator==4.4.2
ipython==7.13.0
ipython-genutils==0.2.0
jedi==0.16.0
kiwisolver==1.1.0
matplotlib==3.2.1
numpy==1.18.2
parso==0.6.2
pexpect==4.8.0
pickleshare==0.7.5
prompt-toolkit==3.0.5
ptyprocess==0.6.0
Pygments==2.6.1
pyparsing==2.4.6
pyserial==3.4
python-dateutil==2.8.1
scipy==1.4.1
six==1.14.0
traitlets==4.3.3
wcwidth==0.1.9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment