Cross-reference: Enhancement Request 240 (http://sandaysoft.com/forum/tracker.php?p=1&t=240
) and 231 (http://sandaysoft.com/forum/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, and included in the main attachment 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 rozen 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:
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.
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 -->
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 my 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 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
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 need to amend column names, as you may be using a different schema to those I use in my script.
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 [url]http://wiki.sandaysoft.com
/a/Customised_templates#What_to_select_on_the_.27Files.27_tab_of_the_Internet_Settings_screen_within_the_.27Configuration.27_menu[/url] 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.
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.
(This download has the full script
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.
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
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:
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.