CAMulator / camulator_inference_tutorial.yml
charlie-becker's picture
Upload camulator_inference_tutorial.yml
3e0a8e0 verified
Raw History Blame Contribute Delete
10.8 kB
# Gen2 CAMulator config for the inference tutorial notebook (CAMulator_inference_tutorial.ipynb).
#
# Rollout only: no trainer / loss / metrics / validation_data. Same model, scaler, preblocks, and validated rollout
# postblock chain as camulator_gen2_local.yml, with these inputs:
# - initial conditions: initial_conditions_%Y.nc (U, V, T, Qtot, PS, TREFHT at 00Z on the 1st of each month)
# - dynamic forcing: forcing_real_%Y.nc (the actual year: SOLIN, SST, ICEFRAC, co2vmr_3d; 6-hourly). The notebook
# points every run at either this or a year-stamped copy of forcing_climo.nc (the 1980-2014
# climatology), and perturbs that base
# - Qtot (3D) is written to the output, for the precipitable-water diagnostic
#
# Paths are environment-variable templates. The notebook sets these and expands them when it writes each
# experiment's config:
# $CAMULATOR_MODEL checkpoint, scaler, output metadata (and this file)
# $CAMULATOR_DATA initial conditions, forcing, statics
# $CAMULATOR_WORK rollout output and perturbed forcing; the notebook links the checkpoint into work/model as
# checkpoint.pt (the name CREDIT loads), which is also where CREDIT writes its grid schema
# ===================================================================================================================== #
save_loc: '$CAMULATOR_WORK/model' # must contain checkpoint.pt (linked by the notebook)
seed: 1000
data:
source:
CESM:
dataset_type: "local"
level_coord: "level"
variables:
prognostic:
vars_3D: ['U', 'V', 'T', 'Qtot']
vars_2D: ['PS', 'TREFHT']
path: '$CAMULATOR_DATA/initial_conditions_%Y.nc'
diagnostic:
vars_2D: ['PRECT', 'TS', 'CLDHGH', 'CLDLOW', 'CLDMED', 'TAUX', 'TAUY', 'U10',
'QFLX', 'FSDS_J', 'FLDS_J', 'FSUS', 'FLUS', 'SHFLX', 'LHFLX', 'FSUTOA', 'FLUT']
path: '$CAMULATOR_DATA/initial_conditions_%Y.nc'
dynamic_forcing:
vars_2D: ['SOLIN', 'SST', 'ICEFRAC', 'co2vmr_3d']
path: '$CAMULATOR_DATA/forcing_real_%Y.nc'
static:
vars_2D: ['z_norm', 'LANDM_COSLAT']
path: '$CAMULATOR_DATA/statics_b_credit_runs_f32_02.nc'
# Explicit dates (the notebook overrides them with each run's own dates): deriving them from cftime (noleap) init times crashes BaseDataset._load_start_datetime.
start_datetime: "1981-01-01"
end_datetime: "1981-12-31"
timestep: "6h"
history_len: 1
forecast_len: 1
one_shot: True
lead_time_periods: 6
skip_periods: null
preblocks:
per_step:
scaler:
type: bridgescaler_transform
args:
scaler_path: '$CAMULATOR_MODEL/scaler_spatial_PS.json'
variables:
- CESM/prognostic/3d/U
- CESM/prognostic/3d/V
- CESM/prognostic/3d/T
- CESM/prognostic/3d/Qtot
- CESM/prognostic/2d/PS
- CESM/prognostic/2d/TREFHT
- CESM/dynamic_forcing/2d/SOLIN
- CESM/dynamic_forcing/2d/SST
- CESM/dynamic_forcing/2d/ICEFRAC
- CESM/dynamic_forcing/2d/co2vmr_3d
- CESM/diagnostic/2d/PRECT
- CESM/diagnostic/2d/TS
- CESM/diagnostic/2d/CLDHGH
- CESM/diagnostic/2d/CLDLOW
- CESM/diagnostic/2d/CLDMED
- CESM/diagnostic/2d/TAUX
- CESM/diagnostic/2d/TAUY
- CESM/diagnostic/2d/U10
- CESM/diagnostic/2d/QFLX
- CESM/diagnostic/2d/FSDS_J
- CESM/diagnostic/2d/FLDS_J
- CESM/diagnostic/2d/FSUS
- CESM/diagnostic/2d/FLUS
- CESM/diagnostic/2d/SHFLX
- CESM/diagnostic/2d/LHFLX
- CESM/diagnostic/2d/FSUTOA
- CESM/diagnostic/2d/FLUT
spatial_variables:
- CESM/prognostic/2d/PS
method: transform
scaler_params:
channels_last: False
concat:
type: concat
# ---- Rollout postblocks (the validated chain from camulator_gen2_local.yml) ---- #
# Order: reconstruct -> wind_filter (normalized) -> inverse_scale -> tracer -> mass -> water -> energy_updown.
postblocks:
per_step:
reconstruct:
type: reconstruct
args:
detach: True
wind_filter:
type: wind_artifact_filter
args:
u_var: CESM/prognostic/3d/U
v_var: CESM/prognostic/3d/V
target_vars:
- CESM/prognostic/3d/U
- CESM/prognostic/3d/V
- CESM/prognostic/3d/T
- CESM/prognostic/3d/Qtot
mask_level: 14
target_levels: [9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
# verbatim from climate/camulator_config.yml (gen1 WindPP; tuned for normalized values)
speed_threshold: 2.8
smooth_sigma: 1.2
smooth_sigma_zonal: 2.0
smooth_sigma_meridional: 0.5
dilation_zonal: 15
dilation_meridional: 5
falloff_sigma: 4.0
preserve_amplitude: true
inverse_scale:
type: bridgescaler_transform
args:
method: inverse_transform
scaler_path: '$CAMULATOR_MODEL/scaler_spatial_PS.json'
variables:
- CESM/prognostic/3d/U
- CESM/prognostic/3d/V
- CESM/prognostic/3d/T
- CESM/prognostic/3d/Qtot
- CESM/prognostic/2d/PS
- CESM/prognostic/2d/TREFHT
- CESM/diagnostic/2d/PRECT
- CESM/diagnostic/2d/TS
- CESM/diagnostic/2d/CLDHGH
- CESM/diagnostic/2d/CLDLOW
- CESM/diagnostic/2d/CLDMED
- CESM/diagnostic/2d/TAUX
- CESM/diagnostic/2d/TAUY
- CESM/diagnostic/2d/U10
- CESM/diagnostic/2d/QFLX
- CESM/diagnostic/2d/FSDS_J
- CESM/diagnostic/2d/FLDS_J
- CESM/diagnostic/2d/FSUS
- CESM/diagnostic/2d/FLUS
- CESM/diagnostic/2d/SHFLX
- CESM/diagnostic/2d/LHFLX
- CESM/diagnostic/2d/FSUTOA
- CESM/diagnostic/2d/FLUT
spatial_variables:
- CESM/prognostic/2d/PS
tracer_fixer:
type: tracer_fixer
args:
tracer_vars:
- CESM/prognostic/3d/Qtot
- CESM/diagnostic/2d/PRECT
- CESM/diagnostic/2d/CLDHGH
- CESM/diagnostic/2d/CLDLOW
- CESM/diagnostic/2d/CLDMED
- CESM/diagnostic/2d/FSDS_J
- CESM/diagnostic/2d/FSUS
- CESM/diagnostic/2d/FSUTOA
- CESM/diagnostic/2d/FLUT
tracer_thres: 0.0
tracer_thres_max: [null, null, 1, 1, 1, null, null, null, null] # gen1: cloud fractions capped at 1
mass_fixer:
type: global_mass_fixer
args:
save_loc_physics: '$CAMULATOR_DATA/b.e21.CREDIT_climate.statics_1.0deg_32levs_latlon_F32_hyai_fixed.nc'
lon_lat_level_name: [lon2d, lat2d, hyai, hybi]
grid_type: sigma
midpoint: true
fix_level_num: 14
q_var: CESM/prognostic/3d/Qtot
sp_var: CESM/prognostic/2d/PS
water_fixer:
type: global_water_fixer
args:
save_loc_physics: '$CAMULATOR_DATA/b.e21.CREDIT_climate.statics_1.0deg_32levs_latlon_F32_hyai_fixed.nc'
lon_lat_level_name: [lon2d, lat2d, hyai, hybi]
grid_type: sigma
midpoint: true
lead_time_periods: 6
q_var: CESM/prognostic/3d/Qtot
sp_var: CESM/prognostic/2d/PS
precip_var: CESM/diagnostic/2d/PRECT
evapor_var: CESM/diagnostic/2d/QFLX
energy_fixer_updown:
type: global_energy_fixer_updown
args:
save_loc_physics: '$CAMULATOR_DATA/b.e21.CREDIT_climate.statics_1.0deg_32levs_latlon_F32_hyai_fixed.nc'
lon_lat_level_name: [lon2d, lat2d, hyai, hybi]
grid_type: sigma
midpoint: true
lead_time_periods: 6
surface_geopotential_name: PHIS
T_var: CESM/prognostic/3d/T
q_var: CESM/prognostic/3d/Qtot
U_var: CESM/prognostic/3d/U
V_var: CESM/prognostic/3d/V
sp_var: CESM/prognostic/2d/PS
toa_down_solar_input_var: CESM/dynamic_forcing/2d/SOLIN
toa_up_solar_var: CESM/diagnostic/2d/FSUTOA
toa_up_olr_var: CESM/diagnostic/2d/FLUT
surf_down_solar_var: CESM/diagnostic/2d/FSDS_J
surf_up_solar_var: CESM/diagnostic/2d/FSUS
surf_down_lw_var: CESM/diagnostic/2d/FLDS_J
surf_up_lw_var: CESM/diagnostic/2d/FLUS
surf_sh_var: CESM/diagnostic/2d/SHFLX
surf_lh_var: CESM/diagnostic/2d/LHFLX
# ---- Model architecture ---- #
# Must match the checkpoint -- do not edit.
model:
type: "camulator"
frames: 1
image_height: 192
image_width: 288
levels: 32
channels: 4 # 3D prognostic: U V T Qtot
surface_channels: 2 # 2D prognostic: PS TREFHT
input_only_channels: 6 # dynamic_forcing (4) + static (2)
output_only_channels: 17 # diagnostic variables
patch_width: 1
patch_height: 1
frame_patch_size: 1
dim: [256, 512, 1024, 2048]
depth: [2, 2, 18, 2]
global_window_size: [4, 4, 2, 1]
local_window_size: 3
cross_embed_kernel_sizes:
- [4, 8, 16, 32]
- [2, 4]
- [2, 4]
- [2, 4]
cross_embed_strides: [2, 2, 2, 2]
attn_dropout: 0.
ff_dropout: 0.
use_spectral_norm: True
interp: True
padding_conf:
activate: True
mode: earth
pad_lat: [48, 48]
pad_lon: [48, 48]
# ---- Inference ---- #
inference:
run_mode: single
mode: none
save_forecast: '$CAMULATOR_WORK/rollout/control' # the notebook overrides this per experiment
single_forecast:
forecast_length: "365d" # 1460 6-hourly steps = one no-leap year
start_datetime: "1981-01-01T00:00Z"
output:
format: netcdf
output_interval: null
group_by: month # 6-hourly steps, one file per month (YYYY-MM.nc)
metadata: '$CAMULATOR_MODEL/camulator_metadata.yaml'
variables:
- name: "CESM/prognostic/3d/Qtot" # ~0.8 GB/month; only used for precipitable water
- name: "CESM/prognostic/2d/PS"
- name: "CESM/prognostic/2d/TREFHT"
- name: "CESM/diagnostic/2d/PRECT"
- name: "CESM/diagnostic/2d/TS"
- name: "CESM/diagnostic/2d/CLDHGH"
- name: "CESM/diagnostic/2d/CLDLOW"
- name: "CESM/diagnostic/2d/CLDMED"
- name: "CESM/diagnostic/2d/TAUX"
- name: "CESM/diagnostic/2d/TAUY"
- name: "CESM/diagnostic/2d/U10"
- name: "CESM/diagnostic/2d/QFLX"
- name: "CESM/diagnostic/2d/SHFLX"
- name: "CESM/diagnostic/2d/LHFLX"
- name: "CESM/diagnostic/2d/FSDS_J"
- name: "CESM/diagnostic/2d/FLDS_J"
- name: "CESM/diagnostic/2d/FSUS"
- name: "CESM/diagnostic/2d/FLUS"
- name: "CESM/diagnostic/2d/FSUTOA"
- name: "CESM/diagnostic/2d/FLUT"
encoding:
dtype: float32
zlib: true
complevel: 1