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#
Postblock that computes MSLP from surface pressure, 2m temperature, and PHIS. |
Functions#
|
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.BasePostblockPostblock that computes MSLP from surface pressure, 2m temperature, and PHIS.
Follows the same batch-dict protocol as
ReconstructandBridgeScalerTransform: it operates on the nested output dict atbatch_dict[key](default"y_processed"), which has the form{source: {var_key: tensor}}wherevar_keyis"source/field_type/dim/varname". The source for each variable is derived from the first path component of itsvar_key. The static surface geopotential is read frombatch_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 intobatch_dict[key]underoutput_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_dictholding the nested output dict written byReconstruct(default:"y_processed").static_source_key – entry in
batch_dictholding 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
keyandstatic_source_keyentries, each of the form{source: {var_key: tensor}}. Prognostic inputs must have shapes broadcastable to(B, 1, n_time, H, W); PHIS may haven_time == 1.- Returns:
The same
batch_dictwithoutput_nameadded underbatch_dict[key][source].