Skip to content

Commit

Permalink
#47 added statistics_tendencies func
Browse files Browse the repository at this point in the history
Co-authored-by: Jakob Schloer <jakob.schloer@gmail.com>
  • Loading branch information
Rilwan-Adewoyin committed Sep 4, 2024
1 parent 02b6ad9 commit 3d822ca
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/anemoi/training/data/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def __init__(
rollout: int = 1,
multistep: int = 1,
timeincrement: int = 1,
timestep: str = '6h',
model_comm_group_rank: int = 0,
model_comm_group_id: int = 0,
model_comm_num_groups: int = 1,
Expand All @@ -48,6 +49,8 @@ def __init__(
length of rollout window, by default 12
timeincrement : int, optional
time increment between samples, by default 1
timestep : int, optional
the time frequency of the samples, by default '6h'
multistep : int, optional
collate (t-1, ... t - multistep) into the input state vector, by default 1
model_comm_group_rank : int, optional
Expand All @@ -68,6 +71,7 @@ def __init__(

self.rollout = rollout
self.timeincrement = timeincrement
self.timestep = timestep

# lazy init
self.n_samples_per_epoch_total: int = 0
Expand Down Expand Up @@ -95,6 +99,14 @@ def statistics(self) -> dict:
"""Return dataset statistics."""
return self.data.statistics

@cached_property
def statistics_tendencies(self) -> dict:
"""Return dataset tendency statistics."""
# The statistics_tendencies are lazily loaded
if callable(self.data.statistics_tendencies):
self.data.statistics_tendencies = self.data.statistics_tendencies(self.timestep)
return self.data.statistics_tendencies

@cached_property
def metadata(self) -> dict:
"""Return dataset metadata."""
Expand Down

0 comments on commit 3d822ca

Please sign in to comment.