-
Notifications
You must be signed in to change notification settings - Fork 7
/
coef
executable file
·53 lines (50 loc) · 1.35 KB
/
coef
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
#!/usr/bin/python3
import pickle
import sys
try:
file = open("coeficients.dat", "rb")
a = pickle.load(file)
except FileNotFoundError:
a = {0: {}, 1: {}, 2: {}, 3: {}}
except UnicodeDecodeError:
a = pickle.load(file, encoding='latin1')
try:
if "-r" in sys.argv:
a[int(sys.argv[-2])].pop(int(sys.argv[-1]))
if "-i" in sys.argv:
a[int(sys.argv[-3])][int(sys.argv[-2])] = float(sys.argv[-1])
except KeyError:
a[int(sys.argv[-3])] = {}
print("DeltaT:\t\t0:\t\t1:\t\t2:\t\t3:")
max_index = 1
min_index = 0
for each in (a[0], a[1], a[2], a[3]):
try:
tmp = list(each.keys())
tmp.append(max_index)
tmp.append(min_index)
max_index = max(tmp)
min_index = min(tmp)
except IOError:
pass
for i in range(min_index, max_index + 1):
try:
print(i, "C\t\t", end="")
print(round(float(a[0][i]), 2), " \t\t", end=' ')
except:
print("\t\t", end=' ')
try:
print(round(float(a[1][i]), 2), "\t\t", end=' ')
except:
print("\t\t", end=' ')
try:
print(round(float(a[2][i]), 2), "\t\t", end=' ')
except:
print("\t\t", end=' ')
try:
print(round(float(a[3][i]), 2), "\t\t")
except:
print("\t\t")
# WRITE TO FILE
if "-r" in sys.argv or "-i" in sys.argv:
pickle.dump(a, open("coeficients.dat", "wb"))