-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsrs-iri-correlation.py
69 lines (45 loc) · 2.07 KB
/
srs-iri-correlation.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
import datetime
import time
import geopy.distance
import numpy as np
import pandas as pd
AGGREGATION_RADIUS = 20
def get_IRI(data):
return np.average(data.values[3:5])
def get_geographical_distance(lat1, long1, lat2, long2):
coords_1 = (lat1, long1)
coords_2 = (lat2, long2)
return geopy.distance.vincenty(coords_1, coords_2).m
def get_PPE_aggregation(lat, long, data):
ppe = []
for index, point in data.iterrows():
distance = get_geographical_distance(lat, long, point[2], point[1])
if distance < AGGREGATION_RADIUS:
#print("distance {0}".format(distance))
ppe.append(point[0])
ppe_avg = np.average(ppe)
return ppe_avg
ppe_data = pd.read_csv("data/denmark-srs-data.csv", delimiter=";")
iri_data = pd.read_csv("data/denmark-iri-data.csv", delimiter=";")
iri_data = iri_data.filter(items=['Distance [m]', 'Latitude', 'Longitude', 'IRI(1)', 'IRI(17)'])
iri_data['AVG IRI'] = iri_data.apply(lambda row: (row['IRI(1)'] + row['IRI(17)'])/2, axis=1)
iri_data.to_csv('data/denmark-avgiri-data.csv', sep=';', encoding='utf-8')
print(ppe_data.head())
print(iri_data.head())
output = pd.DataFrame(columns=['distance', 'latitude', 'longitude', 'iri', 'ppe'])
start = time.time()
for index, row in iri_data.iterrows():
ppe = get_PPE_aggregation(row[1], row[2], ppe_data)
output = output.append({'distance': row[0], 'latitude': row[1], 'longitude': row[2], 'iri': row[5], 'ppe': ppe},
ignore_index=True)
# ETA stats
end = time.time()
elapsed_time = end - start
iteration = index + 1
seconds = (elapsed_time) * (len(iri_data) / iteration)
completion_percentage = (iteration * 100)/len(iri_data)
eta = str(datetime.timedelta(seconds=(seconds-elapsed_time)))
print("\r{3}/{4} Time for completion {0} - ETA: {1} - Completion {2:.2f}%".format(str(datetime.timedelta(seconds=seconds)), eta, completion_percentage, index, len(iri_data)), end='')
print('completed')
output.to_csv('data/srs-iri-data.csv', sep=';', encoding='utf-8')
print(np.corrcoef(output['iri'], output['ppe']))