-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmean_orientation_error.py
109 lines (69 loc) · 2.59 KB
/
mean_orientation_error.py
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# -*- coding: utf-8 -*-
"""
Created on Tue Oct 4 14:06:51 2022
Script that calculates the mean orientation error
@author: binda
"""
#take a txt file from a directory and read the elements in the file
import os
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import math
def listToStringWithoutBrackets(list1):
return str(list1).replace('[','').replace(']','')
def orientation_error():
#take a txt file from a C:\Users\binda\Downloads\check\azimuth_list az_list1
#and read the elements in the file
with open(r'C:\\Users\\binda\\Downloads\\check\\azimuth_list\\az_list1.txt') as f:
az_list1 = f.read().splitlines()
#take a txt file from a C:\Users\binda\Downloads\check\azimuth_list az_list2
#and read the elements in the file
with open(r'C:\\Users\\binda\\Downloads\\check\\azimuth_list\\az_list2.txt') as f:
az_list2 = f.read().splitlines()
#convert az_list1 to pandas series
az_list1 = pd.Series(az_list1)
#convert az_list2 to pandas series
az_list2 = pd.Series(az_list2)
#take all the each elements from the 1st column
az_list1 = az_list1[0]
az_list2=az_list2[0]
az_list1 = listToStringWithoutBrackets(az_list1)
az_list2 = listToStringWithoutBrackets(az_list2)
az_list1 = az_list1.split(",")
az_list2 = az_list2.split(",")
az_list1 = [float(i) for i in az_list1]
az_list2 = [float(i) for i in az_list2]
list_a=[]
list_b=[]
for i in range(len(az_list1)):
if (az_list1[i]-az_list2[i])<200 and (az_list1[i]-az_list2[i])>-200:
list_a.append(az_list1[i])
list_b.append(az_list2[i])
#make a correlation plot with outliers
plt.scatter(list_a, list_b, color='blue', marker='o', s=5)
plt.xlabel('azimuth_list1')
plt.ylabel('azimuth_list2')
plt.title('Correlation plot with outliers')
plt.show()
#save the plot
plt.savefig('C:\\Users\\binda\\Downloads\\check\\azimuth_list\\correlation_plot_with_outliers.png')
corr = np.corrcoef(list_a, list_b)[0,1]
print(corr)
list3 = []
for i in range(len(az_list1)):
if (az_list1[i]-az_list2[i])<150 and (az_list1[i]-az_list2[i])>-150:
list3.append((az_list1[i]-az_list2[i])**2)
else:
pass
#find the sum of the list3
sum(list3)
#find the mean of the list3
sum(list3)/len(list3)
#find the square root of the mean of the list3
return math.sqrt(sum(list3)/len(list3))
#find the standard deviation of the list3
#import statistics
#statistics.stdev(list3)
#