-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparticle_tracks.py
58 lines (49 loc) · 2.33 KB
/
particle_tracks.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
import matplotlib.pyplot as plt
import bathymetry
import config_sedimentdrift
from circle_of_distance import Circle_of_distance
import config_plot
class Tracks():
def __init__(self, lons, lats, z, time, output_filename):
self.z = z
self.lons = lons
self.lats = lats
self.time = time
self.output_filename = output_filename
self.config = config_plot.ConfigPlot()
self.config_sedimentdrift = config_sedimentdrift.MartiniConf()
bath = bathymetry.Bathymetry(self.config)
bath.add_bathymetry_from_etopo1()
def plot_tracks(self):
for traj_index in range(len(self.lons[:, 0])):
print("[Particle_tracks] Plotting trajectory {}".format(traj_index))
x=self.lons[traj_index, (self.lons[traj_index, :] < 1e30)]
y = self.lats[traj_index, (self.lats[traj_index, :] < 1e30)]
z = self.z[traj_index, (self.lats[traj_index, :] < 1e30)]
self.config.ax.plot(x,
y,
c='k',
alpha=0.2,
linewidth=0.2)
if len(z > 0):
# scaled_z = (z - z.min()) / z.ptp()
colors = plt.get_cmap('PiYG')
print("[Particle_tracks] depth variation {} to {}".format(z.min(),z.max()))
cbar = self.config.ax.scatter(x, y, marker=None,
facecolors=colors,
s=2,
alpha=0.8,
linewidth=0.3)
# Seed area drawn as a circle
cs = Circle_of_distance()
X, Y = cs.create_circle_with_radius(self.config_sedimentdrift.st_lats[0],
self.config_sedimentdrift.st_lons[0],
self.config_sedimentdrift.release_radius / 1000.)
self.config.ax.plot(X, Y, marker=None, color='y', linewidth=0.9)
self.config.ax.plot(self.config_sedimentdrift.st_lons[0],
self.config_sedimentdrift.st_lats[0],
marker='D',
color='r',
markersize=0.4)
plt.colorbar(cbar)
plt.savefig(self.output_filename, format='png', dpi=300)