Please read the posts in the Announcements section about the current status of Cumulus development now that I have retired

Please read this post before posting

Latest Cumulus release v1.9.4 (build 1099) - Nov 28 2014
Latest Cumulus MX release - v3.0.0 build 3043 Jan 20 2017. See this post for download

Server Generated Graphs for MX

Discussion of version 3 of Cumulus, which runs on Windows, Linux, and OS X. All Cumulus MX queries in here, please.
User avatar
mcrossley
Posts: 5013
Joined: Thu Jan 07, 2010 9:44 pm
Weather Station: Davis VP2
Operating System: Jessie Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Server Generated Graphs for MX

Postby mcrossley » Sat Oct 24, 2015 3:28 pm

Ah, you are using nginx, I think you will have to convert the .htaccess rules to nginx rewrite rules.

There is an on-line converter here, I have never used though.

Edit: Or use the full xxx.php filenames in gauges.js.

kapo
Posts: 246
Joined: Thu Jan 03, 2013 1:59 pm
Weather Station: Davis VP2
Operating System: Windows 10
Location: Vihtavuori, Laukaa, Finland

Re: Server Generated Graphs for MX

Postby kapo » Sat Oct 24, 2015 6:51 pm

Thank You David and Mark!
After Your advices, I got those graphs to work. I changed those pic addresses in gauges.js, and after that they started to work. Only one thing, which is not a big thing is those Windspeed and Cloudbase values. They are different in those graphs than my page's values are (wind is m/s, graph draws mph. Cloudbase is m, graph draws ft). Is it possible to change those graph values? If it is not, or if it is big work, then those values stay. I am so far very grateful for your help. Thank You once more.




regards
kapo

User avatar
steve
Cumulus Author
Posts: 26311
Joined: Mon Jun 02, 2008 6:49 pm
Weather Station: None
Operating System: None
Location: On tour in Portugal
Contact:

Re: Server Generated Graphs for MX

Postby steve » Sat Oct 24, 2015 7:18 pm

I think your graphs are plotting the correct values, it's just the labels that you need to change in graphSettings.php.

$GRAPH['uom'] = array('temp'=>'C', 'rain'=>'mm', 'wind'=>'mph', 'baro'=>'hPa', 'cloudbase'=>'feet');
Steve
-----
Hosting available for Cumulus web sites. See http://sandaysoft.com/forum/viewtopic.php?f=2&t=11876

Please read the posts in the Announcements section about the current status of Cumulus development since I have retired from my day job

kapo
Posts: 246
Joined: Thu Jan 03, 2013 1:59 pm
Weather Station: Davis VP2
Operating System: Windows 10
Location: Vihtavuori, Laukaa, Finland

Re: Server Generated Graphs for MX

Postby kapo » Sun Oct 25, 2015 8:58 am

Good morning Steve!
Thank you for your answer in yesterday evening. I was in a sleep then...
But just a moment ago, I found your answer, and I made those changes that you recommended to my problem. And now this problem is corrected. Everything is o.k. now. Thank You Steve. And special thanks for this CumMx. This is really good program. Now I begin to study how this program can be used to make those ftp:s and SQL uploads. Now I use Toolbox and cronjob. It should be fine, if I could do everything with one program. Thank you very much to you Steve. :)



Regards
kapo

User avatar
duke
Posts: 845
Joined: Sun Jul 03, 2011 6:23 pm
Weather Station: Davis VP2 Plus - 24hr FARS
Operating System: Windows 10 - 64 bit
Location: Eastleigh, Hampshire, UK
Contact:

Re: Server Generated Graphs for MX

Postby duke » Tue Dec 08, 2015 6:34 am

Has any one been having problems with these lately?

I've been busy with other projects lately so have not looked at my site for a few months. Looking today the graph images are no longer being generated on my site although locally works as they did when I installed them. I have re-uploaded all the required files from a previous working back up but the same errors are displayed.

When viewing the php graph file directly there are various time related errors, here's a link to one of the php files -graphTempOut.php

And a link to where the graphs were and should be.

My host is running PHP Version 5.5.29

Any suggestions gratefully received.
Duke

Nightingale Weather
Eastleigh, Hampshire, UK
------------------------------------------------------
Validate your pages - often!

User avatar
steve
Cumulus Author
Posts: 26311
Joined: Mon Jun 02, 2008 6:49 pm
Weather Station: None
Operating System: None
Location: On tour in Portugal
Contact:

Re: Server Generated Graphs for MX

Postby steve » Tue Dec 08, 2015 9:06 am

Mine's working OK. Googling that message and jpgraph turns up a lot of hits (many of which are because they are actually exhibiting the problem). This person - http://prefetch.net/blog/index.php/2012/02/15/how-to-get-around-the-php-strftime-it-is-not-safe-to-rely-on-the-systems-timezone-settings-warning/ - set the date.timezone in his php.ini, possibly yours used to do that but no longer does?
Steve
-----
Hosting available for Cumulus web sites. See http://sandaysoft.com/forum/viewtopic.php?f=2&t=11876

Please read the posts in the Announcements section about the current status of Cumulus development since I have retired from my day job

User avatar
mcrossley
Posts: 5013
Joined: Thu Jan 07, 2010 9:44 pm
Weather Station: Davis VP2
Operating System: Jessie Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Server Generated Graphs for MX

Postby mcrossley » Tue Dec 08, 2015 9:58 am

Possibly your server's PHP version has been upgraded, this is a 'feature' on later versions? As Steve said, on newer versions of PHP set the server default TZ in our php.ini file - you can then override it in individual scripts if need be.

User avatar
duke
Posts: 845
Joined: Sun Jul 03, 2011 6:23 pm
Weather Station: Davis VP2 Plus - 24hr FARS
Operating System: Windows 10 - 64 bit
Location: Eastleigh, Hampshire, UK
Contact:

Re: Server Generated Graphs for MX

Postby duke » Tue Dec 08, 2015 10:25 pm

Thanks Steve / Mark for your prompt reply.

Firstly, checked my php.ini on my hosts server and the time zone is set correctly - "date.timezone="Europe/London""

Following Steve's link and simply adding "date_default_timezone_set('Europe/London');" to jpgraph.php solved the problem.

thanks.
Duke

Nightingale Weather
Eastleigh, Hampshire, UK
------------------------------------------------------
Validate your pages - often!

mwittl
Posts: 3
Joined: Sun Dec 08, 2013 11:51 am
Weather Station: Vantage Vue
Operating System: Windows 10
Location: Roanoke, VA (USA)
Contact:

Re: Server Generated Graphs for MX

Postby mwittl » Sat Jan 09, 2016 11:03 am

New addition - graphWindRose.php - For server-side dynamic generation of a Windrose plot .png when using CumulusMX.

First, I want to thank user Mark Crossley (mcrossley) for his excellent .php scripts for the graph scripts from the CumulusMX JSON files. I was running Cumulus and when I converted to CumulusMX, I was missing all the .png files needed for the Saratoga/Cumulus scripts. Mark's graphs filled the void, perfectly! At any rate, the only thing missing was a Windrose .png file. With the Saratoga/Cumulus scripts, a Windrose is used on the page that is launched when the Almanac/Weather Trends link is clicked.

Using mcrossley's scripts as a basis, I created a new .php script that will generate the Windrose from the CumulusMX JSON files. Here is the result:

Image

What's needed:

1.) Mark Crossley's original package for graphic files. Download from 1st posting by Mark on this subject.
2.) jpgraph-3.5.0b1 - Available here: http://jpgraph.net/download/ (Only the src directory is needed which contains a windrose chart)
3.) Modify the jpgraph_windrose.php file to remove the import of 'jpgraph_glayout_vh.inc.php'

Code: Select all

//require_once('jpgraph_glayout_vh.inc.php');

4.) Edit the jp-config.inc.php file to point to the font directory under the installed jpgraph location

Code: Select all

define('TTF_DIR','public_html/entreedata/jpgraph/fonts/');

5.) You may need to locate several TTF fonts found on the internet to this location. Depends if you get any font errors.
6.) Download my graphWindRose.php file and place where you put Mark's other graphic scripts. For me this was /cumulus/images/
7.) Add a line to your .htaccess file to allow calling the script by the .png alias

Code: Select all

RewriteRule ^windrose.png$ graphWindRose.php [NC,L]


Here is the windrose.png in context of my web site when served up by the Saratoga scripts:
Image

Feel free to look over the script for errors and modify if needed.

SRC for graphWindRose.php

Code: Select all

<?php
/*!
 * Simple static trend graphs for Cumulus MX
 *
 * Created by Mark Wittl, January 2016
 * based on originals by Mark Crossley, January 2015
 *
 * Released under GNU GENERAL PUBLIC LICENSE, Version 2, June 1991
 * See the enclosed License file
 *
 * File encoding = UTF-8
 *
 */

require_once 'graphSettings.php';

$name = basename($_SERVER['PHP_SELF'], '.php').'.png';


//fetch the data
$w1 = get_data('wdir');
$w2 = get_data('wind');

$datay = $w1['bearing'];
//$datay1 =$w2['wspeed'];
$datay1 =$w2['wgust'];
//**************************************************************************************************************************************************
//You have to call two variables from the clientraw, the winddir($datay) and the speed($datay1).
//The rest of the script is clearly explained at the jpgraph website.


// Loop through raw data arrays and place data into the appropriate arrays
// depending on their wind direction
for ($ii = 0; $ii < count($datay); $ii++){
   switch($datay[$ii]){
      case ($datay[$ii] >= 348.75 or $datay[$ii] < 11.25):
         $direction_array["N"][] = $datay1[$ii];
         break;
      case ($datay[$ii] >= 11.25 and $datay[$ii] < 33.75):
         $direction_array["NNE"][] = $datay1[$ii];
         break;
      case ($datay[$ii] >= 33.75 and $datay[$ii] < 56.25):
         $direction_array["NE"][] = $datay1[$ii];
         break;
      case ($datay[$ii] >= 56.25 and $datay[$ii] < 78.75):
         $direction_array["ENE"][] = $datay1[$ii];
         break;
      case ($datay[$ii] >= 78.75 and $datay[$ii] < 101.25):
         $direction_array["E"][] = $datay1[$ii];
         break;
      case ($datay[$ii] >= 101.25 and $datay[$ii] < 123.75):
         $direction_array["ESE"][] = $datay1[$ii];
         break;
      case ($datay[$ii] >= 123.75 and $datay[$ii] < 146.25):
         $direction_array["SE"][] = $datay1[$ii];
         break;
      case ($datay[$ii] >= 146.25 and $datay[$ii] < 168.75):
         $direction_array["SSE"][] = $datay1[$ii];
         break;
      case ($datay[$ii] >= 168.75 and $datay[$ii] < 191.25):
         $direction_array["S"][] = $datay1[$ii];
         break;
      case ($datay[$ii] >= 191.25 and $datay[$ii] < 213.75):
         $direction_array["SSW"][] = $datay1[$ii];
         break;
      case ($datay[$ii] >= 213.75 and $datay[$ii] < 236.25):
         $direction_array["SW"][] = $datay1[$ii];
         break;
      case ($datay[$ii] >= 236.25 and $datay[$ii] < 258.75):
         $direction_array["WSW"][] = $datay1[$ii];
         break;
      case ($datay[$ii] >= 258.75 and $datay[$ii] < 281.25):
         $direction_array["W"][] = $datay1[$ii];
         break;
      case ($datay[$ii] >= 281.25 and $datay[$ii] < 303.75):
         $direction_array["WNW"][] = $datay1[$ii];
         break;
      case ($datay[$ii] >= 303.75 and $datay[$ii] < 326.25):
         $direction_array["NW"][] = $datay1[$ii];
         break;
      case ($datay[$ii] >= 326.25 and $datay[$ii] < 348.75):
         $direction_array["NNW"][] = $datay1[$ii];
         break;
   }
}

// Some directions may not have any data so this will create an array of the
// directions that do.
$direction_keys = array_keys($direction_array);

// Calculate max windspeed, used for windrose range
$max_wind = round(max($datay1),0);

// Get the number of data points
$num_data = count($datay1);

// Define the data range array for the windrose, this needs to be done
// ahead of time because some of the computational aspects require this range
$wind_range_max = $max_wind < 20 ? 25:$max_wind;
$data_range_array = array(1,5,10,15,20,$wind_range_max);

// Loop through dirction array based on direction keys and calculate the histogram
// stats for each array.
foreach ($direction_keys as $direction) {

   // Set up counter to determine how many data points there are within each
   // direction array and wind range.
   for ($ii = 0; $ii <= 5; $ii++){
      $count_data[$ii] = 0;
   }

   // Define raw data to be processed into array counters
   $raw_data = $direction_array[$direction];
      
   // The windrose software needs to know the % of data points that fall into
   // each range for each wind direction. 
   foreach ($raw_data as $temp_speed) {
      if ($temp_speed >= 0 and $temp_speed < $data_range_array[0]) {
         $count_data[0]++;
      } elseif ($temp_speed >= $data_range_array[0] and $temp_speed < $data_range_array[1]) {
         $count_data[1]++;
      } elseif ($temp_speed >= $data_range_array[1] and $temp_speed < $data_range_array[2]) {
         $count_data[2]++;
      } elseif ($temp_speed >= $data_range_array[2] and $temp_speed < $data_range_array[3]) {
         $count_data[3]++;
      } elseif ($temp_speed >= $data_range_array[3] and $temp_speed < $data_range_array[4]) {
         $count_data[4]++;
      } elseif ($temp_speed >= $data_range_array[4]) {
         $count_data[5]++;
      }
   }
   
   // Place all data in an array that can be used by JPGraph
   // First set up data array
   for ($ii = 0; $ii <= 5; $ii++) {
      $plot_data[$direction][$ii] = 0;      
   }
   
   for ($ii = 0; $ii <= 5; $ii++) {
      $plot_data[$direction][$ii] = ($count_data[$ii] / $num_data) * 100;
   }
      
}


//**************************************************************************************************************************************************
 
// First create a new windrose graph with a title
$graph = new WindroseGraph(400,400);
$graph->title->Set('Windrose');
 
// Create the windrose plot.
$wp = new WindrosePlot($plot_data);
 
// Add and send back to browser
$graph->Add($wp);
$graph->Stroke();

?>


- Mark Wittl
http://www.entreedata.com/weather/roanoke/details/
Last edited by mwittl on Sat Jan 09, 2016 12:45 pm, edited 1 time in total.

User avatar
steve
Cumulus Author
Posts: 26311
Joined: Mon Jun 02, 2008 6:49 pm
Weather Station: None
Operating System: None
Location: On tour in Portugal
Contact:

Re: Server Generated Graphs for MX

Postby steve » Sat Jan 09, 2016 11:51 am

Nice work!
Steve
-----
Hosting available for Cumulus web sites. See http://sandaysoft.com/forum/viewtopic.php?f=2&t=11876

Please read the posts in the Announcements section about the current status of Cumulus development since I have retired from my day job

User avatar
mcrossley
Posts: 5013
Joined: Thu Jan 07, 2010 9:44 pm
Weather Station: Davis VP2
Operating System: Jessie Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Server Generated Graphs for MX

Postby mcrossley » Sat Jan 09, 2016 4:34 pm

Great stuff, I have a version that works with MySQL as well now (http://weather.wilmslowastro.com/images/windrose.png)

I think you have one step missing, you need to add an include to graphSettings.php...

Code: Select all

include $GRAPH['jpgraphloc'] . "jpgraph_windrose.php";


I had to add arial.ttf and verdana.ttf to the jpgraphs/fonts folder.

User avatar
mcrossley
Posts: 5013
Joined: Thu Jan 07, 2010 9:44 pm
Weather Station: Davis VP2
Operating System: Jessie Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Server Generated Graphs for MX

Postby mcrossley » Sat Jan 09, 2016 9:04 pm

With Marks permission, I have added his WindRose script to the overall package, so you can download from the GitHub repository.

Thanks again Mark.

forestedge
Posts: 25
Joined: Sun Jul 29, 2012 11:46 am
Weather Station: Davis Vantage Pro2 Plus
Operating System: Windows 10 64 bit
Location: Ashurst Bridge, Hampshire UK
Contact:

Re: Server Generated Graphs for MX

Postby forestedge » Tue Jan 26, 2016 8:56 pm

You need to edit the JPGraph config file to enable caching and point it at your cache folder. Then edit the graphSettings.php script and set the cache folder and jpgraph fodler locations in there.

I am struggling to set up the popup graphs and could not see the graphsettings.php script anywhere when downloaded and at the moment no graphs are generated in the cache.
I have uploaded jpgraphs package and defined as below in Windows 7, not sure if this is correct though!

define('CACHE_DIR','/public_html/cache'/');
define('TTF_DIR','/public_html/font'/');
define('USE_CACHE',true);
//('MBTTF_DIR','/usr/share/fonts/TrueType/');//

I also tried changing the website MX gauge colours in the MX gauges.js like I have with Cumulus 1 and they did not display so I had to revert to the default colours.

Any assistance appreciated.

User avatar
mcrossley
Posts: 5013
Joined: Thu Jan 07, 2010 9:44 pm
Weather Station: Davis VP2
Operating System: Jessie Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Server Generated Graphs for MX

Postby mcrossley » Tue Jan 26, 2016 9:51 pm

forestedge wrote:I am struggling to set up the popup graphs and could not see the graphsettings.php script anywhere when downloaded and at the moment no graphs are generated in the cache.

graphSettings.php is part of the download from this thread, not JPGraphs.

forestedge wrote:I have uploaded jpgraphs package and defined as below in Windows 7, not sure if this is correct though!

define('CACHE_DIR','/public_html/cache'/');
define('TTF_DIR','/public_html/font'/');
define('USE_CACHE',true);
//('MBTTF_DIR','/usr/share/fonts/TrueType/');//

I'd put the full path in, e.g. something like C:/web/public_html/cache/

But you seem to have an extra quote character before the final / at the end of each path above.

UncleBuck
Posts: 37
Joined: Sat Dec 29, 2012 10:27 pm
Weather Station: Davis VP2+
Operating System: MAC Mini - OSX El Capitan
Location: Victoria, Australia

I am stumped! Please help me if you can.

Postby UncleBuck » Fri Jan 29, 2016 1:24 am

I am at a loss getting these to work on my site......

This is what I have:

Code: Select all

jpgraph.php
(as downloaded)

jpg-config.inc.php
 define('CACHE_DIR',$_SERVER["DOCUMENT_ROOT"].'/site-utils/jpgraph/cache/');
 define('TTF_DIR',$_SERVER["DOCUMENT_ROOT"].'/site-utils/jpgraph/Fonts/');
 define('MBTTF_DIR',$_SERVER["DOCUMENT_ROOT"].'/site-utils/jpgraph/Fonts/');

.httaccess
(as downloaded) and placed in the images folder.

gauges.js
imgPathURL        : 'images/',


Now the problem:
Trying the JpGraph examples testsuit.php shows no images (except one) and one error in the server logs which is
PHP Fatal error: require_once(): Failed opening required 'jpgraph/jpgraph_odo.php' (include_path='.:')

(Take a look for yourself at http://www.pcweather.kcsolutions.com.au ... stsuit.php)
Of the 559 tests, only 36 images are created in the cache.
Test 6 result shows an image BUT it is not in the cache.

Trying the gauges-ss-basic.htm file (http://www.pcweather.kcsolutions.com.au ... -basic.htm) produces 9 images in the cache BUT the log file shows an "Undefined index: uom" error in the graphWind.php file.
Calling any image directly from the images folder such as http://www.pcweather.kcsolutions.com.au/images/temp.png results in the image being created in the cache but not displayed on screen (indicating that the .httaccess is working correctly).

Any ideas as to what the problem may be would be greatly appreciated.

Colin.

Further investigation has shown the following:
Even though the image gets created in the cache folder when you call http://www.pcweather.kcsolutions.com.au ... aphhum.php, if you do this using Firefox it displays the message
The image “http://www.pcweather.kcsolutions.com.au/images/graphhum.php” cannot be displayed because it contains errors.
If you call the direct link to the cached image using Firefox (i.e. http://www.pcweather.kcsolutions.com.au ... aphhum.png) then it displays the image as it should.
Last edited by UncleBuck on Sat Jan 30, 2016 7:20 am, edited 1 time in total.


Return to “Cumulus MX”

Who is online

Users browsing this forum: No registered users and 7 guests