Skip to content

Commit f8ce11c

Browse files
committed
[run-ex] Providing convex_hull=True to plot method will now plot a convex hull around final positions
1 parent d81f90b commit f8ce11c

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

opendrift/models/basemodel/__init__.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3342,6 +3342,7 @@ def _get_comparison_xy_for_plots(self, compare):
33423342
latmax = np.maximum(latmax, other.result.lat.max())
33433343

33443344
# Find map coordinates of comparison simulations
3345+
cd['dataset'] = other.result
33453346
cd['x_other'] = other.result.lon.copy()
33463347
cd['y_other'] = other.result.lat.copy()
33473348
cd['x_other_deactive'], cd['y_other_deactive'] = \
@@ -3383,6 +3384,7 @@ def plot(self,
33833384
show_elements=True,
33843385
show_trajectories=True,
33853386
show_initial=True,
3387+
convex_hull=False,
33863388
density_pixelsize_m=1000,
33873389
lalpha=None,
33883390
bgalpha=.8,
@@ -3523,6 +3525,8 @@ def plot(self,
35233525
label='_nolegend_',
35243526
linewidth=linewidth,
35253527
transform=self.crs_lonlat)
3528+
if convex_hull is True:
3529+
self.result.isel(time=-1).traj.plot.convex_hull(color=linecolor)
35263530
else:
35273531
with np.errstate(invalid="ignore"):
35283532
ax.plot(x,
@@ -3531,6 +3535,8 @@ def plot(self,
35313535
alpha=alpha,
35323536
linewidth=linewidth,
35333537
transform=self.crs_lonlat)
3538+
if convex_hull is True:
3539+
self.result.isel(time=-1).traj.plot.convex_hull(color=linecolor)
35343540
else:
35353541
#colorbar = True
35363542
# Color lines according to given parameter
@@ -3583,7 +3589,7 @@ def plot(self,
35833589
else:
35843590
label_initial = None
35853591
label_active = None
3586-
color_initial = 'gray'
3592+
color_initial = self.status_colors['initial']
35873593
color_active = 'gray'
35883594
if show_elements is True:
35893595
if show_initial is True:
@@ -3685,6 +3691,8 @@ def plot(self,
36853691
linewidths=.2,
36863692
color=self.plot_comparison_colors[i + 1],
36873693
transform=self.crs_lonlat)
3694+
if convex_hull is True:
3695+
c['dataset'].isel(time=-1).traj.plot.convex_hull(color=self.plot_comparison_colors[i + 1])
36883696

36893697
background_zorder = kwargs.pop('background_zorder', 0)
36903698
if background is not None:

0 commit comments

Comments
 (0)