Skip to content

CAMulator

GlobalCM202524 GBNCARPyTorch

Import path: earth2studio.models.px.CAMulator

View source on GitHub View install commands

Documentation

Bases: Module, AutoModelMixin, PrognosticMixin

CAMulator global climate emulator prognostic model. Consists of a single CrossFormer model with a time-step size of 6 hours. CAMulator operates on the 1 degree (192x288) CESM finite-volume lat-lon grid with 130 prognostic variables on 32 hybrid sigma-pressure levels and 17 output-only diagnostics, driven by prescribed sea-surface temperature, sea-ice fraction, TOA insolation and CO2 forcing that callers supply at the input valid time.

The inference-time post-processing of the CREDIT toolbox is reproduced: tracer clipping, the jet wind-artifact filter and the global dry-air mass, water and total-energy conservation fixers. The iterator yields forecasts only, and only the prognostic slice is fed back at each step. Vertical levels use the {var}{k}k naming with k the CAMulator hybrid level index (0 = top of model, 31 = lowest layer). Fluxes CAMulator accumulates over the 6 h step (J m-2) are returned as mean rates (W m-2); precipitation and evaporation are 6 h accumulations (m). The CREDIT toolbox's Quick_Climate.py uses the forcing stored in its initial-condition tensor for the first step, whereas this wrapper takes the supplied forcing at every step; with the same forcing the two agree to float32 rounding. Outputs are stamped with their valid time: time + lead_time of the output coordinates is the time the state is valid for, 6 hours after the input that produced it, whereas older CREDIT tooling stamps each output with its input time.

default_sources recommends forcing_data_source, by default the cyclic climatological year (1980-2014 mean seasonal cycle, CO2 fixed at its year-2000 mean of 369 ppm), so a default rollout is a climatology run; no published CAMulator result uses this forcing. Pass CAMulatorForcing(mode="transient") for the 1980-2014 record. The wrapper runs at PyTorch's default precision (TF32 matmul and cuDNN convolutions enabled on Ampere and later GPUs), as did the published checkpoint-69 runs. Reproducing the bitwise comparison against the CREDIT toolbox requires disabling TF32 and enabling deterministic algorithms on both sides.

Note

This model is NSF NCAR's autoregressive emulator of the CAM6 atmosphere, trained in the CREDIT framework. For more information see the following references:

Parameters:

  • core_model (Module) –

    CAMulator CrossFormer network mapping (batch, 136, 1, lat, lon) to (batch, 147, 1, lat, lon) in normalized units.

  • center (Tensor) –

    Normalization mean of the 147 output channels, shape (147, lat, lon).

  • scale (Tensor) –

    Normalization std of the 147 output channels, shape (147, lat, lon).

  • forcing_center (Tensor) –

    Normalization mean of the 4 forcing channels, shape (4,).

  • forcing_scale (Tensor) –

    Normalization std of the 4 forcing channels, shape (4,).

  • tracer_center (Tensor) –

    Normalization mean used by the tracer clipping, one per tracer channel.

  • tracer_scale (Tensor) –

    Normalization std used by the tracer clipping, one per tracer channel.

  • statics (Tensor) –

    Static input fields z_norm and LANDM_COSLAT, shape (2, lat, lon).

  • hyai (Tensor) –

    Hybrid a interface coefficients (Pa), shape (33,).

  • hybi (Tensor) –

    Hybrid b interface coefficients, shape (33,).

  • area (Tensor) –

    Grid-cell area (m^2), shape (lat, lon).

  • phis (Tensor) –

    Surface geopotential (m^2 s-2), shape (lat, lon).

  • forcing_data_source (DataSource, default: None ) –

    Data source providing mtdwswrf, sst, sic and global_mean_co2 on the CAMulator grid, recommended to drivers through default_sources, by default CAMulatorForcing(), which serves the shipped climatological (cyclic) year: the 1980-2014 mean seasonal cycle with CO2 fixed at its year-2000 mean of 369 ppm. The forcing files use a 365-day calendar, so leap days reuse the 28 February forcing

  • conservation_fixers (bool, default: True ) –

    Apply the global mass, water and energy fixers, by default True

  • wind_filter (bool, default: True ) –

    Apply the wind-artifact filter, by default True

__call__

__call__(x: DataArray, forcing: DataArray) -> DataArray

Predict six hours ahead without iterator hooks.

Parameters:

  • x (DataArray) –

    Initial fields matching input_coords().

  • forcing (DataArray) –

    Forcing at the input valid time matching forcing_coords().

Returns:

  • DataArray –

    First forecast matching output_coords(x).

create_iterator

create_iterator(
    x: DataArray, forcing: DataArray
) -> Generator[
    DataArray,
    DataArray | tuple[DataArray, ...] | None,
    None,
]

Yield forecasts, accepting each new forcing frame through send.

Parameters:

  • x (DataArray) –

    Initial fields matching input_coords().

  • forcing (DataArray) –

    Initial forcing at the input valid time.

Yields:

  • DataArray –

    Forecasts beginning with initialize. The rear hook runs before every yield and the front hook before each subsequent step.

load_default_package classmethod

load_default_package() -> Package

Load the default CAMulator package from HuggingFace

Returns:

load_model classmethod

load_model(
    package: Package,
    checkpoint: str = "checkpoint.pt00069.pt",
    forcing_data_source: DataSource | None = None,
    conservation_fixers: bool = True,
    wind_filter: bool = True,
) -> PrognosticModel

Load prognostic model from package

Parameters:

  • package (Package) –

    Package to load model from

  • checkpoint (str, default: 'checkpoint.pt00069.pt' ) –

    Checkpoint file in the package. The HuggingFace repository hosts several training epochs (checkpoint.pt000NN.pt); epoch 69 is the model card default, by default "checkpoint.pt00069.pt"

  • forcing_data_source (DataSource, default: None ) –

    Forcing data source, by default CAMulatorForcing()

  • conservation_fixers (bool, default: True ) –

    Apply the global mass, water and energy fixers, by default True

  • wind_filter (bool, default: True ) –

    Apply the wind-artifact filter, by default True

Returns:

  • PrognosticModel –

    Prognostic model