sandplover.mobility.channel_presence¶
- sandplover.mobility.channel_presence(chmap)¶
Calculate the normalized channel presence at each pixel location.
Measure the normalized fraction of time a given pixel is channelized, based on method in Liang et al 2016 [1]. This requires providing a 3-D input channel map (t-x-y).
- Parameters:
chmap (ndarray) – A t-x-y shaped array with binary channel maps
- Returns:
channel_presence – A x-y shaped array with the normalized channel presence values.
- Return type:
ndarray
Examples
>>> import matplotlib.pyplot as plt >>> import numpy as np >>> from sandplover.mask import ChannelMask >>> from sandplover.mobility import channel_presence >>> from sandplover.plot import append_colorbar >>> from sandplover.sample_data.sample_data import golf
>>> golfcube = golf() >>> x, y = np.shape(golfcube["eta"][-1, ...])
Calculate channel masks/presence over final 5 timesteps
>>> chmap = np.zeros((5, x, y)) # initialize channel map >>> for i in np.arange(-5, 0): ... chmap[i, ...] = ChannelMask( ... golfcube["eta"][i, ...], ... golfcube["velocity"][i, ...], ... elevation_threshold=0, ... flow_threshold=0, ... ).mask ... >>> >>> fig, ax = plt.subplots(1, 2) >>> golfcube.quick_show("eta", ax=ax[0]) # final delta >>> p = ax[1].imshow(channel_presence(chmap), cmap="Blues") >>> _ = append_colorbar(p, ax[1], label="Channelized Time")
(
Source code,png,hires.png)