.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/12_temporal_interpolation.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_12_temporal_interpolation.py: Temporal Interpolation ====================== Temporal Interpolation inference using InterpModAFNO model. This example demonstrates how to use the InterpModAFNO model to interpolate forecasts from a base model to a finer time resolution. Many of the existing prognostic models have a step size of 6 hours which may prove insufficient for some applications. InterpModAFNO provides a AI driven method for getting hourly resolution given 6 hour predictions. In this example you will learn: - How to load a base prognostic model - How to load the InterpModAFNO model - How to run the interpolation model - How to visualize the results .. GENERATED FROM PYTHON SOURCE LINES 38-45 .. code-block:: Python # /// script # dependencies = [ # "earth2studio[sfno,interp-modafno] @ git+https://github.com/NVIDIA/earth2studio.git", # "matplotlib", # ] # /// .. GENERATED FROM PYTHON SOURCE LINES 46-58 Set Up ------ First, import the necessary modules and set up our environment and load the models. We will use SFNO as the base prognostic model and the InterpModAFNO model to interpolate its output to a finer time resolution. The prognostic model must predict the needed variables in the interpolation model. This example needs the following: - Interpolation Model: :py:class:`earth2studio.models.px.InterpModAFNO`. - Prognostic Base Model: Use SFNO model :py:class:`earth2studio.models.px.SFNO`. - Datasource: Pull data from the GFS data api :py:class:`earth2studio.data.GFS`. .. GENERATED FROM PYTHON SOURCE LINES 60-84 .. code-block:: Python import os import matplotlib.pyplot as plt from earth2studio.data import GFS from earth2studio.io import ZarrBackend from earth2studio.models.px import SFNO, InterpModAFNO # Create output directory os.makedirs("outputs", exist_ok=True) sfno_package = SFNO.load_default_package() px_model = SFNO.load_model(sfno_package) # Load the interpolation model interp_package = InterpModAFNO.load_default_package() interp_model = InterpModAFNO.load_model(interp_package, px_model=px_model) # Create the data source data = GFS() # Create the IO handler io = ZarrBackend() .. GENERATED FROM PYTHON SOURCE LINES 85-90 Run the Interpolation Model --------------------------- Now run the interpolation model to get forecasts at a finer time resolution. The base model (SFNO) produces forecasts at 6-hour intervals, and the interpolation model will interpolate to 1-hour intervals. .. GENERATED FROM PYTHON SOURCE LINES 92-104 .. code-block:: Python # Define forecast parameters forecast_date = "2024-01-01" nsteps = 5 # Number of interpolated forecast steps # Run the model from earth2studio.run import deterministic io = deterministic([forecast_date], nsteps, interp_model, data, io) print(io.root.tree()) .. rst-class:: sphx-glr-script-out .. code-block:: none 2025-12-15 01:26:25.110 | INFO | earth2studio.run:deterministic:75 - Running simple workflow! 2025-12-15 01:26:25.110 | INFO | earth2studio.run:deterministic:82 - Inference device: cuda Fetching GFS data: 0%| | 0/73 [00:00` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 12_temporal_interpolation.py <12_temporal_interpolation.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: 12_temporal_interpolation.zip <12_temporal_interpolation.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_