Skip to content
Snippets Groups Projects
Commit 606b63fa authored by David Schäfer's avatar David Schäfer
Browse files

Update BreakDetection.md and break_detection.py

parent ec563f6c
No related branches found
No related tags found
No related merge requests found
......@@ -8,21 +8,21 @@
```
breaks_spektrumBased(thresh_rel=0.1, thresh_abs=0.01,
first_der_factor=10, first_der_window="12h",
scnd_der_ratio_margin_1=0.05, scnd_der_ratio_margin_2=10,
scnd_der_ratio_range=0.05, scnd_der_ratio_thresh=10,
smooth=True, smooth_window="3h", smooth_poly_deg=2,)
```
| parameter | data type | default value | description |
|-------------------------|---------------------------------------------------------------|---------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| thresh_rel | float | `0.1` | Minimum relative difference between two values to consider the latter as break candidate. See condition (1) |
| thresh_abs | float | `0.01` | Minimum abosulte difference between two values to consider the latter as break candidate. See condition (2) |
| first_der_factor | float | `10` | Factor of the first derivates "arithmetic middle bound". See condition (3). |
| first_der_window | [offset string](docs/ParameterDescriptions.md#offset-strings) | `"12h"` | Determining the size of the window, covering all the values included in the the arithmetic middle calculation of condition (3) |
| scnd_der_ratio_margin_1 | float | `0.05` | Range of the area, covering all the values of the second derivatives quotient, that are regarded "sufficiently close to 1" for signifying a break. See condition (5). |
| scnd_der_ratio_margin_2 | float | `10.0` | Lower bound for the break succeeding second derivatives quotients. See condition (5). |
| smooth | bool | `True` | Smooth the timeseries before differenciation using the Savitsky-Golay filter |
| smooth_window | [offset string](docs/ParameterDescriptions.md#offset-strings) | `None` | Size of the smoothing window of the Savitsky-Golay filter. The default value `None` results in a window of two times the sampling rate (i.e. three values) |
| smooth_poly_deg | integer | `2` | Degree of the polynomial used for smoothing with the Savitsky-Golay filter |
| parameter | data type | default value | description |
|-----------------------|---------------------------------------------------------------|---------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| thresh_rel | float | `0.1` | Minimum relative difference between two values to consider the latter as break candidate. See condition (1) |
| thresh_abs | float | `0.01` | Minimum abosulte difference between two values to consider the latter as break candidate. See condition (2) |
| first_der_factor | float | `10` | Multiplication factor for arithmetic mean of the first derivates surrounding a break candidate. See condition (3). |
| first_der_window | [offset string](docs/ParameterDescriptions.md#offset-strings) | `"12h"` | Window around a break candidate for which the arithmetic mean is calculated. See condition (3) |
| scnd_der_ratio_range | float | `0.05` | Range of the area, covering all the values of the second derivatives quotient, that are regarded "sufficiently close to 1" for signifying a break. See condition (5). |
| scnd_der_ratio_thresh | float | `10.0` | Threshold for the ratio od the second derivatives succeeding a break. See condition (5). |
| smooth | bool | `True` | Smooth the timeseries before differenciation using the Savitsky-Golay filter |
| smooth_window | [offset string](docs/ParameterDescriptions.md#offset-strings) | `None` | Size of the smoothing window of the Savitsky-Golay filter. The default value `None` results in a window of two times the sampling rate (i.e. three values) |
| smooth_poly_deg | integer | `2` | Degree of the polynomial used for smoothing with the Savitsky-Golay filter |
The function flags breaks (jumps/drops) by evaluating the derivatives of a time series.
......@@ -40,9 +40,9 @@ A value $`x_k`$ of a time series $`x_t`$ with timestamps $`t_i`$, is considered
where $`\bar{X}`$ denotes the arithmetic mean of $`X`$.
4. The ratio (last/this) of the second derivatives is close to 1:
* $` 1 -`$ `scnd_der_ratio_margin_1` $`< |\frac{x''_{k-1}}{x_{k''}}| < 1 + `$`scnd_der_ratio_margin_1`
* $` 1 -`$ `scnd_der_ratio_range` $`< |\frac{x''_{k-1}}{x_{k''}}| < 1 + `$`scnd_der_ratio_range`
5. The ratio (this/next) of the second derivatives is sufficiently hight:
* $`|\frac{x''_{k}}{x''_{k+1}}| > `$`scnd_der_ratio_margin_2`
* $`|\frac{x''_{k}}{x''_{k+1}}| > `$`scnd_der_ratio_thresh`
NOTE:
- Only works for time series
......
......@@ -19,8 +19,8 @@ def flagBreaks_spektrumBased(
thresh_abs=0.01,
first_der_factor=10,
first_der_window="12h",
scnd_der_ratio_margin_1=0.05,
scnd_der_ratio_margin_2=10,
scnd_der_ratio_range=0.05,
scnd_der_ratio_thresh=10,
smooth=True,
smooth_window=None,
smooth_poly_deg=2,
......@@ -155,14 +155,14 @@ def flagBreaks_spektrumBased(
# criterion evaluation:
first_second = (
(1 - scnd_der_ratio_margin_1)
(1 - scnd_der_ratio_range)
< abs(
(
second_deri_series.shift(+1)[brake]
/ second_deri_series[brake]
)
)
< 1 + scnd_der_ratio_margin_1
< 1 + scnd_der_ratio_range
)
second_second = (
......@@ -170,7 +170,7 @@ def flagBreaks_spektrumBased(
second_deri_series[brake]
/ second_deri_series.shift(-1)[brake]
)
> scnd_der_ratio_margin_2
> scnd_der_ratio_thresh
)
if (~first_second) | (~second_second):
......
......@@ -82,9 +82,9 @@ def flagSoilMoistureBreaks(
thresh_rel=rel_change_rate_min,
thresh_abs=abs_change_min,
first_der_factor=first_der_factor,
first_der_window_range=first_der_window_size,
scnd_der_ratio_margin_1=scnd_der_ratio_margin_1,
scnd_der_ratio_margin_2=scnd_der_ratio_margin_2,
first_der_window=first_der_window_size,
scnd_der_ratio_range=scnd_der_ratio_margin_1,
scnd_der_ratio_thresh=scnd_der_ratio_margin_2,
smooth_poly_deg=smooth_poly_order,
**kwargs
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment