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

Merge branch 'environmentalStuff' into 'develop'

environment docs added - modified env func selection

See merge request !353
parents 1b5241fc 7a633ab5
No related branches found
No related tags found
2 merge requests!370Release 2.0,!353environment docs added - modified env func selection
Pipeline #52211 passed with stage
in 1 minute and 38 seconds
......@@ -12,45 +12,74 @@ __all__ = [
import numpy as np
import scipy.stats as st
import saqc.lib.ts_operators as ts_ops
#: Internal :py:mod:`flag level constant <saqc.constants>`.
#: When returned by a test, it indicates, that the test did not consider to flag the respective value
UNTOUCHED = np.nan
#: A :py:mod:`flag level constant <saqc.constants>`
#: , evaluating to the level, that indicates, no flag has been assigned to yet.
UNFLAGGED = -np.inf
#: A :py:mod:`flag level constant <saqc.constants>`
#: , evaluating to the lowest level level of flagging, that is
#: not :py:const:`UNFLAGGED <saqc.constants.UNFLAGGED>`.
GOOD = 0
#: A :py:mod:`flag level constant <saqc.constants>`
#: , evaluating to a somewhat modest flag level.
DOUBTFUL = 25.0
#: A :py:mod:`flag level constant <saqc.constants>`
#: , evaluating to the highest (internal) flag level available.
BAD = 255.0
# aliases
DOUBT = DOUBTFUL
DOUBT = DOUBTFUL #: Alias for :py:const:`DOUBTFUL <saqc.constants.DOUBTFUL>`.
ENVIRONMENT = {
# Not A number Constant.
"NAN": np.nan,
# Pointwise absolute Value Function.
"abs": np.abs,
# Maximum Value Function. Ignores NaN.
"max": np.nanmax,
# Minimum Value Function. Ignores NaN.
"min": np.nanmin,
# Mean Value Function. Ignores NaN.
"mean": np.nanmean,
# Summation. Ignores NaN.
"sum": np.nansum,
"std": np.nanstd,
# Standart Deviation. Ignores NaN.
"len": len,
# Pointwise Exponential.
"exp": np.exp,
# Pointwise Logarithm.
"log": np.log,
# Logarithm, returning NaN for zero input, instead of -inf.
"nanLog": ts_ops.zeroLog,
# Standart Deviation. Ignores NaN.
"std": np.nanstd,
# Variance. Ignores NaN.
"var": np.nanvar,
# Median. Ignores NaN.
"median": np.nanmedian,
"first": ts_ops.first,
"last": ts_ops.last,
# Count Number of values. Ignores NaNs.
"count": ts_ops.count,
"deltaT": ts_ops.deltaT,
# Identity.
"id": ts_ops.identity,
# Returns a Series` diff.
"diff": ts_ops.difference,
"relDiff": ts_ops.relativeDifference,
"deriv": ts_ops.derivative,
"rateOfChange": ts_ops.rateOfChange,
"scale": ts_ops.scale,
"normScale": ts_ops.normScale,
"meanStandardize": ts_ops.standardizeByMean,
"medianStandardize": ts_ops.standardizeByMedian,
"zLog": ts_ops.zeroLog,
# Scales data to [0,1] Interval.
"scale": ts_ops.normScale,
# Standardize with Standart Deviation.
"zScore": lambda x: st.zscore(x, nan_policy="omit"),
# Standardize with Median and MAD.
"madScore": ts_ops.standardizeByMedian,
# Standardize with Median and inter quantile range.
"iqsScore": ts_ops.standardizeByIQR,
"GOOD": GOOD,
"BAD": BAD,
"UNFLAGGED": UNFLAGGED,
......
......@@ -111,7 +111,7 @@ def standardizeByMedian(ts):
def standardizeByIQR(ts):
# standardization with median and interquartile range
# standardization with median and inter quantile range
return (ts - np.median(ts)) / iqr(ts, nan_policy="omit")
......
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