.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/16_cbottle_super_resolution.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_16_cbottle_super_resolution.py: CBottle Super Resolution ======================== Climate in a Bottle (cBottle) super resolution workflows for global weather. This example will demonstrate the cBottle diffusion model for super resolution of global weather data. The CBottleSR model takes low-resolution climate data and generates high-resolution outputs using a diffusion-based approach. For more information on cBottle see: - https://arxiv.org/abs/2505.06474v1 In this example you will learn: - Performing super resolution on synthetic data from the cBottle data source - Performing super resolution on ERA5 data after infilling with cBottle - Post-processing and visualizing super-resolution results .. GENERATED FROM PYTHON SOURCE LINES 38-45 .. code-block:: Python # /// script # dependencies = [ # "earth2studio[cbottle] @ git+https://github.com/NVIDIA/earth2studio.git", # "cartopy", # ] # /// .. GENERATED FROM PYTHON SOURCE LINES 46-53 Set Up ------ For this example we will use the cBottle data source, infill diagnostic, and the CBottleSR super resolution model. The workflow demonstrates two approaches: 1. Super resolution on synthetic data generated by cBottle3D 2. Super resolution on real ERA5 data after variable infilling .. GENERATED FROM PYTHON SOURCE LINES 55-61 We need the following components: - Datasource: Generate data from the CBottle3D data api :py:class:`earth2studio.data.CBottle3D`. - Datasource: Pull data from the WeatherBench2 data api :py:class:`earth2studio.data.WB2ERA5`. - Diagnostic Model: Use the built in CBottle Infill Model :py:class:`earth2studio.models.dx.CBottleInfill`. - Super Resolution Model: Use the CBottleSR super resolution model :py:class:`earth2studio.models.dx.CBottleSR`. .. GENERATED FROM PYTHON SOURCE LINES 63-110 .. code-block:: Python import os os.makedirs("outputs", exist_ok=True) from dotenv import load_dotenv load_dotenv() # TODO: make common example prep function import torch from earth2studio.data import WB2ERA5, CBottle3D, fetch_data from earth2studio.models.dx import CBottleInfill, CBottleSR # Get the device device = torch.device("cuda" if torch.cuda.is_available() else "cpu") # Load the cBottle data source package = CBottle3D.load_default_package() cbottle_ds = CBottle3D.load_model(package) cbottle_ds = cbottle_ds.to(device) # Load the super resolution model super_resolution_window = ( 0, -120, 50, -40, ) # (lat south, lon west, lat north, lon east) package = CBottleSR.load_default_package() cbottle_sr = CBottleSR.load_model( package, output_resolution=(1024, 1024), super_resolution_window=super_resolution_window, ) cbottle_sr = cbottle_sr.to(device) # Load the infill model input_variables = ["u10m", "v10m"] package = CBottleInfill.load_default_package() cbottle_infill = CBottleInfill.load_model( package, input_variables=input_variables, sampler_steps=18 ) cbottle_infill = cbottle_infill.to(device) # Load the ERA5 data source era5_ds = WB2ERA5() .. rst-class:: sphx-glr-script-out .. code-block:: none Downloading cBottle-SR.zip: 0%| | 0.00/2.46G [00:00` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 16_cbottle_super_resolution.py <16_cbottle_super_resolution.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: 16_cbottle_super_resolution.zip <16_cbottle_super_resolution.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_