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.

Attributes#

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._LAPSE_RATE = 0.0065#
credit.postblock.mslp._ALPHA_STD = 0.19026120030795432#
credit.postblock.mslp._T_WARM = 290.5#
credit.postblock.mslp._T_COLD = 255.0#
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', dataset_name: str = 'ARCO_ERA5', data_keys: Iterable[str] = ('prediction', 'target'), 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')#

Bases: torch.nn.Module

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

Follows the same data-dict protocol as GeopotentialDiagnostic: all inputs are accessed by variable name from the nested batch dict, and the result is written back under output_name.

Parameters:
  • output_name – key written into data[dataset_name] for the result.

  • dataset_name – top-level key inside each data_type sub-dict.

  • data_keys – which top-level batch-dict keys to process (e.g. ("prediction", "target")).

  • 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⁻²).

output_name = 'ARCO_ERA5/derived_diagnostic/2d/mean_sea_level_pressure'#
dataset_name = 'ARCO_ERA5'#
data_keys = ('prediction', 'target')#
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'#
forward(data_dict: dict) dict#

Compute MSLP for each requested data key and write into the batch dict.

Parameters:

data_dict – nested batch dict. Each data_dict[data_type][dataset_name] must contain surface_pressure_var, temperature_var, and surface_geopotential_var as tensors with shapes broadcastable to (B, 1, n_time, H, W).

Returns:

The same data_dict with output_name added under each processed data_type[dataset_name].