Skip to content

Commit 01cfa3e

Browse files
authored
Merge pull request #11 from kthyng/add_plotting
added plotting code and made cmocean optional
2 parents 0ccc379 + 6d91379 commit 01cfa3e

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

particle_tracking_manager/__init__.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
"""Particle Tracking Manager."""
22

3-
import cmocean
4-
53
from .models.opendrift.model_opendrift import OpenDriftModel
64
from .the_manager import ParticleTrackingManager
7-
8-
9-
cmap = cmocean.tools.crop_by_percent(cmocean.cm.amp, 20, which="max", N=None)

particle_tracking_manager/plotting.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"""Some extra plotting code."""
2+
3+
import opendrift
4+
5+
6+
def plot_dest(o):
7+
"""This is copied from an opendrift example."""
8+
9+
import cmocean
10+
11+
cmap = cmocean.tools.crop_by_percent(cmocean.cm.amp, 20, which="max", N=None)
12+
13+
od = opendrift.open_xarray(o.outfile_name)
14+
density = od.get_histogram(pixelsize_m=5000).isel(time=-1).isel(origin_marker=0)
15+
density = density.where(density > 0)
16+
density = density / density.sum() * 100
17+
vmax = density.max()
18+
19+
return o.plot(
20+
background=density,
21+
clabel="Probability of final location [%]",
22+
markersize=0.5,
23+
lalpha=0.02,
24+
vmin=0,
25+
vmax=vmax,
26+
cmap=cmap,
27+
)

0 commit comments

Comments
 (0)