View source: R/Spatial utilities.R
calculate_depth_share | R Documentation |
This function calculates the thickness of the water layer around each point in a vector. These thicknesses are needed to calculate weighted averages across a depth window.
calculate_depth_share(depths, min_depth = min(depths), max_depth = max(depths))
depths |
A numeric vector of increasing depths. |
min_depth |
The shallowest depth in the depth window. (defaults to minimum depth in the vector) |
max_depth |
The deepest depth in the depth window. (defaults to minimum depth in the vector) |
The function calculates the midpoints between values in a vector and an optional set of boundary depths. The differences between these midpoints are calculated to return the thickness of a depth layer centered on each point in the original vector. In the absence of boundary depths, the maximum and minimum depths are used.
If a depth falls outside the target window it gets a thickness of 0. If all depths fall outside the window the function returns an all 0 vector. If this is passed to 'weighted.mean' the result will be NaN.
A vector of water layer thicknesses to match the length of the original vector.
Other NEMO-MEDUSA spatial tools:
calculate_proximity_weight()
,
netcdf_scheme_helpers
,
scheme_column()
,
scheme_interp_slice()
,
scheme_strathE2E()
,
stratify()
,
voronoi_grid()
,
xyindex_to_nindex()
# Get a vector of depths depths <- seq(0, 100, by = 10) # Water layer thickness within the vector calculate_depth_share(depths) # Water layer thickness using limits of a depth window calculate_depth_share(depths, min_depth = 25, max_depth = 75) # Special case when the depth vector falls outside the target depth window calculate_depth_share(depths, min_depth = 400, max_depth = 600)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.