Skip to content
Snippets Groups Projects

Follow-Up Translations

Merged David Schäfer requested to merge translations into develop
Compare and Show latest version
2 files
+ 60
4
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -22,6 +22,7 @@ from saqc.lib.types import MaterializedGraph
from saqc.core.translator.basetranslator import Translator, ForwardMap
class DmpTranslator(Translator):
"""
@@ -38,6 +39,18 @@ class DmpTranslator(Translator):
"BAD": BAD,
}
_QUALITY_CAUSES = {
"BATTERY_LOW",
"BELOW_MINIMUM",
"ABOVE_MAXIMUM",
"BELOW_OR_ABOVE_MIN_MAX",
"ISOLATED_SPIKE",
"DEFECTIVE_SENSOR",
"LEFT_CENSORED_DATA",
"RIGHT_CENSORED_DATA",
"OTHER",
}
def __init__(self):
super().__init__(forward=self._FORWARD)
@@ -185,10 +198,18 @@ class DmpTranslator(Translator):
causes.append(cause)
comments.append(comment)
# DMP quality_cause needs some special care as only certain values
# and combinations are allowed.
# See: https://wiki.intranet.ufz.de/wiki/dmp/index.php/Qualit%C3%A4tsflags
causes = pd.Series(causes, index=flags[field].index)
causes[(causes == self.ARGUMENTS["cause"]) & (flags[field] > GOOD)] = "OTHER"
if not ((causes == "") | causes.isin(self._QUALITY_CAUSES)).all():
raise ValueError(f"quality causes needs to be one of {self._QUALITY_CAUSES}")
var_flags = {
"quality_flag": tflags[field],
"quality_comment": pd.Series(comments, index=flags[field].index),
"quality_cause": pd.Series(causes, index=flags[field].index),
"quality_cause": causes,
}
out[field] = pd.DataFrame(var_flags)
return pd.concat(out, axis="columns")
Loading