Calculating “Feels Like” Temperatures
Use the Aeris Weather API to calculate Australian Ambient Temperature (AT) or “feels like” calculations from private weather station data published to PWSweather.
I recently purchased a private weather station (PWS) that reports data every 60 seconds to PWSweather. Members of PWSweather can also sign-up to access the AerisWeather API, which allows users to access their weather station data online for downstream purposes (such as publishing to a personal website).
The Australian Bureau of Meteorology (BOM) displays “feels like” temperature readings alongside dry bulb temperatures on its website and app. This is actually known internationally as the Australian Apparent Temperature (AT) and is based on the work of Steadman (1994). It differs from models used in the United States, Canada and United Kingdom which is why I wanted to use it. My weather station does not natively calculate this metric, so I implemented a PHP routine to calculate it and publish the value to a website along with my other data.
There are two models of AT; one which factors in radiation and one that doesn’t. The version that factors-in radiation is complex and not utilised by the BOM. The BOM’s “feels like” metric is calculated as follows:
\[AT=T_a+0.33\rho-0.7\omega-4.00\]
where:
- Ta = dry bulb temperature (°C).
- ρ = water vapour pressure (hPa).
- ω = wind speed (m s-1) at an elevation of 10 metres.
The vapour pressure can be calculated from the temperature and relative humidity using the equation:
\[ \rho =\frac{RH}{100}\times6.105\times e^{ \left(\frac{17.27\times T_a}{237.7 + T_a}\right)}\]
where RH is relative humidity (%).
My weather station provides data for Ta and ω whilst ρ has to be calculated from RH (which is also reported).
To do this in PHP, a call to the AerisWeather API is required:
<?php
$response = file_get_contents('https://api.aerisapi.com/observations/pws_PWSID?client_id=YOURID&client_secret=YOURSECRET');
$json = json_decode($response);
$time = $json->response->ob->dateTimeISO;
date_default_timezone_set('Australia/Melbourne');
?>
The PWSID
, YOURID
and YOURSECRET
strings need to be replaced with your weather station ID (on PWSweather) and API credentials. This will return data in JSON format with current readings for your weather station (as last reported on PWSweather).
Next, add a PHP block that pulls out the relevant data and performs the calculations:
<?php
$rh = $json->response->ob->humidity;
$ta = $json->response->ob->tempC;
$vp = ($rh/100)*6.105*exp((17.27*$ta)/(237.7+$ta));
$ws = $json->response->ob->windSpeedKPH;
$wsm = $ws*0.277778;
$at = $ta+(0.33*$vp)-(0.70*$wsm)-4;
?>
The AerisWeather API returns wind speed in kilometres per hour, so this needs to be changed to metres per second ($wsm
) for the calculation to work.
Then to print the value on the website, call the $at
variable:
<?php echo number_format($at, 1);?>°
This will print the “Feels Like” temperature followed by a degrees symbol (°).
Comments
3 responses to “Calculating “Feels Like” Temperatures”
Hi Adam
I saw that you were linking to bom.gov.au on this page https://code.adonline.id.au/calculating-feels-like-temperatures/
I would be thrilled if you would consider my website for weather information too? I think my website gives a better experience to your users as the design is a little less dated. I also provide hourly forecasts and not just one forecast for the entire day.
Here is my page for Melbourne, (https://justweather.org/Australia/Victoria/Melbourne/Melbourne/). Let me know what you think?
Cheers
Ryan Blundell
Founder at Justweather.org
Great post! I came across this as I was looking to understand how the BOM calculates feels like or apparent temperature. I never knew they used a calculation unique to Australia and that it is not the same as the US or UK feels like calculations. Thanks for sharing your cool PHP script too.
The attribution year for Steadman should be 1984, Roberts initial finding, unless you chose the revision in 94 for a reason that is.