credit.postblock.mslp#

Computes mean sea level pressure (MSLP) from surface pressure, near-surface temperature, and static surface geopotential using the Trenberth et al. (1993) formula. Fully vectorized in PyTorch — no numpy, no per-pixel loops.

Reference:

Trenberth, K., J. Berry, and L. Buja, 1993: Vertical Interpolation and Truncation of Model-Coordinate Data. NCAR Tech. Note NCAR/TN-396+STR. https://doi.org/10.5065/D6HX19NH

Bug fixed vs. the original numpy implementation in credit/interp.py (merged in PR #341): the sea-level temperature branch test used LAPSE_RATE * sgp where sgp is geopotential (m² s⁻²); it must be LAPSE_RATE * sgp / GRAVITY to convert geopotential to height in metres.

Classes#

MSLPDiagnostic

Postblock that computes MSLP from surface pressure, 2m temperature, and PHIS.

Functions#

mslp_from_surface_pressure(→ torch.Tensor)

Vectorized MSLP from surface pressure, near-surface T, and PHIS.

Module Contents#

credit.postblock.mslp.mslp_from_surface_pressure(surface_pressure: torch.Tensor, temperature: torch.Tensor, surface_geopotential: torch.Tensor) → torch.Tensor#

Vectorized MSLP from surface pressure, near-surface T, and PHIS.

Implements the simplified Trenberth et al. (1993) formula. All inputs must be broadcastable to the same shape.

Parameters:
  • surface_pressure – surface pressure in Pa, shape (…, H, W).

  • temperature – near-surface temperature in K, shape (…, H, W).

  • surface_geopotential – PHIS in m² s⁻², shape (…, H, W).

Returns:

MSLP in Pa, same shape as inputs.

class credit.postblock.mslp.MSLPDiagnostic(output_name: str = 'ARCO_ERA5/derived_diagnostic/2d/mean_sea_level_pressure', surface_pressure_var: str = 'ARCO_ERA5/prognostic/2d/surface_pressure', temperature_var: str = 'ARCO_ERA5/prognostic/2d/2m_temperature', surface_geopotential_var: str = 'ARCO_ERA5/static/2d/geopotential_at_surface', key: str = 'y_processed', static_source_key: str = 'ic_raw')#

Bases: credit.postblock.base.BasePostblock

Postblock that computes MSLP from surface pressure, 2m temperature, and PHIS.

Follows the same batch-dict protocol as Reconstruct and BridgeScalerTransform: it operates on the nested output dict at batch_dict[key] (default "y_processed"), which has the form {source: {var_key: tensor}} where var_key is "source/field_type/dim/varname". The source for each variable is derived from the first path component of its var_key. The static surface geopotential is read from batch_dict[static_source_key] (default "ic_raw"), which has the same nested form, since static fields are not part of the reconstructed model output. The result is written back into batch_dict[key] under output_name.

Config example:

type: "mslp_diagnostic"
args:
    output_name: "ARCO_ERA5/derived_diagnostic/2d/mean_sea_level_pressure"
    surface_pressure_var: "ARCO_ERA5/prognostic/2d/surface_pressure"
    temperature_var: "ARCO_ERA5/prognostic/2d/2m_temperature"
    surface_geopotential_var: "ARCO_ERA5/static/2d/geopotential_at_surface"
Parameters:
  • output_name – var_key written into batch_dict[key] for the result.

  • surface_pressure_var – variable name for surface pressure (Pa).

  • temperature_var – variable name for near-surface temperature (K).

  • surface_geopotential_var – variable name for PHIS (m² s⁻²).

  • key – entry in batch_dict holding the nested output dict written by Reconstruct (default: "y_processed").

  • static_source_key – entry in batch_dict holding the nested raw IC dict that provides static fields (default: "ic_raw").

output_name = 'ARCO_ERA5/derived_diagnostic/2d/mean_sea_level_pressure'#
surface_pressure_var = 'ARCO_ERA5/prognostic/2d/surface_pressure'#
temperature_var = 'ARCO_ERA5/prognostic/2d/2m_temperature'#
surface_geopotential_var = 'ARCO_ERA5/static/2d/geopotential_at_surface'#
key = 'y_processed'#
static_source_key = 'ic_raw'#
forward(batch_dict: dict) → dict#

Compute MSLP and write it into the nested output dict.

Parameters:

batch_dict – batch dict containing key and static_source_key entries, each of the form {source: {var_key: tensor}}. Prognostic inputs must have shapes broadcastable to (B, 1, n_time, H, W); PHIS may have n_time == 1.

Returns:

The same batch_dict with output_name added under batch_dict[key][source].