.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/01_deterministic_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_deterministic_workflow.py: Running Deterministic Inference =============================== Basic deterministic inference workflow. This example will demonstrate how to run a simple inference workflow to generate a basic 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-48 .. literalinclude:: ../../earth2studio/run.py :language: python :start-after: # sphinx - deterministic start :end-before: # sphinx - deterministic end .. GENERATED FROM PYTHON SOURCE LINES 50-55 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 57-78 .. code-block:: Python import os os.makedirs("outputs", exist_ok=True) 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() .. rst-class:: sphx-glr-script-out .. code-block:: none 2025-03-27 07:55:25.162 | WARNING | earth2studio.models.auto.ngc:__init__:109 - Using NGC guest mode, which may fail due to unauthorized access. Consider using a valid NGC API key. /usr/lib/python3.12/tarfile.py:2254: DeprecationWarning: Python 3.14 will, by default, filter extracted tar archives and reject files or modify their metadata. Use the filter argument to control this behavior. warnings.warn( /usr/local/lib/python3.12/dist-packages/physicsnemo/registry/model_registry.py:48: DeprecationWarning: Model SFNO is being loaded from the 'modulus.models' group. This probably means it is being exposed from a package that has not yet been updated to use the 'physicsnemo.models' group. This group may be removed in a future release. Please contact the package maintainer to update the entry point. cls._shared_state["_model_registry"] = cls._construct_registry() .. GENERATED FROM PYTHON SOURCE LINES 79-88 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 90-97 .. 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 2025-03-27 07:55:30.403 | INFO | earth2studio.run:deterministic:75 - Running simple workflow! 2025-03-27 07:55:30.404 | INFO | earth2studio.run:deterministic:82 - Inference device: cuda /home/jenkins/agent/workspace/Studio-Build-Docs/repo/earth2studio/utils/time.py:38: DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC). time = [datetime.utcfromtimestamp((date - _unix) / _ds) for date in time] 2025-03-27 07:55:30.570 | DEBUG | earth2studio.data.gfs:_fetch_gfs_dataarray:214 - Fetching GFS index file: 2024-01-01 00:00:00 lead 0: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_deterministic_workflow.py <01_deterministic_workflow.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: 01_deterministic_workflow.zip <01_deterministic_workflow.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_