Please read the posts in the Announcements section about the current status of Cumulus development now that I have retired

Please read this post before posting

Latest Cumulus release v1.9.4 (build 1099) - Nov 28 2014
Latest Cumulus MX release - v3.0.0 build 3043 Jan 20 2017. See this post for download

Lowest Monthly Rainfall record desired on website

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

Moderators: daj, TNETWeather

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

Lowest Monthly Rainfall record desired on website

Postby RayProudfoot » Tue May 09, 2017 6:14 pm

For many years my website has remained pretty much unchanged but with this recent dry spell in the UK I was curious about the driest month record for each month.

Cumulus has a tag for wettest month but not driest. I can't imagine Steve is going to add any new tags now as Cumulus 1 has been mothballed for quite some time.

But this is where my Access database comes in useful. I have created a crosstab query that shows rainfall for each month by year. I was hoping to amend my monthly records page and add the driest month manually.

But I can't because that page is controlled by PHP and I know bugger all about PHP. :(

Here is my query. Is it possible for some kind soul to help integrate this into my Monthly Records?
http://www.cheadlehulmeweather.co.uk/monthlyrecord.htm

RainfallByYearAndMonth.png
You do not have the required permissions to view the files attached to this post.
Cheers,
Ray, Cheshire.

Image

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

Re: Lowest Monthly Rainfall record desired on website

Postby RayProudfoot » Tue May 09, 2017 6:39 pm

I did a bit of digging and have established that the highest monthly rainfall is held in a variable named MonthlyRainH.

Further down monthlyrecordT.htm is an array that is the basis for this record:-

var monthlyrain = new Array("<#ByMonthMonthlyRainH mon=1>","<#ByMonthMonthlyRainH mon=2>","<#ByMonthMonthlyRainH mon=3>","<#ByMonthMonthlyRainH mon=4>","<#ByMonthMonthlyRainH mon=5>","<#ByMonthMonthlyRainH mon=6>","<#ByMonthMonthlyRainH mon=7>","<#ByMonthMonthlyRainH mon=8>","<#ByMonthMonthlyRainH mon=9>","<#ByMonthMonthlyRainH mon=10>","<#ByMonthMonthlyRainH mon=11>","<#ByMonthMonthlyRainH mon=12>");

Does this info rely on a tag within Cumulus to get its data? If it does then I'm probably stuffed. But if it doesn't then it seems it could be derived.
Cheers,
Ray, Cheshire.

Image

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

Re: Lowest Monthly Rainfall record desired on website

Postby RayProudfoot » Tue May 09, 2017 6:59 pm

Damn. :( As I suspected <#ByMonthMonthlyRainH> is a webtag in Cumulus 1. Unfortunately there is no equivalent for Lowest Monthly Rainfall so it looks I can't implement it.
Cheers,
Ray, Cheshire.

Image

User avatar
mcrossley
Posts: 5192
Joined: Thu Jan 07, 2010 9:44 pm
Weather Station: Davis VP2
Operating System: Stretch Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Lowest Monthly Rainfall record desired on website

Postby mcrossley » Tue May 09, 2017 7:19 pm

You need a MySQL database on your server Ray :)

Easy to add this and other things like runs of wet/dry days, sunshine etc...
http://weather.wilmslowastro.com/records_monthly.php

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

Re: Lowest Monthly Rainfall record desired on website

Postby RayProudfoot » Tue May 09, 2017 7:49 pm

Mark,

How much work is involved in that? Switching to Cumulus MX?
Cheers,
Ray, Cheshire.

Image

User avatar
mcrossley
Posts: 5192
Joined: Thu Jan 07, 2010 9:44 pm
Weather Station: Davis VP2
Operating System: Stretch Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Lowest Monthly Rainfall record desired on website

Postby mcrossley » Tue May 09, 2017 7:54 pm

MX makes it easier, but you can stay with Cumulus 1 and use the ImportCumulus script to import the dayfile once a day after midnight (and monthly data file as well if you like - though that is not used as much).

User avatar
PaulMy
Posts: 1675
Joined: Sun Sep 28, 2008 11:54 pm
Weather Station: Davis Vantage Pro 2 w/Envoy USB
Operating System: Windows-8
Location: Komoka, ON Canada
Contact:

Re: Lowest Monthly Rainfall record desired on website

Postby PaulMy » Tue May 09, 2017 9:07 pm

Hi Ray,
I am still using Cumulus 1 and do what Mark is saying, use the ImportCumulus script to import the dayfile in my website MySQL database, once a day after midnight using the Cumulus toolbox for that scheduling, and manually import the monthly log files as well (also do it for realtime.txt).

However I am very limited to using all that data. I have only a few scripts, mostly obtained here on the forum, that provide any output. I should take some more time to get back in to this and see what I can do.

Good luck,
Paul

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

Re: Lowest Monthly Rainfall record desired on website

Postby RayProudfoot » Tue May 09, 2017 9:55 pm

mcrossley wrote:MX makes it easier, but you can stay with Cumulus 1 and use the ImportCumulus script to import the dayfile once a day after midnight (and monthly data file as well if you like - though that is not used as much).


Thanks Mark. I'll take a look at what's involved.
Cheers,
Ray, Cheshire.

Image

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

Re: Lowest Monthly Rainfall record desired on website

Postby RayProudfoot » Tue May 09, 2017 9:58 pm

PaulMy wrote:Hi Ray,
I am still using Cumulus 1 and do what Mark is saying, use the ImportCumulus script to import the dayfile in my website MySQL database, once a day after midnight using the Cumulus toolbox for that scheduling, and manually import the monthly log files as well (also do it for realtime.txt).

However I am very limited to using all that data. I have only a few scripts, mostly obtained here on the forum, that provide any output. I should take some more time to get back in to this and see what I can do.

Good luck,
Paul


Thanks Paul. Looks like I'm going back to school all over again. It's not an immediate requirement but long-term I'd like to include these extra records.
Cheers,
Ray, Cheshire.

Image

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

Re: Lowest Monthly Rainfall record desired on website

Postby steve » Wed May 10, 2017 9:46 am

I agree that a MySQL database is the 'superior' way to do this, but you can do it with what you have if you can write the results of your database query to a text file on your PC. Cumulus could then upload this as an 'extra file' and some additional Javascript (that's what the code is, rather than PHP) could read that file from the server and put the values onto the web page.
Steve
-----
Hosting available for Cumulus web sites. See http://sandaysoft.com/forum/viewtopic.php?f=2&t=11876

Please read the posts in the Announcements section about the current status of Cumulus development since I have retired from my day job

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

Re: Lowest Monthly Rainfall record desired on website

Postby RayProudfoot » Wed May 10, 2017 11:45 am

Hi Steve,

This is the result of outputting the data to a plain text file. The titles are optional. The delimiters can be changed to whatever Java prefers.

"Year","1","2","3","4","5","6","7","8","9","10","11","12"
2009,,,,,2.74,2.70,5.64,2.21,1.60,1.50,6.08,2.92
2010,1.44,2.35,1.99,0.92,0.47,2.20,2.86,4.99,3.73,3.33,2.52,0.81
2011,2.25,5.20,0.68,0.61,2.60,2.08,3.12,2.50,1.81,3.85,1.96,7.21
2012,3.97,1.67,0.86,4.84,2.11,5.10,4.49,2.81,4.07,2.35,2.65,5.34
2013,2.05,1.51,1.07,0.70,2.53,2.43,4.21,2.49,2.69,4.64,2.46,3.18
2014,4.01,3.20,1.97,1.57,3.92,1.87,2.15,4.69,0.43,3.22,2.58,4.90
2015,3.65,2.17,3.49,1.11,4.05,2.02,2.72,3.64,1.69,1.63,5.77,4.50
2016,3.79,3.63,3.70,3.56,1.54,6.11,2.73,2.65,3.77,1.23,3.47,1.73
2017,2.92,2.72,3.62,0.64,0.00,,,,,,,

Could the Java script add it to the existing MonthlyRecordT.htm or would it have to go to a separate one? That wouldn't be desirable for obvious reasons.

Oh, just one other thing. The Access database is on another PC, not the one running Cumulus. Each time I open it it clears down the table holding the dayfile.txt info and reimports it. I suppose it's straight-forward enough to export the text file back to the Cumulus netbook.
Cheers,
Ray, Cheshire.

Image

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

Re: Lowest Monthly Rainfall record desired on website

Postby steve » Wed May 10, 2017 12:32 pm

That looks reasonably straightforward, some new Javascript code could read in those values and put them in arrays, one array per month, and then find the minimum in each array, and its index. This could then form new arrays like the ones for highest monthly rainfall, and the existing code could be modified to put those values into new locations on the page like it does for the existing values.

As the values in your array would only change at the end of each month, you could upload the file manually then. You need to make sure your code doesn't include the current month, because that would show as the driest month (e.g. the zero for this month in your example) but the month hasn't finished yet, so really it doesn't count.

I'll have a go at some code later. And then Mark can show us some better code :lol:
Steve
-----
Hosting available for Cumulus web sites. See http://sandaysoft.com/forum/viewtopic.php?f=2&t=11876

Please read the posts in the Announcements section about the current status of Cumulus development since I have retired from my day job

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

Re: Lowest Monthly Rainfall record desired on website

Postby RayProudfoot » Wed May 10, 2017 12:35 pm

Steve. What would I do without you? Thanks very much! :clap: Easy enough to exclude the current month.
Cheers,
Ray, Cheshire.

Image

User avatar
PaulMy
Posts: 1675
Joined: Sun Sep 28, 2008 11:54 pm
Weather Station: Davis Vantage Pro 2 w/Envoy USB
Operating System: Windows-8
Location: Komoka, ON Canada
Contact:

Re: Lowest Monthly Rainfall record desired on website

Postby PaulMy » Wed May 10, 2017 2:52 pm

Steve. What would I do without you?

And there are others observing/borrowing as well :)

Paul

User avatar
mcrossley
Posts: 5192
Joined: Thu Jan 07, 2010 9:44 pm
Weather Station: Davis VP2
Operating System: Stretch Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Lowest Monthly Rainfall record desired on website

Postby mcrossley » Wed May 10, 2017 5:26 pm

I don't have time to code up a full solution, but this should be a start?...

Code: Select all

// Do some AJAX to get this content from the server
// Simulated here...
var file = '"Year","1","2","3","4","5","6","7","8","9","10","11","12"\r\n2009,,,,,2.74,2.70,5.64,2.21,1.60,1.50,6.08,2.92\r\n2010,1.44,2.35,1.99,0.92,0.47,2.20,2.86,4.99,3.73,3.33,2.52,0.81\r\n2011,2.25,5.20,0.68,0.61,2.60,2.08,3.12,2.50,1.81,3.85,1.96,7.21\r\n2012,3.97,1.67,0.86,4.84,2.11,5.10,4.49,2.81,4.07,2.35,2.65,5.34\r\n2013,2.05,1.51,1.07,0.70,2.53,2.43,4.21,2.49,2.69,4.64,2.46,3.18\r\n2014,4.01,3.20,1.97,1.57,3.92,1.87,2.15,4.69,0.43,3.22,2.58,4.90\r\n2015,3.65,2.17,3.49,1.11,4.05,2.02,2.72,3.64,1.69,1.63,5.77,4.50\r\n2016,3.79,3.63,3.70,3.56,1.54,6.11,2.73,2.65,3.77,1.23,3.47,1.73\r\n2017,2.92,2.72,3.62,0.64,,,,,,,,';

var lines = file.split("\r\n");
var fields = [];
var lowMonthlyRain = [999,999,999,999,999,999,999,999,999,999,999,999];
var lowMonthlyRainT = [];


for (var y=1; y<lines.length; y++) {
   // now extract the records
   fields = lines[y].split(',');
   for (var m=1; m<fields.length; m++) {
      if (fields[m] !== '' && +fields[m] < records[m-1]) {
         lowMonthlyRain[m-1] = fields[m];
         lowMonthlyRainT[m-1] = fields[0];
      }
   }
}

// Now populate the 'new' HTML fields
document.getElementById('lowMonthlyRain').innerHTML = lowMonthlyRain[month];
document.getElementById('lowMonthlyRainT').innerHTML = lowMonthlyRainT[month];

// and add the above HTML updates to the changeData() function


Return to “Web site - General”

Who is online

Users browsing this forum: No registered users and 2 guests