Air Density, Vapor Pressure and I'm Confused


#46

Yeah. I see it. But I’m missing where you see 50% different.

Using the weather.gov formula assuming T is dewpoint:

weather.gov saturated  vapor pressure  0 (mb) = 6.11
weather.gov saturated  vapor pressure 10 (mb) = 12.2833431422
weather.gov saturated  vapor pressure 15 (mb) = 17.0584258108
weather.gov saturated  vapor pressure 20 (mb) = 23.3893568431
weather.gov saturated  vapor pressure 30 (mb) = 42.4416297132
weather.gov saturated  vapor pressure 40 (mb) = 73.773775674

Using the WF formula on the derived formulas page, assuming 100% RH:

weatherflow 100% RH    vapor pressure  0 (mb) = 6.112
weatherflow 100% RH    vapor pressure 10 (mb) = 12.2716959939
weatherflow 100% RH    vapor pressure 15 (mb) = 17.0404945379
weatherflow 100% RH    vapor pressure 20 (mb) = 23.3694712341
weatherflow 100% RH    vapor pressure 30 (mb) = 42.4557544286
weatherflow 100% RH    vapor pressure 40 (mb) = 73.9490058102

They’re the same. Where is the 50% difference ? I’m really not seeing it.


#48

But if you look at https://www.weather.gov/media/epz/wxcalc/vaporPressure.pdf in the ‘for a bonus answer…’ section, you’ll see at 50% RH the actual VP is 50% of the saturation (100% RH) VP.

So at 50% RH they are ‘supposed’ to be calculating out a VP of half the 100% RH value.


#49

That is how you calculate RH. You can’t use RH to calculate RH . The two formulas use the Saturated Vapor Pressure and the Dry Vapor Pressure to calculate RH.

WeatherFlow, is using neither of those formulas. That’s part of what started this. WeatherFlow is using a THIRD formula that is not related to weather.gov.


#50

Still not convinced.

  • RH is observed

  • T (air aka dry-bulb) is observed

  • dewpoint is derived by WF by calculation using those two sensors

  • The wf derived_measurements formula uses RH sensor and dewpoint (calculated) temperature. It would be nice if they said ‘dewpoint’ on their page to make it clearer.

  • the weather.gov formula uses the same dewpoint (calculated) and the T (air) sensor to go the other way, since you can get any missing item of air temp / dewpoint / RH if you have two of the three measured

I don’t see a problem at all, other than not knowing where the WF formula on the derived measurements page actually came from. Mathematically the two formulas get the same answer (or really close), both based on the physical sensor data the Air has available to it.


#52

Sorry, but I can’t find a scenario where that is true.

Give me input data that proves that please.

  • the WF formula takes ‘observed’ temp and observed humidity in as input
  • the weather.gov formula takes in ‘dewpoint’ as input
  • we can calculate dewpoint from observed temp and observed humidity

Consider an observed temperature of 15 C and 50% RH…

  • that’s a dewpoint of 4.65746100514 C

So lets run the data:

  • the weatherflow formula calculates a VP of 8.52024726897 mb from T = 15 and H = 50
  • the weather.gov formula calculates a VP of 8.51940740716 mb from Dp = 4.65746100514

I don’t see any difference.

I think you’re feeding dewpoint in one place where you should be feeding observed temperature, or vice versa. I can’t find any way to show calculations that aren’t close if I feed the two formulas the right data.


#53

Then clearly I am wrong and confused. Thank you.

It seems the topic message is still correct but I became confused and posted wrong results in subsequent posts.


#54

Here is the test code with results. Thank you all for sticking with me and pointing put where I went wrong. A special thanks to @vinceskahan for not giving up on me.

T = 15.0;
H = 50;
Dp = 4.65746100514;

E 8.51940740716102 <= weather.com
Rh 8.52024726897465 <= WeatherFlow
Es 8.513232793184109 <= Herman Wobus

_calcVaporPressureE(Dp);
_calcVaporPressureRh(T, H);
_calcVaporPressure(Dp);

function _calcVaporPressureE(Dp) {
    // (dew point  in C)
    Dp = parseFloat(Dp);
    let a = (7.5 * Dp) / (237.3 + Dp);
    let E = 6.11 * Math.pow(10, a);
    console.log('E ' + E);
    return E;
}	

function _calcVaporPressureRh(T, H) {
    // (temp in C, humidity)
    T = parseFloat(T);
    let a = (17.67 * T) / (243.5 + T);
    let E = (H / 100) * 6.112 * Math.exp(a);
    console.log('Rh ' + E); 
    return E;
}

function _calcVaporPressure(T) {
	// https://wahiduddin.net/calc/density_altitude.htm
	// (temp in C)
	let Eso = 6.1078;
	let C0 = 0.99999683;
	let C1 = -0.90826951E-02;
	let C2 = 0.78736169E-04;
	let C3 = -0.61117958E-06;
	let C4 = 0.43884187E-08;
	let C5 = -0.29883885E-10;
	let C6 = 0.21874425E-12;
	let C7 = -0.17892321E-14;
	let C8 = 0.11112018E-16;
	let C9 = -0.30994571E-19;
	let Pol = C0 + T * (C1 + T * (C2 + T * (C3 + T * (C4 + T * (C5 + T * (C6 + T * (C7 + T * (C8+ T * (C9)))))))));
	let Es = Eso * Math.pow(Pol, -8);
	console.log("Es " + Es);
}

#55

Just FYI. I deleted some of my incorrect posts, not to hide my mistakes but to remove confusing information. No need for my mistakes to screw up others.


#56

FWIW, I put up a github repo (here) with my python code and sample output, if anybody is interested. The python code can be very easily converted to javascript if you’re so inclined. Should be obvious.

To run, just download the .py file and run “python filename.py” to generate the same thing as the sample output file I have in the repo there…


#57

Phew! Glad you guys figured it out. I wasn’t sure when we’d have time to dig back into those formulas and figure out where the issue was… This is a great example of the developer community helping each other. Good work!!

Actually, all “derived parameters” are calculated on server-side. The only quasi-exception (I think) is “sea-level pressure”, which is calculated server-side along with the rest of the “station observation” values, but it’s also computed client-side (in the apps) for the graph display. And that’s only because the API does not currently return any time series “derived parameters” (although it probably will one day).


#58

I see Dew Point, Heat Index, Wind Chill and Delta-T calculated on the client. And of course the conversions are client side.

The client-side javascript is where I obtained a lot of your formulas.


#59

When time permits, I would still like to know where that formula came from.


#60

I believe the formula for vapor pressure shown on our “derived metrics” page is itself “derived” from the formulas in those two NWS tutorials: https://www.weather.gov/media/epz/wxcalc/vaporPressure.pdf & https://www.weather.gov/media/epz/wxcalc/rhTdFromWetBulb.pdf


#61

Thank you, David. My apologies for any and all disruption I caused.


#62

Here is a little more fuel for the fire. NOAA uses 6.112 but their own published findings do not.

TEST OF FUNCTIONS ESW,ES,ESAT,ESGG,ESRW,ESLO
PURPOSE: CALCULATE SATURATION VAPOR PRESSURE OVER LIQUID WATER
GIVEN TEMPERATURE.

TEMP  ESW     ES     ESAT    ESGG    ESRW    ESLO    SMITH.(340)
---- -----  -----   ------  ------  ------  ------   ------
-50 .06356  .06357  .06356  .06356  .06362  .06337   .06356
-30 .50878  .51036  .50878  .50880  .50843  .50877   .5088 
-10 2.8627  2.8677  2.8626  2.8627  2.8625  2.8635   2.8627
  0 6.1080  6.1121  6.1076  6.1078  6.1084  6.1078   6.1078  <==
 10 12.272  12.272  12.272  12.272  12.274  12.271   12.272
 20 23.372  23.370  23.372  23.373  23.375  23.371   23.373
 30 42.430  42.457  42.429  42.430  42.431  42.429   42.430

EFFICIENCY TEST: 5000 CALCULATIONS AT T=20C.

       FUNC.  T(SEC)
       ----   ------
       ESW     1.12
       ES      0.88
       ESAT    4.50
       ESGG    4.63
       ESRW    1.08
       ESLO    0.64

https://wahiduddin.net/calc/density_algorithms.htm


#63

When will Air Density be added to the Derived Metric Formulas page?