@@ -621,15 +621,18 @@ def store_previous_variables(self):
621
621
622
622
def interact_with_coastline (self , final = False ):
623
623
"""Coastline interaction according to configuration setting"""
624
+
624
625
if self .num_elements_active () == 0 :
625
626
return
626
- i = self .get_config ('general:coastline_action' )
627
- coastline_approximation_precision = self .get_config ('general:coastline_approximation_precision' )
628
- if not hasattr (self , 'environment' ) or not hasattr (
629
- self .environment , 'land_binary_mask' ):
627
+ if not hasattr (self , 'environment' ) or not hasattr (self .environment , 'land_binary_mask' ):
630
628
return
629
+
630
+ i = self .get_config ('general:coastline_action' )
631
631
if i == 'none' : # Do nothing
632
632
return
633
+
634
+ coastline_approximation_precision = self .get_config ('general:coastline_approximation_precision' )
635
+
633
636
if final is True : # Get land_binary_mask for final location
634
637
en , en_prof , missing = \
635
638
self .env .get_environment (['land_binary_mask' ],
@@ -706,15 +709,17 @@ def interact_with_coastline(self, final=False):
706
709
707
710
def interact_with_seafloor (self ):
708
711
"""Seafloor interaction according to configuration setting"""
712
+
709
713
if self .num_elements_active () == 0 :
710
714
return
711
715
if 'sea_floor_depth_below_sea_level' not in self .env .priority_list :
712
716
return
713
717
714
- # The shape of these is different than the original arrays
715
- # because it is for active drifters
716
- sea_floor_depth = self .sea_floor_depth ()
717
- sea_surface_height = self .sea_surface_height ()
718
+ sea_floor_depth = self .environment .sea_floor_depth_below_sea_level
719
+ if 'sea_surface_height' in self .required_variables :
720
+ sea_surface_height = self .environment .sea_surface_height
721
+ else :
722
+ sea_surface_height = 0
718
723
719
724
# Check if any elements are below sea floor
720
725
# But remember that the water column is the sea floor depth + sea surface height
@@ -2756,9 +2761,9 @@ def plot_timestep(i):
2756
2761
2757
2762
if drifter is not None :
2758
2763
for drnum , dr in enumerate (drifter ):
2759
- drifter_pos [drnum ].set_offsets (np .c_ [dr ['x ' ][i ],
2760
- dr ['y ' ][i ]])
2761
- drifter_line [drnum ].set_data (dr ['x ' ][0 :i + 1 ], dr ['y ' ][0 :i + 1 ])
2764
+ drifter_pos [drnum ].set_offsets (np .c_ [dr ['lon ' ][i ],
2765
+ dr ['lat ' ][i ]])
2766
+ drifter_line [drnum ].set_data (dr ['lon ' ][0 :i + 1 ], dr ['lat ' ][0 :i + 1 ])
2762
2767
ret .append (drifter_line [drnum ])
2763
2768
ret .append (drifter_pos [drnum ])
2764
2769
@@ -2982,12 +2987,12 @@ def plot_timestep(i):
2982
2987
sts = (self .result .time - self .result .time [0 ]) / np .timedelta64 (1 , 's' )
2983
2988
dr_times = np .array (dr ['time' ], dtype = self .result .time .dtype )
2984
2989
dts = (dr_times - dr_times [0 ]) / np .timedelta64 (1 , 's' )
2985
- dr ['x ' ] = np .interp (sts , dts , dr ['lon' ])
2986
- dr ['y ' ] = np .interp (sts , dts , dr ['lat' ])
2987
- dr ['x ' ][sts < dts [0 ]] = np .nan
2988
- dr ['x ' ][sts > dts [- 1 ]] = np .nan
2989
- dr ['y ' ][sts < dts [0 ]] = np .nan
2990
- dr ['y ' ][sts > dts [- 1 ]] = np .nan
2990
+ dr ['lon ' ] = np .interp (sts , dts , dr ['lon' ])
2991
+ dr ['lat ' ] = np .interp (sts , dts , dr ['lat' ])
2992
+ dr ['lon ' ][sts < dts [0 ]] = np .nan
2993
+ dr ['lon ' ][sts > dts [- 1 ]] = np .nan
2994
+ dr ['lat ' ][sts < dts [0 ]] = np .nan
2995
+ dr ['lat ' ][sts > dts [- 1 ]] = np .nan
2991
2996
dlabel = dr ['label' ] if 'label' in dr else 'Drifter'
2992
2997
dcolor = dr ['color' ] if 'color' in dr else 'r'
2993
2998
dlinewidth = dr ['linewidth' ] if 'linewidth' in dr else 2
@@ -3764,22 +3769,22 @@ def _plot_drifter(self, ax, gcrs, drifter):
3764
3769
'''Plot provided trajectory along with simulated'''
3765
3770
time = np .array (drifter ['time' ], dtype = self .result .time .dtype )
3766
3771
i = np .where ((time >= self .result .time [0 ].values ) & (time <= self .result .time [- 1 ].values ))[0 ]
3767
- x , y = (np .atleast_1d (drifter ['lon' ])[i ],
3772
+ lon , lat = (np .atleast_1d (drifter ['lon' ])[i ],
3768
3773
np .atleast_1d (drifter ['lat' ])[i ])
3769
3774
dlabel = drifter ['label' ] if 'label' in drifter else 'Drifter'
3770
3775
dcolor = drifter ['color' ] if 'color' in drifter else 'r'
3771
3776
dlinewidth = drifter ['linewidth' ] if 'linewidth' in drifter else 2
3772
3777
dzorder = drifter ['zorder' ] if 'zorder' in drifter else 10
3773
3778
3774
- ax .plot (x ,
3775
- y ,
3779
+ ax .plot (lon ,
3780
+ lat ,
3776
3781
linewidth = dlinewidth ,
3777
3782
color = dcolor ,
3778
3783
transform = self .crs_lonlat ,
3779
3784
label = dlabel ,
3780
3785
zorder = dzorder )
3781
- ax .plot (x [0 ], y [0 ], 'ok' , transform = self .crs_lonlat )
3782
- ax .plot (x [- 1 ], y [- 1 ], 'xk' , transform = self .crs_lonlat )
3786
+ ax .plot (lon [0 ], lat [0 ], 'ok' , transform = self .crs_lonlat )
3787
+ ax .plot (lon [- 1 ], lat [- 1 ], 'xk' , transform = self .crs_lonlat )
3783
3788
3784
3789
def get_map_background (self , ax , background , crs , time = None ):
3785
3790
# Get background field for plotting on map or animation
0 commit comments