-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmain_tri.py
77 lines (63 loc) · 1.91 KB
/
main_tri.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
import numpy as np
import matplotlib as mpl
import matplotlib.mlab as mlab
import matplotlib.pyplot as plt
import csv
import matplotlib.tri as tri
import math
'''
x = []
y = []
z = []
with open('data/grohn26082021_raw.csv', 'r') as csvfile:
plots = csv.reader(csvfile, delimiter=',')
for row in plots:
if 0.2 < float(row[2]) < 2.5:
x.append(float(row[4]))
y.append(float(row[3]))
z.append(float(row[2]))
'''
x = []
y = []
z = []
time = []
tidal_data = []
with open('data/tidal_data.csv', 'r') as csvfile:
plots = csv.reader(csvfile, delimiter=',')
for row in plots:
tidal_data.append([row[0], row[1]])
with open('data/grohn26082021_raw.csv', 'r') as csvfile:
plots = csv.reader(csvfile, delimiter=',')
for row in plots:
for tidal in tidal_data:
if tidal[0] == row[1][:-3] and 0.3 < float(row[2]) < 2:
# time.append(row[1][:-3])
x.append(float(row[4]))
y.append(float(row[3]))
z.append(4 - (float(tidal[1]) - float(row[2])))
break
print(z)
latmin = min(x)
latmax = max(x)
lngmin = min(y)
lngmax = max(y)
npts = 150
ngridx = 150
ngridy = 150
fig, ax = plt.subplots()
xi = np.linspace(latmin, latmax, ngridx)
yi = np.linspace(lngmin, lngmax, ngridy)
triang = tri.Triangulation(x, y)
interpolator = tri.LinearTriInterpolator(triang, z)
Xi, Yi = np.meshgrid(xi, yi)
zi = interpolator(Xi, Yi)
ax.contour(xi, yi, zi, levels=20, linewidths=0.2, colors='k')
cntr1 = ax.contourf(xi, yi, zi, levels=20, cmap="gist_rainbow") # RdBu_r
fig.colorbar(cntr1, ax=ax, orientation="horizontal").set_label("Tiefe in m")
ax.plot(x, y, 'ko', ms=0.5)
ax.set(xlim=(latmin, latmax), ylim=(lngmin, lngmax))
ax.set_title("Tiefenkarte Grohner Yachthafen")
ax.ticklabel_format(useOffset=False)
ax.set_aspect(1 / math.cos(math.radians(60.0)))
plt.savefig("depthmap.png", dpi=220)
plt.show()