torchMWRT.atm#

Functions

goff_gratch_saturation_vapor_pressure(T[, ice])

Compute saturation vapor pressure using the Goff-Gratch formula.

saturation_vapor_pressure(T[, formula, ice])

Compute saturation vapor pressure.

saturation_vapor_pressure_magnus(T[, ice])

Compute saturation vapor pressure using a Magnus-type formula.

vapor_pressure_from_relative_humidity(T, rh)

Compute vapor pressure from relative humidity.

vapor_pressure_from_specific_humidity(q, p)

Compute vapor pressure from specific humidity.

torchMWRT.atm.saturation_vapor_pressure(T, formula='magnus', ice=False)[source]#

Compute saturation vapor pressure.

Parameters:
  • T (torch.Tensor) – Temperature in K.

  • formula (str, optional) – Saturation formula to use. Supported values are "magnus" and "goff_gratch".

  • ice (bool, optional) – If True, apply ice coefficients/branch where supported by the selected formula.

Returns:

Saturation vapor pressure in Pa.

Return type:

torch.Tensor

Raises:

ValueError – If formula is not recognized.

Notes

The Goff-Gratch helper computes in hPa and is converted to Pa in this dispatcher.

torchMWRT.atm.vapor_pressure_from_relative_humidity(T, rh, formula='goff_gratch', ice=False)[source]#

Compute vapor pressure from relative humidity.

Parameters:
  • T (torch.Tensor) – Temperature in K.

  • rh (torch.Tensor) – Relative humidity as a fraction (0-1).

  • formula (str, optional) – Saturation-vapor-pressure formula passed to saturation_vapor_pressure().

  • ice (bool, optional) – Ice handling flag passed to saturation_vapor_pressure().

Returns:

Vapor pressure in Pa.

Return type:

torch.Tensor

torchMWRT.atm.goff_gratch_saturation_vapor_pressure(T, ice=False)[source]#

Compute saturation vapor pressure using the Goff-Gratch formula.

Parameters:
  • T (torch.Tensor) – Temperature in K.

  • ice (bool, optional) – If True, apply the ice branch below 263.16 K, matching legacy behavior.

Returns:

Saturation vapor pressure in hPa.

Return type:

torch.Tensor

Notes

This implementation mirrors the legacy pyrtlib RTEquation.vapor formulation.

torchMWRT.atm.saturation_vapor_pressure_magnus(T, ice=False)[source]#

Compute saturation vapor pressure using a Magnus-type formula.

Parameters:
  • T (torch.Tensor) – Temperature in K.

  • ice (bool, optional) – If True, use ice coefficients a=22.46 and b=272.62. Otherwise use water coefficients a=17.62 and b=243.12.

Returns:

Saturation vapor pressure in Pa.

Return type:

torch.Tensor

torchMWRT.atm.vapor_pressure_from_specific_humidity(q, p)[source]#

Compute vapor pressure from specific humidity.

Parameters:
  • q (torch.Tensor) – Specific humidity in kg/kg.

  • p (torch.Tensor) – Total air pressure in Pa.

Returns:

Vapor pressure in Pa.

Return type:

torch.Tensor

Notes

Uses \(e = q p / (\epsilon + (1-\epsilon)q)\) with \(\epsilon = R_d / R_v\).