Daily Summary: Difference between revisions

From Cumulus Wiki
Jump to navigationJump to search
2,068 bytes removed ,  9 January 2022
Updated links, changed sequence of material on page
m (→‎DAILY SUMMARY: paste from another page)
(Updated links, changed sequence of material on page)
 
 
= DAILY SUMMARY =
 
[[Category:WebTools]][[Category:User Contributions]]
This page describes routines that read [[Dayfile.txt]] log file, and display a selected part of its content in a friendly way.
 
=Available options=
==Options for reading dayfile.txt for other uses==
 
This page describes routines that either read [[Dayfile.txt]] log file, or run queries against a database table with one row per [[Meteorological day|day]]. The various scripts then display either a selection of the rows, or a selection of the derivatives in a more friendly way that just browsing the file or table. In general, these scripts display some summary information, such as highest/lowest in month/season/year, and some scripts use coloured fonts to group values.
*Some people take a copy of the local dayfile.txt, and use it locally for other purposes.
* Various third-party routines that make use of the [[dayfile.txt]] file (and in some cases, others) are listed at [[:Category:WebTools]].
** 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).
** 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.
**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.
 
There is discussion about many of the available scripts in the Cumulus Support forum section called "Website Development", mostly (but not exclusively) in [https://cumulus.hosiene.co.uk/viewforum.php?f=18 3rd Party Tools sub-forum], and/or [https://cumulus.hosiene.co.uk/viewforum.php?f=14 Web site - general subforum]. Where there is information in this Wiki, links are given in summary below.
=== Populating a database table ===
 
The scripts use various computer languages:
* C# - see [[Yadr]], (a novice might prefer this first choice as it is part of [[:Category:CumulusUtils|a package]], so there is no code to edit)
* jQuery - a number of scripts are available, if you make use of [http://jquery.com/download/ jQuery] including:
** see the [[AnnualDataSummary|Annual Data Summary page]] contributed by David Jamieson ([http://kippfordweather.uk current web site]) in March 2011, (be aware that this requires some user configuration (see towards end of this Wiki page), so some understanding of JavaScript helps, and you need to load jQuery).
** see [https://cumulus.hosiene.co.uk/viewtopic.php?f=18&t=8690 Alternative Javascript/jQuery solution] within the '''3rd party tools''' sub forum of the Cumulus forum. (The advantages are discussed in file within December 2011 package, but essentially this has similar output to previous, but is far easier to customise)
** see [https://cumulus.hosiene.co.uk/viewtopic.php?f=14&t=8631&hilit=one+year+ago#p71709 Comparing with one year ago] written in style of the yesterday web page provided with legacy Cumulus 1.
* PHP - a number of scripts are available (if you use [[Your Own Server]] then you need to install PHP), including:
*# Be aware, some of these scripts only work with the syntax available in the PHP version that was current when the script was written
*# Be aware, scripts may use "include ..." or "require ..." to bring in variables (such as those for accessing the database) or functions (to do standard actions) or templates (shared headers, navigation menus and footers) or text (any other common content) that is used with a number of pages on author's site. If you don't comment out those references to external scripts, or replace the references with your equivalents, the PHP parser may fail to produce a HTML page and nothing will be available to the browser. Thus you do need a simple understanding of PHP, a PHP book, or the ability to look up PHP instructions on the web if you are to be successful with tailoring these scripts to your site.
*# If you find a site displaying a graph or table you would like to copy on your own site, you might be able to see the PHP source that is responsible, but (see [https://cumulus.hosiene.co.uk/viewtopic.php?f=14&t=16425&p=126065#p126065 here]) most authors do not make it easy to see their PHP code. Of course one of the reasons for using PHP script is that processing is done quickly on the web server and only the resulting HTML is passed onto the client browser. This inability to see the PHP code that generates the web page does protect intellectual property and adds security against hacking by not showing the database access code.
** [https://cumulus.hosiene.co.uk/viewtopic.php?f=14&t=11397&start=405#p91488 'Yet Another Dayfile Reader (PHP)'] - Download from here the ultimate PHP parsing dayfile.txt version that has progressed a long way from David's original, it incorporates all the ideas discussed in earlier forum topics, some of the features are: the highlighting makes day of week appear in row headers, you can swap between daily and seasonal views and there is a table summary including averages. See that forum url for links to some of the many sites that have adopted this version, if you do not have a database, but do have PHP, then this is version for you. Mark Crossley has his own offshoot of this script, [https://weather.wilmslowastro.com/datasummary.php?view=getorfmiland data summary], that reads a database table, but uses much of the same script so produces a similar summary.
** [http://saratoga-weather.org/legacy-scripts/dayfile.txt Source: Parse dayfile.txt PHP no database] - This script by the late Kevin Reed who ran the web site TNETweather.com, it is a no frills reader written in PHP (change '.txt' into '.php' when you download it) that parses dayfile.txt and produces an output table with headings. The script can be downloaded on Ken True's site from the link quoted, but see the forum reference [https://cumulus.hosiene.co.uk/viewtopic.php?f=14&t=2419#p20155 Forum: Parse dayfile.txt PHP no database] for the only further information still available.
** [https://cumulus.hosiene.co.uk/viewtopic.php?f=14&t=5319 'Annual Data Summary - Coloured Values'] - An extensively coloured version of David's original script modified by Mark Crossley with some useful discussion on the trade-off between testing values and efficient code here. The source link in that thread no longer works, but (at time of typing this) the source may be found [http://www.komokaweather.com/weather/datasummary-colour2.php?view=sce here on Paul's site].
** [https://cumulus.hosiene.co.uk/viewtopic.php?f=14&t=11133 'Annual data Summary (DAJ script) - show day-of-week'] - This is just one of several places on the forum where further ideas are explored by Mark Crossley and beteljuice.
** [https://cumulus.hosiene.co.uk/viewtopic.php?f=14&t=16891#p130117 'Re: New Script that displays a selected daily statistic for every day'] - In [[#Enhancement of JavaScript script]] above, [[User:Sfws|Sfws]] refers to a pure PHP version that reads data from a database table. That version is now available in the linked paragraph, but using a site specific schema.
** [https://cumulus.hosiene.co.uk/viewtopic.php?f=14&t=16891#p129796 'New Script that displays a selected daily statistic for every day'] - Download from here, in the above topic, the newest (at time of writing) way to display daily statistics. This is the "daily pick" script where you select one criterion and all the daily values available are output, for ease of display there is a separate table for each month with HTML <detail> tags to show/hide. Both this and previous scripts were written for a schema that is different to the David Jamieson/Mark Crossley/Cumulus MX standard, but the daily pick script has both schemas available, comment out the one you don't want and remove comments round the one you do want. See further information in posts in the topic and the topic that it follows on from, at [https://cumulus.hosiene.co.uk/viewtopic.php?f=14&t=16880 MySQL Code Help].
** [https://cumulus.hosiene.co.uk/viewtopic.php?f=14&t=15983 'SQL dayfile data Viewer'] - This is another (widely adopted) PHP script for reading daily values from a database. It displays a number of key statistics, and you can order the results by the contents of any column. Read the forum topic for more information. You can scroll through the days or set a filter to only show certain days. There is a summary line, but because some columns include units, the calculation of the summary for those columns fails. It is quite simple to edit out the units, so all columns show a summary, but most users adopt the script as published and just accept that some summary figures are replaced by text.
**[https://cumulus.hosiene.co.uk/viewtopic.php?p=87081#p87081 Top 10 Records Page]- This script by Mark Crossley runs several queries against the daily summary table of a database and picks various extremes displaying the top ten extremes (e.g. lowest daily temperature).
**[https://cumulus.hosiene.co.uk/viewtopic.php?f=14&t=16534#p126964 What to do with data from MySQL] - This posting lists a number of web pages on PaulMy's website where he presents statistics from the daily summary table of his database in different formats.
** [https://cumulus.hosiene.co.uk/viewtopic.php?f=14&t=8631 Comparing with one year ago] - This post [https://cumulus.hosiene.co.uk/viewtopic.php?f=14&t=7834#p66013 as requested here] has a query in a php file (as you save the download change '.txt' to '.php') that will extract from the daily summary table in a database, values for one year ago, to display alongside for example statistics for yesterday. An equivalent script using jQuery to read dayfile.txt directly was listed earlier. If you have some programming skills, you can vary either of these scripts to for example display statistics for each day in the last week (or month). I have written scripts that display the statistics for last week using a combination of this daily table in database approach and Cumulus recent tags. I have another script that uses the daily table in the database to calculate the equivalent of what Cumulus 1 shows in View menu, this month selection, for any past month and adds the equivalent of what Cumulus this month web tags show and the resulting statistics are shown for various selectable mixtures of past months.
 
== Graphical output from dayfile.txt ==
 
 
There are '''various scripts out there that output graphs''' from the values in recent history web tags, or values read off either a daily table in a database or dayfile.txt directly. There are two to highlight here:
* An alternative to the Cumulus 1 or Cumulus MX trend web page is described in [https://cumulus.hosiene.co.uk/viewtopic.php?f=18&t=12321 this topic] this can use all the sources mentioned.
* Highcharts (that cannot be used on a business website) are exploited by Mark Crossley in [https://cumulus.hosiene.co.uk/viewtopic.php?f=18&t=8672 this topic]; it is a very long topic, and discusses various issues to consider with using such data, as well as including the script. Cumulus MX now implements this both in its interface pages and its default web pages.
 
 
== Another approach using a combination of PHP and jQuery ==
 
''Unsure who supplied this approach, need to do a forum search''
 
# extract all the values off the daily summary table with a simple "SELECT * FROM name_of_your_table" query
# store those values in XML format using a PHP script called 'read_dayfile_historic.php' ''(needs a reference to say where get this)''
# use a jQuery library routine to produce a table of values using JavaScript:
<pre>
<script src="jquery.jqGrid.min.js" type="text/javascript"></script>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery("#list").jqGrid({
url:'read_dayfile_historic.php',
datatype: 'xml',
height: 460,
width: 970,
mtype: 'GET',
colNames:['Date','Highest<br/>Gust<br/>(mph)','Wind<br/>Bearing','Time of<br/>Gust','Min. Temp<br/>(&deg;C)','Time of<br/>Min.','Max. Temp<br/>(&deg;C)','Time of<br/>Max.','Avg. Temp<br/>(&deg;C)','Lowest<br/>pressure<br/>(mb)','Time of<br/>low','Highest<br/>pressure<br/>(mb)','Time of<br/>high','Highest<br/>Rain rate<br/>(mm/hr)','Time of<br/>High Rate','Total Rain<br/>fall (mm)','Tot.Wind<br/>run'],
colModel :[
{name:'UKLogDate', index:'LogDate', width:65, label: 'Date', sortable: true},
{name:'HighestWindGust', index:'HighWindGust', width:50, align:'right'},
{name:'HWindGBear', index:'HWindGBear', width:50, align:'right'},
{name:'THWindG', index:'THWindG', width:55, align:'right', sortable: false},
{name:'MinTemp', index:'MinTemp', width:55, align:'right'},
{name:'TMinTemp', index:'TMinTemp', width:55, align:'right', sortable: false},
{name:'MaxTemp', index:'MaxTemp', width:60, align:'right'},
{name:'TMaxTemp', index:'TMaxTemp', width:55, align:'right', sortable: false},
{name:'AvgTemp', index:'AvgTemp', width:57, align:'right'},
{name:'MinPress', index:'MinPress', width:60, align:'right'},
{name:'TMinPress', index:'TMinPress', width:50, align:'right', sortable: false},
{name:'MaxPress', index:'MaxPress', width:60, align:'right'},
{name:'TMaxPress', index:'TMaxPress', width:50, align:'right', sortable: false},
{name:'MaxRainRate', index:'MaxRainRate', width:55, align:'right'},
{name:'TMaxRR', index:'TMaxRR', width:60, align:'right', sortable: false},
{name:'TotRainFall', index:'TotRainFall', width:55, align:'right'},
{name:'TotWindRun', index:'TotWindRun', width:55, align:'right'}],
pager:'#pager',
rowNum:19,
rowList:[10,20,30],
viewrecords: true,
sortname: "LogDate",
sortorder: "desc",
caption: 'Daily Statistics'
});
});
</script>
</pre>
The above code uses jQuery to output a table showing all the statistics from the database, note that any column containing values can be clicked upon and the table will be resorted by those values, but any column containing time-stamps has the sorting set to false, so you cannot pick them. The selection of column names used above are from the schema created by David Jamieson, as used by Cumulus MX.
 
==Developing your own script?==
 
If you have the technical computer script language knowledge to write your own script for reading "dayfile.txt", then you do need some understanding of how Steve Loft developed that file. The forum post [https://cumulus.hosiene.co.uk/viewtopic.php?f=18&t=2367 a PHP script to read the contents of the dayfile.txt] is a good starting point, it is about the development of [[ImportCumulusFile]].
 
That post explains the date delimiter, how a Comma Separated Variable file may use other punctuation to separate the fields, how to specify the location of your dayfile.txt log to the script and the reason the key variable is used.
 
The thread contains several insights into how Cumulus was developed and it is useful to read Steve's posts in that thread if you are developing your own scripts.
 
If, having developed a script, you want to share it with others, publish it on the Cumulus Support Forum in the '''Web general''' sub forum. However, be prepared to deal with ongoing support, writing a script that will work out of the box for other people is impossible, there are so many ways that people set up their website. For example if your script accesses a database, be aware that not everyone has the same approach to missing data. Decide whether your script will only work with perfect data, whether you need to treat zeroes as missing data, or whether your script expects missing data to have "Null" in the relevant column. As MX is developed and supports a greater variety of sensors, you cannot assume that everybody uses the column names invented by David Jamieson and used by Cumulus MX, some people may want their database table to use daily derivatives that do not come from a field in dayfile.txt, a few might want to implement a more consistent way of naming columns. If your script uses jQuery, or PHP, be aware that the versions you have done your development on may not match the versions used by other people. Generally anything written in just HTML and JavaScript (despite evolving ECMA 262 standard) will be portable, everyone now uses HTML 5, CSS 3, and even Microsoft browsers use JavaScript, not their own jSCript (used by early Internet Explorer versions).
 
 
At the end of this Wiki page are several sections dealing with issues found with the earliest script that was developed, even the original author ditched that script, and adopted one written by another author. That said the example sites section shows that at least one site is still using that script, at a later version.
 
==Key differences between the legacy Cumulus 1 and MX==
 
Cumulus 1 only reads "dayfile.txt" when you choose to display a period, or edit the file. MX reads the entire file when it starts and uses the file for various charting operations including [[Highcharts - Historic|history chart drawing]]. Thus with MX it is more important to take a copy of the file once a day and use that copy for all the scripts discussed on this Wiki page.
 
MX has (optional) functionality to create/update a database table, that by default uses columns that are all derived from fields in dayfile.txt; if you choose the defaults for this table creation then another option will update the table if you use the editor on dayfile.txt. (You can choose to give the table a different name or different columns, MX provides Custom options to automatically upload (insert rows,replace rows, update particular columns) at various time intervals for a table with different columns, but it won't do this when you edit the file if either table name or table columns have changed).
 
Cumulus 1 does not include any functionality for creating/updating a database table to hold daily summarised data. You will find below various suggestions about how to get a copy of your file to your web server, and how to update a daily based table on your database server
 
 
=Example sites=
 
Do be aware that references to external sites either in the Wiki or the Forum may quote links that no longer work, the destination site might have closed down, changed its name, or just eliminated its past content in a revamp.
 
If you do want access to a script, or demonstration, that you can no longer find, post in the forum as it might still exist in an archive somewhere, or another Cumulus user may have a copy to share with you.
 
== Third-party contributions ==
 
Here are some URLs where some of the scripts in the list earlier can be viewed.
 
# This Wiki page was inspired by the David Jamieson (DAJ) code. Its problems are discussed later on this Wiki page, and nobody uses it now.
# An improved version of that was developed by BCJKiwi, and a working example of that Annual Weather Data Summary Ver 1.2. November 2012 Script (PHP script) can still be found [http://www.fordingbridgeweather.co.uk/datasummary.php here]
#* A different carrier page (see below) is 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>]. The link that used to be here for a daily summary page has been removed as that site no longer uses it.
# David's site https://www.fordingbridgeweather.co.uk/datasummary.php, now uses an improved version of the 'SQL dayfile data Viewer' script .
# There are many websites using a derivative of the YADR developed by beteljuice, including https://weather.wilmslowastro.com/datasummary.php and by selecting Reports, then YADR at https://meteo-wagenborgen.nl
 
''Please update or add to these links if you find other exampless.''
 
 
 
 
=Getting a copy of dayfile.txt onto web server=
 
If you are using Cumulus MX, the "Extra Web Files" settings page allows you to copy or file transfer at end of day. Set the local file to "data/dayfile.txt" (or if using Microsoft operating system "data\dayfile.txt"), remote file to destination, tick EOD column.
 
If you are using legacy Cumulus 1, 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).
 
 
 
= 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]]
*[[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.
** '''CumulusMX.exe''' has an optional feature with a standard option to insert a new row into a database table at end of each day - see [[MX_Administrative_Interface#Standard_Daily_Summary_Table]] section for details of how 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.
** '''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.
 
=Technical information=
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]].
 
== Displaying daily statistics from dayfile.txt ==
====Just another example of how much you can get from just one (daily summary) log file====
 
If you choose a script that parses a copy of the [[Dayfile.txt]], then the script you choose might require some customisation:
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 define where the file is to be found,
* to define what character separates fields in the file, it does not have to be [[:Category:Files with Comma Separated Values|Comma Separated Values]]
* to define what character separates the day of month from month and from year
 
Some scripts might work out at least some of these from examining the file.
 
 
== Displaying daily statistics from a database table ==
 
Cumulus MX has a standard name and standard set of columns it uses for the database table with one row for each day. If you have accepted these defaults, skip the next section, as it is likely that you are using a routine that knows the defaults and does not need any customisation for running against your database server.
 
If you use Cumulus 1, or you have created a database table with a different table name or with columns that suit you, then it is likely you have some database knowledge and skills, but the next section goes into some technical detail that might help you, although novices might want to skip it!
 
=== Schema ===
 
# The retrieval script needs to have the following defined for it to use (it is suggested that these variables are defined in a separate PHP script that is in a directory that the PHP parser can access, but is not in the part of the web server that is visible to a client):
#* The server host name, or w.x.y.z format Internet Protocol (=IP) address, running your MySQL database
#* The user name used to log-in to your database server
#* The password used to log-in to your database server
#** (It is good practice to have separate authentication for users with privileges of read only access, and for users with privileges of read and update access, alternatively use an additional key variable as David does in his update script described below)
#* The name of the (MySQL or whatever) database with the table
#* The name for the daily summary table
# The retrieval script needs to know the names of the columns it is to read from the database.
#* Database designers talk about the ''schema'' meaning the specification that describes the design of the table.
#* A schema lists the column names together with what type and size of variables they hold.
#* For the daily summary database table, the columns can copy the fields in the [[dayfile.txt|daily summary log file]], and this is what David Jamieson does in his approach [https://cumulus.hosiene.co.uk/viewtopic.php?f=18&t=2367 a PHP script to read the contents of the dayfile.txt] where the columns are generated in the same order as the corresponding fields in the log file, so David's script uses the field numbers to identify the columns by Position (rather than by Column Name).
#* Remember that while the fields in the log appear in the order that statistic was added during Cumulus 1 development, in theory the columns can appear in any order (if all your scripts identify the columns by name rather than position) so columns associated with rain (these are separated in dayfile.txt fields 12, 13, 14, 31, and 32) can appear together, as can those for wind (these are dispersed in dayfile.txt fields 1, 2, 3, 16, 17, 18, and 39).
# If you have the skills to write your own script, then you might want to consider a different schema, daily information is in three log files for Cumulus 1, "dayfile.txt" should have the statistics for all completed days (that excludes today), "today.ini" has values for today-so-far, and the [[Weather Diary]] where snow records (and general weather text) can be manually recorded. A schema that combines information extracted from those three files to show everything the legacy Cumulus has for a day is available in [https://cumulus.hosiene.co.uk/viewtopic.php?f=14&t=16880#p129719 this forum post].
 
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 externalextra sensors or other log files.
* Functionality is included in Cumulus MX to handle your own schema (your choice of columns); for full details of the functionality see [https://cumulus.hosiene.co.uk/viewtopic.php?f=27&t=12908&start=15#p107639 Cumulus MX Announcements - PLEASE READ THESE!].
 
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.
 
===Validation===
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]].
 
The standard functionality in MX, and that described in [[ImportCumulusFile]], assume that your data within Cumulus is perfect, you never have rogue values, nor do you have any missing data, and that you are using a weather station that has all the sensors to populate all the fields in dayfile.txt.
*[[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.
 
Thus your database table gets an exact copy of what numbers were found for all values and time-stamps in the logging file. Each of your scripts driving web pages for viewing data from your database table needs to include some validation to ensure that what is shown makes sense.
== Third-party contributions ==
 
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 or even sometimes 99.99 or -99, that Cumulus MX uses in its inconsistent way. That way you don't get any longer period averages skewed by the invalid numbers.
# This page was inspired by the [[AnnualDataSummary|Annual Data Summary page]] 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 different carrier page (see below) is 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 page 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:
* Some are direct descendants of David Jamieson's original idea, in that they read the ''[[dayfile.txt|daily summary]]'' log file that Cumulus creates, and produce an output that looks like a calendar with months heading the columns and one row per day of the month while the internal content shows how a selected statistic varies from one day to another
** Others are variants in that the columns might represent years, or you may be able to scroll the columns so although they are months, they don't have to start with January.
** Some use purely HTML, CSS, and JavaScript (although they use a JavaScript library called '''[http://jquery.com/download/ jQuery]''')
** Others add some PHP Hypertext Preprocessor ('''[http://php.net/ PHP]''') script so that some of the work is done on the web server before the HTML page reaches the browser
**I have included cross-references to various forum threads that explore variations to the original idea by adding enhancements such as colour shading, day naming (e.g. 'Wednesday'), seasonal summaries, or in some other way offer a different look, but are still generally based on reading the log file.
 
To implement those changes, you need a little knowledge about Structured Query Language, and you will need to write your own script (possibly based on the script in [[ImportCumulusFile]], that validates what it reads from each field, and stores 'NULL' for any unacceptable content. Having ensured your database table only has good data, all your retrieval queries can much more easily ensure that you don't get what is shown on your web pages skewed by invalid data.
 
* However, there are also scripts that are written in PHP and either read the dayfile.txt or use database queries (typically '''[https://dev.mysql.com/doc/ MySQL]''') to retrieve the required statistics from a database Table containing these statistics with one table row for each day
*# The output from these scripts can be a calendar type table, similar to David's concept, that only shows a single weather criterion
*# The output can be a subset of the database table, in that a number of selected database columns are shown, and there is one row for each day
*# The output can be for a single criterion, and for each day of the month (or year), figures shown for every year available; this allows instant comparison between the same day in all years
 
 
Finally do be aware that references to external sites either in the Wiki or the Forum may use links that no longer work, the destination site might have closed down, changed its name, or just eliminated its past content in a revamp. If you do want access to a script, or demonstration, that you can no longer find, post in the forum as it might still exist in an archive somewhere, or another Cumulus user may have a copy to share with you.
 
== 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.
*Version 1.0 and 1.1 default to showing a table for viewer's local current calendar year. Remember the dayfile.txt (even if updated each day) only contains records up to the day ending at the last rollover time using the timezone local to the weather station. Timezone differences when combined with rollover time variations can lead to a period of 2 days discrepancy. At New Year a blank table will be displayed during this period by default. For example, 30 or 31 (depending on whether rollover has occured) in December of the last year could be the latest available for a site in USA whilst the original version of the code is showing a blank table of the next year during early morning on 2 January in Austrailia. Even when station and viewer are in same timezone, there will be a blank table until the first rollover on 2 January.
*Version 1.2 defaults to showing the year found in the last row of dayfile.txt.
*The final field on each row is not read correctly, because the row break has been specified wrongly for a Microsoft Windows environment, it should quote '''fdata.split("\r\n");''' i.e. ''defines that carriage return then line feed (newline) used to split daily observations in dayfile''. Because the script presented here only processes a small number of fields from earlier in the row, this error does not affect the output for the published code.
* See more background in forum thread [https://cumulus.hosiene.co.uk/viewtopic.php?f=18&t=8600 AnnualDataSummary PHP].
 
=The Inspiring Script=
=== Configuration Variables ===
 
The rest of this Wiki page can be skipped, unless you have a thirst for knowledge about the development of early scripts for processing this daily information. The text is retained purely as historic record, but if you are developing your own script you might want to understand what problems were hit earlier. For PHP scripts a lot of the issues faced by authors of scripts derive from the way that new releases of PHP add new features and deprecate others, this leads to better functionality but it can stop old scripts working!
By default in 'readDayfile.php':
* Assume the dayfile.txt is read from a subfolder called 'data'.
** Look for the line 'dayfile='/data/dayfile.txt';' around line 15 and change this to point to your dayfile.txt on your webserver.
:for ''PHP'' version the path should start from the / (root)
 
* Assume the date format in the dayfile is ''dd/mm/yy''
** You may need to edit the file if you do not use '/' between the parts of the date (the month is always in the middle for all Cumulus log files), look in file for ''date_delimiter''' - the symbol separating your date format. See [[setup]].
* Assume the data in the dayfile is separated with a ''comma''
** Look for the line mentioning '''field_delimiter''' - the symbol separating each of your fields in the dayfile.txt. For most people this is a '''comma''' but (if you use comma to separate integer and decimal parts of real numbers) it could be a semi-colon (''';''') or other symbol.
 
== Issues with DAJ script ==
 
The technical issues and the usability issues below, have been addressed by BCJKiwi's replacement script, by the SFWS alternative script, and by the beteljuice "Yet Another Dayfile Reader".
=== Localization / Language ===
The script has been designed to be easily translated to your language of choice.
 
 
As in '''[[#Instructions|Instructions below]]''', edit the readDayfile.php
The following sections describe how DAJ's script made configuration complex.
 
=== Localisation / Language in DAJ script ===
 
DAJ claimed that his script had been designed to be easily translated to your language of choice.
 
Just edit the readDayfile.php
 
*variable '''mn''' is a list of the 12 months of the year, in an abbreviated format. You may change these as necessary, but try to keep it to an abbreviation as there is limited space.
*The first element, in this case 'maxtemp' -- is a system variable to identify the data set, used for the URL parameter option, used by the ''Switch'' coding (so any change here needs to be reflected there), and also tested elsewhere in the code (in the Rainfall and Windgust data sets a particular style is applied to their zero values).
 
=== Adding/removing data sets in DAJ script ===
However, if you add a new data set, then your new first element should be a unique identifier.
 
If you add a new data set, then your new first element should be a unique identifier.
*Second, '''Max Temp''' is the text to be displayed in the ''button'' at the top of the table. You may change this to your own language
 
*Third, '''Maximum Temperature''' is the text shown at the top of the table to ''describe the current data set''; again you may change this
*Finally, 'true' will display this button at the top; 'false' will hide it. Therefore, if you do not wish to allow users to jump to the 'Rainfall data set' change the 'true' to 'false' in the 'rainfall' element of the variable. (true/false MUST be lowercase)
 
<span style="color: red">NOTE: [[User:Sfws|Sfws]] 12:22, 31 December 2012 (UTC)</span>
 
<span style="color: red">Having made any change to the array as DAJ says above, you also need to change what is in a '''switch''' section and you will find that is below where DAJ says '// Nothing to edit below here'.</span>
 
 
 
=== Instructions ===
== Update of DAJ PHP script by BCJKiwi ==
The instructions in [[AnnualDataSummary| David's original]] article for PHP version still apply, so these are repeated below in a simplified manner. The files in the zip include additional notes, and explanations on the changes made in the update, where relevant.
 
There 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. The text that follows describes issues with David's script, and how they were rectified by Brian's script
 
See [[AnnualDataSummary]] page.
 
 
=== Configuration Variables ===
 
One issue with early scripts was that the user had to edit the files in the package to configure the script to work in their installation, here are details of the sort of issues end users had with the assumptions in those scripts.
 
By default in 'readDayfile.php':
* Assume the dayfile.txt is read from a subfolder called 'data'.
** Look for the line 'dayfile='/data/dayfile.txt';' around line 15 and change this to point to your dayfile.txt on your webserver.
:for ''PHP'' version the path should start from the / (root)
 
* Assume the date format in the dayfile is ''dd/mm/yy''
** You may need to edit the file if you do not use '/' between the parts of the date (the month is always in the middle for all Cumulus log files), look in file for ''date_delimiter''' - the symbol separating your date format. See [[setup]].
* Assume the data in the dayfile is separated with a ''comma''
** Look for the line mentioning '''field_delimiter''' - the symbol separating each of your fields in the dayfile.txt. For most people this is a '''comma''' but (if you use comma to separate integer and decimal parts of real numbers) it could be a semi-colon (''';''') or other symbol.
 
 
=== Errors rectified by Brian's 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 David's script, jQuery version 1.5 is called, this permitted use of '.attr' object to add/remove the highlight;
** this will not work for later jQuery version 1.6 asuse of that object was deprecated and the '.prop' object is now specified for the same purpose.
*Version 1.0 and 1.1 of David's script default to showing a table for viewer's local current calendar year. Remember the dayfile.txt (even if updated each day) only contains records up to the day ending at the last rollover time using the timezone local to the weather station. Timezone differences when combined with rollover time variations can lead to a period of 2 days discrepancy. At New Year a blank table will be displayed during this period by default. For example, 30 or 31 (depending on whether rollover has occurred) in December of the last year could be the latest available for a site in USA whilst the original version of the code is showing a blank table of the next year during early morning on 2 January in Australia. Even when station and viewer are in same timezone, there will be a blank table until the first rollover on 2 January.
*Version 1.2 of David's script defaults to showing the year found in the last row of dayfile.txt.
*The final field on each row is not read correctly, because the row break has been specified wrongly for a Microsoft Windows environment, it should quote '''fdata.split("\r\n");''' i.e. ''defines that carriage return then line feed (newline) used to split daily observations in dayfile''. Because the script presented here only processes a small number of fields from earlier in the row, this error does not affect the output for the published code.
* See more background in forum thread [https://cumulus.hosiene.co.uk/viewtopic.php?f=18&t=8600 AnnualDataSummary PHP].
 
 
=== Instructions for using any of these scripts ===
 
The instructions on [[AnnualDataSummary| David's original]] Wiki page for PHP version still apply to most subsequent alternatives, so these are repeated below in a simplified manner. The files in the zip include additional notes, and explanations on the changes made in the update, where relevant.
 
*Download the following zip file...[https://cumuluswiki.org/files/AnnualDataSummary_12.zip AnnualDataSummary_12.zip], the zip contains 3 files:
 
=== Usage ===
 
* Open ''datasummary.php'' from your website in a browser
 
 
=== Opening a specific data set when the page is first loaded ===
 
By default (in the original version) the table created will show the available daily values of the ''maximum temperature'' for the current ''local calendar year'', however you can start with any data set and any year (assuming you have those values in the dayfile.txt) by ''adding a 'Query String' to the end of your URL'' in the browser.
 
 
=== Creating your own Carrier Page ===
 
To create your own page, follow another page you are using successfully on your site and modify it by removing any content from &lt;body&gt; section you don't want and including in the &lt;head&gt; section:
* the CSS styling:
 
=== Styling ===
 
The table styling is completely configurable using the included [[Stylesheet|Cascading Style Sheet]] datasummary.css. By default it is using similar colours to the standard Cumulus website. Below are a few of the key entries to consider when adjusting settings (typically colouring)... Also see [https://cumulus.hosiene.co.uk/viewtopic.php?f=14&t=5319 support forum thread about colouring with php]
 
 
 
== Enhancement of JavaScript script ==
This section was originated by [[User:Sfws|Sfws]] to mention script originated 24 Nov 2012
Update of text here 00:53, 18 May 2013 (PDT)
Finalised version of script in forum 7:08 am 15 Jan 2014, minor update 8:51 pm 15 Nov 2014
Find my package in [https://cumulus.hosiene.co.uk/viewtopic.php?f=18&t=8690 alternative Javascript/jQuery solution] within the '''3rd party tools''' sub forum of the Cumulus forum.
 
I originally created the alternative Javascript version in December 2011 by editing the DAJ original (with similar aims to BCJKiwi with his PHP version 1.2) to offer easier customisation plus standards compliance, i.e. addressing all the issues [[AnnualDataSummary#Possible_problems|with David's version]]. If you don't use PHP, this is the script you should install, and you will find various threads on the forum about it in the Web site - General sub-forum as well as posts in the thread containing the source.
 
<span style="color: red">It really is much easier to add new data sets if you use this alternative JavaScript version in the forum. That includes more explanation about the original coding, and an alternative simpler way to specify and adjust the columns in a revised version of the array specified for the PHP version above.</span>
 
The advantages of my script are fully described in a file within the package. They include standards compliance, better integration with standard Cumulus pages, statistical additions to the bottom of each month's column, and easier tailoring to your preferences on wording, language, and text colouring. During 2012-2013, my alternative JavaScript version was rewritten from scratch (losing the original DAJ code), a number of additional features were added, whilst attempting to preserve ease of customisation to suit any requirements you have e.g. on the language and level of diagnostics output. One new feature is ability to scroll sideways, so calendar look can start with any month (any year) but always with 12 columns showing month headings.
 
One site using in January 2013 a variant based on an early version of my Javascript/jQuery alternative code, with its own look to the page, is [http://sassafras.id.au/projects/weather/dailyrecords.shtml found here]. Whilst a number of other people have tried later versions of this alternative code, and you can see some commenting in the forum thread, remember this was designed for easy tailoring, so is not an off the shelf package.
 
At the end of 2014, I rewrote this again, by adding use of PHP script for some of the actions previously done by JavaScript, retaining JavaScript for handling the selection of a change of criterion, and for handling the change of months to be shown (either by scrolling one month at a time or by picking one of the predefined periods on buttons). The resulting script was to prove very useful to me, but with the mix of languages (and the way it was developed) I found it was not easy to understand and hard to improve so I abandoned any idea of a version to share. However, I decided to rewrite that PHP version making it simpler by totally eliminating JavaScript, although given how many PHP versions existed (see below), mine was not shared.
 
== Variants of the original Daily Summary discussed in the support forum ==
 
Many of the forum discussions are in the sub-forum: '''Cumulus &gt; Cumulus 1 &gt; 3rd Party Tools''', but there are a few in the sub-forum:
''Website Development &gt; Web site - General''. So you really need to search through both for all available information as it is spread through hundreds of topics. I highlight just the most useful threads below.
 
=== Using JavaScript ===
As well as the alternative JavaScript version above, SFWS produced a few other scripts that were developed from David's original script including [https://cumulus.hosiene.co.uk/viewtopic.php?f=14&t=8631&hilit=one+year+ago#p71709 Comparing with one year ago], a script that allowed you to compare statistics from yesterday (in Cumulus' yesterdayT.htm style) with those from a year earlier (or any other past date). The forum thread includes feedback and consequent changes.
 
=== PHP scripts ===
'''IMPORTANT''' - ''Be aware if you use PHP scripts written by someone else .... These scripts may use "include ..." or "require ..." to bring in variables (such as those for accessing the database) or functions (to do standard actions) or templates (shared headers, navigation menus and footers) or text (any other common content) that is used with a number of pages on author's site. If you don't comment out those references to external scripts, or replace the references with your equivalents, the PHP parser may fail to produce a HTML page and nothing will be available to the browser. Thus you do need a simple understanding of PHP, a PHP book, or the ability to look up PHP instructions on the web if you are to be successful with tailoring these scripts to your site.''
 
Most of these are found in the Website Development section of the Cumulus support forum - '''Web general''' sub forum:
* [http://saratoga-weather.org/legacy-scripts/dayfile.txt Source: Parse dayfile.txt PHP no database] - This script by the late Kevin Reed who ran the web site TNETweather.com, it is a no frills reader written in PHP (change '.txt' into '.php' when you download it) that parses dayfile.txt and produces an output table with headings. The script can be downloaded on Ken True's site from the link quoted, but see the forum reference [https://cumulus.hosiene.co.uk/viewtopic.php?f=14&t=2419#p20155 Forum: Parse dayfile.txt PHP no database] for the only further information still available.
*[https://cumulus.hosiene.co.uk/viewtopic.php?f=14&t=5319 'Annual Data Summary - Coloured Values'] - An extensively coloured version of David's original script modified by Mark Crossley with some useful discussion on the trade-off between testing values and efficient code here. The source link in that thread no longer works, but (at time of typing this) the source may be found [http://www.komokaweather.com/weather/datasummary-colour2.php?view=sce here on Paul's site].
*[https://cumulus.hosiene.co.uk/viewtopic.php?f=14&t=11133 'Annual data Summary (DAJ script) - show day-of-week'] - This is just one of several places on the forum where further ideas are explored by Mark Crossley and beteljuice.
*[https://cumulus.hosiene.co.uk/viewtopic.php?f=14&t=11397&start=405#p91488 'Yet Another Dayfile Reader (PHP)'] - Download from here the ultimate PHP parsing dayfile.txt version that has progressed a long way from David's original, it incorporates all the ideas discussed in earlier forum topics, some of the features are: the highlighting makes day of week appear in row headers, you can swap between daily and seasonal views and there is a table summary including averages. See that forum url for links to some of the many sites that have adopted this version, if you do not have a database, but do have PHP, then this is version for you. Mark Crossley has his own offshoot of this script, [https://weather.wilmslowastro.com/datasummary.php?view=getorfmiland data summary], that reads a database table, but uses much of the same script so produces a similar summary.
* [https://cumulus.hosiene.co.uk/viewtopic.php?f=14&t=16891#p130117 'Re: New Script that displays a selected daily statistic for every day'] - In [[#Enhancement of JavaScript script]] above, [[User:Sfws|Sfws]] refers to a pure PHP version that reads data from a database table. That version is now available in the linked paragraph, but using a site specific schema.
* [https://cumulus.hosiene.co.uk/viewtopic.php?f=14&t=16891#p129796 'New Script that displays a selected daily statistic for every day'] - Download from here, in the above topic, the newest (at time of writing) way to display daily statistics. This is the "daily pick" script where you select one criterion and all the daily values available are output, for ease of display there is a separate table for each month with HTML &lt;detail&gt; tags to show/hide. Both this and previous scripts were written for a schema that is different to the David Jamieson/Mark Crossley/Cumulus MX standard, but the daily pick script has both schemas available, comment out the one you don't want and remove comments round the one you do want. See further information in posts in the topic and the topic that it follows on from, at [https://cumulus.hosiene.co.uk/viewtopic.php?f=14&t=16880 MySQL Code Help].
*[https://cumulus.hosiene.co.uk/viewtopic.php?f=14&t=15983 'SQL dayfile data Viewer'] - This is another (widely adopted) PHP script for reading daily values from a database. It displays a number of key statistics, and you can order the results by the contents of any column. Read the forum topic for more information. You can scroll through the days or set a filter to only show certain days. There is a summary line, but because some columns include units, the calculation of the summary for those columns fails. It is quite simple to edit out the units, so all columns show a summary, but most users adopt the script as published and just accept that some summary figures are replaced by text.
 
== Displaying daily statistics from a database table ==
=== Schema ===
 
# The retrieval script needs to have the following defined for it to use (it is suggested that these variables are defined in a separate PHP script that is in a directory that the PHP parser can access, but is not in the part of the web server that is visible to a client):
#* The server host name, or w.x.y.z format Internet Protocol (=IP) address, running your MySQL database
#* The user name used to log-in to your database server
#* The password used to log-in to your database server
#** (It is good practice to have separate authentication for users with privileges of read only access, and for users with privileges of read and update access, alternatively use an additional key variable as David does in his update script described below)
#* The name of the (MySQL or whatever) database with the table
#* The name for the daily summary table
# The retrieval script needs to know the names of the columns it is to read from the database.
#* Database designers talk about the ''schema'' meaning the specification that describes the design of the table.
#* A schema lists the column names together with what type and size of variables they hold.
#* For the daily summary database table, the columns can copy the fields in the [[dayfile.txt|daily summary log file]], and this is what David Jamieson does in his approach [https://cumulus.hosiene.co.uk/viewtopic.php?f=18&t=2367 a PHP script to read the contents of the dayfile.txt] where the columns are generated in the same order as the corresponding fields in the log file, so David's script uses the field numbers to identify the columns by Position (rather than by Column Name).
#* Remember that while the fields in the log appear in the order that statistic was added during Cumulus 1 development, in theory the columns can appear in any order (if all your scripts identify the columns by name rather than position) so columns associated with rain (these are separated in dayfile.txt fields 12, 13, 14, 31, and 32) can appear together, as can those for wind (these are dispersed in dayfile.txt fields 1, 2, 3, 16, 17, 18, and 39).
# If you have the skills to write your own script, then you might want to consider a different schema, daily information is in three log files for Cumulus 1, "dayfile.txt" should have the statistics for all completed days (that excludes today), "today.ini" has values for today-so-far, and "log.xml" is the Weather Diary where snow records (and general weather text) can be manually recorded. A schema that combines information extracted from those three files to show everything Cumulus has for a day is available in [https://cumulus.hosiene.co.uk/viewtopic.php?f=14&t=16880#p129719 this forum post].
 
=== Loading and Updating the database table ===
Obviously if you are using a script that reads statistics from a table, you also need to be running a script that ensures the table is updated at the end of each day, and therefore always up to date.
* Functionality is included in Cumulus MX to do this update, it uses the schema devised by Mark Crossley by default, but Cumulus MX can also handle your own schema; for full details of the functionality see [https://cumulus.hosiene.co.uk/viewtopic.php?f=27&t=12908&start=15#p107639 Cumulus MX Announcements - PLEASE READ THESE!].
* Cumulus 1 users need to use a script to create a database table, populate and update it from the daily summary log file. The most widely used script is an update by Mark Crossley of the script mentioned above by David Jamieson; and it is described in [[ImportCumulusFile|this Wiki article]].
** It is however worth also reading the forum post [https://cumulus.hosiene.co.uk/viewtopic.php?f=18&t=2367 a PHP script to read the contents of the dayfile.txt] as that explains the date delimiter, how a Comma Separated Variable file may use other punctuation to separate the fields, how to specify the location of your dayfile.txt log to the script and the reason the key variable is used. The thread contains several insights into how Cumulus was developed and it is a definite must to read Steve's posts in that thread if you are developing your own scripts.
 
=== Some example Scripts ===
As for the [[#PHP_scripts|PHP daily summary scripts section]] - '''Be aware if you use PHP scripts written by someone else''' .... ''These scripts may use "include ..." or "require ..." to bring in further scripts that introduce variables (such as those for accessing the database) or functions (to do standard actions) or templates (shared headers, navigation menus and footers) or text (any other common content) that is used with a number of pages on author's site. If you don't comment out those references to external scripts, or replace the references with your equivalents, the PHP parser may fail to produce a HTML page and nothing will be available to the browser. Thus you do need a simple understanding of PHP, a PHP book, or the ability to look up PHP instructions on the web if you are to be successful with tailoring these scripts to your site.''
 
If the script you decide to use accesses a database, be aware that not everyone has the same approach to missing data. Some will only work with perfect data, some treat zeroes as missing data, others expect missing data to have "Null" in the relevant column. Also, although David Jamieson invented a schema, and that is the default used by Cumulus MX; it is possible to use a different schema and that means the column names might be different between how you have set up your database and what is used by a particular script. As I often say, you do really need to develop some understanding of PHP and database access instructions to sucessfully get most of the PHP scripts database using scripts working. If you are new and inexperienced, using HTML, and JavaScript may be best for you.
 
Look in the Website Development section of the Cumulus support forum - '''Web general''' sub forum:
* Look at the Javascript and PHP scripts already listed for showing raw values, but some others present a summary view:
**[https://cumulus.hosiene.co.uk/viewtopic.php?f=14&t=10755#p87081 Top 10 Records Page]- This script by Mark Crossley runs several queries against the daily summary table of a database and picks various extremes displaying the top ten extremes (e.g. ). The latest source php can be seen using a [https://weather.wilmslowastro.com/test/top10s/top10sContent.php?view=sce query-string on Mark Crossley's web site] and there have been several updates since the forum thread was created.
**[https://cumulus.hosiene.co.uk/viewtopic.php?f=14&t=16534#p126964 What to do with data from MySQL] - This posting lists a number of web pages on PaulMy's web site where he presents statistics from the daily summary table of his database in different formats.
** [https://cumulus.hosiene.co.uk/viewtopic.php?f=14&t=8631 Comparing with one year ago] - This post [https://cumulus.hosiene.co.uk/viewtopic.php?f=14&t=7834#p66013 as requested here] has a query in a php file (as you save the download change '.txt' to '.php') that will extract from the daily summary table in a database, values for one year ago, to display alongside for example statistics for yesterday. An equivalent script using jQuery to read dayfile.txt directly is available for those who don't have a database. If you have some programming skills, you can vary either of these scripts to for example display statistics for each day in the last week (or month). I have written scripts that display the statistics for last week using a combination of this daily table in database approach and Cumulus recent tags. I have another script that uses the daily table in the databse to calculate the equivalent of what Cumulus 1 shows in View menu, this month selection, for any past month and adds the equivalent of what Cumulus this month web tags show and the resulting statistics are shown for various selectable mixtures of past months.
 
There are '''various scripts out there that output graphs''' from the values in recent history web tags, or values read off either a daily table in a database or dayfile.txt directly. There are two to highlight here:
* An alternative to the Cumulus 1 or Cumulus MX trend web page is described in [https://cumulus.hosiene.co.uk/viewtopic.php?f=18&t=12321 this topic] this can use all the sources mentioned.
* Highcharts (that cannot be used on a business web site) are exploited by Mark Crossley in [https://cumulus.hosiene.co.uk/viewtopic.php?f=18&t=8672 this topic]; it is a very long topic, and discusses various issues to consider with using such data, as well as including the script.
If you find a site displaying a graph or table you would like to copy on your own site, you might be able to see the PHP source that is responsible, but as I have commented [https://cumulus.hosiene.co.uk/viewtopic.php?f=14&t=16425&p=126065#p126065 elsewhere] most authors do not make it easy to see their code. Of course one of the reasons for using PHP script is that processing is done quickly on the web server and only the resulting HTML is passed onto the client browser and this does protect interlectual property and adds security by not showing the database access code.
 
=== Other jQuery approaches ===
If you extract all the values off the daily summary table with a simple "SELECT * FROM name_of_your_table" query and store those values in XML format using a PHP script called 'read_dayfile_historic.php', then you can use a jQuery library routine to produce a table of values using JavaScript:
<pre>
<script src="jquery.jqGrid.min.js" type="text/javascript"></script>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery("#list").jqGrid({
url:'read_dayfile_historic.php',
datatype: 'xml',
height: 460,
width: 970,
mtype: 'GET',
colNames:['Date','Highest<br/>Gust<br/>(mph)','Wind<br/>Bearing','Time of<br/>Gust','Min. Temp<br/>(&deg;C)','Time of<br/>Min.','Max. Temp<br/>(&deg;C)','Time of<br/>Max.','Avg. Temp<br/>(&deg;C)','Lowest<br/>pressure<br/>(mb)','Time of<br/>low','Highest<br/>pressure<br/>(mb)','Time of<br/>high','Highest<br/>Rain rate<br/>(mm/hr)','Time of<br/>High Rate','Total Rain<br/>fall (mm)','Tot.Wind<br/>run'],
colModel :[
{name:'UKLogDate', index:'LogDate', width:65, label: 'Date', sortable: true},
{name:'HighestWindGust', index:'HighWindGust', width:50, align:'right'},
{name:'HWindGBear', index:'HWindGBear', width:50, align:'right'},
{name:'THWindG', index:'THWindG', width:55, align:'right', sortable: false},
{name:'MinTemp', index:'MinTemp', width:55, align:'right'},
{name:'TMinTemp', index:'TMinTemp', width:55, align:'right', sortable: false},
{name:'MaxTemp', index:'MaxTemp', width:60, align:'right'},
{name:'TMaxTemp', index:'TMaxTemp', width:55, align:'right', sortable: false},
{name:'AvgTemp', index:'AvgTemp', width:57, align:'right'},
{name:'MinPress', index:'MinPress', width:60, align:'right'},
{name:'TMinPress', index:'TMinPress', width:50, align:'right', sortable: false},
{name:'MaxPress', index:'MaxPress', width:60, align:'right'},
{name:'TMaxPress', index:'TMaxPress', width:50, align:'right', sortable: false},
{name:'MaxRainRate', index:'MaxRainRate', width:55, align:'right'},
{name:'TMaxRR', index:'TMaxRR', width:60, align:'right', sortable: false},
{name:'TotRainFall', index:'TotRainFall', width:55, align:'right'},
{name:'TotWindRun', index:'TotWindRun', width:55, align:'right'}],
pager:'#pager',
rowNum:19,
rowList:[10,20,30],
viewrecords: true,
sortname: "LogDate",
sortorder: "desc",
caption: 'Daily Statistics'
});
});
</script>
</pre>
The above code uses jQuery to output a table showing all the statistics from the database, note that any column containing values can be clicked upon and the table will be resorted by those values, but any column containing time-stamps has the sorting set to false, so you cannot pick them. The column names used above are from the schema by David Jamieson, as used by Cumulus MX.
[[Category:User Contributions]]
5,838

edits

Navigation menu