Technical Information
Graphing Scripts
The graphs on this site are created using the Image_Graph PEAR package. For those of you that would like to create similar graphs on your own sites, I have provided the source code that creates my graphs. I have left out the core code for the content management system that creates the database connection, sets the timezone and defines some basic functions. Please note that the database functions seen in these scripts are using the DB PEAR package.This script runs every 10 minutes:
cron_10.php
The script runs in two stages, first it generates the datasets and sets up the canvas and plot area for each graph, then once that's complete each graph is drawn and outputted to a file using the 'done' method. It has been designed this way to allow changes to the graph before it's saved. As you can see in the above file, there are several included files containing classes for each type of graph. This is parent class for all of the large graphs created:
graph.class.php
It contains methods to setup the canvas and plotarea, create a basic type of dataset, debug a graph and write the graph to a file. The following types of graph are used on this site:
modules/weather/graph.temp.class.php Temperature, Dew point, Humidity
modules/weather/graph.alltemp.class.php Temperature from 4 sensors
modules/weather/graph.pressurewind.class.php Wind speed, Wind gust speed and Pressure
modules/weather/graph.winddir.class.php Wind direction
modules/weather/graph.winddist.class.php Wind Distribution
modules/weather/graph.solar.class.php Solar radiation
The code isn't documented very much at all, so if you need any help setting up these scripts on your site please email me. Some time in the future I may try to release this as package with a bit more user friendliness and documentation if there's demand.
$txt = '';
$txt .= $current['temp_current_c'] . "\n";
$txt .= $current['humidity'] . "\n";
$txt .= $current['pressure_current_mbar'] . "\n";
$txt .= 0 . "\n"; //Precipitation, I don't have a rain gauge
$txt .= $current['wind_speed_kph'] . "\n";
$txt .= $current['wind_direction_deg'] . "\n";
$txt .= date('H:i') . "\n"; //Time
$txt .= date('d.m.Y') . "\n"; //Date
$txt .= $current['pressure_change1_mbar']; //1-Hour pressure change
$txt .= $current['temp_current_c'] . "\n";
$txt .= $current['humidity'] . "\n";
$txt .= $current['pressure_current_mbar'] . "\n";
$txt .= 0 . "\n"; //Precipitation, I don't have a rain gauge
$txt .= $current['wind_speed_kph'] . "\n";
$txt .= $current['wind_direction_deg'] . "\n";
$txt .= date('H:i') . "\n"; //Time
$txt .= date('d.m.Y') . "\n"; //Date
$txt .= $current['pressure_change1_mbar']; //1-Hour pressure change
AWEKAS
The AWEKAS automatic weather map system plots personal weather station data from all over the world. The software my station uses is not officially supported by AWEKAS but after figuring out the format of the awekas.txt file I have been able to send data to the system.For those interested in making their own awekas.txt file for uploading data, the format is shown to the right as a direct extract from my PHP code.





