Welcome to the Cumulus Support forum.

Latest Cumulus MX V4 release 4.4.2 (build 4085) - 12 March 2025

Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024

Legacy Cumulus 1 release 1.9.4 (build 1099) - 28 November 2014
(a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)

Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki

If you are posting a new Topic about an error or if you need help PLEASE read this first viewtopic.php?p=164080#p164080

PressTrendVal and PHP question

Discussion and questions about Cumulus weather station software version 1. This section is the main place to get help with Cumulus 1 software developed by Steve Loft that ceased development in November 2014.
RayProudfoot
Posts: 3602
Joined: Wed 06 May 2009 6:29 pm
Weather Station: Davis VP2 with Daytime FARS
Operating System: Windows XP SP3
Location: Cheadle Hulme, Cheshire, England
Contact:

PressTrendVal and PHP question

Post by RayProudfoot »

In recent times there have been huge pressure changes in the UK but although my Cumulus pages showed "Falling Very Rapidly" on several occasions my PHP banner never did. It just showed "Falling Rapidly".

Here is the code that was in place...

$weather_trend = ret_value("presstrend") * 3;
if ($weather_trend >= 6.0)
$pressure_trend_text = "Rising Rapidly";
elseif ($weather_trend > 3.5)
$pressure_trend_text = "Rising Quickly";
elseif ($weather_trend > 1.5)
$pressure_trend_text = "Rising";
else if ($weather_trend > 0.1)
$pressure_trend_text = "Rising Slowly";
elseif ($weather_trend > -0.1)
$pressure_trend_text = "Steady";
elseif ($weather_trend > -1.5)
$pressure_trend_text = "Falling Slowly";
elseif ($weather_trend > -3.5)
$pressure_trend_text = "Falling";
elseif ($weather_trend > -6.0)
$pressure_trend_text = "Falling Quickly";
else
$pressure_trend_text = "Falling Rapidly";

As you can see it's incorrect when pressure is falling at a great rate.

So this afternoon I changed it to what follows and although I think it will resolve the "Falling Very Rapidly" problem I'm not sure about the logic for Steady which is why I've put it in the Else part but I'm uncomfortable doing that as it doesn't look right.

$weather_trend = ret_value("presstrend") * 3;
if ($weather_trend >= 6.0)
$pressure_trend_text = "Rising Very Rapidly";
elseif ($weather_trend > 3.5)
$pressure_trend_text = "Rising Quickly";
elseif ($weather_trend > 1.5)
$pressure_trend_text = "Rising";
else if ($weather_trend > 0.1)
$pressure_trend_text = "Rising Slowly";
elseif ($weather_trend > -0.1)
$pressure_trend_text = "Falling Slowly";
elseif ($weather_trend > -1.5)
$pressure_trend_text = "Falling";
elseif ($weather_trend > -3.5)
$pressure_trend_text = "Falling Quickly";
elseif ($weather_trend > -6.0)
$pressure_trend_text = "Falling Very Rapidly";
else
$pressure_trend_text="Steady";

I did try adding an AND condition but the PHP webpage just went blank so I guessed it couldn't resolve the argument...

else if ($weather_trend > -0.1) AND ($weather_trend < 0.1)
$pressure_trend_text ="Steady"

Appreciate any help to correct the syntax and logic.
Cheers,
Ray, Cheshire.

Image
RayProudfoot
Posts: 3602
Joined: Wed 06 May 2009 6:29 pm
Weather Station: Davis VP2 with Daytime FARS
Operating System: Windows XP SP3
Location: Cheadle Hulme, Cheshire, England
Contact:

Re: PressTrendVal and PHP question

Post by RayProudfoot »

I appear to have resolved the problem by changing the code as follows:-

$weather_trend = ret_value("presstrend") * 3;
if ($weather_trend >= 6.0)
$pressure_trend_text = "Rising Very Rapidly";
elseif ($weather_trend > 3.5)
$pressure_trend_text = "Rising Quickly";
elseif ($weather_trend > 1.5)
$pressure_trend_text = "Rising";
else if ($weather_trend > 0.1)
$pressure_trend_text = "Rising Slowly";
elseif ($weather_trend >= -0.1 && $weather_trend <= 0.1)
$pressure_trend_text="Steady";
elseif ($weather_trend < -0.1)
$pressure_trend_text = "Falling Slowly";
elseif ($weather_trend < -1.5)
$pressure_trend_text = "Falling";
elseif ($weather_trend < -3.5)
$pressure_trend_text = "Falling Quickly";
elseif ($weather_trend < -6.0)
$pressure_trend_text = "Falling Very Rapidly";
Cheers,
Ray, Cheshire.

Image
User avatar
mcrossley
Posts: 14388
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: PressTrendVal and PHP question

Post by mcrossley »

No that will not work for negative trends.

Try it with -8.0 say - you will get "Falling Slowly"

All your comparisons must be > (or >=), so if you want 'Steady' to be +0.1 to -0.1 then...

$weather_trend = ret_value("presstrend") * 3;
if ($weather_trend >= 6.0)
$pressure_trend_text = "Rising Very Rapidly";
elseif ($weather_trend > 3.5)
$pressure_trend_text = "Rising Quickly";
elseif ($weather_trend > 1.5)
$pressure_trend_text = "Rising";
elseif ($weather_trend > 0.1)
$pressure_trend_text = "Rising Slowly";
elseif ($weather_trend >= -0.1)
$pressure_trend_text="Steady";
elseif ($weather_trend > -1.5)
$pressure_trend_text = "Falling Slowly";
elseif ($weather_trend > -3.5)
$pressure_trend_text = "Falling";
elseif ($weather_trend > -6.0)
$pressure_trend_text = "Falling Quickly";
else
$pressure_trend_text = "Falling Very Rapidly";
Last edited by mcrossley on Tue 04 Feb 2014 7:34 am, edited 1 time in total.
User avatar
steve
Cumulus Author
Posts: 26672
Joined: Mon 02 Jun 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

Re: PressTrendVal and PHP question

Post by steve »

I don't think that's right, Ray. If the value is -7, say, then elseif ($weather_trend < -0.1) will be true and it will return "Falling slowly".

Edit: OK, Mark, you win this time ;)
Steve
User avatar
mcrossley
Posts: 14388
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: PressTrendVal and PHP question

Post by mcrossley »

Odd, the forum has always warned me in the past about posts before mine - we must have synchronised 'submit' buttons tonight!
User avatar
steve
Cumulus Author
Posts: 26672
Joined: Mon 02 Jun 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

Re: PressTrendVal and PHP question

Post by steve »

Often it does, but sometimes if they are very close it seems not to. Sometimes I have completely missed the fact that someone has posted again, possibly with further information to a question, just before my reply.
Steve
RayProudfoot
Posts: 3602
Joined: Wed 06 May 2009 6:29 pm
Weather Station: Davis VP2 with Daytime FARS
Operating System: Windows XP SP3
Location: Cheadle Hulme, Cheshire, England
Contact:

Re: PressTrendVal and PHP question

Post by RayProudfoot »

Thanks Mark and Steve. I follow your logic with the -8 example but I'm still struggling to understand negative comparisons must be> or >= rather than < or <=.

I will of course change it as you have suggested Mark. Oh to be able to step through the code with VB. PHP is not very user-friendly. :(
Cheers,
Ray, Cheshire.

Image
RayProudfoot
Posts: 3602
Joined: Wed 06 May 2009 6:29 pm
Weather Station: Davis VP2 with Daytime FARS
Operating System: Windows XP SP3
Location: Cheadle Hulme, Cheshire, England
Contact:

Re: PressTrendVal and PHP question

Post by RayProudfoot »

Mark,

Looking at your provided code why is there a Rising Very Rapidly but no Falling Very Rapidly?
Cheers,
Ray, Cheshire.

Image
BCJKiwi
Posts: 1259
Joined: Mon 09 Jul 2012 8:40 pm
Weather Station: Davis VP2 Cabled
Operating System: Windows 10 Pro
Location: Auckland, New Zealand
Contact:

Re: PressTrendVal and PHP question

Post by BCJKiwi »

Ray,
did you try;
else if ($weather_trend > -0.1 && $weather_trend < 0.1)
User avatar
mcrossley
Posts: 14388
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: PressTrendVal and PHP question

Post by mcrossley »

RayProudfoot wrote:Mark,

Looking at your provided code why is there a Rising Very Rapidly but no Falling Very Rapidly?
A cut'n'paste error from the original code you posted, now fixed.

You have to compare greater than throughout because if you switch from > to < halfway, any large negative value will satisfy the first compare and the code will not then check the other compares.

You could code the whole thing in reverse and do all the compares < , but then you could not have some of the compares >
User avatar
steve
Cumulus Author
Posts: 26672
Joined: Mon 02 Jun 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

Re: PressTrendVal and PHP question

Post by steve »

This is the code in Cumulus (Pascal, but hopefully understandable). And I think it's effectively the same as Mark's PHP, with perhaps some slight differences over ">" and ">=".

Code: Select all

  if ThreeHourlyPressureChangeMB > 6 then
    presstrendstr := Risingveryrapidly
  else if ThreeHourlyPressureChangeMB > 3.5 then
    presstrendstr := Risingquickly
  else if ThreeHourlyPressureChangeMB > 1.5 then
    presstrendstr := Rising
  else if ThreeHourlyPressureChangeMB > 0.1 then
    presstrendstr := Risingslowly
  else if ThreeHourlyPressureChangeMB > -0.1 then
    presstrendstr := Steady
  else if ThreeHourlyPressureChangeMB > -1.5 then
    presstrendstr := Fallingslowly
  else if ThreeHourlyPressureChangeMB > -3.5 then
    presstrendstr := Falling
  else if ThreeHourlyPressureChangeMB > -6 then
    presstrendstr := Fallingquickly
  else
    presstrendstr := Fallingveryrapidly;
Your original code looks correct to me. Isn't the only problem that you have the string "Falling rapidly" rather than "Falling very rapidly" (and the same for rising)?
Steve
RayProudfoot
Posts: 3602
Joined: Wed 06 May 2009 6:29 pm
Weather Station: Davis VP2 with Daytime FARS
Operating System: Windows XP SP3
Location: Cheadle Hulme, Cheshire, England
Contact:

Re: PressTrendVal and PHP question

Post by RayProudfoot »

BCJKiwi wrote:Ray,
did you try;
else if ($weather_trend > -0.1 && $weather_trend < 0.1)
Hi,

No but I did use:-

elseif ($weather_trend >= -0.1 && $weather_trend <= 0.1)

But the Steady condition is catered for in Mark's code. It was my change to the falling pressure part that would result in the wrong condition being satisfied.
Cheers,
Ray, Cheshire.

Image
RayProudfoot
Posts: 3602
Joined: Wed 06 May 2009 6:29 pm
Weather Station: Davis VP2 with Daytime FARS
Operating System: Windows XP SP3
Location: Cheadle Hulme, Cheshire, England
Contact:

Re: PressTrendVal and PHP question

Post by RayProudfoot »

mcrossley wrote:A cut'n'paste error from the original code you posted, now fixed.
Thanks.
You have to compare greater than throughout because if you switch from > to < halfway, any large negative value will satisfy the first compare and the code will not then check the other compares.

You could code the whole thing in reverse and do all the compares < , but then you could not have some of the compares >
It did occur to me I could change the falling pressure section by starting with the greatest fall and ending with the smallest. Almost a mirror copy of the rising section. But I'll stick with your amended code, thanks.

Steve,

In the original code I pasted Falling Slowly, Falling and Falling Quickly all have different criteria to Rising Slowly, Rising and Rising Quickly. Unless I'm missing something very obvious.

One final point. >6 equates to Rising Very Rapidly but >-6 only equates to Falling Rapidly. What would trigger Falling Very Rapidly?
Cheers,
Ray, Cheshire.

Image
User avatar
steve
Cumulus Author
Posts: 26672
Joined: Mon 02 Jun 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

Re: PressTrendVal and PHP question

Post by steve »

RayProudfoot wrote:In the original code I pasted Falling Slowly, Falling and Falling Quickly all have different criteria to Rising Slowly, Rising and Rising Quickly. Unless I'm missing something very obvious.
Your original post said that for large drops in pressure, Cumulus was showing "Falling very rapidly", but the PHP was showing "Falling rapidly". This is because the PHP you quoted has no "Falling very rapidly". It uses the phrase "Falling rapidly" instead. So it was showing "Falling rapidly" for the same conditions where Cumulus was showing "Falling very rapidly", simply because the text is different, not because the logic is different.
One final point. >6 equates to Rising Very Rapidly but >-6 only equates to Falling Rapidly. What would trigger Falling Very Rapidly?
A fall of more than 6 mb, i.e. a negative number which isn't greater than -6, e.g. -7.
Steve
RayProudfoot
Posts: 3602
Joined: Wed 06 May 2009 6:29 pm
Weather Station: Davis VP2 with Daytime FARS
Operating System: Windows XP SP3
Location: Cheadle Hulme, Cheshire, England
Contact:

Re: PressTrendVal and PHP question

Post by RayProudfoot »

Hi Steve,

I've copied that code into a module in Visual Basic in Access just so I can step through various values and see how they're dealt with. The fact the language is different shouldn't make any difference and because I can step through the code I can better see how it deals with negative values.

So -5.7 is greater than -6. I think I had it in my head that it was less. :bash: So now I see the sense in how it's coded. Thanks to you and Mark for your help.
Cheers,
Ray, Cheshire.

Image
Post Reply