Created
April 7, 2020 22:00
-
-
Save DiegoAscanio/261f7702dac87ea854f6a0262c060abf to your computer and use it in GitHub Desktop.
Plot, heating curve fit and libraries needed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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))') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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