Welcome to the Cumulus Support forum.

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

Cumulus MX V4 beta test release 4.0.0 (build 4018) - 28 March 2024

Legacy Cumulus 1 release v1.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

Comparing with one year ago

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

Moderator: daj

sfws
Posts: 1183
Joined: Fri 27 Jul 2012 11:29 am
Weather Station: Chas O, Maplin N96FY, N25FR
Operating System: rPi 3B+ with Buster (full)

Comparing with one year ago

Post by sfws »

'Cumulus 1 Enhancement request 240' from Jacques asks if it is possible to add web tags for all parameters shown on a web page, but for one year ago.
I'm unsure if the original requestor that Jacques refers to is the person who has used a database to get this result: http://www.lalocherie.com/weather/todayprevyears.php

Important: Later posts in this thread contain more recent versions of this script, and comments relating to various parts of the script.

For those without PHP and databases, but using Cumulus original web page designs (or their own designs but using JavaScript/jQuery), I attach an alternative solution (as threatened in my reply to enhancement 240):
AYearAgo.zip
EDIT: See attachment for screen shot of effect on standard Cumulus Yesterday page.

I've worked on 'yesterday.htm' as comparing a complete day with another complete (EDIT: spelling error in original posting corrected) day makes some sense to me. I have used the Cumulus web tag for the meteorological day

Code: Select all

<#metdate> 
so that it applies to all rollover times, and because that made it simple for me to do a full test of the behavoir in leap years and ordinary years, on leap days and before and after such leap days (simply by changing the parameters passed from HTML to script). If yesterday is a leap day, the 28 Feb one year ago is displayed. I've added the day and date to confirm what is yesterday and what is one year ago. In testing, I actually had a separate list of values and times for one year ago to check correct ones are displayed. I have edited out most of the extras inserted for testing, but left in comments, especially those that indicate where some people might want to customise for their own set up or simply explain why I have taken a particular approach.
You do not have the required permissions to view the files attached to this post.
Last edited by sfws on Tue 23 Oct 2018 6:57 am, edited 5 times in total.
User avatar
steve
Cumulus Author
Posts: 26702
Joined: Mon 02 Jun 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

Re: Comparing with one year ago

Post by steve »

Sounds good; have you got an example page up anywhere?
Steve
sfws
Posts: 1183
Joined: Fri 27 Jul 2012 11:29 am
Weather Station: Chas O, Maplin N96FY, N25FR
Operating System: rPi 3B+ with Buster (full)

Re: Comparing with one year ago

Post by sfws »

steve wrote:Sounds good; have you got an example page up anywhere?
The attachment (that at the moment I can see you have not downloaded) includes a screen shot (and the HTML and script code) to show what it looks like.
The HTML is taken from the web/originals folder, and apart from changes to insert the extra columns, and to pass <#metdate> to the script, all I did was change the beaufort number into its description, since v.1.9.3 provides description for yesterday web tag . (Steve - that last change is a simple one, you might consider for your next build):

Code: Select all

<tr class="td_wind_data">
      <td>Highest&nbsp;Speed</td> <td><#windYM>&nbsp;<#windunit>&nbsp;(<#Ybeaudesc>)</td>
A future task is to produce a template in the style of my other ones (it is in my head currently), but I don't normally have web pages online, because I rarely run Cumulus to generate updated versions!
User avatar
steve
Cumulus Author
Posts: 26702
Joined: Mon 02 Jun 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

Re: Comparing with one year ago

Post by steve »

sfws wrote:change the beaufort number into its description, since v.1.9.3 provides description for yesterday web tag . (Steve - that last change is a simple one, you might consider for your next build):
possibly; but personally I'd want the number anyway, so I'd want to leave that in.
Steve
sfws
Posts: 1183
Joined: Fri 27 Jul 2012 11:29 am
Weather Station: Chas O, Maplin N96FY, N25FR
Operating System: rPi 3B+ with Buster (full)

Re: Comparing with one year ago

Post by sfws »

steve wrote:personally I'd want the number anyway, so I'd want to leave that in
Great minds ... as I logged out after that comment, I thought both "F1 = Light air" or similar would be even better and suit more people, but I was too lazy to edit the post!

EDIT - the PHP version in the posting subsequent to this one does implement the "F1= Light Air" suggestion.
Last edited by sfws on Fri 05 Dec 2014 9:27 pm, edited 1 time in total.
sfws
Posts: 1183
Joined: Fri 27 Jul 2012 11:29 am
Weather Station: Chas O, Maplin N96FY, N25FR
Operating System: rPi 3B+ with Buster (full)

Updated code for: Comparing with one year ago

Post by sfws »

Cross-reference: Two Cumulus 1 Enhancement Requests
240 (https://cumulus.hosiene.co.uk/tracker.php?p=1&t=240)
and 231 (https://cumulus.hosiene.co.uk/tracker.php?p=1&t=231)
ask for Cumulus to be enhanced to show information for one year ago and inspired the development of the routine described in this thread.
Both PHP script (using MySQL database) and JavaScript (using dayfile.txt directly) versions are included in the main attachments to this posting.

EDITS made 4 October 2018:
The list of enhancements referenced above was not copied across when Steve moved this forum to a new server, and Steve has since ceased development on Cumulus 1 that all the enhancements used as the starting point. His Cumulus 2 (later withdrawn) and 3 (MX, currently frozen in a beta release) introduced some changes to the statistics that are retained. I don't use MX, but I understand some old month and year statistics are retained in their "ini" file format, so it is possible a different solution might be possible now.

My basic Cumulus template "yesterday_to_a_year_agoT.htm" that has been edited to produce various script versions below was written in 2012 when Cumulus 1 was used by everybody. Line 188 therefore reads:

Code: Select all

<script>var metDate=['<#metdate format="dd">','<#metdate format="mm">','<#metdate format="yyyy">',(parseInt("0"+"<#rollovertime>",10)),"<#rollovertime>"];</script><!-- Pass current Meteorological date and rollover time to script to search dayfile.txt, so knows what day to start search from -->
but the 'mm' selector should read 'MM' as shown next:

Code: Select all

<script>var metDate=['<#metdate format="dd">','<#metdate format="MM">','<#metdate format="yyyy">',(parseInt("0"+"<#rollovertime>",10)),"<#rollovertime>"];</script><!-- Pass current Meteorological date and rollover time to script to search dayfile.txt, so knows what day to start search from -->
because in Cumulus 1 either 'mm' or 'MM' will select month number, but in Cumulus MX if you use 'mm' it selects minutes part of the time whereas only 'MM' selects the required month number part of today's date.
I have not edited the downloads below, but if you are downloading them now, you should manually make this change to whichever template you download. As I don't use MX, it is possible other aspects of scripts need amendment. See most recent postings in this thread.

As a later post in this thread says, all the software libraries (PHP, MySQL, and jQuery) have been updated since this posting was made in 2012. Consequently, I have edited this post below to highlight the implications if you choose to use later versions than those available in 2012.

I do still use a script that displays statistics for one year ago, and another script that shows statistics for each day in the last week, these were both derived from the scripts posted here, but have had several edits in their lifetime. I have not shared these later versions because they were edited specifically to suit me and I use a me-specific set-up including a database schema that is now changed again from the one I used in 2012, in fact my scripts have changed several times, and I do not have time (and maybe skill now) in my busy life now to maintain scripts that are easy for others to use as well as maintaining scripts that suit me.
END OF EDIT 4 October 2018 [/color]


This particular posting in the thread incorporates the calculation of a derived value like the temperature range (t_range) for a year ago, if I remember correctly that is in all of the zip files attached to this post although as I worked on each zip at different times, so there is potential for me to be muddled about exact content.


PHP Version
yesterday_lastYearT.zip
This download is a zip file that contains a Cumulus template file, so to use it you need to get cumulus to process the template file in the attachment and copy/FTF it into a .../????? directory. If you have Cumulus web-tags available as PHP variables, then you may feel you don't want a template file, and indeed on my own implementation I use the PHP variables approach.
If you have studied PHP scripts made available as third-party ones in Wiki and forum you will understand there are various PHP variable naming set-ups used by different scripts on this forum and I don't have inclination to study what others have done so I understand them nor to make multiple versions available. Consequently, I stick to the template approach here, and leave you to consider if you have expertise to adopt a different approach.

The attachment above uses PHP, MySQL and a database table containing daily information, so if that is the environment you are comfortable working in (you will probably need to tailor my PHP as I cannot control how you have implemented PHP on your server), then you can choose this download. Cumulus 1 does not automatically populate such a database table (you can see http://wiki.sandaysoft.com/a/ImportCumulusFile for a suitable tool to populate such a database, although column names that David Jameson selected for that tool may not match mine, so either edit his script as developed further by Mark Crossley or edit my script).

Please note that the PHP code to define the user-name, password, and database name to access such a table is not included in the download, and the code I supply assumes you have a .../forbidden directory containing a PHP file with those details in it (the one suggested by 'ImportCumulusFile' might do, but check if it uses the same variable names as defined in my connect instruction or you need to edit some PHP).

Don't forget that you may be using a different schema to those I use in my script. When you use PHP to read a row the script can place the columns read into an array. A particular column can be referenced by its column name e.g. $required_fields['MinTemp'] if the column name for the lowest temperature is 'MinTemp' in your schema. But in my script as posted here I have used numerical indices( because I know that Mark Crossley has changed some column names in the schema referenced in the Wiki) e.g. if you adopt the David Jamieson schema that follows the sequence Steve has used in dayfile.txt the column number for lowest temperature implies you can use $required_fields[4]. If you use a different schema, I suggest you use column names instead of the numerical indices.


The zip encloses one file called 'yesterday_lastYearT.php', it includes the calculation of temperature range, a function to convert a bearing to a compass direction (thanks beteljuice), a function to derive 'absolute humidity' from dewpoint, and a function to express all time-stamps in am/pm format. Hopefully, you have enough PHP expertise so you can comment out any parts you do not want, but will find included all parts that you might want.

Basically I have included everything available from Cumulus for these two days (the original 'yesterdayT.htm' does not include average temperature or heating/cooling degree days for example), making it easy for you to take out what you do not want (see instructions in code for sunshine hours).

The template I supply is designed to use 'weatherstyle.css' just as Cumulus standard templates do, the HTML page created should be file transferred to the same directory and the style sheet expects you to have 'picture.jpg' in an 'images' sub-directory. Simple Instructions for how to get Cumulus to process the provided template file are in Cumulus 1 Help screens. Alternatively you can see http://wiki.sandaysoft.com /a/Customise ... on.27_menu because I have made sure that contains Full Instructions.

The attached file is edited from what I installed on my site when I was learning PHP and wanted to try something different to the top tens page from Mark Crossley that was the first PHP I decided to experiment on by adding different queries. But my site is on my PC and only operated when I have the time (fairly rarely) to experiment with learning more code. It is purely a test environment and much of my 'weather data' is frankly rubbish from a low cost unreliable Fine Offset station. Although my own site is not available online, I have a diurnal web page that shows weather ststistics for today, yesterday and one year ago. The same web page includes an almanac section that shows sunrise/sunset, dusk/dawn for each of the 3 days, and it does some conversions to show the observations in alternative units. I use a portable server called "Uniform" (other portable cut-down servers are available) rather than the more widely known and much more complicated "XAMPP" on my PCs. From time-to-time I have and will revamp my test site and/or change my database schema so it suits whatever I am testing when I can't pursue my other interests.
Since I developed the template-based scripts shared here, I have drastically changed my web pages (mostly they are now using multiple PHP scripts to produce different parts of the content), so I don't have any of the files in the versions I attached here left in use on my site.

EDITS made 4 October 2018: See my note earlier, I can't promise that my PHP script will still work with latest PHP and latest MySQL as I have not tested it with versions released after 2012, and indeed my test environment does not not use the latest versions of those libraries even if I had time and inclination to retest my script. Cumulus MX did not exist when I released this script; however MX has the ability to update a MySQL database, and you can choose to use my schema with my column names, but you do need to check that the way that dates are processed differently in MX does not stop my script written for Cumulus 1 from working for you.

JavaScript Versions - complete package and some alternative patches
The scripts below use JavaScript (and some jQuery) to access the daily summary log file (dayfile.txt), a less efficient and far more complicated approach to code, but all you need is a copy of the 'dayfile.txt' to have been uploaded to your web-space sometime recently.

You can look at http://www.christelow.co.uk/Website/files/today.htm to see a hybrid version of my JQuery/JavaScript routine working. - this URL edited 2017.
Mike chose to also include 'today' columns (taken from Steve's Loft's today template and added to my modified yesterday template, I offer such an alternative as a patch below), to take out the bit of code that I included to show the date for one year ago (I wanted to make it easy for people to spot whether they were seeing the right date - see my point about subtracting 365 from line count below), and to include last year's 'temperature range' (using my one decimal place script variant below). Because you too may wish to select what parts of my coding you choose to include, I still include multiple versions of my script allowing you to pick and choose the bits you want from the various alternatives.

a_year_apart.zip
You may wish to modify this download to use whatever is the latest jQuery version when you are running this script, hopefully the functionality I use here will continue to be available when jQuery updates are released.
EDITS made 4 October 2018: See my note earlier, about how the template file needs one line to be edited to work with all Cumulus versions.
If you do not have a solar sensor, edit both the HTML and javascript as necessary (see my guidance included in the files) in these downloads.
revised_script.zip
(This download has the full script, but under a new name and it has better written code, it also will produce a Beaufort Force wind description. If you want a JavaScript based script, this download is probably better than the previous one, but the previous note about jQuery version still applies.


NOTE: There are a number of alternative ways of getting a fixed number of decimal places, one is 'Math.round(variable*10)/10' where you choose the number of decimal places by whether you use 10 or 100 etc in the two places, another (favoured by experienced coders on this forum) is 'variable.toFixed(n)' where n determines the number of decimal places (I have used the last mentioned approach in revised attachment above).

The version in my code extract below is more complicated, it is designed to achieve the best accuracy in subtraction of numbers using binary arithmetric, by ensuring that the numbers on each side are both integers by pre-multiplication, and it then converts the answer by rearranging the decimal point.
extract from searchDayfile.zip



I have another page that displays (for each day of the last week), both the highs and lows of that day and the spot values at the closest time to the latest update time for each day. As well as using a modification of the script used here to derive the highest and lowest value for each day, it uses 'Recent tags' to derive the spot values. For calculated observations like apparent temperature, that do not appear in recent tags, it takes the corresponding recent tags for wind speed, humidity and temperature and applies the formula that Cumulus uses to calculate the spot apparent temperature.

Incidentally, with simple changes in script and HTML, the posted routine can be changed to display:
  • * one week ago
    * each day in last (any number) of days, (such as last week as per my description above)
    * one fortnight ago
    * any number of days or weeks ago
One month ago is complex as months vary in length, so you need to check which month you are in, look up how many days it has (and whether for February it is 28 or 29) and then decide which day of previous month you wish to see.
Two (or more) years ago is also complex because of extending checks for leap day.

Note about deriving the correct date for one year ago
PHP includes a function for subtracting a time period when deriving one date from another (so I can ask PHP to work out the primary key for the row I need to retrieve by subtracting one year from yesterday's date), but JavaScript does not have such functionality (so I need to manually calculate the date required by working out what is 366 or 367 days before today's date). As that suggests it is very complicated, because some years have a leap day. That means I have to first convert today's date into a number, then work out which number of days to subtract by working out if a leap day is included between today and one year ago. Then I have to convert the new number back to a date. I also have to decide when to report Feb 29 if it was available (my decision is last day of February for yesterday should also be last day for a year ago regardless of whether in one year it is 28 and the other year it is 29 or it is 28 in both years).
Those scripts I have posted above that use JavaScript therefore use a complicated sequence of calculations to work out the date for a year ago and then use the jQuery 'each' function to check every line in the file to see if it contains the required (calculated) date. I did that because I assumed that the daily summary might not contain a row for every day (some dates might be missing) so I could not just count 365 (or 366) records back from the end of the file, and indeed if the date sought does not exist, I look for one day before.

In the related script I mention above that extracts just the last week, it simply takes the length of the array created to hold all lines from dayfile.txt and derives the index of the earliest line required by subtracting 8 from the index of the last (actually empty) line. It then processes the following 5 lines to populate the full week in my table (yesterday and today are available from web tags, so you don't need 7 lines). That is so simple that I wonder whether I should have assumed that everybody has all days on their dayfile and simply subtracted the 366 or 367 from the length to pick the record required in my one year ago script?
If you know you have all days present on your daily summary file then you may prefer to use this simpler download:
take_365_Days_Ago_from_Dayfile.zip
If you can make this code (there are probably other parts that you do not need) work, you have something to work on to get output for any date you choose relative to the last day on the file.
You do not have the required permissions to view the files attached to this post.
Last edited by sfws on Tue 23 Oct 2018 7:20 am, edited 4 times in total.
User avatar
mikechristelow
Posts: 165
Joined: Wed 01 Feb 2012 9:33 pm
Weather Station: Watson W8681 (solar)
Operating System: Windows XP SP3
Location: Crewe, Cheshire
Contact:

Re: Comparing with one year ago

Post by mikechristelow »

Hi,

All this seems a long time ago now and I have been really pleased with my "Today - Yesterday - Year ago" page even though it is only humble HTML and javascript. The work by SFWS to help me get this working was great and very much appreciated.

I've changed my website now, so the urls listed in the post need to be updated to just read http://www.christelow.co.uk/Website/files/today.htm which should be all you need to see the page in action.

Thanks once again!
Mike
http://www.christelow.co.uk
“It's snowing still," said Eeyore gloomily.
"So it is."
"And freezing."
"Is it?"
"Yes," said Eeyore. "However," he said, brightening up a little, "we haven't had an earthquake lately.”

User avatar
dazza1223
Posts: 860
Joined: Sun 25 Jan 2015 8:41 pm
Weather Station: Davis Vantage Pro 2 plus
Operating System: Raspberry pi 4 (4gb)
Location: Worthing
Contact:

Re: Comparing with one year ago

Post by dazza1223 »

hi sorry to drag up all this but im trying to add this can somone tell me what one is better out off all off them ie

AYearAgo.zip ?

yesterday_lastYearT.zip pS i got php and sql running


revised_script.zip

extract from searchDayfile.zip

a_year_apart.zip

take_365_Days_Ago_from_Dayfile.zip

thanks :D
Have fun and keep learning

dazza :D

https://www.davisworthing.co.uk

Image
sfws
Posts: 1183
Joined: Fri 27 Jul 2012 11:29 am
Weather Station: Chas O, Maplin N96FY, N25FR
Operating System: rPi 3B+ with Buster (full)

Re: Comparing with one year ago

Post by sfws »

I struggle to recall what I did last week, let alone back in 2012. It is certainly true that I no longer use 6 year old scripts. The scripts I use (locally only) now (I still have one for the last 7 days as well as the one just comparing today, yesterday and a year ago) are probably totally different from those originals and I can't easily tell you the differences off the top of my head. However, my 16 Nov 2012 4:58 pm post still seems clear enough to me, and you should download from there.

If you want to use PHP and MySQL, 'yesterday_lastYearT.php' includes everything (just beware column names, as I did not follow DAJ's originals (loosely based on the dayfile.txt), but invented a more rule based naming standard, as mentioned in some of my postings earlier this year). Anyway 35 downloads suggests that several people took an interest. I cannot promise that script works with latest PHP version and latest MySQL, it worked well with versions available in 2012. See this version in operation on https://warehamwx.co.uk/yesterday_lastYear.php.

If you were not using PHP nor MySQL, then that same posting offers 'revised-script.zip' as the best version for a JavaScript option, and that achieved 27 downloads, although it was older and did not have extras like 'absolute humidity' as included in PHP version. Again jQuery versions have changed since 2012, but hopefully my script only uses functionality still available. Mike's site http://www.christelow.co.uk/Website/files/today.htm (see his most recent post, you can view the source he uses by clicking in his table and selecting "View Frame Source"), is still using jQuery 1.8.3 the latest in 2012, the current version of jQuery is 3.3.1.

The other versions were left as attachments as again they had many downloads, and I made slightly different choices (e.g. whether temperatures were shown as integers or to one decimal place) and some people might be interested in doing file compares to see the differences, or merging code from different versions (some mention solar for example). The extract, as its name suggests, was just a snippet, not a full script. The 365 days ago, as explained in 2012, was a simpler script as it did not check dates in each line, it just looked at the dayfile.txt file line 365 lines back from current line.

The very first post has an older version, with screenshot that was just showing off, you can ignore that now.
Last edited by sfws on Sat 06 Oct 2018 3:43 pm, edited 2 times in total.
User avatar
dazza1223
Posts: 860
Joined: Sun 25 Jan 2015 8:41 pm
Weather Station: Davis Vantage Pro 2 plus
Operating System: Raspberry pi 4 (4gb)
Location: Worthing
Contact:

Re: Comparing with one year ago

Post by dazza1223 »

hey there sorry for not geting back to you been busy ok ive setup a test folder on my site to test this out and ive download

aYearAgo_from_Dayfile.js and added it but i can get my head around why it not working if u have a min do you minding taking a look plz



http://www.davisworthing.co.uk/test/yesterday.htm
Have fun and keep learning

dazza :D

https://www.davisworthing.co.uk

Image
sfws
Posts: 1183
Joined: Fri 27 Jul 2012 11:29 am
Weather Station: Chas O, Maplin N96FY, N25FR
Operating System: rPi 3B+ with Buster (full)

Re: Comparing with one year ago

Post by sfws »

A very quick peep (because I am very busy) shows that the javascript (view-source:http://www.davisworthing.co.uk/test/aYe ... Dayfile.js) is looking in your day file (http://www.davisworthing.co.uk/test/dayfile.txt) for a day in 2020 that does not exist yet as a line in that file. So there is a problem in your HTML file (view-source:http://www.davisworthing.co.uk/test/yesterday.htm), it is not picking up today's date correctly at line 188. Have you made an error in the Cumulus template file for producing your HTML?
User avatar
dazza1223
Posts: 860
Joined: Sun 25 Jan 2015 8:41 pm
Weather Station: Davis Vantage Pro 2 plus
Operating System: Raspberry pi 4 (4gb)
Location: Worthing
Contact:

Re: Comparing with one year ago

Post by dazza1223 »

hi um no i just kept every think the same just rename the js file and put the js to the dayfile thank u


i just look

has this got somthink to do with it

var field_delimiter = ","; // edit this to ';' if necessary to match the delimiter between fields in your dayfile.txt
var date_delimiter = "/"; // edit this to include your computer default short date format separator
Have fun and keep learning

dazza :D

https://www.davisworthing.co.uk

Image
Mapantz
Posts: 1775
Joined: Sat 17 Dec 2011 11:55 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 11 x64
Location: Dorset - UK
Contact:

Re: Comparing with one year ago

Post by Mapantz »

Anything to do with Cumulus V1 vs Cumulus V3?
Image
User avatar
dazza1223
Posts: 860
Joined: Sun 25 Jan 2015 8:41 pm
Weather Station: Davis Vantage Pro 2 plus
Operating System: Raspberry pi 4 (4gb)
Location: Worthing
Contact:

Re: Comparing with one year ago

Post by dazza1223 »

Anything to do with Cumulus V1 vs Cumulus V3? I dont know what u mean

im running Cumulus MX

or do u mean what time format im using?
Have fun and keep learning

dazza :D

https://www.davisworthing.co.uk

Image
User avatar
dazza1223
Posts: 860
Joined: Sun 25 Jan 2015 8:41 pm
Weather Station: Davis Vantage Pro 2 plus
Operating System: Raspberry pi 4 (4gb)
Location: Worthing
Contact:

Re: Comparing with one year ago

Post by dazza1223 »

ok i got a bit more done

but

Yesterday's data (from midnight Thursday 3 Jan 2019) One Year ago (from midnight Friday 5 Jan 2018) that rong

and im missing Temperature Range ?
You do not have the required permissions to view the files attached to this post.
Have fun and keep learning

dazza :D

https://www.davisworthing.co.uk

Image
Post Reply