NuMRI/kalman/compute_errors_kalman.py
2021-02-09 10:35:48 -03:00

51 lines
1.9 KiB
Python

import numpy as np
vref = [10, 250, 250, 250, 30]
#case 2
v_no = [9.37, 246.18, 251.68, 252.37, 29.79]
v_70 = [18.21, 217.19, 198, 227.76, 29]
vnew_70 = [9.42, 244.59, 247.93, 246.89, 29.79]
v_50 = [64.05, 205.9, 195.55, 246.47, 22.58]
vnew_50 = [ 9.46 ,244.47 ,248.09 ,244.69 ,29.76]
#acse 1
v_no_case1 = [ 9.58 , 246.97, 252.41 , 252.47 , 29.81]
v_70_case1 = [17.93, 215.25, 193.09, 226.87, 29.02]
v_50_case1 = [64.59, 207.49, 193.08, 248.51, 22.63]
vnew_70_case1 = [ 9.51 , 237.32, 238.26, 234.33, 29.79]
vnew_50_case1 = [ 9.48, 237.58, 239.46, 231.55, 29.76]
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)
eps_ref = compute_relative_error(v_no,vref)
eps_70 = compute_relative_error(v_70,vref)
eps_new70 = compute_relative_error(vnew_70,vref)
eps_50 = compute_relative_error(v_50,vref)
eps_new50 = compute_relative_error(vnew_50,vref)
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)
print('reference error = {e}'.format(e=np.round(100*eps_ref,2)))
print('venc 70% error = {e}'.format(e=np.round(100*eps_70,2)))
print('odv venc 70% error = {e}'.format(e=np.round(100*eps_new70,2)))
print('venc 50% error = {e}'.format(e=np.round(100*eps_50,2)))
print('odv venc 50% error = {e}'.format(e=np.round(100*eps_new50,2)))
print('-------------------')
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)))
print('odv venc 50% error = {e}'.format(e=np.round(100*eps_new50_case1,2)))