From 16b1cb23019558d8e0a3000a7900974643d3a892 Mon Sep 17 00:00:00 2001 From: Florian Pinault Date: Wed, 19 Jun 2024 14:47:36 +0000 Subject: [PATCH] more flexible stat tendencies generation --- src/anemoi/datasets/create/__init__.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/anemoi/datasets/create/__init__.py b/src/anemoi/datasets/create/__init__.py index b5aed41c..c2f0effc 100644 --- a/src/anemoi/datasets/create/__init__.py +++ b/src/anemoi/datasets/create/__init__.py @@ -97,13 +97,14 @@ def patch(self, **kwargs): apply_patch(self.path, **kwargs) - def init_additions(self, delta=[1, 3, 6, 12, 24]): + def init_additions(self, delta=[1, 3, 6, 12, 24], statistics=True): from .loaders import StatisticsAddition from .loaders import TendenciesStatisticsAddition from .loaders import TendenciesStatisticsDeltaNotMultipleOfFrequency - a = StatisticsAddition.from_dataset(path=self.path, print=self.print) - a.initialise() + if statistics: + a = StatisticsAddition.from_dataset(path=self.path, print=self.print) + a.initialise() for d in delta: try: @@ -112,13 +113,14 @@ def init_additions(self, delta=[1, 3, 6, 12, 24]): except TendenciesStatisticsDeltaNotMultipleOfFrequency: self.print(f"Skipping delta={d} as it is not a multiple of the frequency.") - def run_additions(self, parts=None, delta=[1, 3, 6, 12, 24]): + def run_additions(self, parts=None, delta=[1, 3, 6, 12, 24], statistics=True): from .loaders import StatisticsAddition from .loaders import TendenciesStatisticsAddition from .loaders import TendenciesStatisticsDeltaNotMultipleOfFrequency - a = StatisticsAddition.from_dataset(path=self.path, print=self.print) - a.run(parts) + if statistics: + a = StatisticsAddition.from_dataset(path=self.path, print=self.print) + a.run(parts) for d in delta: try: @@ -127,13 +129,14 @@ def run_additions(self, parts=None, delta=[1, 3, 6, 12, 24]): except TendenciesStatisticsDeltaNotMultipleOfFrequency: self.print(f"Skipping delta={d} as it is not a multiple of the frequency.") - def finalise_additions(self, delta=[1, 3, 6, 12, 24]): + def finalise_additions(self, delta=[1, 3, 6, 12, 24], statistics=True): from .loaders import StatisticsAddition from .loaders import TendenciesStatisticsAddition from .loaders import TendenciesStatisticsDeltaNotMultipleOfFrequency - a = StatisticsAddition.from_dataset(path=self.path, print=self.print) - a.finalise() + if statistics: + a = StatisticsAddition.from_dataset(path=self.path, print=self.print) + a.finalise() for d in delta: try: