Home Forum Community Radiation vs Weather Reply To: Radiation vs Weather

#1951
David
Participant

Those graphs look really nice Steve, what are you using to generate those?

I’m using jpgraph for mine which seems to be alright but as you can see from the above I’m yet to refine them into nice looking ones.

Apache, PHP, MYSQL are all running on a Debian VM and a cron job runs every 5 minutes with that python script to poll the data into MYSQL.
Weather data is injected using Weather Display which runs on a Windows 7 VM.
I noticed you are using “weewx” for yours I may have to give that a look as the less stuff I have running on the Windows 7 VM the better.

All of this data is stored in one MYSQL database called “temps” this includes a table for uRAD, weather, bathroom, laundry and rack.
The last three being for my home automation system to control extraction fans.
I then use jpgraph and PHP to pull data from the tables.
This is the PHP script for the Wind vs CPM graph. (I’m far from good with programming so it’s a bit of a mess)

<?php // content="text/plain; charset=utf-8"
 
define('__ROOT__', dirname(dirname(__FILE__)));
require_once ('../jpgraph/jpgraph.php');
require_once ('../jpgraph/jpgraph_line.php');
require_once ('../jpgraph/jpgraph_error.php');
 
 
$x_axis = array();
$y_axis = array();
$y1_axis = array();
$y2_axis = array();
$i = 0;
 
$con=mysqli_connect("localhost","username","password","temps");
// Check connection
if (mysqli_connect_errno()) {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
 
$result = mysqli_query($con,"SELECT * FROM urad ORDER BY <code>id</code> DESC LIMIT 288");
 
 
while($row = mysqli_fetch_array($result)) {
$x_axis[$i] =  $row["time"];
$y_axis[$i] = $row["cpm"];
    $i++;

} 

$i = 0;
$result = mysqli_query($con,"SELECT * FROM weather ORDER BY <code>datetime</code> DESC LIMIT 288");

 
while($row = mysqli_fetch_array($result)) {
$y1_axis[$i] = $row["average_windspeed"];
    $i++;

}
    

$i = 0;
$result = mysqli_query($con,"SELECT * FROM weather ORDER BY <code>datetime</code> DESC LIMIT 288");

 
while($row = mysqli_fetch_array($result)) {
$y2_axis[$i] = $row["gust_windspeed"];
    $i++;

}

mysqli_close($con);
 
 
 
$graph = new Graph(1000,500);
$graph->img->SetMargin(40,40,40,40); 
$graph->img->SetAntiAliasing();
$graph->SetScale("textlin");
$graph->SetShadow();
$graph->title->Set("Red: Average Windspeed Green: Gust Windspeed Blue: CPM");
$graph->title->SetFont(FF_FONT1,FS_BOLD);
 
 
// Use 20% "grace" to get slightly larger scale then min/max of
// data
$graph->yscale->SetGrace(0);
 
 
$p1 = new LinePlot($y_axis);
//$p1->mark->SetType(MARK_FILLEDCIRCLE);
//$p1->mark->SetFillColor("red");
$p1->mark->SetWidth(2);
$p1->SetColor("blue");
$p1->SetCenter();
$graph->Add($p1);

$p2 = new LinePlot($y1_axis);
//$p2->mark->SetType(MARK_FILLEDCIRCLE);
//$p2->mark->SetFillColor("red");
$p2->mark->SetWidth(2);
$p2->SetColor("red");
$p2->SetCenter();
$graph->Add($p2);

$p3 = new LinePlot($y2_axis);
//$p2->mark->SetType(MARK_FILLEDCIRCLE);
//$p2->mark->SetFillColor("red");
$p3->mark->SetWidth(2);
$p3->SetColor("green");
$p3->SetCenter();
$graph->Add($p3);
 
$graph->Stroke();
 
?>