diff --git a/saqc/funcs/functions.py b/saqc/funcs/functions.py index c56303fa7fedfe4b247fe2db5b11102545f5b9f8..1864ff377a2f8238f741d4c25e7cf925b7bc93db 100644 --- a/saqc/funcs/functions.py +++ b/saqc/funcs/functions.py @@ -235,7 +235,7 @@ def flagSesonalRange( data, flagger = modelling_mask(data, field + "_masked", flagger, mode='seasonal', season_start=f"{startmonth:02}-{startday:02}T00:00:00", season_end=f"{endmonth:02}-{endday:02}T00:00:00", - inclusive_selection='season') + include_bounds=True) data, flagger = flagRange(data, field + "_masked", flagger, min=min, max=max, **kwargs) data, flagger = proc_projectFlags(data, field, flagger, method='match', source=field + "_masked") data, flagger = proc_drop(data, field + "_masked", flagger) diff --git a/saqc/funcs/modelling.py b/saqc/funcs/modelling.py index 4bdabb5998bc3634c6d820d5fe9fb053cf825e8e..8fede4c050482d5e41c3439469acc81094a935d3 100644 --- a/saqc/funcs/modelling.py +++ b/saqc/funcs/modelling.py @@ -252,7 +252,7 @@ def modelling_rollingMean(data, field, flagger, winsz, eval_flags=True, min_peri def modelling_mask(data, field, flagger, mode, mask_var=None, season_start=None, season_end=None, - inclusive_selection="mask"): + include_bounds=True): """ This function realizes masking within saqc. @@ -280,7 +280,7 @@ def modelling_mask(data, field, flagger, mode, mask_var=None, season_start=None, The fieldname of the column, holding the data-to-be-masked. flagger : saqc.flagger A flagger object, holding flags and additional Informations related to `data`. - mode : {"seasonal", "mask_var"}select + mode : {"seasonal", "mask_var"} The masking mode. - "seasonal": parameters "season_start", "season_end" are evaluated to generate a seasonal (periodical) mask - "mask_var": data[mask_var] is expected to be a boolean valued timeseries and is used as mask. @@ -299,13 +299,8 @@ def modelling_mask(data, field, flagger, mode, mask_var=None, season_start=None, String denoting starting point of every period. Formally, it has to be a truncated instance of "mm-ddTHH:MM:SS". Has to be of same length as `season_end` parameter. See examples section below for some examples. - inclusive_selection : {"mask","season"}, default "mask" - Only effective if mode == "seasonal" - - "mask": the `season_start` and `season_end` keywords inclusivly frame the mask (INCLUDING INTERVAL BOUNDS) - - "season": the `season_start` and `season_end` keywords inclusivly frame the season - (INCLUDING INTERVAL BOUNDS) - (Parameter mainly introduced to provide backwards compatibility. But, as a side effect, provides more control - over what to do with samples at the exact turning points of date-defined masks and season.) + include_bounds : boolean + Wheather or not to include the mask defining bounds to the mask. Returns ------- @@ -358,7 +353,7 @@ def modelling_mask(data, field, flagger, mode, mask_var=None, season_start=None, data = data.copy() datcol = data[field] if mode == 'seasonal': - to_mask = seasonalMask(datcol.index, season_start, season_end, inclusive_selection) + to_mask = seasonalMask(datcol.index, season_start, season_end, include_bounds) elif mode == 'mask_var': to_mask = data[mask_var] diff --git a/saqc/lib/tools.py b/saqc/lib/tools.py index aa689efb15abbdc93d5c68a55520eaa9303d3a26..040f85a11f36ae7b84b97992dc48e5b90fad495f 100644 --- a/saqc/lib/tools.py +++ b/saqc/lib/tools.py @@ -219,12 +219,8 @@ def seasonalMask(dtindex, season_start, season_end, include_bounds): String denoting starting point of every period. Formally, it has to be a truncated instance of "mm-ddTHH:MM:SS". Has to be of same length as `season_end` parameter. See examples section below for some examples. - include_bounds : {"mask","season"} - - "mask": the `season_start` and `season_end` keywords inclusivly frame the mask (INCLUDING INTERVAL BOUNDS) - - "season": the `season_start` and `season_end` keywords inclusivly frame the season - (INCLUDING INTERVAL BOUNDS) - (Parameter mainly introduced to provide backwards compatibility. But, as a side effect, provides more control - over what to do with samples at the exact turning points of date-defined masks and season.) + include_bounds : boolean + Wheather or not to include the mask defining bounds to the mask. Returns ------- @@ -283,25 +279,17 @@ def seasonalMask(dtindex, season_start, season_end, include_bounds): return _replace - selectors = {"mask": False, "season": True} - if include_bounds not in selectors: - raise ValueError( - f"invalid value '{include_bounds}' was passed to " - f"parameter 'inclusive_selection'. Please select from " - f"{list(include_bounds.keys())}." - ) - base_bool = selectors[include_bounds] - mask = pd.Series(base_bool, index=dtindex) + mask = pd.Series(include_bounds, index=dtindex) start_replacer = _replaceBuilder(season_start) end_replacer = _replaceBuilder(season_end) if pd.Timestamp(start_replacer(dtindex)) <= pd.Timestamp(end_replacer(dtindex)): - def _selector(x, base_bool=base_bool): + def _selector(x, base_bool=include_bounds): x[start_replacer(x.index):end_replacer(x.index)] = not base_bool return x else: - def _selector(x, base_bool=base_bool): + def _selector(x, base_bool=include_bounds): x[:end_replacer(x.index)] = not base_bool x[start_replacer(x.index):] = not base_bool return x