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

cleanups

parent 9e8d8a51
No related branches found
No related tags found
No related merge requests found
...@@ -102,8 +102,8 @@ def runner(config_file, flagger, data, flags=None, nodata=np.nan, error_policy=" ...@@ -102,8 +102,8 @@ def runner(config_file, flagger, data, flags=None, nodata=np.nan, error_policy="
start_date = configrow[Fields.START] start_date = configrow[Fields.START]
end_date = configrow[Fields.END] end_date = configrow[Fields.END]
flag_test = testcol[idx] func = testcol[idx]
if pd.isnull(flag_test): if pd.isnull(func):
continue continue
if varname not in data and varname not in flagger.getFlags(): if varname not in data and varname not in flagger.getFlags():
...@@ -118,14 +118,14 @@ def runner(config_file, flagger, data, flags=None, nodata=np.nan, error_policy=" ...@@ -118,14 +118,14 @@ def runner(config_file, flagger, data, flags=None, nodata=np.nan, error_policy="
try: try:
# actually run the tests # actually run the tests
dchunk_result, flagger_chunk_result = evalExpression( dchunk_result, flagger_chunk_result = evalExpression(
flag_test, func,
data=dchunk, data=dchunk,
field=varname, field=varname,
flagger=flagger_chunk, flagger=flagger_chunk,
nodata=nodata, nodata=nodata,
) )
except Exception as e: except Exception as e:
if _handleErrors(e, configrow, flag_test, error_policy): if _handleErrors(e, configrow, func, error_policy):
raise e raise e
continue continue
...@@ -137,7 +137,7 @@ def runner(config_file, flagger, data, flags=None, nodata=np.nan, error_policy=" ...@@ -137,7 +137,7 @@ def runner(config_file, flagger, data, flags=None, nodata=np.nan, error_policy="
flagger_chunk_result, flagger_chunk_result,
varname, varname,
configrow[Fields.PLOT], configrow[Fields.PLOT],
flag_test, func,
) )
plotAllHook(data, flagger) plotAllHook(data, flagger)
......
...@@ -736,8 +736,9 @@ def _toMerged( ...@@ -736,8 +736,9 @@ def _toMerged(
data.drop(fieldname, axis="columns", errors="ignore", inplace=True) data.drop(fieldname, axis="columns", errors="ignore", inplace=True)
flags.drop(fieldname, axis="columns", errors="ignore", inplace=True) flags.drop(fieldname, axis="columns", errors="ignore", inplace=True)
# first case: there is no data, the data-to-insert would have to be merged with, and also are we not deharmonizing: # first case: there is no data, the data-to-insert would have
if (flags.empty) & (target_index is None): # to be merged with, and also are we not deharmonizing:
if (data.empty) & (target_index is None):
return data_to_insert.to_frame(name=fieldname), flagger_to_insert return data_to_insert.to_frame(name=fieldname), flagger_to_insert
# if thats not the case: generate the drop mask for the remaining data: # if thats not the case: generate the drop mask for the remaining data:
......
...@@ -20,16 +20,16 @@ def plotAllHook(data, flagger): ...@@ -20,16 +20,16 @@ def plotAllHook(data, flagger):
_plot(data, flagger, True, __plotvars) _plot(data, flagger, True, __plotvars)
def plotHook(data, old, new, varname, do_plot, flag_test, plot_nans=False): def plotHook(data, flagger_old, flagger_new, varname, do_plot, flag_test, plot_nans=False):
# old/new: flagger # flagger_old/flagger_new: flagger
if do_plot: if do_plot:
__plotvars.append(varname) __plotvars.append(varname)
# cannot use getFlags here, because if a flag was set (e.g. with force) the # cannot use getFlags here, because if a flag was set (e.g. with force) the
# flag may be the same, but any additional row (e.g. comment-field) would differ # flag may be the same, but any additional row (e.g. comment-field) would differ
mask = (old._flags[varname] != new._flags[varname]) mask = (flagger_old._flags[varname] != flagger_new._flags[varname])
if isinstance(mask, pd.DataFrame): if isinstance(mask, pd.DataFrame):
mask = mask.any(axis=1) mask = mask.any(axis=1)
_plot(data, new, mask, varname, title=flag_test, plot_nans=plot_nans) _plot(data, flagger_new, mask, varname, title=flag_test, plot_nans=plot_nans)
def _plot( def _plot(
......
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