forked from sbordeyne/Divers
/
tdcausse1.py
109 lines (81 loc) · 2.54 KB
/
tdcausse1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import matplotlib.pyplot as plt
import scipy as sp
import numpy as np
from scipy import interpolate
from scipy.interpolate import KroghInterpolator
from math import*
FaCO=[0.172,0.345,0.689,1.03,1.38,2.07,3.45,5.17,6.89]
e=[0.19,0.22,0.26,0.28,0.30,0.34,0.38,0.42,0.44]
Y=[2.30,1.99,1.71,1.55,1.45,1.31,1.15,1.04,1.00]
#question 1
plt.plot(FaCO,e,'.')
plt.plot(FaCO,Y,'.')
plt.show()
#question 2
f = interpolate.interp1d(FaCO,e) #fonction interpolation lineaire
x=np.linspace(0.172,6.89,100) #on divise l'intervalle en 100 elements
y=f(x)
plt.plot(FaCO,e,'o',x,f(x),'-') #courbe (FaCO,e) et (x,f(x))
plt.xlabel('FaCO') #nomme l'axe des x puis apres y
plt.ylabel('e')
plt.title('interpolation_lineaire,e=f(FaCO)') #on nomme le graphique
plt.show() #on affiche
g = interpolate.interp1d(FaCO,Y)
x=np.linspace(0.172,6.89,100)
y=g(x)
plt.plot(FaCO,Y,'o',x,g(x),'-')
plt.xlabel('Y')
plt.ylabel('e')
plt.title('interpolation_lineaire,Y=f(Faco)')
plt.show()
f = KroghInterpolator(FaCO,e) #interpolation polynomiale
x=np.linspace(0.172,6.89,100)
y=f(x)
plt.plot(FaCO,e,'o',x,f(x),'-')
plt.xlabel('FaCO')
plt.ylabel('e')
plt.title('interpolation_polynomiale,e=f(FaCO)')
plt.show()
g = KroghInterpolator(FaCO,Y)
x=np.linspace(0.172,6.89,100)
y=g(x)
plt.plot(FaCO,Y,'o',x,g(x),'-')
plt.xlabel('Y')
plt.ylabel('e')
plt.title('interpolation_polynomiale,Y=f(Faco)')
plt.show()
f = interpolate.interp1d(FaCO,e,kind='cubic') #interpolation cubique
x=np.linspace(0.172,6.89,100)
y=f(x)
plt.plot(FaCO,e,'o',x,f(x),'-')
plt.xlabel('FaCO')
plt.ylabel('e')
plt.title('interpolation_cubique,e=f(FaCO)')
plt.show()
g = interpolate.interp1d(FaCO,Y,kind='cubic')
x=np.linspace(0.172,6.89,100)
y=g(x)
plt.plot(FaCO,Y,'o',x,g(x),'-')
plt.xlabel('Y')
plt.ylabel('e')
plt.title('interpolation_cubique,Y=f(Faco)')
plt.show()
#question 3
def parametres(r,interpolation):
FaCO=[0.172,0.345,0.689,1.03,1.38,2.07,3.45,5.17,6.89]
e=[0.19,0.22,0.26,0.28,0.30,0.34,0.38,0.42,0.44]
Y=[2.30,1.99,1.71,1.55,1.45,1.31,1.15,1.04,1.00]
if interpolation == "lineaire" :
f = interpolate.interp1d(FaCO,e)
g = interpolate.interp1d(FaCO,Y)
if interpolation == "cubique" :
f = KroghInterpolator(FaCO,e)
g = KroghInterpolator(FaCO,Y)
if interpolation == "cubique" :
f = interpolate.interp1d(FaCO,e,kind='cubic')
g = interpolate.interp1d(FaCO,Y,kind='cubic')
e=f(r)
y=g(r)
X=1-e*y
return float(e),float(X),float(y)
print (parametres(0.5,"lineaire"))