.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/09_stormcast_example.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_09_stormcast_example.py: Running StormCast Inference =========================== Basic StormCast inference workflow. This example will demonstrate how to run a simple inference workflow to generate a basic determinstic forecast using StormCast. For details about the stormcast model, see - https://arxiv.org/abs/2408.10958 .. GENERATED FROM PYTHON SOURCE LINES 33-38 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 40-44 .. literalinclude:: ../../earth2studio/run.py :language: python :start-after: # sphinx - deterministic start :end-before: # sphinx - deterministic end .. GENERATED FROM PYTHON SOURCE LINES 46-55 Thus, we need the following: - Prognostic Model: Use the built in StormCast Model :py:class:`earth2studio.models.px.StormCast`. - Datasource: Pull data from the HRRR data api :py:class:`earth2studio.data.HRRR`. - IO Backend: Let's save the outputs into a Zarr store :py:class:`earth2studio.io.ZarrBackend`. StormCast also requires a conditioning data source. We use a forecast data source here, GFS_FX :py:class:`earth2studio.data.GFS_FX`, but a non-forecast data source such as ARCO could also be used with appropriate time stamps. .. GENERATED FROM PYTHON SOURCE LINES 57-90 .. code-block:: Python from datetime import datetime, timedelta from loguru import logger from tqdm import tqdm logger.remove() logger.add(lambda msg: tqdm.write(msg, end=""), colorize=True) 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_FX, HRRR from earth2studio.io import ZarrBackend from earth2studio.models.px import StormCast # Load the default model package which downloads the check point from NGC package = StormCast.load_default_package() model = StormCast.load_model(package) # Create the data source data = HRRR() # Create and set the conditioning data source conditioning_data_source = GFS_FX() model.conditioning_data_source = conditioning_data_source # Create the IO handler, store in memory io = ZarrBackend() .. rst-class:: sphx-glr-script-out .. code-block:: none ╭─▌▌Herbie─────────────────────────────────────────────╮ │ INFO: Created a default config file. │ │ You may view/edit Herbie's configuration here: │ │ /root/.config/herbie/config.toml │ ╰──────────────────────────────────────────────────────╯ .. GENERATED FROM PYTHON SOURCE LINES 91-99 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 4 hours .. GENERATED FROM PYTHON SOURCE LINES 101-110 .. code-block:: Python import earth2studio.run as run nsteps = 4 today = datetime.today() - timedelta(days=1) date = today.isoformat().split("T")[0] io = run.deterministic([date], nsteps, model, data, io) print(io.root.tree()) .. rst-class:: sphx-glr-script-out .. code-block:: none 2025-03-27 08:01:00.806 | INFO | earth2studio.run:deterministic:75 - Running simple workflow! 2025-03-27 08:01:00.807 | INFO | earth2studio.run:deterministic:82 - Inference device: cuda Fetching HRRR data: 0%| | 0/99 [00:00` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 09_stormcast_example.py <09_stormcast_example.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: 09_stormcast_example.zip <09_stormcast_example.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_