SV: Humidity Calculation Error and Fix v 1.59
Brought to you by:
iridium
|
From: Funder, J. O. <jh...@NA...> - 2002-02-01 07:29:57
|
Hi,
For your information, the official formular looks like this:
1779,75 (Td - Tt)
RH = ANTILOG ( -------------------------- + 2 )
(237,3 + Td) ( 237.3 + Tt)
where Tt = temperature and Td = dewpoint (of course)
This is how my code looks like in Fortran 77 (for what it's worth)
TAELLER = (DEWPOINT-TEMPERATURE)*1779.75
NAEVNER = (237.3+DEWPOINT)*(237.3+TEMPERATURE)
LOG10_VAL = ((TAELLER/NAEVNER)+2)
BASE = 10
CONSTANT = LOG(BASE)
R_HUMIDITY = EXP(LOG10_VAL * CONSTANT)
It should be very easy to convert that to php.
best regards
Johnny Funder
Danish Civil Aviation Administration
Software development division.
-----Oprindelig meddelelse-----
Fra: James and Jan Wiles [mailto:kk...@nc...]
Sendt: 1. februar 2002 07:21
Til: php...@li...
Emne: Humidity Calculation Error and Fix v 1.59
In using PHPWeather for an amateur-radio project I am working on, I came
across a situation where the humidity was being incorrectly
calculated. This afternoon, for the station PAPK (Anaktuvuk Pass, AK--I
just picked it at random!), PHPWeather calculated a negative humidty value
(it was somewhere in the -90% range).
I did a little research and found another formula for calculating relative
humidity from the temp and dew point and implemented it in my copy of
phpweather. The result came out correct (it was the same as our National
Weather Service had calculated on their web page), and was also correct for
several other weather stations. Also, the code is probably more efficient
as it is only doing 2 pow() calculations rather than 8.
This is your original code:
$decoded_metar['rel_humidity'] = number_format(100 *
(
610.710701 +
44.4293573 * $decoded_metar['dew_c'] +
1.41696846 * pow($decoded_metar['dew_c'], 2) +
0.0274759545 * pow($decoded_metar['dew_c'], 3) +
2.61145937E-4 * pow($decoded_metar['dew_c'], 4) +
2.85993708E-6 * pow($decoded_metar['dew_c'], 5)
)
/
(
610.710701 +
44.4293573 * $decoded_metar['temp_c'] +
1.41696846 * pow($decoded_metar['temp_c'], 2) +
0.0274759545 * pow($decoded_metar['temp_c'], 3) +
2.61145937E-4 * pow($decoded_metar['temp_c'], 4) +
2.85993708E-6 * pow($decoded_metar['temp_c'], 5)
), 1);
This is my new code:
$decoded_metar['rel_humidity'] = number_format(100 *
(6.11*(pow(10,(7.5*$decoded_metar['dew_c']/(237.7+$decoded_metar['dew_c'])))
))
/
(6.11*(pow(10,(7.5*$decoded_metar['temp_c']/(237.7+$decoded_metar['temp_c'])
))))
,1);
The only thing I haven't done is to not calculate the RH if one or the
other temp is missing (PAKP is currently not showing a dew point in the
METAR).
Also, for my purposes, I have removed the thousand's separator from the air
pressure calculation. It was hampering a reformat of the data for my
project.
I hope this helps your efforts!
Thanks,
James Wiles
kk...@nc... - White County, AR, USA
_______________________________________________
PHPWeather-devel mailing list
PHP...@li...
https://lists.sourceforge.net/lists/listinfo/phpweather-devel
|