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

Number of days without rain - possible webtag

Other discussion about creating web sites for Cumulus that doesn't have a specific subforum

Moderator: daj

Post Reply
Hillbilly
Posts: 112
Joined: Tue 26 Jan 2010 8:54 am
Weather Station: Davis Vantage Pro2 Plus
Operating System: Vista Home Premium SP2
Location: Mayenne, Pays De La Loire, France
Contact:

Number of days without rain - possible webtag

Post by Hillbilly »

The Cumulus display can show me number of days with rain on the summaries. Would it be possible/useful to have a webtag that outputs either that, or my preference, number of days without rain, in current month and/or year to date?
Many thanks
Helen

La Locherie Weather
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: Number of days without rain - possible webtag

Post by steve »

It would be possible, yes. At the moment that would require trawling through dayfile.txt each time the tag was encountered, which isn't the most efficient way to do it. What it really needs is for Cumulus to keep track of the two values so they're readily available during tag processing.

I think I might reinstate the bug/enhancement reporting/tracking site, but just use it for enhancements this time. I can't really do anything other than simple changes at the moment, due to working on the "next version", so things that I don't do immediately will get forgotten - by me anyway!
Steve
Hillbilly
Posts: 112
Joined: Tue 26 Jan 2010 8:54 am
Weather Station: Davis Vantage Pro2 Plus
Operating System: Vista Home Premium SP2
Location: Mayenne, Pays De La Loire, France
Contact:

Re: Number of days without rain - possible webtag

Post by Hillbilly »

Hi Steve,

it's a good idea to reinstate the enhancement request process because it would be mad to expect you to keep track of ideas. I had trawled the forum and seen something similar had been discussed last year, so was raising to 'add to the list'.

Of course the next version is priority, very happy that that is the case.
Many thanks
Helen

La Locherie Weather
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: Number of days without rain - possible webtag

Post by mcrossley »

Spookily I was thinking of this feature just yesterday. maybe something do with the dry spell we are having :roll:

Maybe I'll add a view to the SQL db on my web server...
Hillbilly
Posts: 112
Joined: Tue 26 Jan 2010 8:54 am
Weather Station: Davis Vantage Pro2 Plus
Operating System: Vista Home Premium SP2
Location: Mayenne, Pays De La Loire, France
Contact:

Re: Number of days without rain - possible webtag

Post by Hillbilly »

Thanks for raising the enhancement request Mark. I had a think about doing something in the mean time and came up with the idea of writing a query to run on the SQL database and display the result on my Record page. I went for 'No of days without rain 'nn' in the last month' and use a rolling month to calculate.

I can't speak for the quality of my SQL query as I know little about SQL, but it seems to reconcile! I renamed my Record.htm page to Record.php and added that to the list for Cumulus to process.

The query is:
raindaysquery.txt
This is in the <body> after my header banner.

In the rainfall table, I have added the following:
<tr class="td_rainfall_data">
<td class="labels">Days&nbsp;Without&nbsp;Rain&nbsp;</td>
<?php print "<td>$raindays</td>\n"; ?>
<td>in&nbsp;the&nbsp;last&nbsp;month</td>
</tr>

If anyone has any comments on the code, always looking to improve.
You do not have the required permissions to view the files attached to this post.
Last edited by Hillbilly on Mon 19 Apr 2010 8:39 pm, edited 1 time in total.
Many thanks
Helen

La Locherie Weather
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: Number of days without rain - possible webtag

Post by mcrossley »

Thanks for that Helen, I've been looking into to, but I want to show the number of consecutive days without rain. The SQL for that is proving much trickier, and I'm having to self join the table and perform sub-queries. I think it will be simpler to combine a simple SQL query with some PHP code to check for the consecutive day count.
Hillbilly
Posts: 112
Joined: Tue 26 Jan 2010 8:54 am
Weather Station: Davis Vantage Pro2 Plus
Operating System: Vista Home Premium SP2
Location: Mayenne, Pays De La Loire, France
Contact:

Re: Number of days without rain - possible webtag

Post by Hillbilly »

Yes I can see that would be tricky. I'd be interested to have an update on how you go on.
Many thanks
Helen

La Locherie Weather
User avatar
daj
Posts: 2041
Joined: Tue 29 Jul 2008 8:00 pm
Weather Station: WH1081
Operating System: Pi & MX
Location: SW Scotland
Contact:

Re: Number of days without rain - possible webtag

Post by daj »

I've had an attempt to work out the number of consecutive days without rain. The possible solution below assumes your dayfile is contained within an SQL data table on your web server. Here is the SQL code....

Code: Select all

SET @count = 0;
 
SELECT LogDate,Count FROM (
    SELECT *, @count:=(CASE WHEN TotRainFall=0 THEN @count+1 ELSE 0 END) AS `count`
    FROM dayfile
) temp
ORDER BY `count` DESC
LIMIT 1
This will return a date and a number, so in my case....
2010-01-12, 26
This tells me that 12 January 2010 was the last day of a run of 26 days with no rain and it was the longest running since my records began

I would be interested in others testing this if you have your data in SQL
David
kippfordweather.uk
Cumulus MX & Raspberry Pi
Hillbilly
Posts: 112
Joined: Tue 26 Jan 2010 8:54 am
Weather Station: Davis Vantage Pro2 Plus
Operating System: Vista Home Premium SP2
Location: Mayenne, Pays De La Loire, France
Contact:

Re: Number of days without rain - possible webtag

Post by Hillbilly »

I would be interested in others testing this if you have your data in SQL
David, just tested the query and my result was 18th March 2010 for 17 days, which is correct.
Many thanks
Helen

La Locherie Weather
Hillbilly
Posts: 112
Joined: Tue 26 Jan 2010 8:54 am
Weather Station: Davis Vantage Pro2 Plus
Operating System: Vista Home Premium SP2
Location: Mayenne, Pays De La Loire, France
Contact:

Re: Number of days without rain - possible webtag

Post by Hillbilly »

I've finally got round to trying to add this to my records page. The query works fine when run as a SQL query directly on my database table. However, I am struggling to work out how to assign the resulting date and count to two separate variables which can then be displayed. (I can do one!). I have not managed to find a good reference to running MYSQL in PHP, which doesn't help.

Can anyone help?
Many thanks
Helen

La Locherie Weather
GrahamBuxton
Posts: 5
Joined: Wed 11 Nov 2009 5:41 pm
Weather Station: Ecowitt
Operating System: Raspberry Pi
Location: East Tennessee USA
Contact:

Re: Number of days without rain - possible webtag

Post by GrahamBuxton »

The query works fine when run as a SQL query directly on my database table. However, I am struggling to work out how to assign the resulting date and count to two separate variables which can then be displayed. (I can do one!). I have not managed to find a good reference to running MYSQL in PHP, which doesn't help.

Check out Example #2 at this page:
http://www.php.net/manual/en/function.mysql-query.php
Hillbilly
Posts: 112
Joined: Tue 26 Jan 2010 8:54 am
Weather Station: Davis Vantage Pro2 Plus
Operating System: Vista Home Premium SP2
Location: Mayenne, Pays De La Loire, France
Contact:

Re: Number of days without rain - possible webtag

Post by Hillbilly »

Thanks Graham. There are certainly a good few examples there. Will have a good look when I get a chance.
Many thanks
Helen

La Locherie Weather
Post Reply