Skip to content

CBottle Tropical Cyclone Guidance

Guided tropical cyclone sampling with cBottle and odds-ratio diagnostics.

This example demonstrates the cBottle TC guidance model for generating synthetic tropical cyclone samples at user-specified locations and computing the log-odds ratio between the guided and unguided distributions. The odds ratio quantifies how much more likely a particular sample is under guidance compared to the base model.

For more information on cBottle see:

For more information on the odds ratio see:

In this example you will learn:

  • Running guided TC sampling with earth2studio.models.dx.CBottleTCGuidance
  • Visualizing a guided sample over a regional domain
  • Reloading the model with second-order derivative support for odds-ratio computation
  • Computing and interpreting the log-odds ratio of a guided sample

Set Up

For this example we need the cBottle TC guidance diagnostic model. We load it twice:

  1. Default (fast) path for standard guided sampling
  2. Second-order-derivative path for odds-ratio computation

Thus, we need the following:

import os

os.makedirs("outputs", exist_ok=True)
from dotenv import load_dotenv

load_dotenv()  # TODO: make common example prep function

from datetime import datetime

import numpy as np
import torch

from earth2studio.models.dx import CBottleTCGuidance

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

# Load the default model package which downloads the checkpoint from NGC
package = CBottleTCGuidance.load_default_package()

Guided TC Sampling (Fast Path)

The guidance tensor marks the location where we want TC activity. Here we place a single guidance point near Florida and request one timestamp during hurricane season. The fast model path (allow_second_order_derivatives=False) is optimized for standard guided inference.

lat = torch.tensor([27.0], device=device)  # Near Florida
lon = torch.tensor([-82.0], device=device)  # Converted internally to [0, 360)
times = [datetime(2005, 10, 11, 12)]

model = CBottleTCGuidance.load_model(package).to(device)
model.set_rng(0)
# Create guidance tensor
guidance = model.create_guidance_tensor(lat, lon, times)
# Run guided sampling
guided_sample = model(guidance)
Console output31 lines
Downloading ema-checkpoint-002176000.checkpoint: 0%|          | 0.00/568M [00:00<?, ?B/s]
Downloading ema-checkpoint-002176000.checkpoint: 2%|โ–         | 10.0M/568M [00:00<00:41, 14.0MB/s]
Downloading ema-checkpoint-002176000.checkpoint: 5%|โ–Œ         | 30.0M/568M [00:00<00:13, 42.2MB/s]
Downloading ema-checkpoint-002176000.checkpoint: 9%|โ–‰         | 50.0M/568M [00:01<00:08, 67.0MB/s]
Downloading ema-checkpoint-002176000.checkpoint: 12%|โ–ˆโ–        | 70.0M/568M [00:01<00:05, 87.6MB/s]
Downloading ema-checkpoint-002176000.checkpoint: 16%|โ–ˆโ–Œ        | 90.0M/568M [00:01<00:04, 104MB/s] 
Downloading ema-checkpoint-002176000.checkpoint: 19%|โ–ˆโ–‰        | 110M/568M [00:01<00:04, 116MB/s] 
Downloading ema-checkpoint-002176000.checkpoint: 23%|โ–ˆโ–ˆโ–Ž       | 130M/568M [00:01<00:03, 126MB/s]
Downloading ema-checkpoint-002176000.checkpoint: 26%|โ–ˆโ–ˆโ–‹       | 150M/568M [00:01<00:03, 134MB/s]
Downloading ema-checkpoint-002176000.checkpoint: 30%|โ–ˆโ–ˆโ–‰       | 170M/568M [00:01<00:02, 140MB/s]
Downloading ema-checkpoint-002176000.checkpoint: 33%|โ–ˆโ–ˆโ–ˆโ–Ž      | 190M/568M [00:02<00:02, 144MB/s]
Downloading ema-checkpoint-002176000.checkpoint: 37%|โ–ˆโ–ˆโ–ˆโ–‹      | 210M/568M [00:02<00:02, 145MB/s]
Downloading ema-checkpoint-002176000.checkpoint: 40%|โ–ˆโ–ˆโ–ˆโ–ˆ      | 230M/568M [00:02<00:02, 147MB/s]
Downloading ema-checkpoint-002176000.checkpoint: 44%|โ–ˆโ–ˆโ–ˆโ–ˆโ–     | 250M/568M [00:02<00:02, 149MB/s]
Downloading ema-checkpoint-002176000.checkpoint: 48%|โ–ˆโ–ˆโ–ˆโ–ˆโ–Š     | 270M/568M [00:02<00:02, 149MB/s]
Downloading ema-checkpoint-002176000.checkpoint: 51%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ     | 290M/568M [00:02<00:01, 150MB/s]
Downloading ema-checkpoint-002176000.checkpoint: 55%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–    | 310M/568M [00:02<00:01, 144MB/s]
Downloading ema-checkpoint-002176000.checkpoint: 58%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–Š    | 330M/568M [00:03<00:01, 143MB/s]
Downloading ema-checkpoint-002176000.checkpoint: 62%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–   | 350M/568M [00:03<00:01, 146MB/s]
Downloading ema-checkpoint-002176000.checkpoint: 65%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–Œ   | 370M/568M [00:03<00:01, 148MB/s]
Downloading ema-checkpoint-002176000.checkpoint: 69%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–Š   | 390M/568M [00:03<00:01, 149MB/s]
Downloading ema-checkpoint-002176000.checkpoint: 72%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–  | 410M/568M [00:03<00:01, 150MB/s]
Downloading ema-checkpoint-002176000.checkpoint: 76%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–Œ  | 430M/568M [00:03<00:00, 152MB/s]
Downloading ema-checkpoint-002176000.checkpoint: 79%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‰  | 450M/568M [00:03<00:00, 153MB/s]
Downloading ema-checkpoint-002176000.checkpoint: 83%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–Ž | 470M/568M [00:03<00:00, 153MB/s]
Downloading ema-checkpoint-002176000.checkpoint: 86%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–Œ | 490M/568M [00:04<00:00, 154MB/s]
Downloading ema-checkpoint-002176000.checkpoint: 90%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‰ | 510M/568M [00:04<00:00, 154MB/s]
Downloading ema-checkpoint-002176000.checkpoint: 93%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–Ž| 530M/568M [00:04<00:00, 154MB/s]
Downloading ema-checkpoint-002176000.checkpoint: 97%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‹| 550M/568M [00:04<00:00, 153MB/s]
Downloading ema-checkpoint-002176000.checkpoint: 100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 568M/568M [00:04<00:00, 154MB/s]
Downloading ema-checkpoint-002176000.checkpoint: 100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 568M/568M [00:04<00:00, 128MB/s]

Post Processing Guided Sample

Plot the 10-metre zonal wind (u10m) over a Caribbean domain to visualize the generated tropical cyclone structure.

import cartopy.crs as ccrs
import matplotlib.pyplot as plt

plt.close("all")

variables = guided_sample.coords["variable"].values
u_var = "u10m"
u_idx = int(np.where(variables == u_var)[0][0])

# guided_sample dims: [time, lead_time, variable, lat, lon]
u = guided_sample[0, 0, u_idx].e2s.as_numpy().values
lat_coords = guided_sample.coords["lat"].values
lon_coords = guided_sample.coords["lon"].values

# Caribbean box in 0-360 longitude convention
lon_min, lon_max = 260.0, 300.0  # 100W to 60W
lat_min, lat_max = 15.0, 40.0  # 15N to 40N
lon_mask = (lon_coords >= lon_min) & (lon_coords <= lon_max)
lat_mask = (lat_coords >= lat_min) & (lat_coords <= lat_max)

u_carib = u[np.ix_(lat_mask, lon_mask)]
lat_carib = lat_coords[lat_mask]
lon_carib = lon_coords[lon_mask]
# Convert to -180..180 for plotting
lon_carib_deg = ((lon_carib + 180.0) % 360.0) - 180.0

fig, ax = plt.subplots(subplot_kw={"projection": ccrs.PlateCarree()}, figsize=(8, 4.5))
pcm = ax.pcolormesh(
    lon_carib_deg,
    lat_carib,
    u_carib,
    shading="auto",
    cmap="RdBu_r",
    vmin=-30,
    vmax=30,
    transform=ccrs.PlateCarree(),
)
ax.set_extent([-100.0, -60.0, lat_min, lat_max], crs=ccrs.PlateCarree())
ax.coastlines(resolution="110m", linewidth=0.8)
ax.gridlines(draw_labels=True, linewidth=0.5, alpha=0.5, linestyle="--")
plt.colorbar(pcm, ax=ax, label=f"{u_var} (m/s)", pad=0.08, shrink=0.92)
ax.set_title("Guided TC Sample: 10m Zonal Wind")
plt.tight_layout()
plt.savefig("outputs/05_cbottle_tc_guided_sample.jpg")

Output from CBottle Tropical Cyclone Guidance

Computing the Odds Ratio

The odds ratio requires computing Hutchinson divergence terms that need second-order derivatives through the model. We reload with allow_second_order_derivatives=True for odds ratio calculations.

Note: sampler_steps is also reduced in this section to speed up runtime. Use the default sampler settings for improved quality and more stable odds-ratio values.

model = CBottleTCGuidance.load_model(
    package,
    sampler_steps=2,
    allow_second_order_derivatives=True,
).to(device)
model.set_rng(0)

log_odds_ratio, forward_latents = model.calculate_odds_ratio(guidance)

print(f"Log odds ratio: {log_odds_ratio:.4f}")
print(f"Forward latents shape: {tuple(forward_latents.shape)}")
Console output89 lines
calculate_odds_ratio[forward]:   0%|          | 0/27 [00:00<?, ?it/s]
calculate_odds_ratio[forward]:   4%|โ–Ž         | 1/27 [00:01<00:27,  1.04s/it]
calculate_odds_ratio[forward]:   7%|โ–‹         | 2/27 [00:02<00:25,  1.02s/it]
calculate_odds_ratio[forward]:  11%|โ–ˆ         | 3/27 [00:03<00:24,  1.02s/it]
calculate_odds_ratio[forward]:  15%|โ–ˆโ–        | 4/27 [00:04<00:23,  1.00s/it]
calculate_odds_ratio[forward]:  19%|โ–ˆโ–Š        | 5/27 [00:05<00:21,  1.00it/s]
calculate_odds_ratio[forward]:  22%|โ–ˆโ–ˆโ–       | 6/27 [00:06<00:21,  1.01s/it]
calculate_odds_ratio[forward]:  26%|โ–ˆโ–ˆโ–Œ       | 7/27 [00:07<00:20,  1.00s/it]
calculate_odds_ratio[forward]:  30%|โ–ˆโ–ˆโ–‰       | 8/27 [00:08<00:21,  1.13s/it]
calculate_odds_ratio[forward]:  33%|โ–ˆโ–ˆโ–ˆโ–Ž      | 9/27 [00:09<00:19,  1.08s/it]
calculate_odds_ratio[forward]:  37%|โ–ˆโ–ˆโ–ˆโ–‹      | 10/27 [00:10<00:18,  1.06s/it]
calculate_odds_ratio[forward]:  41%|โ–ˆโ–ˆโ–ˆโ–ˆ      | 11/27 [00:11<00:16,  1.03s/it]
calculate_odds_ratio[forward]:  44%|โ–ˆโ–ˆโ–ˆโ–ˆโ–     | 12/27 [00:12<00:15,  1.02s/it]
calculate_odds_ratio[forward]:  48%|โ–ˆโ–ˆโ–ˆโ–ˆโ–Š     | 13/27 [00:13<00:14,  1.02s/it]
calculate_odds_ratio[forward]:  52%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–    | 14/27 [00:14<00:13,  1.02s/it]
calculate_odds_ratio[forward]:  56%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–Œ    | 15/27 [00:15<00:12,  1.01s/it]
calculate_odds_ratio[forward]:  59%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‰    | 16/27 [00:16<00:10,  1.01it/s]
calculate_odds_ratio[forward]:  63%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–Ž   | 17/27 [00:17<00:09,  1.00it/s]
calculate_odds_ratio[forward]:  67%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‹   | 18/27 [00:18<00:08,  1.01it/s]
calculate_odds_ratio[forward]:  70%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ   | 19/27 [00:19<00:07,  1.01it/s]
calculate_odds_ratio[forward]:  74%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–  | 20/27 [00:20<00:06,  1.01it/s]
calculate_odds_ratio[forward]:  78%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–Š  | 21/27 [00:21<00:05,  1.00it/s]
calculate_odds_ratio[forward]:  81%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ– | 22/27 [00:22<00:05,  1.00s/it]
calculate_odds_ratio[forward]:  85%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–Œ | 23/27 [00:23<00:03,  1.00it/s]
calculate_odds_ratio[forward]:  89%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‰ | 24/27 [00:24<00:03,  1.00s/it]
calculate_odds_ratio[forward]:  93%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–Ž| 25/27 [00:25<00:02,  1.01s/it]
calculate_odds_ratio[forward]:  96%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‹| 26/27 [00:26<00:01,  1.14s/it]
calculate_odds_ratio[forward]: 100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 27/27 [00:27<00:00,  1.10s/it]


calculate_odds_ratio[backward]:   0%|          | 0/26 [00:00<?, ?it/s]
calculate_odds_ratio[backward]:   4%|โ–         | 1/26 [00:04<02:02,  4.89s/it]
calculate_odds_ratio[backward]:   8%|โ–Š         | 2/26 [00:09<01:55,  4.81s/it]
calculate_odds_ratio[backward]:  12%|โ–ˆโ–        | 3/26 [00:16<02:09,  5.61s/it]
calculate_odds_ratio[backward]:  15%|โ–ˆโ–Œ        | 4/26 [00:22<02:10,  5.95s/it]
calculate_odds_ratio[backward]:  19%|โ–ˆโ–‰        | 5/26 [00:29<02:08,  6.13s/it]
calculate_odds_ratio[backward]:  23%|โ–ˆโ–ˆโ–Ž       | 6/26 [00:35<02:04,  6.25s/it]
calculate_odds_ratio[backward]:  27%|โ–ˆโ–ˆโ–‹       | 7/26 [00:42<01:59,  6.30s/it]
calculate_odds_ratio[backward]:  31%|โ–ˆโ–ˆโ–ˆ       | 8/26 [00:48<01:54,  6.34s/it]
calculate_odds_ratio[backward]:  35%|โ–ˆโ–ˆโ–ˆโ–      | 9/26 [00:54<01:48,  6.37s/it]
calculate_odds_ratio[backward]:  38%|โ–ˆโ–ˆโ–ˆโ–Š      | 10/26 [01:01<01:42,  6.40s/it]
calculate_odds_ratio[backward]:  42%|โ–ˆโ–ˆโ–ˆโ–ˆโ–     | 11/26 [01:07<01:36,  6.41s/it]
calculate_odds_ratio[backward]:  46%|โ–ˆโ–ˆโ–ˆโ–ˆโ–Œ     | 12/26 [01:14<01:29,  6.41s/it]
calculate_odds_ratio[backward]:  50%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ     | 13/26 [01:21<01:25,  6.57s/it]
calculate_odds_ratio[backward]:  54%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–    | 14/26 [01:27<01:18,  6.53s/it]
calculate_odds_ratio[backward]:  58%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–Š    | 15/26 [01:34<01:11,  6.51s/it]
calculate_odds_ratio[backward]:  62%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–   | 16/26 [01:40<01:04,  6.50s/it]
calculate_odds_ratio[backward]:  65%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–Œ   | 17/26 [01:46<00:58,  6.48s/it]
calculate_odds_ratio[backward]:  69%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‰   | 18/26 [01:53<00:51,  6.47s/it]
calculate_odds_ratio[backward]:  73%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–Ž  | 19/26 [01:59<00:45,  6.47s/it]
calculate_odds_ratio[backward]:  77%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‹  | 20/26 [02:06<00:38,  6.48s/it]
calculate_odds_ratio[backward]:  81%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ  | 21/26 [02:12<00:32,  6.48s/it]
calculate_odds_ratio[backward]:  85%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ– | 22/26 [02:19<00:25,  6.48s/it]
calculate_odds_ratio[backward]:  88%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–Š | 23/26 [02:25<00:19,  6.46s/it]
calculate_odds_ratio[backward]:  92%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–| 24/26 [02:32<00:12,  6.45s/it]
calculate_odds_ratio[backward]:  96%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–Œ| 25/26 [02:38<00:06,  6.45s/it]
calculate_odds_ratio[backward]: 100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 26/26 [02:43<00:00,  6.04s/it]


calculate_odds_ratio[backward_no_guidance]:   0%|          | 0/26 [00:00<?, ?it/s]
calculate_odds_ratio[backward_no_guidance]:   4%|โ–         | 1/26 [00:04<01:44,  4.17s/it]
calculate_odds_ratio[backward_no_guidance]:   8%|โ–Š         | 2/26 [00:08<01:40,  4.18s/it]
calculate_odds_ratio[backward_no_guidance]:  12%|โ–ˆโ–        | 3/26 [00:12<01:35,  4.17s/it]
calculate_odds_ratio[backward_no_guidance]:  15%|โ–ˆโ–Œ        | 4/26 [00:16<01:31,  4.16s/it]
calculate_odds_ratio[backward_no_guidance]:  19%|โ–ˆโ–‰        | 5/26 [00:20<01:27,  4.16s/it]
calculate_odds_ratio[backward_no_guidance]:  23%|โ–ˆโ–ˆโ–Ž       | 6/26 [00:24<01:22,  4.15s/it]
calculate_odds_ratio[backward_no_guidance]:  27%|โ–ˆโ–ˆโ–‹       | 7/26 [00:29<01:18,  4.15s/it]
calculate_odds_ratio[backward_no_guidance]:  31%|โ–ˆโ–ˆโ–ˆ       | 8/26 [00:33<01:14,  4.16s/it]
calculate_odds_ratio[backward_no_guidance]:  35%|โ–ˆโ–ˆโ–ˆโ–      | 9/26 [00:37<01:10,  4.16s/it]
calculate_odds_ratio[backward_no_guidance]:  38%|โ–ˆโ–ˆโ–ˆโ–Š      | 10/26 [00:41<01:06,  4.16s/it]
calculate_odds_ratio[backward_no_guidance]:  42%|โ–ˆโ–ˆโ–ˆโ–ˆโ–     | 11/26 [00:45<01:02,  4.16s/it]
calculate_odds_ratio[backward_no_guidance]:  46%|โ–ˆโ–ˆโ–ˆโ–ˆโ–Œ     | 12/26 [00:49<00:58,  4.15s/it]
calculate_odds_ratio[backward_no_guidance]:  50%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ     | 13/26 [00:54<00:54,  4.16s/it]
calculate_odds_ratio[backward_no_guidance]:  54%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–    | 14/26 [00:58<00:49,  4.16s/it]
calculate_odds_ratio[backward_no_guidance]:  58%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–Š    | 15/26 [01:02<00:45,  4.16s/it]
calculate_odds_ratio[backward_no_guidance]:  62%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–   | 16/26 [01:07<00:43,  4.31s/it]
calculate_odds_ratio[backward_no_guidance]:  65%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–Œ   | 17/26 [01:11<00:38,  4.28s/it]
calculate_odds_ratio[backward_no_guidance]:  69%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‰   | 18/26 [01:15<00:34,  4.25s/it]
calculate_odds_ratio[backward_no_guidance]:  73%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–Ž  | 19/26 [01:19<00:29,  4.23s/it]
calculate_odds_ratio[backward_no_guidance]:  77%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‹  | 20/26 [01:23<00:25,  4.23s/it]
calculate_odds_ratio[backward_no_guidance]:  81%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ  | 21/26 [01:28<00:21,  4.21s/it]
calculate_odds_ratio[backward_no_guidance]:  85%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ– | 22/26 [01:32<00:16,  4.21s/it]
calculate_odds_ratio[backward_no_guidance]:  88%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–Š | 23/26 [01:36<00:12,  4.20s/it]
calculate_odds_ratio[backward_no_guidance]:  92%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–| 24/26 [01:40<00:08,  4.19s/it]
calculate_odds_ratio[backward_no_guidance]:  96%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–Œ| 25/26 [01:44<00:04,  4.19s/it]
calculate_odds_ratio[backward_no_guidance]: 100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 26/26 [01:48<00:00,  4.18s/it]

Log odds ratio: 3.2442
Forward latents shape: (1, 1, 45, 721, 1440)

Post Processing Forward Latents

The forward_latents tensor is returned on the same grid as the model output (lat-lon when lat_lon=True). We visualize a single channel (u10m) over the same Caribbean domain. This shows the latent-space representation that the odds-ratio computation operates on.

plt.close("all")

# Identify the u10m channel in output variable ordering
latent_variables = forward_latents.coords["variable"].values
u_latent_idx = int(np.where(latent_variables == u_var)[0][0])
latent_u = forward_latents.sel(variable=u_var).squeeze().e2s.as_numpy().values

latent_u_carib = latent_u[np.ix_(lat_mask, lon_mask)]

fig, ax = plt.subplots(subplot_kw={"projection": ccrs.PlateCarree()}, figsize=(8, 4.5))
pcm = ax.pcolormesh(
    lon_carib_deg,
    lat_carib,
    latent_u_carib,
    shading="auto",
    cmap="viridis",
    transform=ccrs.PlateCarree(),
)
ax.set_extent([-100.0, -60.0, lat_min, lat_max], crs=ccrs.PlateCarree())
ax.coastlines(resolution="110m", linewidth=0.8)
ax.gridlines(draw_labels=True, linewidth=0.5, alpha=0.5, linestyle="--")
plt.colorbar(pcm, ax=ax, label=f"Forward Latent ({u_var})", pad=0.08, shrink=0.92)
ax.set_title(f"Forward Latents: {u_var} Channel")
plt.tight_layout()
plt.savefig("outputs/05_cbottle_tc_forward_latents.jpg")

Output from CBottle Tropical Cyclone Guidance


Execution profile

Runtime telemetry

Total runtime5m 55s

Execution environment

CPUAMD EPYC 9554 64-Core Processor
GPUNVIDIA H100 NVL ยท 93.6 GiB
System RAM58.4 GiB
PlatformLinux 6.8.0-147-generic
Python3.13.13
GPU driver / CUDADriver 595.99.02 ยท CUDA support 13.2