diff --git a/saqc/funcs/break_detection.py b/saqc/funcs/break_detection.py index 6562ead338b647a755b61db11eff50c77c4eab1f..60112d885a9b809f3b81fb432e325929f947ad97 100644 --- a/saqc/funcs/break_detection.py +++ b/saqc/funcs/break_detection.py @@ -7,7 +7,7 @@ import pandas as pd from scipy.signal import savgol_filter from saqc.funcs.register import register -from saqc.lib.tools import retrieveTrustworthyOriginal, offset2periods +from saqc.lib.tools import retrieveTrustworthyOriginal @register("breaks_spektrumBased") diff --git a/saqc/funcs/constants_detection.py b/saqc/funcs/constants_detection.py index f0c561d68ee1a5bc2d1948716c37619d7a8fc140..639aa1801a28435586742f750ed169bcb6f9db5f 100644 --- a/saqc/funcs/constants_detection.py +++ b/saqc/funcs/constants_detection.py @@ -83,7 +83,7 @@ def flagConstant_varianceBased( dataseries, data_rate = retrieveTrustworthyOriginal(data, field, flagger) - min_periods = int(offset2periods(plateau_window_min, data_rate)) + min_periods = int(np.ceil(pd.Timedelta(plateau_window_min) / pd.Timedelta(data_rate))) plateaus = dataseries.rolling( window=plateau_window_min, min_periods=min_periods diff --git a/saqc/funcs/soil_moisture_tests.py b/saqc/funcs/soil_moisture_tests.py index 5722c0a368ac50dc12909890332094af243eab3f..712c492e374f84cd6312eae454dc293b4fbd76bb 100644 --- a/saqc/funcs/soil_moisture_tests.py +++ b/saqc/funcs/soil_moisture_tests.py @@ -12,9 +12,7 @@ from saqc.funcs.spike_detection import flagSpikes_spektrumBased from saqc.funcs.constants_detection import flagConstant_varianceBased from saqc.funcs.register import register from saqc.lib.tools import ( - estimateSamplingRate, - retrieveTrustworthyOriginal, - offset2periods, + retrieveTrustworthyOriginal ) diff --git a/saqc/lib/tools.py b/saqc/lib/tools.py index bb5bb7b217455d4bc0b77ab5fb866d7823ff87ad..c2ca0764423eaa3746df31a5bf8c0450bc07df76 100644 --- a/saqc/lib/tools.py +++ b/saqc/lib/tools.py @@ -157,17 +157,6 @@ def offset2seconds(offset): return pd.Timedelta.total_seconds(pd.Timedelta(offset)) -def offset2periods(input_offset, period_offset): - """Function returns the number of periods of length "periods_offset" that sum up to length "input offset". - (Namely their fraction.) - - :param input_offset Offset string or pandas offset object. - :param period_offset Offset string or pandas offset object. - """ - - return offset2seconds(input_offset) / offset2seconds(period_offset) - - def flagWindow( flagger_old, flagger_new, field, direction="fw", window=0, **kwargs ) -> pd.Series: