improve lab 51 script to provide more useful data

This commit is contained in:
dymik739 2023-04-02 18:10:49 +03:00
parent 27e706a757
commit 77a51eac70
1 changed files with 41 additions and 7 deletions

View File

@ -4,7 +4,7 @@ import os
# defining some constants
r = 3 # round to n digits
r = 32 # round to n digits
column_width = 11 # set column width of final table
# checking if the file is provided correctly
@ -144,10 +144,44 @@ sigma_beta2 = round(math.sqrt(avg(list(map(lambda x: x**2, list(zip(*required_da
sigma_beta3 = round(math.sqrt(avg(list(map(lambda x: x**2, list(zip(*required_data["2"]['stats']))[2]))) + avg(list(zip(*required_data["2"]['stats']))[2])**2), r)
sigma_beta4 = round(math.sqrt(avg(list(map(lambda x: x**2, list(zip(*required_data["2"]['stats']))[5]))) + avg(list(zip(*required_data["2"]['stats']))[5])**2), r)
sigma_t1 = round(math.sqrt(avg(list(map(lambda x: x**2, list(zip(*required_data["1"]['stats']))[1]))) + avg(list(zip(*required_data["1"]['stats']))[1])**2), r)
sigma_t2 = round(math.sqrt(avg(list(map(lambda x: x**2, list(zip(*required_data["1"]['stats']))[3]))) + avg(list(zip(*required_data["1"]['stats']))[3])**2), r)
sigma_t3 = round(math.sqrt(avg(list(map(lambda x: x**2, list(zip(*required_data["2"]['stats']))[1]))) + avg(list(zip(*required_data["2"]['stats']))[1])**2), r)
sigma_t4 = round(math.sqrt(avg(list(map(lambda x: x**2, list(zip(*required_data["2"]['stats']))[3]))) + avg(list(zip(*required_data["2"]['stats']))[3])**2), r)
sigma_M1 = round(math.sqrt(avg(list(map(lambda x: x**2, list(zip(*required_data["1"]['stats']))[0]))) + avg(list(zip(*required_data["1"]['stats']))[0])**2), r)
sigma_M2 = round(math.sqrt(avg(list(map(lambda x: x**2, list(zip(*required_data["1"]['stats']))[3]))) + avg(list(zip(*required_data["1"]['stats']))[3])**2), r)
sigma_M3 = round(math.sqrt(avg(list(map(lambda x: x**2, list(zip(*required_data["2"]['stats']))[0]))) + avg(list(zip(*required_data["2"]['stats']))[0])**2), r)
sigma_M4 = round(math.sqrt(avg(list(map(lambda x: x**2, list(zip(*required_data["2"]['stats']))[3]))) + avg(list(zip(*required_data["2"]['stats']))[3])**2), r)
print("σβ (1-4) (DO NOT USE):", sigma_beta1/avg(list(zip(*required_data["1"]['stats']))[2]), sigma_beta2/avg(list(zip(*required_data["1"]['stats']))[5]), sigma_beta3/avg(list(zip(*required_data["2"]['stats']))[2]), sigma_beta4/avg(list(zip(*required_data["2"]['stats']))[5]))
print("σt (1-4) (DO NOT USE):", sigma_t1/avg(list(zip(*required_data["1"]['stats']))[1]), sigma_t2/avg(list(zip(*required_data["1"]['stats']))[3]), sigma_t3/avg(list(zip(*required_data["2"]['stats']))[1]), sigma_t4/avg(list(zip(*required_data["2"]['stats']))[3]))
#print("σβ (1-4) (DO NOT USE):", sigma_beta1/avg(list(zip(*required_data["1"]['stats']))[2]), sigma_beta2/avg(list(zip(*required_data["1"]['stats']))[5]), sigma_beta3/avg(list(zip(*required_data["2"]['stats']))[2]), sigma_beta4/avg(list(zip(*required_data["2"]['stats']))[5]))
#print("σM (1-4) (DO NOT USE):", sigma_t1/avg(list(zip(*required_data["1"]['stats']))[0]), sigma_t2/avg(list(zip(*required_data["1"]['stats']))[3]), sigma_t3/avg(list(zip(*required_data["2"]['stats']))[0]), sigma_t4/avg(list(zip(*required_data["2"]['stats']))[3]))
print("σβ:", avg([math.sqrt(sigma_beta1), math.sqrt(sigma_beta2), math.sqrt(sigma_beta3), math.sqrt(sigma_beta4)]))
print("σM:", avg([math.sqrt(sigma_M1), math.sqrt(sigma_M2), math.sqrt(sigma_M3), math.sqrt(sigma_M4)]))
print(required_data)
'''
for t in required_data:
I_values_r1 = [(i[0] / i[1]) for i in zip(list(zip(*required_data[t]['stats']))[0], list(zip(*required_data[t]['stats']))[2])]
Mt1 = required_data[t]['stats'][I_values_r1.index(min(I_values_r1))][0] - (min(I_values_r1) * required_data[t]['stats'][I_values_r1.index(min(I_values_r1))][2])
print(f"Таблиця {t}, стовпець 1: Imin = {required_data[t]['stats'][I_values_r1.index(min(I_values_r1))][0]} / {required_data[t]['stats'][I_values_r1.index(min(I_values_r1))][2]} = {round(min(I_values_r1), r)}; Mт = {required_data[t]['stats'][I_values_r1.index(min(I_values_r1))][0]} - {min(I_values_r1)}*{required_data[t]['stats'][I_values_r1.index(min(I_values_r1))][2]} = {round(Mt1, r)} (за мінімальний узято рядок {I_values_r1.index(min(I_values_r1))})")
I_values_r2 = [(i[0] / i[1]) for i in zip(list(zip(*required_data[t]['stats']))[3], list(zip(*required_data[t]['stats']))[5])]
Mt2 = required_data[t]['stats'][I_values_r2.index(min(I_values_r2))][3] - (min(I_values_r2) * required_data[t]['stats'][I_values_r2.index(min(I_values_r2))][5])
print(f"Таблиця {t}, стовпець 2: Imin = {round(min(I_values_r2), r)}; Mт = {round(Mt2, r)}")
#i_min_2 = min([(i[0] / i[1]) for i in zip(list(zip(*required_data[t]['stats']))[3], list(zip(*required_data[t]['stats']))[5])])
#print(f"Imin for {t}-2: {round(i_min_2, r)}")
'''
for t in required_data:
I_values_r1 = []
M_and_beta = list(zip(list(zip(*required_data[t]['stats']))[0], list(zip(*required_data[t]['stats']))[2]))
print(M_and_beta)
for i in range(5):
print((M_and_beta[i+1][0] - M_and_beta[i][0]) / (M_and_beta[i+1][1] - M_and_beta[i][1]))
I_values_r1.append((M_and_beta[i+1][0] - M_and_beta[i][0]) / (M_and_beta[i+1][1] - M_and_beta[i][1]))
print(f"Таблиця {t}, стовпець 1: Imin = {min(I_values_r1)}; Mт = {M_and_beta[I_values_r1.index(min(I_values_r1))][0] - min(I_values_r1)*M_and_beta[I_values_r1.index(min(I_values_r1))][1]}")
I_values_r2 = []
M_and_beta = list(zip(list(zip(*required_data[t]['stats']))[3], list(zip(*required_data[t]['stats']))[5]))
for i in range(5):
print((M_and_beta[i+1][0] - M_and_beta[i][0]) / (M_and_beta[i+1][1] - M_and_beta[i][1]))
I_values_r2.append((M_and_beta[i+1][0] - M_and_beta[i][0]) / (M_and_beta[i+1][1] - M_and_beta[i][1]))
print(f"Таблиця {t}, стовпець 2: Imin = {min(I_values_r2)}; Mт = {M_and_beta[I_values_r2.index(min(I_values_r2))][0] - min(I_values_r2)*M_and_beta[I_values_r2.index(min(I_values_r2))][1]}")