-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |