Skip to content

Commit

Permalink
working on w-avg operator
Browse files Browse the repository at this point in the history
  • Loading branch information
cehbrecht committed Oct 27, 2023
1 parent 23c85a1 commit c0a2508
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions rook/utils/weighted_average_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from roocs_utils.parameter import collection_parameter
from roocs_utils.parameter import dimension_parameter

from daops.ops.base import Operation

from clisops.ops import average_over_dims

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(params.get("dims"))
collection = collection_parameter.CollectionParameter(collection)

self.collection = collection
self.params = {
"dims": dims,
"ignore_undetected_dims": params.get("ignore_undetected_dims"),
}

# def get_operation_callable(self):
# return clisops_average_over_dims

def _calculate(self):
avg_ds = average_over_dims(
self.ds,
self.params.get("dims", None),
self.params.get("ignore_undetected_dims", None),
)

return avg_ds

0 comments on commit c0a2508

Please sign in to comment.