Graphique rose des vents
Posté : 13 sept. 2020, 13:38
Bonjour à tous,
Je viens d'arriver sur ce forum en connaissant déjà depuis longtemps le site de Meteo Villarzel.
J'ai un site internet de 2013 qui a été construit par un ami : Christian de Meteo Kogenheim qui a fait un énorme travail pour que le site puisse voir le jour assez rapidement.
Pour votre information je travaille avec les logiciels Cumulus et WsWin qui est en mode surveillance de fichier Weatherlink. Ma BDD a un pas de 10 minutes.
Certaines anomalies ont été constatées et je me suis mis en relation avec Pascal de Meteo Conflans en Jarnisy qui m'a bien aidé pour corriger un certain nombre de points et je le remercie encore !!!
Aujourd'hui j'ai deux points qui restent encore ouverts sur mes graphiques de rose des vents.
Je vais commencer par vous exposer mon premier problème sur ma page relevés en cours:
http://www.meteo-offenheim.fr/releves_en_cours.php
Le cumul des pourcentage de la rose des vents ne fait pas 100%, la raison, la programmation a été effectuée de telle sorte à ce que l'on part d’un diviseur fixe (144 pour 24 heures : come indiqué j'ai un pas de 10 minutes dans ma BDD). Mais ça maintenant c’est faux étant donné que je ne tiens plus compte des valeurs de rafales à zéro. Comment corriger ce premier point ?
Désolé mais comme vous pouvez le comprendre je suis amateur dans tout cela....
Vous trouverez ci dessous le script :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15">
<title>Météo Stutzheim-Offenheim / Graphique dynamique girouette sur 24 heures</title>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="../highcharts3/js/highcharts.js"></script>
<script type="text/javascript" src="../highcharts3/js/highcharts-more.js"></script>
<script type="text/javascript" src="../highcharts3/js/modules/data.js"></script>
<script type="text/javascript" src="../highcharts3/js/themes/grid.js"></script>
<link href="http://ajax.googleapis.com/ajax/libs/jq ... ery-ui.css" rel="stylesheet"/>
<style type ='text/css'></style>
<script type="text/javascript">
$(function () {
// Parse the data from an inline table using the Highcharts Data plugin
Highcharts.data({
table: 'freq',
startRow: 1,
endRow: 17,
endColumn: 7,
complete: function (options) {
// Some further processing of the options
options.series.reverse(); // to get the stacking right
// Create the chart
window.chart = new Highcharts.Chart(Highcharts.merge(options, {
chart: {
renderTo: 'container',
polar: true,
type: 'area',
borderWidth: 2,
borderColor: '#8eb5d8',
borderRadius: 15,
marginTop: 8,
marginBottom: 30,
marginLeft: 8,
marginRight: 8,
backgroundColor: '#cce0ed'
},
title: {
text: ''
},
credits: { enabled: false },
pane: {
size: '85%'
},
legend: {
layout: 'horizontal',
align: 'center',
x: 10,
verticalAlign: 'bottom',
y: 10,
floating: true,
backgroundColor: false,
borderColor: null,
itemStyle: { color: 'black', font: 'normal 11px sans-serif', paddingBottom: '2px'}
},
xAxis: {
tickmarkPlacement: 'on'
},
yAxis: {
min: 0,
endOnTick: false,
showLastLabel: true,
title: {
text: 'Pourcentage (%)'
},
labels: {
formatter: function () {
return this.value + '%';
}
}
},
tooltip: {
valueSuffix: '%'
},
plotOptions: {
series: {
stacking: 'normal',
shadow: false,
groupPadding: 0,
pointPlacement: 'on'
}
}
}));
}
});
});
<?php
// $nb_enreg = 143 ;
$nb_enreg = 144 ;
require_once ("../Includes/DBConn.php");
//memorisation de la date et de l'heure
// $date_actuelle = mktime(date("H"),(intval(date("i")*0.1))*10,0,date("m"),date("d"),date("Y")) + date("Z") ;
$date_actuelle = mktime(date("H"),(intval(date("i")*0.1))*10,0,date("m"),date("d"),date("Y")) ;
// connexion à la base mysql
$link = connectToDB() ;
// calcul l'heure du premier relevé
$date_recherche = date("Y-m-d", $date_actuelle - 86400) ;
$heure_recherche = date("H:i:s" , $date_actuelle - 86400) ;
$depart = strtotime($date_recherche . " " . $heure_recherche)*1000 ;
//lance le chargement des données
for ($i = 1 ; $i <= 16 ; $i++) {
$pos[$i] = 0 ;
}
for ($i = 0 ; $i <= $nb_enreg ; $i++) {
//calcul la date et l'heure à chercher
$date_recherche = date("Y-m-d", $date_actuelle - (86400-($i*600))) ;
$heure_recherche = date("H:i:s" , $date_actuelle - (86400-($i*600))) ;
//recherche dans la base
$strQuery = "select * from wswin where date='" . $date_recherche . "' and horaire='" . $heure_recherche . "' and rafale>'0'" ;
$result = mysqli_query($link,$strQuery) or die(mysql_error()) ;
//lecture des réponses
$trouve = 0 ;
if ($result) {
while($data = mysqli_fetch_array($result)) {
if (($data["direction"]>=349) || ($data["direction"]<=11)) {
$pos[1] += 1 ;
}
if (($data["direction"]>=12) && ($data["direction"]<=33)) {
$pos[2] += 1 ;
}
if (($data["direction"]>=34) && ($data["direction"]<=55)) {
$pos[3] += 1 ;
}
if (($data["direction"]>=56) && ($data["direction"]<=78)) {
$pos[4] += 1 ;
}
if (($data["direction"]>=79) && ($data["direction"]<=101)) {
$pos[5] += 1 ;
}
if (($data["direction"]>=102) && ($data["direction"]<=123)) {
$pos[6] += 1 ;
}
if (($data["direction"]>=124) && ($data["direction"]<=146)) {
$pos[7] += 1 ;
}
if (($data["direction"]>=147) && ($data["direction"]<=168)) {
$pos[8] += 1 ;
}
if (($data["direction"]>=169) && ($data["direction"]<=190)) {
$pos[9] += 1 ;
}
if (($data["direction"]>=191) && ($data["direction"]<=213)) {
$pos[10] += 1 ;
}
if (($data["direction"]>=214) && ($data["direction"]<=235)) {
$pos[11] += 1 ;
}
if (($data["direction"]>=236) && ($data["direction"]<=258)) {
$pos[12] += 1 ;
}
if (($data["direction"]>=259) && ($data["direction"]<=281)) {
$pos[13] += 1 ;
}
if (($data["direction"]>=282) && ($data["direction"]<=303)) {
$pos[14] += 1 ;
}
if (($data["direction"]>=304) && ($data["direction"]<=326)) {
$pos[15] += 1 ;
}
if (($data["direction"]>=327) && ($data["direction"]<=348)) {
$pos[16] += 1 ;
}
}
}
}
// calcul le total de positions
$total = 0 ;
for ($i = 1 ; $i <= 16 ; $i++) {
$total += $pos[$i] ;
}
// calcul le pourcentage de chaque position et l'intègre dans les données pour le graphique
$donnees[] = ($pos[1] * 100) / $total ;
for ($i = 16 ; $i >= 2 ; $i--) {
$donnees[] = ($pos[$i] * 100) / $total ;
}
//déconnexion de la base
mysqli_close($link) ;
?>
</script>
</head>
<body>
<!-- 3. Add the container -->
<div id="container" style="width: 390px; height: 370px; margin: 0 auto"></div>
<div style="display:none">
<table id="freq" border="0" cellspacing="0" cellpadding="0">
<tr nowrap bgcolor="#CCCCFF">
<th colspan="9" class="hdr">Table of Frequencies (percent)</th>
</tr>
<tr nowrap bgcolor="#CCCCFF">
<th class="freq">Direction</th>
<th class="freq">% de distribution du vent</th>
</tr>
<tr nowrap>
<td class="dir">N</td>
<td class="data"><?php echo $pos[1]; ?></td>
</tr>
<tr nowrap bgcolor="#DDDDDD">
<td class="dir">NNE</td>
<td class="data"><?php echo $pos[2]; ?></td>
</tr>
<tr nowrap>
<td class="dir">NE</td>
<td class="data"><?php echo $pos[3]; ?></td>
</tr>
<tr nowrap bgcolor="#DDDDDD">
<td class="dir">ENE</td>
<td class="data"><?php echo $pos[4]; ?></td>
</tr>
<tr nowrap>
<td class="dir">E</td>
<td class="data"><?php echo $pos[5]; ?></td>
</tr>
<tr nowrap bgcolor="#DDDDDD">
<td class="dir">ESE</td>
<td class="data"><?php echo $pos[6]; ?></td>
</tr>
<tr nowrap>
<td class="dir">SE</td>
<td class="data"><?php echo $pos[7]; ?></td>
</tr>
<tr nowrap bgcolor="#DDDDDD">
<td class="dir">SSE</td>
<td class="data"><?php echo $pos[8]; ?></td>
</tr>
<tr nowrap>
<td class="dir">S</td>
<td class="data"><?php echo $pos[9]; ?></td>
</tr>
<tr nowrap bgcolor="#DDDDDD">
<td class="dir">SSO</td>
<td class="data"><?php echo $pos[10]; ?></td>
</tr>
<tr nowrap>
<td class="dir">SO</td>
<td class="data"><?php echo $pos[11]; ?></td>
</tr>
<tr nowrap bgcolor="#DDDDDD">
<td class="dir">WSO</td>
<td class="data"><?php echo $pos[12]; ?></td>
</tr>
<tr nowrap>
<td class="dir">O</td>
<td class="data"><?php echo $pos[13]; ?></td>
</tr>
<tr nowrap bgcolor="#DDDDDD">
<td class="dir">ONO</td>
<td class="data"><?php echo $pos[14]; ?></td>
</tr>
<tr nowrap>
<td class="dir">NO</td>
<td class="data"><?php echo $pos[15]; ?></td>
</tr>
<tr nowrap bgcolor="#DDDDDD">
<td class="dir">NNO</td>
<td class="data"><?php echo $pos[16]; ?></td>
</tr>
</table>
</div>
</body>
</html>
D'avance merci
Je viens d'arriver sur ce forum en connaissant déjà depuis longtemps le site de Meteo Villarzel.
J'ai un site internet de 2013 qui a été construit par un ami : Christian de Meteo Kogenheim qui a fait un énorme travail pour que le site puisse voir le jour assez rapidement.
Pour votre information je travaille avec les logiciels Cumulus et WsWin qui est en mode surveillance de fichier Weatherlink. Ma BDD a un pas de 10 minutes.
Certaines anomalies ont été constatées et je me suis mis en relation avec Pascal de Meteo Conflans en Jarnisy qui m'a bien aidé pour corriger un certain nombre de points et je le remercie encore !!!
Aujourd'hui j'ai deux points qui restent encore ouverts sur mes graphiques de rose des vents.
Je vais commencer par vous exposer mon premier problème sur ma page relevés en cours:
http://www.meteo-offenheim.fr/releves_en_cours.php
Le cumul des pourcentage de la rose des vents ne fait pas 100%, la raison, la programmation a été effectuée de telle sorte à ce que l'on part d’un diviseur fixe (144 pour 24 heures : come indiqué j'ai un pas de 10 minutes dans ma BDD). Mais ça maintenant c’est faux étant donné que je ne tiens plus compte des valeurs de rafales à zéro. Comment corriger ce premier point ?
Désolé mais comme vous pouvez le comprendre je suis amateur dans tout cela....
Vous trouverez ci dessous le script :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15">
<title>Météo Stutzheim-Offenheim / Graphique dynamique girouette sur 24 heures</title>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="../highcharts3/js/highcharts.js"></script>
<script type="text/javascript" src="../highcharts3/js/highcharts-more.js"></script>
<script type="text/javascript" src="../highcharts3/js/modules/data.js"></script>
<script type="text/javascript" src="../highcharts3/js/themes/grid.js"></script>
<link href="http://ajax.googleapis.com/ajax/libs/jq ... ery-ui.css" rel="stylesheet"/>
<style type ='text/css'></style>
<script type="text/javascript">
$(function () {
// Parse the data from an inline table using the Highcharts Data plugin
Highcharts.data({
table: 'freq',
startRow: 1,
endRow: 17,
endColumn: 7,
complete: function (options) {
// Some further processing of the options
options.series.reverse(); // to get the stacking right
// Create the chart
window.chart = new Highcharts.Chart(Highcharts.merge(options, {
chart: {
renderTo: 'container',
polar: true,
type: 'area',
borderWidth: 2,
borderColor: '#8eb5d8',
borderRadius: 15,
marginTop: 8,
marginBottom: 30,
marginLeft: 8,
marginRight: 8,
backgroundColor: '#cce0ed'
},
title: {
text: ''
},
credits: { enabled: false },
pane: {
size: '85%'
},
legend: {
layout: 'horizontal',
align: 'center',
x: 10,
verticalAlign: 'bottom',
y: 10,
floating: true,
backgroundColor: false,
borderColor: null,
itemStyle: { color: 'black', font: 'normal 11px sans-serif', paddingBottom: '2px'}
},
xAxis: {
tickmarkPlacement: 'on'
},
yAxis: {
min: 0,
endOnTick: false,
showLastLabel: true,
title: {
text: 'Pourcentage (%)'
},
labels: {
formatter: function () {
return this.value + '%';
}
}
},
tooltip: {
valueSuffix: '%'
},
plotOptions: {
series: {
stacking: 'normal',
shadow: false,
groupPadding: 0,
pointPlacement: 'on'
}
}
}));
}
});
});
<?php
// $nb_enreg = 143 ;
$nb_enreg = 144 ;
require_once ("../Includes/DBConn.php");
//memorisation de la date et de l'heure
// $date_actuelle = mktime(date("H"),(intval(date("i")*0.1))*10,0,date("m"),date("d"),date("Y")) + date("Z") ;
$date_actuelle = mktime(date("H"),(intval(date("i")*0.1))*10,0,date("m"),date("d"),date("Y")) ;
// connexion à la base mysql
$link = connectToDB() ;
// calcul l'heure du premier relevé
$date_recherche = date("Y-m-d", $date_actuelle - 86400) ;
$heure_recherche = date("H:i:s" , $date_actuelle - 86400) ;
$depart = strtotime($date_recherche . " " . $heure_recherche)*1000 ;
//lance le chargement des données
for ($i = 1 ; $i <= 16 ; $i++) {
$pos[$i] = 0 ;
}
for ($i = 0 ; $i <= $nb_enreg ; $i++) {
//calcul la date et l'heure à chercher
$date_recherche = date("Y-m-d", $date_actuelle - (86400-($i*600))) ;
$heure_recherche = date("H:i:s" , $date_actuelle - (86400-($i*600))) ;
//recherche dans la base
$strQuery = "select * from wswin where date='" . $date_recherche . "' and horaire='" . $heure_recherche . "' and rafale>'0'" ;
$result = mysqli_query($link,$strQuery) or die(mysql_error()) ;
//lecture des réponses
$trouve = 0 ;
if ($result) {
while($data = mysqli_fetch_array($result)) {
if (($data["direction"]>=349) || ($data["direction"]<=11)) {
$pos[1] += 1 ;
}
if (($data["direction"]>=12) && ($data["direction"]<=33)) {
$pos[2] += 1 ;
}
if (($data["direction"]>=34) && ($data["direction"]<=55)) {
$pos[3] += 1 ;
}
if (($data["direction"]>=56) && ($data["direction"]<=78)) {
$pos[4] += 1 ;
}
if (($data["direction"]>=79) && ($data["direction"]<=101)) {
$pos[5] += 1 ;
}
if (($data["direction"]>=102) && ($data["direction"]<=123)) {
$pos[6] += 1 ;
}
if (($data["direction"]>=124) && ($data["direction"]<=146)) {
$pos[7] += 1 ;
}
if (($data["direction"]>=147) && ($data["direction"]<=168)) {
$pos[8] += 1 ;
}
if (($data["direction"]>=169) && ($data["direction"]<=190)) {
$pos[9] += 1 ;
}
if (($data["direction"]>=191) && ($data["direction"]<=213)) {
$pos[10] += 1 ;
}
if (($data["direction"]>=214) && ($data["direction"]<=235)) {
$pos[11] += 1 ;
}
if (($data["direction"]>=236) && ($data["direction"]<=258)) {
$pos[12] += 1 ;
}
if (($data["direction"]>=259) && ($data["direction"]<=281)) {
$pos[13] += 1 ;
}
if (($data["direction"]>=282) && ($data["direction"]<=303)) {
$pos[14] += 1 ;
}
if (($data["direction"]>=304) && ($data["direction"]<=326)) {
$pos[15] += 1 ;
}
if (($data["direction"]>=327) && ($data["direction"]<=348)) {
$pos[16] += 1 ;
}
}
}
}
// calcul le total de positions
$total = 0 ;
for ($i = 1 ; $i <= 16 ; $i++) {
$total += $pos[$i] ;
}
// calcul le pourcentage de chaque position et l'intègre dans les données pour le graphique
$donnees[] = ($pos[1] * 100) / $total ;
for ($i = 16 ; $i >= 2 ; $i--) {
$donnees[] = ($pos[$i] * 100) / $total ;
}
//déconnexion de la base
mysqli_close($link) ;
?>
</script>
</head>
<body>
<!-- 3. Add the container -->
<div id="container" style="width: 390px; height: 370px; margin: 0 auto"></div>
<div style="display:none">
<table id="freq" border="0" cellspacing="0" cellpadding="0">
<tr nowrap bgcolor="#CCCCFF">
<th colspan="9" class="hdr">Table of Frequencies (percent)</th>
</tr>
<tr nowrap bgcolor="#CCCCFF">
<th class="freq">Direction</th>
<th class="freq">% de distribution du vent</th>
</tr>
<tr nowrap>
<td class="dir">N</td>
<td class="data"><?php echo $pos[1]; ?></td>
</tr>
<tr nowrap bgcolor="#DDDDDD">
<td class="dir">NNE</td>
<td class="data"><?php echo $pos[2]; ?></td>
</tr>
<tr nowrap>
<td class="dir">NE</td>
<td class="data"><?php echo $pos[3]; ?></td>
</tr>
<tr nowrap bgcolor="#DDDDDD">
<td class="dir">ENE</td>
<td class="data"><?php echo $pos[4]; ?></td>
</tr>
<tr nowrap>
<td class="dir">E</td>
<td class="data"><?php echo $pos[5]; ?></td>
</tr>
<tr nowrap bgcolor="#DDDDDD">
<td class="dir">ESE</td>
<td class="data"><?php echo $pos[6]; ?></td>
</tr>
<tr nowrap>
<td class="dir">SE</td>
<td class="data"><?php echo $pos[7]; ?></td>
</tr>
<tr nowrap bgcolor="#DDDDDD">
<td class="dir">SSE</td>
<td class="data"><?php echo $pos[8]; ?></td>
</tr>
<tr nowrap>
<td class="dir">S</td>
<td class="data"><?php echo $pos[9]; ?></td>
</tr>
<tr nowrap bgcolor="#DDDDDD">
<td class="dir">SSO</td>
<td class="data"><?php echo $pos[10]; ?></td>
</tr>
<tr nowrap>
<td class="dir">SO</td>
<td class="data"><?php echo $pos[11]; ?></td>
</tr>
<tr nowrap bgcolor="#DDDDDD">
<td class="dir">WSO</td>
<td class="data"><?php echo $pos[12]; ?></td>
</tr>
<tr nowrap>
<td class="dir">O</td>
<td class="data"><?php echo $pos[13]; ?></td>
</tr>
<tr nowrap bgcolor="#DDDDDD">
<td class="dir">ONO</td>
<td class="data"><?php echo $pos[14]; ?></td>
</tr>
<tr nowrap>
<td class="dir">NO</td>
<td class="data"><?php echo $pos[15]; ?></td>
</tr>
<tr nowrap bgcolor="#DDDDDD">
<td class="dir">NNO</td>
<td class="data"><?php echo $pos[16]; ?></td>
</tr>
</table>
</div>
</body>
</html>
D'avance merci