.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/01_simple_workflow.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_01_simple_workflow.py: Running Simple Inference ======================== Simple deterministic inference workflow. This example will demonstrate how to run a simple inference workflow to generate a simple determinstic forecast using one of the built in models of Earth-2 Inference Studio. In this example you will learn: - How to instantiate a built in prognostic model - Creating a data source and IO object - Running a simple built in workflow - Post-processing results .. GENERATED FROM PYTHON SOURCE LINES 37-42 Set Up ------ All workflows inside Earth2Studio require constructed components to be handed to them. In this example, let's take a look at the most basic: :py:meth:`earth2studio.run.deterministic`. .. GENERATED FROM PYTHON SOURCE LINES 44-47 .. literalinclude:: ../../earth2studio/run.py :language: python :lines: 35-42 .. GENERATED FROM PYTHON SOURCE LINES 49-54 Thus, we need the following: - Prognostic Model: Use the built in FourCastNet Model :py:class:`earth2studio.models.px.FCN`. - Datasource: Pull data from the GFS data api :py:class:`earth2studio.data.GFS`. - IO Backend: Let's save the outputs into a Zarr store :py:class:`earth2studio.io.ZarrBackend`. .. GENERATED FROM PYTHON SOURCE LINES 56-74 .. code-block:: Python from dotenv import load_dotenv load_dotenv() # TODO: make common example prep function from earth2studio.data import GFS from earth2studio.io import ZarrBackend from earth2studio.models.px import FCN # Load the default model package which downloads the check point from NGC package = FCN.load_default_package() model = FCN.load_model(package) # Create the data source data = GFS() # Create the IO handler, store in memory io = ZarrBackend() .. GENERATED FROM PYTHON SOURCE LINES 75-84 Execute the Workflow -------------------- With all components initialized, running the workflow is a single line of Python code. Workflow will return the provided IO object back to the user, which can be used to then post process. Some have additional APIs that can be handy for post-processing or saving to file. Check the API docs for more information. For the forecast we will predict for two days (these will get executed as a batch) for 20 forecast steps which is 5 days. .. GENERATED FROM PYTHON SOURCE LINES 86-93 .. code-block:: Python import earth2studio.run as run nsteps = 20 io = run.deterministic(["2024-01-01"], nsteps, model, data, io) print(io.root.tree()) .. rst-class:: sphx-glr-script-out .. code-block:: none 2024-04-19 00:24:51.126 | INFO | earth2studio.run:deterministic:68 - Running simple workflow! 2024-04-19 00:24:51.198 | INFO | earth2studio.run:deterministic:71 - Inference device: cuda 2024-04-19 00:24:51.365 | DEBUG | earth2studio.data.gfs:fetch_gfs_dataarray:151 - Fetching GFS index file: 2024-01-01 00:00:00 Fetching GFS for 2024-01-01 00:00:00: 0%| | 0/26 [00:00` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 01_simple_workflow.py <01_simple_workflow.py>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_