Functions#
The XBeach toolbox contains various functions. The functions are defined into the following topics:
- General
General functions, see General
- Grid
Functions related to the grid, see Grid
- xbeachtools
Tools to setup a model, see XBeachtools
- xb_analyse
Tools to analyse a model, see XBeachModelAnalysis
General#
Wave Functions#
- xbTools.general.wave_functions.dispersion()#
Computes the wave number given a radial frequeny and water depth
- wfloat
Radial frequency.
- dfloat
water depth.
- max_errorfloat, optional
maximum error. The default is 0.00001.
- gfloat, optional
gravitational acceleration.
- kfloat
wave number.
- xbTools.general.wave_functions.wavecelerity()#
Computes the group velocity and wave celerity ratio based on the wave period and water depth.
- Tpfloat
Peak period.
- dfloat
Water depth.
- gfloat, optional
gravitational acceleration. The default is 9.81.
- cgfloat
Group velocity.
- nfloat
celerity ratio.
- xbTools.general.wave_functions.directional_spread_kuik()#
Determine mean wave direction and directional spreading, Kuik et al. 1988 see SWAN user manual for definitions theta0 and dspr only for range [fmin,fmax]
- thetaarray
Array with the directions.
- eeTYPE
Array with the energy density.
- float
Directional spreading in degrees.
- xbTools.general.wave_functions.celerity_ratio_equals_09()#
Function to find water depth for which the n ration equal 0.9.
- Tpfloat
Peak period.
- d_startfloat
Water depth.
- dfloat
Depth.
- xbTools.general.wave_functions.offshore_depth()#
Compute required Offshore water depth to correctly force the waves
- Hm0float
Wave height.
- Tpfloat
Peak period.
- depth_offshore_profilefloat
Offshore depth of the profile.
- depth_boundary_conditionsfloat
Depth of the boundary conditions.
- d_startfloat
Required offshore water depth.
- slopefloat
Artificial slope.
- Hm0_shoalfloat
Wave height at the boundary.
Visualize mesh#
- xbTools.general.visualize_mesh.plot_mesh()#
Function to plot mesh based on meshgrid regular grid, option for thinning
- mesh_xarray
Array with x grid.
- mesh_yarray
Array with y grid.
thinning : integer to specify thinning of grid to plot. Default = 1 ax : specify ax to which the mesh should be added. Default = None, which makes a new figure **kwargs : kwargs to feed into the plot function (e.g. color, linewidth)
none.
- xbTools.general.visualize_mesh.write_mesh_to_shp()#
Function to write mesh to shapefile
- mesh_xarray
x-coordinates of the mesh
- mesh_yarray
y-coordinates of the mesh
- file_namestring
where to store the file
- modelnrfloat
which number to give to the lines
- EPSGint
optional CRS choice. The default is 32635.
None.
- xbTools.general.visualize_mesh.grid_parameter_to_shape()#
saves a parameter defined at grid points to a shapefile
- xgridarray
array with x-coordinates of grid
- ygridarray
array with y-coordinates of grid
- parameter_namestring
name of parameter to save to shapefile
- parameter_valuesarray of size xgrid, ygrid
parameter to save to shapefile
- filenamepath
where to save shapefile
- EPSGinteger
EPSG-code of grid. The default is 4326.
None.
- xbTools.general.visualize_mesh.grid_parameter_to_shape()#
saves a parameter defined at grid points to a shapefile
- xgridarray
array with x-coordinates of grid
- ygridarray
array with y-coordinates of grid
- parameter_namestring
name of parameter to save to shapefile
- parameter_valuesarray of size xgrid, ygrid
parameter to save to shapefile
- filenamepath
where to save shapefile
- EPSGinteger
EPSG-code of grid. The default is 4326.
None.
Executing runs#
- xbTools.general.executing_runs.xb_run_script_win()#
Create batch script to run simulations.
- xbLIST or CLASS
list with simulation paths or XBeachModelSetup class
- Nint
Number of batch scripts.
- maindirTYPE
path where run script is created.
- xbeach_exeTYPE
path of XBeach executable.
None.
Geometry#
- xbTools.general.geometry.rotate()#
Rotates the coordinates (x,y) counterclockwise through an angle theta around origin
- xfloat
x-coordinate.
- yfloat
y-coordinate.
- thetafloatd
angle in radians.
- origin: list length 2
list of floats [x0, y0] origin coordinate. Default [0, 0]
rotated arrays x,y
- xbTools.general.geometry.rotate_grid()#
Rotate_grid(xgr,ygr,theta) rotates a grid xgr,ygr over the angle theta (in radians)
- xgrarray
x grid.
- ygrarray
y grid.
- thetafloatd
ange in radians.
- uvarray
rotated grid.
- vdarray
rotated grid.
- xbTools.general.geometry.grid_world2local()#
Identifies the rotation angle of the x-axis of a 2D XBeach grid and returns grid in local coordinates (i.e. x only cross shore, y only alongshore) output: rotated grid x,y and grid angle alpha
- xgrarray
x-grid.
- ygrarray
y-grid.
- xlarray
x-grid in local coordinates
- ylarray
y-grid in local coordinates
- alphaTYPE
rotation.
- xbTools.general.geometry.samples_to_local_grid()#
# shift samples in local grid coordinates for simple interpolation and modification Parameters ———- xs: x-world coordinates of samples ys: y-world coordinates of samples x0: x-origin of grid in world coordinates y0: y-origin of grid in world coordinates theta: angle of x-dir (nautical Returns ——- xl: x-coordinates of samples in local coordinates yl: y-coordintes of samples in local coordinates
- xbTools.general.geometry.in_polygon()#
checks whether the coordinate (x,y) or list of coordinates (xi,yi) fall within the polygon poli.
- xnumpy array, either 1D or 2D
x coordinates.
- ynumpy array, either 1D or 2D
y coordintes.
- polishapely Polygon geometry
polygon to test.
- ipnumpy array, either 1D or 2D
mask being 1 if in polyon, 0 outside polygon.
Author: Marlies van der Lugt Revision 0
- xbTools.general.geometry.get_points_in_polygon()#
to-do, replace in_polygon by this function returns True for points inside the polygon and False for points outside
Note: If a point falls on the border of the polygon, a False is returned Parameters ———- pol : shapely.geometry.Polygon
polygon to get points in.
- x_coordsnp.array
x coords
- y_coordsnp.array
y coords
- ind_insidenp.array
boolean array with True if point inside and False if outside.
- xbTools.general.geometry.path_distance()#
- polxTYPE array
X COORDINATES.
- polyTYPE array
Y COORDINATES.
- Returns: TYPE array
PATHDISTANCE
python alternative to matlab function.
Grid#
Refinement#
- xbTools.grid.refinement.grid_refine_grid()#
grid_refine_grid(xgr,ygr,zgr,xfactor = 2, yfactor = 1, ne_layer=None) refines the grid with the factor xfactor in xdirection and yfactor in y direction works only on rectilinear grids returns refined grid where the grid has kept its coordinates
Author: Marlies van der Lugt Revision 0 # todo: add better docstring and syntax
Extionsion#
- xbTools.grid.extension.lateral_extend()#
Extend the model domain at both lateral sides with n number of cells
- xarray
x-grid.
- yTYPE
y-grid.
- zarray
bathymetry.
- nint, optional
extension at both lateral sides. The default is 5.
- xnewarray
x-grid.
- ynewarray
y-grid.
- znewarray
bathymetry
- xbTools.grid.extension.seaward_extend()#
Compute the seaward extend of the bathymery based on an artificial slope and required offshore depth
- xarray
x coordinates of the grid.
- yarray
y coordinates of the grid.
- zarray
array with the bathymetry. positive upwards
- slopefloat, optional
artificial slope applied at the offshore to boundary. The default is 1/20.
- depthfloat, optional
Required offshore depth at the boundary. The default is -20.
- xgrarray
x grid.
- ygrarray
y grid.
- zgrarray
bathymetry.
Creation#
- xbTools.grid.creation.xgrid()#
Compute spatially varying grid based on the local wave length
- xarray
x points of the bathymetry.
- zarray
bathymetry (positive upwards).
- ppwlinteger, optional
Number of points per wave length. The default is 20.
- dxminfloat, optional
minimum grid resolution. The default is 5.
- dxmaxfloat, optional
maximum grid reslution. The default is np.inf.
- vardxint, optional
1=spatially varying grid; 0=equidistant grid resolution. The default is 1.
- wlfloat, optional
Water level. The default is 0.
- epsfloat, optional
Minimum water depth. The default is 0.01.
- Tmfloat, optional
Mean wave period. The default is 8.
- xdryfloat, optional
bathymetry is considered dry for x-grids larger than xdry. The default is None.
- zdryfloat, optional
bathymetry is considered dry for z values larger than zdry. The default is None.
- dxdryfloat, optional
Resolution of dry cells. The default is None.
- depthfacfloat, optional
. The default is 2.
- maxfacTYPE, optional
DESCRIPTION. The default is 1.15.
- xgrarray
grid points.
- zgrarray
depth points.
#todo improve docstring and syntax of code
- xbTools.grid.creation.ygrid()#
function to setup a basic ygrid array
- yTYPE
DESCRIPTION.
- dyminTYPE, optional
DESCRIPTION. The default is 5.
- dymaxTYPE, optional
DESCRIPTION. The default is 20.
- area_typeTYPE, optional
DESCRIPTION. The default is ‘center’.
- maxerrorTYPE, optional
DESCRIPTION. The default is 0.05.
- transition_distanceTYPE, optional
DESCRIPTION. The default is -0.1.
- area_sizeTYPE, optional
DESCRIPTION. The default is 0.4.
- ygrarray
array with y grid.
- xbTools.grid.creation.grid_transition()#
function for grid_transition from one cell to the other
- Returns:
ff, nf, gridf, error
#todo improve docstring and syntax of code
XBeachtools#
- xbTools.xbeachtools.XBeachModelSetup()#
XBeach model setup class
XBeachModelAnalysis#
- xbTools.xbeachpost.XBeachModelAnalysis()#
XBeach model analysis class