Re: PressTrendVal and PHP question
Posted: Tue 04 Feb 2014 2:53 pm
Actually I don't think any of them are correct!
Using the original logic you get an asymmetry between positive and negative values (example using 1dp)....
I think the most understandable way of writing this logic that would also work with 1dp or more would be (using the definitions I found on the Met Office)*...
*http://www.metoffice.gov.uk/weather/mar ... ssary.html
Rising (or falling) slowly
- Pressure change of 0.1 to 1.5 hPa in the preceding three hours
Rising (or falling)
- Pressure change of 1.6 to 3.5 hPa in the preceding three hours
Rising (or falling) quickly
- Pressure change of 3.6 to 6.0 hPa in the preceding three hours
Rising (or falling) v. rapidly
- Pressure change of more than 6.0 hPa in the preceding three hours
Which is ambiguous if you use more than 1dp, what is +1.52 'Rising Slowly' or 'Rising'? I have assumed that >n.5 jumps to the next higher category.
Using the original logic you get an asymmetry between positive and negative values (example using 1dp)....
Code: Select all
6.0 ... +999 = Rising Very Rapdily
3.6 ... 5.9 = Rising Quickly
1.6 ... 3.5 = Rising
0.2 ... 1.5 = Rising Slowly
0.1 ... 0.0 = Steady
-0.1 ... -1.4 = Falling Slowly
-1.5 ... -3.4 = Falling
-3.5 ... -5.9 = Falling Quickly
-6.0 ... -999 = Falling Very RapidlyCode: Select all
$weather_trend = ret_value("presstrend") * 3;
$pressure_trend_text = ($weather_trend >= 0.1) ? 'Rising' : ($weather_trend <= -0.1) ? 'Falling' : '';
$weather_trend = abs($weather_trend);
if ($weather_trend > 6.0)
$pressure_trend_text .= ' Very Rapidly';
elseif ($weather_trend > 3.5)
$pressure_trend_text .= ' Quickly';
elseif ($weather_trend > 1.6)
// Rising or Falling
elseif ($weather_trend >= 0.1)
$pressure_trend_text .= ' Slowly';
else
$pressure_trend_text = 'Steady';
*http://www.metoffice.gov.uk/weather/mar ... ssary.html
Rising (or falling) slowly
- Pressure change of 0.1 to 1.5 hPa in the preceding three hours
Rising (or falling)
- Pressure change of 1.6 to 3.5 hPa in the preceding three hours
Rising (or falling) quickly
- Pressure change of 3.6 to 6.0 hPa in the preceding three hours
Rising (or falling) v. rapidly
- Pressure change of more than 6.0 hPa in the preceding three hours
Which is ambiguous if you use more than 1dp, what is +1.52 'Rising Slowly' or 'Rising'? I have assumed that >n.5 jumps to the next higher category.