-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
165 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import datetime | ||
|
||
import numpy as np | ||
|
||
from anemoi.inference.runner import DefaultRunner | ||
|
||
# Create a runner with the checkpoint file | ||
runner = DefaultRunner("checkpoint.ckpt") | ||
|
||
# Select a starting date | ||
date = datetime.datetime(2024, 10, 25) | ||
|
||
# Assuming that the initial conditions requires two | ||
# dates, e.g. T0 and T-6 | ||
|
||
lagged = 2 | ||
|
||
# Define the grid | ||
|
||
latitudes = np.linspace(90, -90, 181) # 1 degree resolution | ||
longitudes = np.linspace(0, 359, 360) | ||
|
||
number_of_points = len(latitudes) * len(longitudes) | ||
latitudes, longitudes = np.meshgrid(latitudes, longitudes) | ||
|
||
# Create the initial state | ||
|
||
input_state = { | ||
"date": date, | ||
"latitudes": latitudes, | ||
"longitudes": longitudes, | ||
"fields": { | ||
"2t": np.random.rand(lagged, number_of_points), | ||
"msl": np.random.rand(lagged, number_of_points), | ||
"z_500": np.random.rand(lagged, number_of_points), | ||
...: ..., | ||
}, | ||
} | ||
|
||
# Run the model | ||
|
||
for state in runner.run(input_state=input_state, lead_time=240): | ||
# This is the date of the new state | ||
print("New state:", state["date"]) | ||
|
||
# This is value of a field for that date | ||
print("Forecasted 2t:", state["fields"]["2t"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.. _api_level1: | ||
|
||
#################### | ||
NumPy to NumPy API | ||
#################### | ||
|
||
The simplest way to run a inference from a checkpoint is to provide the | ||
initial state as a dictionary containing NumPy arrays for each input | ||
variable. | ||
|
||
You then create a Runner object and call the `run` method, which will | ||
yield the state at each time step. Below is a simple code example to | ||
illustrate this: | ||
|
||
.. literalinclude:: code/state.py | ||
:language: python |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.. _api_level2: | ||
|
||
##################### | ||
Object oriented API | ||
##################### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.. _api_level1: | ||
|
||
################## | ||
Command line API | ||
################## |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
inspect | ||
========== | ||
|
||
.. argparse:: | ||
:module: anemoi.inference.__main__ | ||
:func: create_parser | ||
:prog: anemoi-inference | ||
:path: inspect |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
patch | ||
========== | ||
|
||
.. argparse:: | ||
:module: anemoi.inference.__main__ | ||
:func: create_parser | ||
:prog: anemoi-inference | ||
:path: patch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
requests | ||
========== | ||
|
||
.. argparse:: | ||
:module: anemoi.inference.__main__ | ||
:func: create_parser | ||
:prog: anemoi-inference | ||
:path: requests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
run | ||
========== | ||
|
||
.. argparse:: | ||
:module: anemoi.inference.__main__ | ||
:func: create_parser | ||
:prog: anemoi-inference | ||
:path: run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
############ | ||
checkpoint | ||
############ | ||
|
||
.. automodule:: anemoi.inference.checkpoint | ||
:members: | ||
:no-undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
########## | ||
forcings | ||
########## | ||
|
||
.. automodule:: anemoi.inference.forcings | ||
:members: | ||
:no-undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
####### | ||
input | ||
####### | ||
|
||
.. automodule:: anemoi.inference.input | ||
:members: | ||
:no-undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
########## | ||
metadata | ||
########## | ||
|
||
.. automodule:: anemoi.inference.metadata | ||
:members: | ||
:no-undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
######## | ||
output | ||
######## | ||
|
||
.. automodule:: anemoi.inference.output | ||
:members: | ||
:no-undoc-members: | ||
:show-inheritance: |
File renamed without changes.