Skip to content

fix: Add check for date is None with earthkit-data GRIB input #184

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/anemoi/inference/inputs/ekd.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ def _create_input_state(
self,
input_fields: ekd.FieldList,
*,
date: Date,
date: Optional[Date] = None,
variables: Optional[List[str]] = None,
latitudes: Optional[FloatArray] = None,
longitudes: Optional[FloatArray] = None,
Expand Down Expand Up @@ -362,10 +362,16 @@ def _create_input_state(
State
The created input state.
"""
if date is None:
date = input_fields.order_by(valid_datetime="ascending")[-1].datetime()["valid_time"]
LOG.info(
"%s: `date` not provided, using the most recent date: %s", self.__class__.__name__, date.isoformat()
)

# TODO: where we do this might change in the future
date = to_datetime(date)

dates = [date + h for h in self.checkpoint.lagged]

return self._create_state(
input_fields,
variables=variables,
Expand Down
Loading