2004 Weather Recordings

Relates to Apache and PEAR, Meteorology

The Weather Centre Archives have now been updated with daily pressure and temperature readings for 2004. Annual temperature summaries over the four years I have been taking recordings are as follows:

Average annual temperature for the years 2001 to 2004
Year Maximum Minimum Average
2001 22.1 -0.9 8.9
2002 23.6 -0.9 10.1
2003 27.5 -4.6 10.4
2004 23.2 -2.9 10.2

The annual mean for the last three years all exceed the 1961 - 1990 mean CET surface temperature of 9.47°C and are consistent with the recurring higher than average mean annual temperatures recorded throughout the 1990's. Note, however, that my weather station is not housed in a Stevenson screen, so comparison between these readings and the principle meterological records should only be interpreted for trends.

The principle reason for the Weather Archives is to record local variation in the climate at my location. Then once enough data is collated to be able to develop a weather application to analyse and graphically represent the data.

To this end I hope to do more work on the Weather Archives application this year, and to get the ball rolling, I decided to tweak the current API, by incorporating a caching module for the graphs which are dynamically created with PHP. This was a fairly painless process involving some URL rewriting to conceal PHP files as JPEG images and Cache_Lite to store the image data.

For example, mod-rewrite will translate a request for the file
/temperature/2004/01.png
to
/create_graph.php?year=2004&month=01&mime=png.


RewriteRule
  temperature/([0-9]{4})/([0-9]{2})\.(jpg|png|gif)$ 
  /create_graph.php?year=$1&month=$2&mime=$3

The routine in create_graph.php will then look for (or create) cached data to serve as the corresponding mime-type -


$id = A_UNIQUE_ID_FOR_IMAGE

$cache = new Cache_Lite($options);
if (! $data = $cache->get($id)) {

    // here some code will use the GD Library 
    // to create the image resource $image
  
    ob_start();
    switch($mime) {
      case 'png':
         imagepng($image);
         break;
      
      // etc
    
    }

    $data = ob_get_contents();
    ob_end_clean(); 
    imagedestroy($image);
  
  }    
  $cache->save($data);
}  
unset($cache);


switch($mime) {
  case 'png':
     header("Content-type: image/png");
     break;
  
  // etc

echo $data;

So with that side of the API performance covered, I hope now to find time to develop this application further through the year. As well as graphical comparison of hot and cold day indicators, some interesting ideas with image transparencies and live requests to create comparative graph overlays spring to mind.

Posted on Monday, Jan 17, 2005 at 20:54:19.

Comments on 2004 Weather Recordings (0)

Breadcrumbs Trail

[ Home ] -> TW Blog -> Jan 05 -> 2004 Weather Recordings
Site Map

The Severn Solutions website achieves the following standards:

[ XHTML 1.0 ] [ CSS 2 ] [ WAI AA ] [ Bobby AA ]

Page compiled in 0.008 seconds