MetPy icon indicating copy to clipboard operation
MetPy copied to clipboard

wet_bulb_temperature for dry-bulb temperature less than dew point temperature

Open CongGao-CG opened this issue 1 year ago • 9 comments

What went wrong?

>>> wet_bulb_temperature(1000 * units.hPa, 15 * units.degC, 20 * units.degC) <Quantity(18.4582946, 'degree_Celsius')>

The metpy.calc.wet_bulb_temperature function does not automatically validate input physics?

Operating System

MacOS

Version

MetPy 1.6.3

Python Version

Python 3.10.16

Code to Reproduce

>>> wet_bulb_temperature(1000 * units.hPa, 15 * units.degC, 20 * units.degC)
<Quantity(18.4582946, 'degree_Celsius')>

Errors, Traceback, and Logs


CongGao-CG avatar Feb 15 '25 16:02 CongGao-CG

function does not automatically validate input physics?

It would be helpful to be more verbose with what you are saying. Do you have references to what you believe is being violated?

akrherz avatar Feb 15 '25 16:02 akrherz

The dew point temperature is always less than or equal to the wet-bulb temperature, which is always less than or equal to the dry-bulb temperature. This is called Normand's theorem or Normand's rule.

https://glossary.ametsoc.org/wiki/Normand's_theorem

CongGao-CG avatar Feb 15 '25 16:02 CongGao-CG

The page you referenced points out the problem with enforcing such a rule within MetPy.

akrherz avatar Feb 15 '25 16:02 akrherz

You mean "It is not, however, true in supersaturated air or for air temperatures below freezing if the wet bulb is frozen and the air is supersaturated with respect to ice."

You can see my example; it is evidently above freezing.

CongGao-CG avatar Feb 15 '25 16:02 CongGao-CG

I am not surprised by an output for an unrealistic situation because the algorithm still works even when the dew point temperature is greater than the dry-bulb temperature. The issue is that relative humidity can exceed 100% since the algorithm does not check for this upper limit. That is the problem. You can ignore Normand’s rule, but how do we handle the upper limits of relative humidity in MetPy?

CongGao-CG avatar Feb 15 '25 16:02 CongGao-CG

I hope you can include this issue at least in the introduction of the function. Users should be aware of what they are using.

CongGao-CG avatar Feb 15 '25 16:02 CongGao-CG

You mean "It is not, however, true in supersaturated air or for air temperatures below freezing if the wet bulb is frozen and the air is supersaturated with respect to ice."

You can see my example; it is evidently above freezing.

The other part of that condition is that the parcel must not be supersaturated: when you pass information for a supersaturated parcel ($T_d > T$), that condition doesn't hold, and the $T_d<T_w<T$ relationship may be violated. I suppose you could request a warning for supersaturated parcels, but supersaturation with respect to ice is, I am told, really common.

If you want to add a line to the docstring so people know that, if they pass conditions implying supersaturation to this function, they cannot expect $T_d<T_w<T$, you are entirely welcome to submit a PR.

DWesl avatar Feb 18 '25 23:02 DWesl

We don't have a history of warning or erroring on potentially broken physics unless, eg #3758, the results break things further or are truly non-physical. In this case, we aren't going to judge the difference between supersaturation and non-physical quantities without a citation or physical explanation. You can calculate LCL, parcel profiles, etc. with dewpoint temperatures greater than or equal to the environmental temperature. We do our best to document and cite validity regimes where possible, but tend not to enforce more strongly than we think we need to.

PRs are welcome for clarification you could find useful in the doc string, and we're open to discuss how much more or less MetPy should provide feedback or errors on physicality. We actually just discussed this at last week's dev call!

dcamron avatar Feb 19 '25 21:02 dcamron

Just to follow on: given that many (most?) calculations deal with entire numpy arrays of values, catching these kinds of regions of validity can be a bit more tricky. Assumptions are usually only validated for a handful of points out of the array, and then dealing with these become more complicated masking operations.

@CongGao-CG With that said, I'm curious what impacts the lack of enforcement had on your use of MetPy and what kind of behavior (warning, error, masked value, etc.) you would have found helpful to make things easier for you.

dopplershift avatar Feb 21 '25 22:02 dopplershift