Daily Summary: Difference between revisions

From Cumulus Wiki
Jump to navigationJump to search
m
→‎DAILY SUMMARY: paste from another page
m (→‎Some example Scripts: correct one link)
m (→‎DAILY SUMMARY: paste from another page)
This page describes routines that read [[Dayfile.txt]] log file, and display a selected part of its content in a friendly way.
 
==Options for reading dayfile.txt for other uses==
 
*Some people take a copy of the local dayfile.txt, and use it locally for other purposes.
== Introduction ==
* Various third-party routines that make use of the [[dayfile.txt]] file (and in some cases, others) are listed at [[:Category:WebTools]].
# This article updates [[AnnualDataSummary|Annual Data Weather article]] contributed by David Jamieson ([http://kippfordweather.uk current web site]) in March 2011.
** Some people use [[Upload_Dayfile|the method described here]] or [[Toolbox|Cumulus Toolbox]] to get a copy of the local file to use on their web server. (If your web server is local, you can simply copy the file to that server, once a day).
# A working example of the original Annual Weather Data Summary Ver 1.2. November 2012 Script by David Jamieson (PHP variant), is [http://www.fordingbridgeweather.co.uk/datasummary.php here]; note that example uses a different carrier page (see below) from the Weather Blue set of Alternative Templates available from the French only site [http://meteoduquebec.com/ Météo du Québec] and the international site [http://weatherbyyou.com/demo.php <strong>Weather</strong> <small>by</small><sub>You</sub>].
** Search in the Cumulus support forum for examples of third-party JavaScript projects that read the web copy, for example to insert data for one year ago, or to enable extremes for each day in a week to be included in a web page.
# This article is called '''Daily Summary''' as it summarises scripts that various authors have contributed that take as their source daily statistics output from Cumulus
**Dayfile.txt (and other files!) are used as described at the [[:Category:CumulusUtils]] link.
*Other people load the contents of their dayfile.txt into a database table (see sub-section directly below), allowing SQL enquiries to efficiently display, or summarise, the contents of the file.
**Cumulus MX provides optional functionality to create a database table, and to automatically insert a new row each time a new line is added to the local '''dayfile.txt''' file.
 
=== Populating a database table ===
 
*[[File:Badge v1.png]] The [[ImportCumulusFile]] page describes a method that can be used with Cumulus 1 to mimic the contents of dayfile.txt in a database table. However, be aware that the later versions of that script have been edited for MX, so you will need to use an older version of that script that matches the version of Cumulus 1 you are using.
*[[File:Badge vMx.png]] Please see [[MX_Administrative_Interface#Standard_Daily_Summary_Table]] section for details of how '''CumulusMX.exe''' has an optional feature with a standard option to insert a new row into a database table holding columns relating to the dayfile.txt fields.
** Either (for all early MX releases) '''ExportMySql.exe''', or (for all later MX releases) '''ExportToMySQL.exe''' (see [[Software#ExportToMySQL]]), can update the database table with past rows.
 
=== Using a database table ===
 
Your web site can use the database table, created as described in last sub-section, for a range of queries (from simple to complicated) written in SQL, and sometimes queries are discussed in the support forum.
 
For examples of some of the third party tools (Cumulus [[Category:User_Contributions|user contributions]]) using the database daily summary table described above, see [[#Some_example_Scripts|here]].
 
====Just another example of how much you can get from just one (daily summary) log file====
 
I have a number of web pages, based on the "this month" web page supplied with Cumulus. Thus I can look at this month, see several consecutive months, compare any month with any other month, and so on. I also have display just key values, all the values supported by monthly web tags, or even all the extra derivatives I can derive from examining daily summary data for any month.
 
To give me that versatility, with the minimum data transfers between Cumulus and my database/web servers, all the fields I might want to display are calculated after a month ends (and on a number of days during the month) by calling a script that stores these calculated values as columns in another database table that has one row for each month.
 
==== Alternative schemas ====
 
Of course, the schema in your database table does not need to exactly mimic the fields in the dayfile.txt file.
* Perhaps you do not use all of the fields; your weather station may not produce solar values so those fields in dayfile.txt need not be columns in your database table
* Perhaps you want columns representing values from external sensors or other log files.
 
Alternatively, you might feel that you want to validate all the fields read from the daily summary file, before writing them to your database table to ensure your database only contains good quality data. Equally, to simplify querying your database table, you might want missing data to be stored as real nulls in the database columns, rather than the "zero" or "space" or empty character string, that Cumulus uses in its inconsistent way. That way you don't get any longer period averages skewed by the invalid zeroes.
 
To implement those changes, you need a little knowledge about Structured Query Language, and you may need to write your own script (possibly based on the script in [[ImportCumulusFile]].
 
*[[File:Badge vMx.png]] MX makes this implementation slightly easier for you. If you are able to create the database table with the columns you want, then you can input the SQL for updating the table directly into MX quoting web tags for the necessary data, and Cumulus can automatically trigger this as part of its end of day routine
*[[File:Badge v1.png]] In the legacy Cumulus 1 software, there is no built in way to create or update database tables.
 
== Third-party contributions ==
 
# This articlepage updateswas inspired by the [[AnnualDataSummary|Annual Data WeatherSummary articlepage]] contributed by David Jamieson ([http://kippfordweather.uk current web site]) in March 2011.
# A working example of the original Annual Weather Data Summary Ver 1.2. November 2012 Script by David Jamieson (PHP variant), is [http://www.fordingbridgeweather.co.uk/datasummary.php here]
#* A working example of the original Annual Weather Data Summary Ver 1.2. November 2012 Script by David Jamieson (PHP variant), is [http://www.fordingbridgeweather.co.uk/datasummary.php here]; note that example uses a different carrier page (see below) fromis the Weather Blue set of Alternative Templates available from the French only site [http://meteoduquebec.com/ Météo du Québec] and the international site [http://weatherbyyou.com/demo.php <strong>Weather</strong> <small>by</small><sub>You</sub>].
# This articlepage is called '''Daily Summary''' as it summarises scripts that various authors have contributed that take as their source daily statistics output from Cumulus
#* Typically these scripts allow the maximum, minimum, average, or total of a statistic calculated for an individual day to be seen in a table that shows such values for many days often spanning at least one year.
# The scripts mentioned below range quite widely:
 
== Update of David Jamieson PHP script by BCJKiwi ==
 
Here is a revised set of files (PHP only) ver 1.2. contributed by BCJKiwi on 17 December 2012 that update David's Ver 1.2 (November 2012) fileset to eliminate errors in validation due to non-standard or deprecated code routines. They also include a couple of updates from DAJ version as advised by posts in the Forum.
 
=== Errors rectified by this version ===
 
*Non-standard attributes 'datacol' and 'datarow' are generated by the original javascript and php routines that will not pass validation against standards (in HTML5 these can be made to validate by changing to 'data-col' and 'data-row').
*In version 1.1 of this tool, jQuery version 1.5 is called, this permitted use of '.attr' object to add/remove the highlight; from jQuery version 1.6 that was deprecated and the '.prop' object is now specified for the same purpose.
 
=== Configuration Variables ===
 
By default in 'readDayfile.php':
* Assume the dayfile.txt is read from a subfolder called 'data'.
5,838

edits

Navigation menu