A contour that connects points of constant AND exceedance. Such
contours are described, for example, in Mazas (2019) [7].
This implementation uses Monte Carlo simulation and only works for 2D models.
Parameters:
model (MultivariateModel) – The model to be used to calculate the contour.
alpha (float) – The exceedance probability. The probability that an observation
falls outside the environmental contour.
n (int, optional) – Number of data points that shall be Monte Carlo simulated. Defaults
to None, which calculates n based on alpha: n = int(100 / alpha).
deg_step (float, optional) – Directional step in degrees. Defaults to 5.
sample (2-dimensional ndarray, optional) – Monte Carlo simulated environmental states. Array is of shape (n, d)
with d being the number of variables and n being the number of
observations.
allowed_error (float, optional) – Required precision for the alpha value. For example 0.1 means that
the algorithm searches along the path until the probability of exceedance
at the current point p_e satisfies | p_e - alpha | / alpha < 0.1.
Defaults to 0.01.
Direct sampling contour as introduced by Huseby et al. (2013) [6]
The provided direct sampling contour method only works for 2D models.
Parameters:
model (MultivariateModel) – The model to be used to calculate the contour.
alpha (float) – The exceedance probability. The probability that an observation
falls outside the environmental contour.
n (int, optional) – Number of data points that shall be Monte Carlo simulated. Defaults
to None, which calculates n based on alpha: n = int(100 / alpha).
deg_step (float, optional) – Directional step in degrees. Defaults to 5.
sample (2-dimensional ndarray, optional) – Monte Carlo simulated environmental states. Array is of shape (n, d)
with d being the number of variables and n being the number of
observations.
This method was proposed by Haselsteiner et. al (2017) [5]
Parameters:
model (MultivariateModel) – The model to be used to calculate the contour.
alpha (float) – The exceedance probability. The probability that an observation
falls outside the environmental contour.
limits (list of tuples, optional) – The limits of the grid to use for calculation. One 2-element tuple
for each dimension of the model, containing the minimum and maximum
for that dimension. (min, max). If not given, reasonable values are
choosen using the models marginal_icdf as upper limit and 0 as lower
limit.
deltas (float or list of float, optional) – The step size of the grid to use for calculation. If a single float
is supplied it is used for all dimensions. If a list is supplied
there has to be one entry for each dimension of the model. Defaults
to 0.25% of the range defined by limits.
Calculates the cell averaged joint probabilty density function.
Multiplies the cell averaged probability densities of all distributions.
Parameters:
coords (list of array) – List with one coordinate array for each dimension.
Returns:
fbar – Joint cell averaged probability density function evaluated at coords.
Cell averaged probability density function evaluated at coords.
n dimensional array, where n is the number of dimensions of the
model used for calculation.
Calculates the cell averaged probabilty density function of a single
distribution.
Calculates the pdf by approximating it with the finite differential
quotient of the cumulative distributions function, evaluated at the
grid cells borders.
i.e. \(f(x) \approx \frac{F(x+ 0.5\Delta x) - F(x- 0.5\Delta x) }{\Delta x}\)
Parameters:
dist_idx (int) – The index of the distribution to calcululate the pdf for.
coords (list of array) – List with one coordinate array for each dimension.
Returns:
fbar – Cell averaged probability density function evaluated at coords.
n dimensional array, where n is the number of dimensions of the
model used for calculation. All dimensions but, the dist_idx and
the cond_idx dimensions are of length 1. The dist_idx and cond_idx
dimensions are of length equal to the length of coords.
Sorts array, and calculates the cumulative sum.
Returns a boolean array with the same shape as array indicating the
fields summed to reach limit, as well as the last value added.
Parameters:
array (ndarray) – Array of arbitrary shape with all values >= 0.
A contour that connects points of constant OR exceedance. Such
type of multivariate exceedance is described, for example, in Serinaldi (2015) [8].
This implementation uses Monte Carlo simulation and only works for 2D models.
Parameters:
model (MultivariateModel) – The model to be used to calculate the contour.
alpha (float) – The exceedance probability. The probability that an observation
falls outside the environmental contour.
n (int, optional) – Number of data points that shall be Monte Carlo simulated. Defaults
to None, which calculates n based on alpha: n = int(100 / alpha).
deg_step (float, optional) – Directional step in degrees. Defaults to 5.
sample (2-dimensional ndarray, optional) – Monte Carlo simulated environmental states. Array is of shape (n, d)
with d being the number of variables and n being the number of
observations.
allowed_error (float, optional) – Required precision for the alpha value. For example 0.1 means that
the algorithm searches along the path until the probability of exceedance
at the current point p_e satisfies | p_e - alpha | / alpha < 0.1.
Defaults to 0.01.
lowest_theta (float, optional) – Lowest angle considered in the calculation of the contour. Given in deg.
Defaults to 10.
highest_theta (float, otptional) – Highest angle considered in the calculation of the contour. Given in deg.
Defaults to 80.
Calculates the probability that an environmental contour is exceeded
(exceedance probability).
The exceedance probability, α, corresponds to a certain recurrence or
return period, T, which describes the average time period between two
consecutive environmental states that exceed the contour . Note that
exceedance can be defined in various ways for environmental contours
(Mackay and Haselsteiner, 2021) [1]
Parameters:
state_duration (float) – Time period for which an environmental state is measured,
expressed in hours \((T_s)\).
return_period (float) – Describes the average time period between two consecutive
environmental states that exceed a contour.
Returns:
alpha – The probability that an environmental contour is exceeded.
Saves the coordinates of the calculated contour.
Saves a .txt file to the given path.
Parameters:
contour (Contour) – The contour with the coordinates to save.
file_path (string) – Indicates the path, where the contour coordinates are saved.
semantics (dictionary) – The description of the model. semantics has the keys ‘names’, ‘symbols’
and ‘units’. Each value is a list of strings. For each dimension of the
model the strings describe the name, symbol or unit of that dimension,
respectively. This information is used as the header of the created file.
Defaults to a dict with general descriptions.