-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIntrepolation.py
68 lines (50 loc) · 1.88 KB
/
Intrepolation.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
import json
import pandas as pd
from sklearn.linear_model import LinearRegression
from sklearn.metrics import r2_score
import matplotlib.pyplot as plt
from scipy.interpolate import interp1d
import numpy as np
from scipy.interpolate import griddata
#Regreasaion Model For Fuel Flow
#4D Function For fuleFLow
#Speed Intervall
def LoadData():
#LOAD DATA
with open("data/ac_poor_1.bsad", "r") as fin:
ac_data = json.loads(fin.read())
tables = ac_data["tables"]
dataframes = []
for table in tables:
if table["header"]["flightphase"] == "cruise":
cols = table["header"]["variables"]
data = table["table"]
dataframes.append(pd.DataFrame(data, columns=cols))
#Merge All data Frames
print(len(dataframes))
mesureRun = dataframes[1]
variables = ["DISA","ALTITUDE","MASS","TAS"]
predictor = ["FUELFLOW"]
X = pd.DataFrame(mesureRun.get(variables), columns=variables)
Y = pd.DataFrame(mesureRun.get(predictor), columns=predictor)
return(X,Y)
def CleanData(data):
print("cleaning Data")
def Intepolation(wantedPoint,dataType):
[X,Y] = LoadData()
variables = ['DISA','ALTITUDE','MASS','TAS']
predictor = ['FUELFLOW']
dataPointCoordinates = X.to_numpy()
dataPointValues = Y.to_numpy()
#Make GRid for all point that want to be interpolated
#grid_Disa, grid_ALTITUDE, grid_MASS, grid_TAS= np.mgrid[0:1000:10j, 0:1000:10j, 0:1000:10j, 0:1000:10j]
interpolatePoints = np.array([0,0,0,0])
#grid_FUELFLOW = griddata(dataPointCoordinates, dataPointValues, (grid_Disa, grid_ALTITUDE, grid_MASS, grid_TAS), method='nearest')
grid_FUELFLOW = griddata(dataPointCoordinates, dataPointValues, interpolatePoints, method='nearest')
print(grid_FUELFLOW)
def main():
dataSet = "Por"
wantedPoint = [0,0,0,0]
Intepolation(wantedPoint,dataSet)
if __name__== "__main__":
main()