Skip to content

Commit

Permalink
fix: use earthkit-data datetime valid_time
Browse files Browse the repository at this point in the history
  • Loading branch information
gmertes committed Sep 10, 2024
1 parent ff10e68 commit ba5b567
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/anemoi/inference/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def run(
LOGGER.info("Loading input: %d fields (lagged=%d)", len(input_fields), len(self.lagged))

if start_datetime is None:
start_datetime = input_fields.order_by(valid_datetime="ascending")[-1].metadata("valid_datetime")
start_datetime = input_fields.order_by(valid_datetime="ascending")[-1].datetime()["valid_time"]

num_fields_per_date = len(input_fields) // len(self.lagged) # assumed

Expand All @@ -129,7 +129,8 @@ def run(
for i, lag in enumerate(self.lagged):
date = start_datetime + datetime.timedelta(hours=lag)
dates_found = set(
field.datetime() for field in input_fields[i * num_fields_per_date : (i + 1) * num_fields_per_date]
field.datetime()["valid_time"]
for field in input_fields[i * num_fields_per_date : (i + 1) * num_fields_per_date]
)
# All chunks must have the same datetime that must agree with the lag
if dates_found != {date}:
Expand All @@ -139,7 +140,7 @@ def run(
f"Expected datetime: {date.isoformat()} (for lag {lag})"
)

input_fields_numpy = input_fields.to_numpy(dtype=np.float32, reshape=False)
input_fields_numpy = input_fields.to_numpy(dtype=np.float32)

print(input_fields_numpy.shape)

Expand Down

0 comments on commit ba5b567

Please sign in to comment.