Skip to content
Snippets Groups Projects
Commit 09e51aef authored by Peter Lünenschloß's avatar Peter Lünenschloß
Browse files

include bounds bool now

parent 732bb2ec
No related branches found
No related tags found
3 merge requests!193Release 1.4,!188Release 1.4,!85Seasonal and custom data masking
......@@ -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)
......
......@@ -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]
......
......@@ -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
......
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