-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathheat_map1.py
48 lines (34 loc) · 1.01 KB
/
heat_map1.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
import numpy as np
import matplotlib.pyplot as plt
import json
data_file = 'clean_data/combined_inspection_data.json'
with open(data_file, 'r') as f:
data = dict(json.load(f))
lats = []
longs = []
weights = []
# weight data points based on their score
for d in data.values():
if len(d['scores']) >= 5:
lats.append(d['lat'])
longs.append(d['long'])
w = (100 - np.mean([s[2] for s in d['scores']]))**2
weights.append(w)
lat_res = 0.02
long_res = 0.02
lat_mean = np.mean(lats)
long_mean = np.mean(longs)
lat_std = np.std(lats)
long_std = np.std(longs)
lat_limits = [lat_mean - 0.1*lat_std, lat_mean + 0.1*lat_std]
long_limits = [long_mean - 0.1*long_std, long_mean + 0.05*long_std]
H, x_edges, y_edges = np.histogram2d(x=lats, y=longs, bins=500, range=[lat_limits, long_limits], normed=True, weights=weights)
X, Y = np.meshgrid(x_edges, y_edges)
fig = plt.figure()
ax = fig.add_subplot(111)
<<<<<<< HEAD
plt.pcolormesh(X, Y, H, vmin=0)
=======
plt.pcolormesh(X, Y, H)
>>>>>>> origin/Mkkeffeler1
plt.show()