Extremes¶
Block-extrema (block maxima / minima for a generalized extreme-value workflow) and peaks-over-threshold (POT) diagnostics: threshold selection, exceedances, and Poisson-process counts and statistics.
Functions¶
These pure functions back the operators above; each takes xr.DataArray/xr.Dataset and a dim: argument.
block_maxima
¶
block_maxima(da: DataArray, block_size: int = 365, time: str = 'time', boundary: str = 'trim', side: str = 'left') -> DataArray
Coarsen along time and take the maximum per block.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
da
|
DataArray
|
Input DataArray with a |
required |
block_size
|
int
|
Number of time steps per block. |
365
|
time
|
str
|
Name of the time dimension. |
'time'
|
boundary
|
str
|
Passed to |
'trim'
|
side
|
str
|
Passed to |
'left'
|
Returns:
| Type | Description |
|---|---|
DataArray
|
DataArray of block maxima. |
Source code in packages/xrtoolz-ops/src/xrops/extremes/_src/extremes.py
block_minima
¶
block_minima(da: DataArray, block_size: int = 365, time: str = 'time', boundary: str = 'trim', side: str = 'left') -> DataArray
Coarsen along time and take the minimum per block.
Source code in packages/xrtoolz-ops/src/xrops/extremes/_src/extremes.py
pot_threshold
¶
Threshold for peaks-over-threshold: the quantile of da.
Source code in packages/xrtoolz-ops/src/xrops/extremes/_src/extremes.py
pot_exceedances
¶
pot_exceedances(da: DataArray, quantile: float = 0.98, decluster_freq: int | None = None, time: str = 'time') -> DataArray
Return values above the quantile threshold, optionally declustered.
When decluster_freq is set, values are declustered by taking the
block maximum over that many steps; this converts the peaks series
into independent exceedances (standard POT practice).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
da
|
DataArray
|
Input DataArray. |
required |
quantile
|
float
|
Quantile (in [0, 1]) used to compute the threshold. |
0.98
|
decluster_freq
|
int | None
|
If given, apply a block-maximum declustering filter with this block size and drop resulting NaNs. |
None
|
time
|
str
|
Name of the time dimension. |
'time'
|
Returns:
| Type | Description |
|---|---|
DataArray
|
DataArray of exceedances. If |
DataArray
|
returned array has the same shape as |
DataArray
|
points replaced by NaN. |
Source code in packages/xrtoolz-ops/src/xrops/extremes/_src/extremes.py
pp_counts
¶
pp_counts(da: DataArray, quantile: float = 0.98, block_size: int = 5, time: str = 'time', boundary: str = 'trim', side: str = 'left') -> DataArray
Count exceedances of a high quantile within each time block.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
da
|
DataArray
|
Input DataArray. |
required |
quantile
|
float
|
Quantile used to build the threshold. |
0.98
|
block_size
|
int
|
Size of the time block in which to count. |
5
|
time
|
str
|
Name of the time dimension. |
'time'
|
boundary, side
|
Passed to :func: |
required |
Returns:
| Type | Description |
|---|---|
DataArray
|
DataArray with one count per block along the (coarsened) time |
DataArray
|
dimension. |
Source code in packages/xrtoolz-ops/src/xrops/extremes/_src/extremes.py
pp_stats
¶
pp_stats(da: DataArray, quantile: float = 0.98, block_size: int = 5, statistic: Callable[[ndarray], float] = mean, time: str = 'time', boundary: str = 'trim', side: str = 'left') -> DataArray
Summarize exceedances within each time block.
Applies statistic to the subset of values in each block that
exceed the quantile threshold.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
da
|
DataArray
|
Input DataArray. |
required |
quantile
|
float
|
Quantile used to build the threshold. |
0.98
|
block_size
|
int
|
Size of the time block. |
5
|
statistic
|
Callable[[ndarray], float]
|
Reduction to apply to the exceedances (default
|
mean
|
time
|
str
|
Name of the time dimension. |
'time'
|
boundary, side
|
Passed to :func: |
required |
Returns:
| Type | Description |
|---|---|
DataArray
|
DataArray of per-block summary statistics. |