Skip to content
Snippets Groups Projects
Commit 0f53dffa authored by Felix Kleinert's avatar Felix Kleinert
Browse files

update transform methods to proplery work when external transformation parameetrs are preovided

parent 121ed8a1
No related branches found
No related tags found
7 merge requests!319add all changes of dev into release v1.4.0 branch,!318Resolve "release v1.4.0",!283Merge latest develop into falcos issue,!279include Develop,!278Felix issue295 transformation parameters in data handler,!277Resolve "Transformation parameters in data_handler_single_station must be xarray",!259Draft: Resolve "WRF-Datahandler should inherit from SingleStationDatahandler"
Pipeline #63919 passed
......@@ -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":
......
......@@ -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."""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment