Skip to content
Snippets Groups Projects
Commit 416fc325 authored by Bert Palm's avatar Bert Palm 🎇
Browse files

fixed flagWindow and assignTypeSafe

parent 590ae714
No related branches found
No related tags found
No related merge requests found
......@@ -28,7 +28,7 @@ def flagWindow(flagger, flags, mask, direction='fw', window=0, **kwargs) -> pd.S
fw = f.rolling(window=window, closed='both').sum().astype(bool)
fmask = bw | fw
flags[fmask] = flagger.setFlag(flags[fmask], **kwargs)
flags.loc[fmask] = flagger.setFlag(flags.loc[fmask], **kwargs)
return flags
......@@ -47,7 +47,8 @@ def assignTypeSafe(df, colname, rhs):
all columns are converted to the most generic
of the dtypes
"""
df.loc[:, colname] = rhs
# do not use .loc here, as it fails silently :/
df[colname] = rhs
if isinstance(rhs, pd.Series):
dtypes = rhs.dtypes
else:
......@@ -123,8 +124,8 @@ def runner(metafname, flagger, data, flags=None, nodata=np.nan):
raise NameError(
f"function name {func_name} is not definied (variable '{varname}, 'line: {idx + 1})")
old = flagger.isFlagged(fchunk[varname])
new = flagger.isFlagged(ffchunk[varname])
old = flagger.getFlags(fchunk[varname])
new = flagger.getFlags(ffchunk[varname])
mask = old != new
# flag a timespan after the condition is met
......@@ -136,8 +137,7 @@ def runner(metafname, flagger, data, flags=None, nodata=np.nan):
# flag a certain amount of values after condition is met
if Params.FLAGVALUES in flag_params:
ffchunk = assignTypeSafe(
ffchunk,
varname,
ffchunk, varname,
flagNext(flagger, ffchunk[varname], mask, func_name=func_name, **flag_params))
if flag_params.get(Params.PLOT, False):
......
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