Skip to content

Commit

Permalink
more flexible stat tendencies generation
Browse files Browse the repository at this point in the history
  • Loading branch information
floriankrb committed Jun 19, 2024
1 parent bc734bf commit 16b1cb2
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/anemoi/datasets/create/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit 16b1cb2

Please sign in to comment.