Skip to content

Commit

Permalink
added fixed file-namer
Browse files Browse the repository at this point in the history
  • Loading branch information
cehbrecht committed Nov 8, 2023
1 parent e768713 commit 4802b55
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion rook/utils/weighted_average_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@

from daops.ops.average import Average as DaopsAverage
from clisops.ops.average import Average as ClisopsAverage
from clisops.utils.file_namers import StandardFileNamer


class FixedFileNamer(StandardFileNamer):
def _get_project(self, ds):
return "c3s-cmip6"


def calc_weighted_mean(ds):
Expand All @@ -26,6 +32,14 @@ def calc_weighted_mean(ds):


class WeightedAverage_(ClisopsAverage):
def _get_file_namer(self):
extra = f"_w-avg"

# namer = get_file_namer(self._file_namer)(extra=extra)
namer = FixedFileNamer(extra=extra)

return namer

def _calculate(self):
avg_ds = calc_weighted_mean(self.ds)

Expand Down Expand Up @@ -57,7 +71,7 @@ def weighted_average(
output_dir=None,
output_type="netcdf",
split_method="time:auto",
file_namer="simple",
file_namer="standard",
apply_fixes=False,
):
result_set = WeightedAverage(**locals()).calculate()
Expand Down

0 comments on commit 4802b55

Please sign in to comment.