Welcome to the Cumulus Support forum.

Latest Cumulus MX V4 release 4.4.2 (build 4085) - 12 March 2025

Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024

Legacy Cumulus 1 release 1.9.4 (build 1099) - 28 November 2014
(a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)

Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki

If you are posting a new Topic about an error or if you need help PLEASE read this first viewtopic.php?p=164080#p164080

Cloud base Graph

Discussion and questions about Cumulus weather station software version 1. This section is the main place to get help with Cumulus 1 software developed by Steve Loft that ceased development in November 2014.
Post Reply
User avatar
K8POS
Posts: 94
Joined: Sat 03 Jan 2015 4:17 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 7
Location: Thumb of Michigan
Contact:

Cloud base Graph

Post by K8POS »

Not sure if I should direct this one to Steve or Mark.
I am using the SS Gauges in my web pages, when you hover over the cloud base gauge, a graph pops up giving the cloud base, but the scale shows Pressure, not feet/meters.
Also notice that this graph is not shown in the trends page of graphs.

Bob
water01
Posts: 3670
Joined: Sat 13 Aug 2011 9:33 am
Weather Station: Ecowitt HP2551
Operating System: Windows 10/11 64bit Synology NAS
Location: Burnham-on-Sea
Contact:

Re: Cloud base Graph

Post by water01 »

Quite correct. That is what it shows. And there is no trends graph for Cloud base.
David
Image
User avatar
mcrossley
Posts: 14388
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Cloud base Graph

Post by mcrossley »

Correct, no cloud base graph in Cumulus, so you can either remove the graph altogether, or create your own as I have with jpgraphs in PHP, but that does require you to log your real time data.
User avatar
laulau
Posts: 678
Joined: Tue 13 Oct 2009 10:52 pm
Weather Station: WeatherDuino Pro2
Operating System: Win 7
Location: Meyenheim, Alsace, FR
Contact:

Re: Cloud base Graph

Post by laulau »

Laurent

Image
water01
Posts: 3670
Joined: Sat 13 Aug 2011 9:33 am
Weather Station: Ecowitt HP2551
Operating System: Windows 10/11 64bit Synology NAS
Location: Burnham-on-Sea
Contact:

Re: Cloud base Graph

Post by water01 »

Laurent is this produced as part of Mark's JSON MX Graphs because I cannot see it in the source files, or did you produce it using Mark's code as a base?
David
Image
User avatar
laulau
Posts: 678
Joined: Tue 13 Oct 2009 10:52 pm
Weather Station: WeatherDuino Pro2
Operating System: Win 7
Location: Meyenheim, Alsace, FR
Contact:

Re: Cloud base Graph

Post by laulau »

mcrossley wrote:
laulau wrote:Hi Mark,
I guess it's possible to get the data to feed jpgraphs with realtimeLogSql.php script ?
Guess how I do mine :lol: I don't have MX uploading the json files, just my tag files, so yes I just query my real time MySQL table.
It's based on Mark's code but the data are extracted from my SQL table !
Laurent

Image
water01
Posts: 3670
Joined: Sat 13 Aug 2011 9:33 am
Weather Station: Ecowitt HP2551
Operating System: Windows 10/11 64bit Synology NAS
Location: Burnham-on-Sea
Contact:

Re: Cloud base Graph

Post by water01 »

Care to share?
David
Image
User avatar
mcrossley
Posts: 14388
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Cloud base Graph

Post by mcrossley »

Image

All my 'mx' graphs come from a MySQL dB too, I had to adapt the MySQL code to use the MX JSON files. The only real change is in graphSettings.php to the get_data() function to query the dB rather than reformat the MX JSON data.

You can then create whatever graph you want - I also separate out the UV from Solar.

Image
User avatar
laulau
Posts: 678
Joined: Tue 13 Oct 2009 10:52 pm
Weather Station: WeatherDuino Pro2
Operating System: Win 7
Location: Meyenheim, Alsace, FR
Contact:

Re: Cloud base Graph

Post by laulau »

graphSettings.php (modifs) :

.......................

Code: Select all

function reorg_data1($dat) {
	$keyname = array(
		"press" => "Pressure",
		"rfall" => "Rain today",
		"rrate" => "Rain rate",
		"hum" => "Outdoor humidity",
		"inhum" => "Indoor humidity",
		"temp" => "Temperature",
		"intemp" => "Indoor",
		"dew" => "Dew point",
		"apptemp" => "Apparent temp",
		"wchill" => "Wind chill",
		"bearing" => "Direction",
		"avgbearing" => "Average direction",
		"wspeed" => "Wind speed",
		"wgust" => "Wind gust",
		"cloudbasevalue" => "Cloudbase",
		);	
	$keys = array_keys($dat);
	$retVal = array();
	
 
    for ($i = 0; $i < count($keys); $i++) {
        
		$key = $keys[$i];
		
        for ($j = 0; $j < count($dat[$key]); $j++) {
            if ($i === 0) {
                // JavaScript time in msecs, convert to secs
                $retVal['time'][] = $dat[$key][$j][0] / 1000;
            }
            $retVal[$keyname[$key]][] = $dat[$key][$j][1];
        }
    }
	
    return $retVal;	
}

function get_data($type) {
    global $GRAPH;

    // get the units
    $units = json_decode(file_get_contents($GRAPH['jsonloc'] . 'units.json'), true);

    // get the data
	// realtimeLogSql.php?recordAge=24&recordUnit=hour&nth=5&rfall
	// http://www.laurentmey.fr/test/mx-jpgraphs/graphTempOut.php
    switch ($type) {
    case 'temp':
        //$data = reorg_data(json_decode(file_get_contents($GRAPH['jsonloc'] . 'tempdatad3.json'), true));
		$data = reorg_data1(json_decode(file_get_contents('http://$path/realtimeLogSql.php?recordAge=24&recordUnit=hour&nth=10&temp&intemp&dew&apptemp&wchill'), true));
        $data['units'] = $units['temp'];
        break;
.....case ETC....
realtimeLogSql.php based on Mark's code ;) :

Code: Select all

<?php
//-----------------------------------------------------------------
// Query a Cumulus realtime MySQL table and return the requested fields
// along with the time stamps in a JSON format suitable for use with
// the Highcharts graphing package.
// Author: Mark Crossley
//
// Version 0.2 - 18 Dec 2012
//
// Call this script as e.g. ...
//         realtimeLogSql.php?recordAge=NNN&recordUnit=XXX&nth=NNN&temp&press
//         realtimeLogSql.php?recordAge=6&recordUnit=hour&nth=5&temp&press
//  Where:
//    recordAge=NNN
//		Returns records newer than NNN recordUnits, 6 hours in this example
//    recordUnit=XXX
//		The units to use for recordAge (second,minute,hour,day,week,month,quarter,year)
//    nth=NNN [OPTIONAL parameter]
//		If supplied the script will only return every n'th row from the realtime table, otherwise all
//      rows within the time range are returned. Useful for reducing large data sets for presentation.
//      This example will return every 5th row from the table
//    &temp&press
//		Returns the temperature and pressure data - concatenate as many record types as you wish.
//
//  The data arrays are returned in an object with the key name equal to
//  the param name supplied in the URL. In the example above the returned
//  object will be: {"temp": [[t0,v0],[t1,v1],...],
//                   "press": [[t0,v0],[t1,v1],...]}
//-----------------------------------------------------------------

// EDIT THIS NEXT SECTION CAREFULLY
// ----------------------------------------------------------------
// The server host name or number running your MySQL database
// usually 127.0.0.1 or localhost will suffice
$dbhost = ' ';
//
// The username used to log-in to your database server
$dbuser = ' ';
//
// The password used to log-in to your database server
$dbpassword = ' ';
//
// The name of the MySQL database we will store the tables in
$database = ' ';
//
// A better way of entering your login details is to put them in a separate script
// and include this here. This script should be placed in an area accessible to PHP
// but not web users. Your login details will not then beexposed by crashing this
// script.
// e.g. ...
include ('../forbidden/db_ro_details.php');

// The name of your realtime log table
$logtable = 'Realtime';

//-----------------------------------------------------------------

// Acceptable recordUnit parameter values
$validunits = array('second', 'minute', 'hour', 'day', 'week', 'month', 'quarter', 'year');

// Columns of realtime log table
// Use the same names as the corresponding web tags
$rfields = array(
    'datetime','temp','hum','dew','wspeed','wlatest','bearing',
    'rrate','rfall','press','currentwdir','beaufortnumber',
    'windunit','tempunitnodeg','pressunit','rainunit',
    'windrun','presstrendval','rmonth','ryear','rfallY','intemp','inhum','wchill',
    'temptrend','tempTH','TtempTH','tempTL','TtempTL',
    'windTM','TwindTM','wgustTM','TwgustTM',
    'pressTH','TpressTH','pressTL','TpressTL',
    'version','build','wgust','heatindex','humidex','UV','ET','SolarRad',
    'avgbearing','rhour', 'forecastnumber', 'isdaylight', 'SensorContactLost',
    'wdir','cloudbasevalue','cloudbaseunit','apptemp','SunshineHours','CurrentSolarMax','IsSunny');



// ============= Start it off... ============


// check parameters (just presence, no value checking)
if (array_key_exists('recordAge', $_GET)) {
	$recordAge = $_GET['recordAge'];
} else {
	die('You must supply a "recordAge" parameter');
}

if (array_key_exists('recordUnit', $_GET)) {
	$recordUnit = strtolower($_GET['recordUnit']);
	if (!in_array($recordUnit, $validunits)) {
		die("invalid 'recordUnit' supplied - '$recordUnit'");
	}
} else {
		die('You must supply a "recordVal" parameter');
}

if (array_key_exists('nth', $_GET)) {
	$nth = $_GET['nth'];
} else {
	$nth = '';
}

// Process the script value arguments
$dataTypes = array();
foreach($_GET as $key => $value) {
    if (in_array($key, $rfields)) {
        $dataTypes[] = $key;
    }
}

// Did we get any valid parameters?
if (count($dataTypes) == 0) {
    die('No valid return data types supplied');
}

// Connect to the datbase
$con = mysql_connect($dbhost, $dbuser, $dbpassword);
if (!$con) {
	die('Failed to connect to the database server');
}

if (!mysql_select_db($database, $con)) {
	die('Failed to connect to the database on the server');
}

$result = mysql_query('SET time_zone="+0:00"');
if (!$result) {
	die('ERROR - TZ Statement');
}

// Was the 'nth' parameter supplied? If not, do a standard query, else, only return every nth row from the table
if ($nth === '') {

	// Start of query string, then...
	$query = 'SELECT UNIX_TIMESTAMP(LogDateTime)';

	// add query data columns, then..
	foreach($dataTypes as $key) {
		$query .= ', ' . $key;
	}

	// end of query string.
	$query .= " FROM $logtable WHERE LogDateTime > DATE_SUB(NOW(), INTERVAL $recordAge $recordUnit) ORDER BY LogDateTime ASC";

} else {  // Only return every nth row

	// Start of query string, then...
	$query = 'SELECT ts';

	// add query data columns, then..
	foreach($dataTypes as $key) {
		$query .= ', ' . $key;
	}
	$query .= ' FROM ( SELECT @row := @row +1 AS rownum, UNIX_TIMESTAMP(LogDateTime) AS ts';

	// add query data columns, then..
	foreach($dataTypes as $key) {
		$query .= ', ' . $key;
	}
	// end of query string.
	$query .= " FROM $logtable WHERE LogDateTime > DATE_SUB(NOW(), INTERVAL $recordAge $recordUnit) ORDER BY LogDateTime ASC) as DT WHERE MOD(rownum,$nth)=0";

	// initialise the row counter
	$result = mysql_query('SET @row := 0;');
	if (!$result) {
		die("ERROR - Bad SQL Statement: $query");
	}
}

// Perform query
$result = mysql_query($query);
if (!$result) {
	die("ERROR - Bad Select Statement: $query");
}

// for each of the returned rows, put the data into a series of arrays...
while($row = mysql_fetch_row($result)) {
	$tim = $row[0] * 1000;
	$i = 1;
	foreach($dataTypes as $key) {
        ${"arr_$key"}[]  = array($tim, (float)$row[$i++]);
    }
}

// build the return array
foreach($dataTypes as $key) {
    $return[$key] = ${'arr_' . $key};
}

header('Cache-Control: private');
header('Cache-Control: no-cache, must-revalidate');
header('Content-type: text/json  charset=UTF-8');

// encode the result and echo it back to the client
echo json_encode($return);

// ========== End of Module ===========
?>
Laurent

Image
User avatar
K8POS
Posts: 94
Joined: Sat 03 Jan 2015 4:17 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 7
Location: Thumb of Michigan
Contact:

Re: Cloud base Graph

Post by K8POS »

Just when I thought it was going to be easy! :bash:
User avatar
mcrossley
Posts: 14388
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Cloud base Graph

Post by mcrossley »

I'll post a SQL version in the MX forum soon...
OliII
Posts: 54
Joined: Mon 19 Mar 2012 11:47 am
Weather Station: WMR 200 by Oregon Scientific
Operating System: WinXP SP3
Location: Belgium

Re: Cloud base Graph

Post by OliII »

Hi ! I'll be interessed too for these graphs. But, i don't have access to the mxforum. Could you post these here ?
Thx.
Image
http://www.7331.be/meteo website based on the phpBB3 forum and template. WMR200 + UVN 800 - Cumulus 1.9.4 1062 / Windows XP Service Pack 3 build 2600 FR
Post Reply