torchMWRT.atm#
Functions
|
Compute saturation vapor pressure using the Goff-Gratch formula. |
|
Compute saturation vapor pressure. |
|
Compute saturation vapor pressure using a Magnus-type formula. |
Compute vapor pressure from relative humidity. |
|
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
formulais 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.vaporformulation.
- 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 coefficientsa=22.46andb=272.62. Otherwise use water coefficientsa=17.62andb=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\).