49 lines
1.5 KiB
Plaintext
49 lines
1.5 KiB
Plaintext
Columns delimited with ;
|
|
First column is altitude
|
|
Second column is FF per engine in kg/hr
|
|
Column contains values for weights ranging from 140t to 290t in 10t increments
|
|
Delimited with ,
|
|
Third column is IAS
|
|
If single value, apply to all weights
|
|
If multiple values, apply to respective weights (delimited with ,)
|
|
Fourth column is MACH
|
|
If single value, apply to all weights
|
|
If multiple values, apply to respective weights (delimited with ,)
|
|
|
|
|
|
Parser in Python
|
|
split() -> split string into array at given delimiter
|
|
strip() -> remove whitespaces at start and end of string
|
|
|
|
|
|
matrix = {}
|
|
|
|
def parseFile(file):
|
|
weights = [140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290]
|
|
matrix = {}
|
|
file = open(file, 'r')
|
|
lines = file.readlines()
|
|
|
|
count = 0
|
|
for line in lines:
|
|
count += 1
|
|
if count == 1:
|
|
continue
|
|
fields = line.split(";")
|
|
alt = int(fields[0]) / 100
|
|
ff = [int(item.strip()) for item in fields[1].split(",")]
|
|
ias = [int(item.strip()) for item in fields[2].split(",")]
|
|
mach = [float(item.strip()) for item in fields[3].split(",")]
|
|
|
|
inner = {}
|
|
for i in range(len(ff)):
|
|
_ias = ias[i] if len(ias) > 1 else ias[0]
|
|
_mach = mach[i] if len(mach) > 1 else mach[0]
|
|
inner[weights[i]] = (ff[i], _ias, _mach)
|
|
matrix[alt] = inner
|
|
return matrix
|
|
|
|
matrix["LRC"] = parseFile("LRC.data")
|
|
matrix[82] = parseFile(".82.data")
|
|
matrix[83] = parseFile(".83.data")
|
|
matrix[84] = parseFile(".84.data") |