NuMRI/kalman/compute_errors_kalman.py

72 lines
2.1 KiB
Python
Raw Normal View History

2021-02-09 14:35:48 +01:00
import numpy as np
def compute_relative_error(vcur,vref):
eps = 0
for i in range(len(vref)):
eps += ((vcur[i] - vref[i])/vref[i])**2
return np.sqrt(eps)
2021-02-10 20:46:37 +01:00
vref = [10, 250, 250, 250, 30]
#case 1
v_no_case1 = [ 10.05 , 248.34, 250.52 , 254.43 , 29.82]
v_70_case1 = [20.38, 211.19, 189.01, 207.09, 28.78]
v_50_case1 = [90.45, 240.98, 241.03, 316.89, 21.27]
vnew_70_case1 = [ 10.26 , 250.73, 252.78, 256.62 , 29.77]
vnew_50_case1 = [ 10.27 , 248.41 ,254.71 ,253.01 , 29.82]
#case 2
v_no_case2 = [ 9.77, 249.7 , 251.94, 254.91 , 29.82]
v_70_case2 = [ 20.7 , 214.77 ,196.47 ,209.31 , 28.76]
v_50_case2 = [ 88.4, 236.73 ,240.39 ,312.85, 21.22]
vnew_70_case2 = [ 10 , 250.24 ,252.05 ,254.98 , 29.76]
vnew_50_case2 = [ 9.92 ,247.61 ,253.35 ,250.64 ,29.81]
2021-02-09 14:35:48 +01:00
eps_ref_case1 = compute_relative_error(v_no_case1,vref)
eps_70_case1 = compute_relative_error(v_70_case1,vref)
eps_new70_case1 = compute_relative_error(vnew_70_case1,vref)
eps_50_case1 = compute_relative_error(v_50_case1,vref)
eps_new50_case1 = compute_relative_error(vnew_50_case1,vref)
2021-02-10 20:46:37 +01:00
eps_ref_case2 = compute_relative_error(v_no_case2,vref)
eps_70_case2 = compute_relative_error(v_70_case2,vref)
eps_new70_case2 = compute_relative_error(vnew_70_case2,vref)
eps_50_case2 = compute_relative_error(v_50_case2,vref)
eps_new50_case2 = compute_relative_error(vnew_50_case2,vref)
print('--------- CASE 1 ---------')
2021-02-09 14:35:48 +01:00
print('reference error = {e}'.format(e=np.round(100*eps_ref_case1,2)))
print('venc 70% error = {e}'.format(e=np.round(100*eps_70_case1,2)))
print('odv venc 70% error = {e}'.format(e=np.round(100*eps_new70_case1,2)))
print('venc 50% error = {e}'.format(e=np.round(100*eps_50_case1,2)))
2021-02-10 20:46:37 +01:00
print('odv venc 50% error = {e}'.format(e=np.round(100*eps_new50_case1,2)))
print('--------- CASE 2 ---------')
print('reference error = {e}'.format(e=np.round(100*eps_ref_case2,2)))
print('venc 70% error = {e}'.format(e=np.round(100*eps_70_case2,2)))
print('odv venc 70% error = {e}'.format(e=np.round(100*eps_new70_case2,2)))
print('venc 50% error = {e}'.format(e=np.round(100*eps_50_case2,2)))
print('odv venc 50% error = {e}'.format(e=np.round(100*eps_new50_case2,2)))