From 6da07622cef307c2fc93abbfdc79d0fa096f0201 Mon Sep 17 00:00:00 2001 From: Pingu Carsti Date: Wed, 8 Nov 2023 15:55:45 +0100 Subject: [PATCH] clean up --- .gitignore | 1 + rook/utils/weighted_average_utils.py | 34 ++-------------------------- 2 files changed, 3 insertions(+), 32 deletions(-) diff --git a/.gitignore b/.gitignore index 430b9c7..dcdde5d 100644 --- a/.gitignore +++ b/.gitignore @@ -82,6 +82,7 @@ src/ *.log *.lock testdata.json +output_*.nc # IPython .ipynb_checkpoints diff --git a/rook/utils/weighted_average_utils.py b/rook/utils/weighted_average_utils.py index a78e6e7..1def1e4 100644 --- a/rook/utils/weighted_average_utils.py +++ b/rook/utils/weighted_average_utils.py @@ -1,12 +1,7 @@ import numpy as np -import xarray as xr - import collections -from roocs_utils.parameter import collection_parameter -from roocs_utils.parameter import dimension_parameter - from roocs_utils.project_utils import derive_ds_id from daops.ops.base import Operation @@ -14,8 +9,6 @@ from clisops.ops import subset -# from clisops.ops.average import average_over_dims as average - def apply_weighted_mean(ds): # fix cftime calendar @@ -33,44 +26,21 @@ def apply_weighted_mean(ds): class WeightedAverage(Operation): - def _resolve_params(self, collection, **params): - """ - Resolve the input parameters to `self.params` and parameterise - collection parameter and set to `self.collection`. - """ - dims = dimension_parameter.DimensionParameter(["latitude", "longitude"]) - collection = collection_parameter.CollectionParameter(collection) - - self.collection = collection - self.params = { - "dims": dims, - "ignore_undetected_dims": params.get("ignore_undetected_dims"), - } - def _calculate(self): - config = { - "output_type": self._output_type, - "output_dir": self._output_dir, - "split_method": self._split_method, - "file_namer": self._file_namer, - } - - self.params.update(config) - new_collection = collections.OrderedDict() for dset in self.collection: ds_id = derive_ds_id(dset) new_collection[ds_id] = dset.file_paths - # Normalise (i.e. "fix") data inputs based on "character" + # Normalise data inputs norm_collection = normalise.normalise( new_collection, False # self._apply_fixes ) rs = normalise.ResultSet(vars()) - # apply weights + # calculate weighted mean datasets = [] for ds_id in norm_collection.keys(): ds = norm_collection[ds_id]