Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

cesm_hawc.waccm

cesm_hawc.waccm

source

Read CESM2/WACCM history files and extract atmospheric columns.

Columns are interpolated onto a regular altitude grid, with the MAM4 accumulation and coarse sulfate modes described by lognormal number and median radius. Tested with the BWSSP245 and TSMLT compsets (MAM4 aerosol). The history file needs:

Attributes

hybrid_to_pressure

def hybrid_to_pressure(
    hyam: np.ndarray,
    hybm: np.ndarray,
    p0: float,
    ps: float,
) -> np.ndarray

source

Pressure on hybrid sigma-pressure levels.

Parameters

Returns

pressure_to_altitude

def pressure_to_altitude(
    pressure: np.ndarray,
    temperature: np.ndarray,
    ps: float,
    z_surface: float = 0.0,
) -> np.ndarray

source

Height of each model level by hydrostatic integration.

Parameters

Returns

Notes

Integrates the hypsometric equation layer by layer from the surface. Interface pressures are the geometric means of adjacent levels, with ps at the bottom and half the top level’s pressure at the top. Each level sits at the midpoint of its layer. Gravity is the constant standard value, so the result is geopotential height, slightly below geometric altitude in the stratosphere (about 140 m at 30 km).

blend_h2o

def blend_h2o(
    q_vmr: np.ndarray,
    chem_h2o: np.ndarray,
    pressure: np.ndarray,
    join_pa: float = 10000.0,
) -> np.ndarray

source

Blend tropospheric humidity with stratospheric chemistry water vapour.

Parameters

Returns

mam4_lognormal

def mam4_lognormal(
    so4_mmr: np.ndarray,
    num_per_kg: np.ndarray,
    n_air_cm3: np.ndarray,
    sigma_g: float,
) -> tuple[np.ndarray, np.ndarray]

source

Lognormal median radius and number from MAM4 mixing ratios.

Parameters

Returns

Notes

Inverts the lognormal mass moment M = N (4/3) π ρ r_m³ exp(4.5 ln²σ_g) with ρ = RHO_SULFATE. The number concentration does not depend on ρ. The radius is a dry-mass radius: it ignores water taken up by the particles, so WACCMAtmosphere uses it only when the file has no wet diameters.

WACCMAtmosphere

class WACCMAtmosphere(
    filepath,
    alt_grid_km=None,
    z_surface=0.0,
    h2o_join_hpa=100.0,
)

source

A CESM2/WACCM history file, from which columns are extracted.

Parameters

Raises

Attributes

Examples

>>> atm = WACCMAtmosphere("run.cam.h0.2035-02.nc")
>>> profiles = atm.get_column_profiles(lat=30.6, lon=180.0, time_index=0)
>>> burden = atm.sulfate_column_burden(lat=30.6, lon=180.0)

WACCMAtmosphere.get_column_profiles

def get_column_profiles(lat: float, lon: float, time_index: int = 0) -> dict

source

Extract one column and interpolate it onto the altitude grid.

Parameters

Returns

Notes

Longitudes are converted to 0–360, matching the CAM grid, before the nearest column is selected. Pressure, mixing ratios, air density, aerosol number and mass are interpolated in log space.

Each mode’s median radius is half its wet median diameter (dgnumwet1, dgnumwet3) when the file has it. Otherwise it is derived from dry sulfate mass and number with mam4_lognormal(), which ignores water uptake and so underestimates the wet radius the optical calculations assume.

WACCMAtmosphere.sulfate_column_burden

def sulfate_column_burden(
    lat: float,
    lon: float,
    time_index: int = 0,
    alt_range_km: tuple = (15.0, 35.0),
) -> dict

source

Sulfate column burden and peak properties over an altitude range.

Parameters

Returns

WACCMAtmosphere.extract_cesm_extinction

def extract_cesm_extinction(
    lat: float,
    lon: float,
    time_index: int,
    alt_m: np.ndarray,
    varnames: tuple = ('EXTINCTdn', 'EXTINCTUVdn', 'EXTINCTNIRdn'),
) -> dict

source

CESM’s own aerosol extinction for a column, if the file has it.

CESM computes EXTINCTdn (550 nm), EXTINCTUVdn (350 nm) and EXTINCTNIRdn (1020 nm) during the model run, over all aerosol species. They give an independent check on the extinction cesm-hawc computes from number and radius; 1020 nm is also an ALI wavelength.

Parameters

Returns

WACCMAtmosphere.save_column_profiles

def save_column_profiles(
    lat: float,
    lon: float,
    output_path: str,
    time_index: int = 0,
) -> None

source

Save one column’s profiles to a NetCDF file.

For a simulator-ready file, use cesm_hawc.save_inputs.save_column_inputs() instead.

Parameters

WACCMAtmosphere.list_variables

def list_variables() -> list[str]

source

Print the chemistry and aerosol variables in the file.

Marks the variables cesm-hawc relies on and lists any of them that are missing.

Returns