Guard against zero specific humidity in theta-e computation
This commit is contained in:
parent
9d5ebc650b
commit
72051fe5ee
1 changed files with 4 additions and 0 deletions
|
|
@ -24,6 +24,10 @@ defmodule Microwaveprop.Weather.ThetaE do
|
|||
"""
|
||||
@spec compute(float, float, float) :: float
|
||||
def compute(temp_k, spfh, pressure_pa) do
|
||||
# Guard: zero or negative humidity makes the log terms undefined.
|
||||
# Clamp to a tiny positive value (equivalent to extremely dry air).
|
||||
spfh = max(spfh, 1.0e-8)
|
||||
|
||||
# Mixing ratio from specific humidity: r = q / (1 - q)
|
||||
r = spfh / (1.0 - spfh)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue