diff --git a/mlair/data_handler/data_handler_single_station.py b/mlair/data_handler/data_handler_single_station.py index 0c83e625fd0e1aa4aafdcf204ed00b813868f4f2..e9db27a9ff88efa2cc800723ac99279ec66d6cbb 100644 --- a/mlair/data_handler/data_handler_single_station.py +++ b/mlair/data_handler/data_handler_single_station.py @@ -195,7 +195,17 @@ class DataHandlerSingleStation(AbstractDataHandler): else: raise NotImplementedError - def f_apply(data, method, mean=None, std=None, min=None, max=None): + def f_apply(data, method, **kwargs): + for k, v in kwargs.items(): + if not (isinstance(v, xr.DataArray) or v is None): + _, opts = statistics.min_max(data, dim) + helper = xr.ones_like(opts['min']) + kwargs[k] = helper * v + mean = kwargs.pop('mean', None) + std = kwargs.pop('std', None) + min = kwargs.pop('min', None) + max = kwargs.pop('max', None) + if method == "standardise": return statistics.standardise_apply(data, mean, std), {"mean": mean, "std": std, "method": method} elif method == "centre": diff --git a/mlair/data_handler/default_data_handler.py b/mlair/data_handler/default_data_handler.py index 5eb6fd026e4dead07ab1a3115640a0d853708313..2eceff328bf696bd954ec6649c78db03173c9bdb 100644 --- a/mlair/data_handler/default_data_handler.py +++ b/mlair/data_handler/default_data_handler.py @@ -241,6 +241,8 @@ class DefaultDataHandler(AbstractDataHandler): * standardise (default, if method is not given) * centre + * min_max + * log ### mean and std estimation @@ -256,14 +258,16 @@ class DefaultDataHandler(AbstractDataHandler): If mean and std are not None, the default data handler expects this parameters to match the data and applies this values to the data. Make sure that all dimensions and/or coordinates are in agreement. + + ### min and max given + If min and max are not None, the default data handler expects this parameters to match the data and applies + this values to the data. Make sure that all dimensions and/or coordinates are in agreement. """ sp_keys = {k: copy.deepcopy(kwargs[k]) for k in cls._requirements if k in kwargs} - transformation_dict = sp_keys.get("transformation", None) - if transformation_dict is None: + if "transformation" not in sp_keys.keys(): return - if isinstance(transformation_dict, dict): # tuple for (input, target) transformation - transformation_dict = copy.deepcopy(transformation_dict), copy.deepcopy(transformation_dict) + transformation_dict = ({}, {}) def _inner(): """Inner method that is performed in both serial and parallel approach."""