Skip to content

Commit

Permalink
Add dry gauge plotting
Browse files Browse the repository at this point in the history
  • Loading branch information
mandli committed May 22, 2024
1 parent 1bd6508 commit c678e33
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
4 changes: 4 additions & 0 deletions examples/storm-surge/ike/setplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ def friction_after_axes(cd):

plotitem = plotaxes.new_plotitem(plot_type='1d_plot')
plotitem.plot_var = surgeplot.gauge_surface
# Plot red area if gauge is dry
plotitem = plotaxes.new_plotitem(plot_type='1d_plot')
plotitem.plot_var = surgeplot.gauge_dry_regions
plotitem.kwargs = {"color":'lightcoral', "linewidth":5}

# Gauge Location Plot
def gauge_location_afteraxes(cd):
Expand Down
4 changes: 4 additions & 0 deletions examples/storm-surge/isaac/setplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@ def plot_observed(current_data):

plotitem = plotaxes.new_plotitem(plot_type='1d_plot')
plotitem.plot_var = surgeplot.gauge_surface
# Plot red area if gauge is dry
plotitem = plotaxes.new_plotitem(plot_type='1d_plot')
plotitem.plot_var = surgeplot.gauge_dry_regions
plotitem.kwargs = {"color":'lightcoral', "linewidth":5}

# Gauge Location Plot
def gauge_location_afteraxes(cd):
Expand Down
9 changes: 7 additions & 2 deletions src/python/geoclaw/surge/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,15 @@ def gauge_locations(current_data, gaugenos='all'):
add_labels=True, xoffset=0.02,
yoffset=0.02)

def gauge_dry_regions(cd, dry_tolerance=1e-16):
"""Masked array of zeros where gauge is dry."""
return np.ma.masked_where(np.abs(cd.gaugesoln.q[0, :]) > dry_tolerance,
np.zeros(cd.gaugesoln.q[0,:].shape))

def gauge_surface(cd):
def gauge_surface(cd, dry_tolerance=1e-16):
"""Sea surface at gauge masked when dry."""
return np.ma.masked_where(cd.gaugesoln.q[0, :] < 0.0, cd.gaugesoln.q[3, :])
return np.ma.masked_where(np.abs(cd.gaugesoln.q[0, :]) < dry_tolerance,
cd.gaugesoln.q[3, :])


def plot_landfall_gauge(gauge, axes, landfall=0.0, style='b', kwargs={}):
Expand Down

0 comments on commit c678e33

Please sign in to comment.