David, @dsj
I added Air Density to WFArchive so I loaded the old code I wrote that, a year ago matched the WeatherFlow data.
It no longer matches.
So I dug in deep and started from the beginning. I went to your published documents. The first thing I find is an issue with calculating Vapor Pressure. The doument at: https://weatherflow.github.io/SmartWeather/api/derived-metric-formulas.html
shows Vapor Pressuer as:
And the link to Weather.gov shows:
As one can see they are very different.
As for Air Density, I cannot find any link to the formula you now use .
My issue, is the application shows Air Density as 1.01344 kg/m3 and my calculation is 1.00507, which in this respect is not even close.
Please help. How does WeatherFlow calculate Air Density.
Given these values:
P = 827.8;
T = 11.4;
Dp = 0.8;
RH = 48;
_calcVaporPressureE(Dp) = 6.4726824888727394
_calcVaporPressureEs(T) = 13.47946029051131
_calcVaporPressureRh(T, RH) = 6.465935635535494
As you can see, even the calculations for Vapor Pressure return two really distinct values that are so far off I don’t know which to trust.
Please, what am I doing incorrectly?
function _calcVaporPressureEs(T) {
// (temp in C)
T = parseFloat(T);
var a = (7.5 * T) / (237.3 + T);
var Es = 6.1078 * Math.pow(10, a);
console.log('Es');
console.log(Es);
return Es;
}
function _calcVaporPressureE(Dp) {
// (dew point in C)
Dp = parseFloat(Dp);
var a = (7.5 * Dp) / (237.3 + Dp);
var E = 6.1078 * Math.pow(10, a);
console.log('E');
console.log(E);
return E;
}
function _calcVaporPressureRh(T, RH) {
// (temp in C, humidity)
T = parseFloat(T);
var a = (17.67 * T) / (243.5 + T);
var Es = (RH / 100) * 6.112 * Math.exp(a);
console.log('Rh');
console.log(Es);
return Es;
}
This is how I have been calculating Air Density with the adjustment for the new Vapor Pressure:
WeatherCalc.calcAirDensity = function(T, P, Dp, Rh) {
// (air temp in C, station pressure, dew point in C, humidity)
// var d = (P * 100) / (287.05 * (T + 273.15));
T = parseFloat(T);
P = parseFloat(P);
Dp = parseFloat(Dp)
var Es = _calcVaporPressureRh(T, Rh),
Rv = 461.4964,
Rd = 287.0531,
tk = T + 273.15,
pv = Es * 100,
pd = (P - Es) * 100,
d = (pv / (Rv * tk) ) + (pd / (Rd * tk) );
return d.toFixed(5);