Skip to content

Commit

Permalink
fix accumulations
Browse files Browse the repository at this point in the history
  • Loading branch information
b8raoult committed Apr 1, 2024
1 parent ba8c19c commit d8f0505
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion anemoi/datasets/create/functions/actions/accumulations.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ def add(self, field, values):
@classmethod
def mars_date_time_steps(cls, dates, step1, step2, frequency, base_times, adjust_step):

# assert step1 > 0, (step1, step2, frequency)

for valid_date in dates:
base_date = valid_date - datetime.timedelta(hours=step2)
add_step = 0
Expand Down Expand Up @@ -191,9 +193,10 @@ def compute(self, values, startStep, endStep):
@classmethod
def _mars_date_time_step(cls, base_date, step1, step2, add_step, frequency):
assert frequency > 0, frequency
# assert step1 > 0, (step1, step2, frequency, add_step, base_date)

steps = []
for step in range(step1, step2, frequency):
for step in range(step1 + frequency, step2 + frequency, frequency):
steps.append(step + add_step)
return (
base_date.year * 10000 + base_date.month * 100 + base_date.day,
Expand Down Expand Up @@ -286,6 +289,7 @@ def compute_accumulations(
ds = cml.load_source("empty")
for r in compressed.iterate():
request.update(r)
print("🌧️", request)
ds = ds + cml.load_source("mars", **request)

accumulations = defaultdict(list)
Expand Down Expand Up @@ -382,6 +386,8 @@ def accumulations(context, dates, **request):

kwargs = KWARGS.get((class_, stream), {})

context.trace('🌧️', f"accumulations {request} {user_accumulation_period} {kwargs}")

return compute_accumulations(
dates,
request,
Expand Down

0 comments on commit d8f0505

Please sign in to comment.