Tuto "Rose des Vents" HighCharts

Vous avez créé un tutoriel, postez-le ici

Modérateurs : jturlier, Météo Villarzel

Avatar du membre
helmain
Administrateur du site
Messages : 54
Enregistré le : 09 févr. 2014, 12:44
Localisation : FRANCE - Lagny-sur-Marne (77)
Contact :

Re: Tuto "Rose des Vents" HighCharts

Message par helmain » 29 mai 2014, 18:28

Jean,

Pourquoi un elseif en dernier ??
Parce que dans de furieux copier/coller je ne me suis pas rendu compte que j'étais arrivé à la fin.
Mais tu as raison, en dernier il faut mettre un else et indiquer tout de suite la valeur à donner.
Ce else traite normalement tous les cas non vus avant, et évite de ce fait un planton.
Donc je corrige !!

Pour les if(!isset($gustN2)) {$gustN2="0.00";}
Si le vent n'a pas soufflé dans une direction, les requêtes ne trouveront rien dans la table.
Pourtant il me faut quelque chose à mettre dans la rose de vents.
La fonction isset() indique si une variables est définie.
Le ' ! ' placé avant renvoie l'inverse de la fonction, donc placé devant isset() veut dire si la variable n'est pas définie.
Donc en clair if(!isset($gustN2)) {$gustN2="0.00";} veut dire si le vent n' a pas soufflé du nord, alors je définis cette valeur avec 0.00

Ca te va Jean ?
Station Vantage Pro2 + Soil/Leaf + Anémomètre déporté - Weatherlink 6.0.3 - Weather Display 10.37S build 84 - Cumulus 1.9.4 build 1099 - GraphWeather 3.0.28 - Windows 10/64 - VP2SQL + WDTU 1.2 pour Envoy8x - Hébergé par o2switch (MySql/PgSql)

Image

Avatar du membre
Landéda
Messages : 35
Enregistré le : 01 avr. 2014, 01:35

Re: Tuto "Rose des Vents" HighCharts

Message par Landéda » 30 mai 2014, 01:40

Bonjour ou bonsoir( Jean Michel et les autres)
Si ce "elseif en dernier" m'a intrigué c'est uniquement car tu me l'avais expliqué précédemment dans un mail .
Mais encore une question, c'est sur $nombre, j'ai peur de me planter mais tant pis .
On veut compter "le nombre d'enregistrements qu'il y a eu durant ces 24 heures". Si on a un enregistrement toutes les 5 minutes ( 300sec), en 24 H (86400 sec) pourquoi on n'a pas tout simplement (86400/300)=288 enregistrements ? Ou une fois de plus j'ai pas tout compris ?
Jean
Station Vantage pro
http://www.meteo-landeda.org/
Linux
WeeWX
MesoWx

Avatar du membre
helmain
Administrateur du site
Messages : 54
Enregistré le : 09 févr. 2014, 12:44
Localisation : FRANCE - Lagny-sur-Marne (77)
Contact :

Re: Tuto "Rose des Vents" HighCharts

Message par helmain » 30 mai 2014, 18:51

Jean,

Je suis OK un enregistrement toutes les 5 minutes = 288/jour.
Mais voilà, tu vas vite te rendre compte que certains jours, est-ce à cause de la météo, des enregistrements passent à la trappe !
Des jours avec 275 enregistrements ne sont pas exceptionnels !!
Alors tu fais comme tu veux, mais afin d'avoir un taux correct, le mieux est de les compter, en plus c'est très vite fait.
Station Vantage Pro2 + Soil/Leaf + Anémomètre déporté - Weatherlink 6.0.3 - Weather Display 10.37S build 84 - Cumulus 1.9.4 build 1099 - GraphWeather 3.0.28 - Windows 10/64 - VP2SQL + WDTU 1.2 pour Envoy8x - Hébergé par o2switch (MySql/PgSql)

Image

Avatar du membre
Landéda
Messages : 35
Enregistré le : 01 avr. 2014, 01:35

Re: Tuto "Rose des Vents" HighCharts jusque là ça va !

Message par Landéda » 10 juin 2014, 21:56

Bonsoir à tous
J’espère ne pas trop vous perturber, Je l’ai déjà dit Php et Mysql je débarque.
Je me suis donc procuré un livre que voici , en papier, je suis de la vieille école , et le site qui va avecici
Premier problème :
Pour une connexion à la base ils utilisent PDO ……
quand je cherche des renseignements sur mysql_query , je trouve :
Cette extension est obsolète depuis PHP 5.5.0, et sera supprimée dans le futur. À la place, les extensions MySQLi ou PDO_MySQL doivent être utilisées.
Je patauge encore plus et donc je bidouille
Concernant le Tutoriel Rose des vents , voilà où j’en suis
<?php
require("graph/mysql_connect.php");

$sql="select max(tstamp) from data";
$query=mysql_query($sql);
$list=mysql_fetch_array($query);
$stop=$list[0];
$start=$stop-(86400);

$sql="Select count(*) from data where tstamp > '$start' and tstamp <= '$stop'";
$query=mysql_query($sql);
$result=mysql_fetch_array($query);
$nombre = $result[0];

// V<5
$sql="Select winddir, count(*) from data where tstamp > '$start' and tstamp <= '$stop' and windgust < 5 group by 1 order by 1 ";
$query=mysql_query($sql);
$result=mysql_fetch_array($query);
$dir = $result[0];
Maintenant il faut placer un while......, la boucle et le test .....
Comment tout celà s'articule ?
Où trouver de la doc ?
Merci
Jean
Station Vantage pro
http://www.meteo-landeda.org/
Linux
WeeWX
MesoWx

Avatar du membre
Météo Villarzel
Administrateur du site
Messages : 524
Enregistré le : 06 févr. 2014, 09:48
Contact :

Re: Tuto "Rose des Vents" HighCharts

Message par Météo Villarzel » 11 juin 2014, 00:15

Salut Jean
pour MYSQLi, Jean-Michel à donné la solution ici, mais j'avoue que je n'ai pas encore eu le temps de changer tous mes graphiques :roll:
http://www.boock.ch/meteo/forum/viewtop ... ySQLi#p185

A+
Station Vantage Pro2+ avec station agricole - Weatherlink - GraphWeather 3.0.15b - Cumulus 1.9.4 - Windows 7/64
Graphique dynamique à partir d'une bd MySql - VP2SQL

Image

Avatar du membre
Landéda
Messages : 35
Enregistré le : 01 avr. 2014, 01:35

Re: Tuto "Rose des Vents" HighCharts

Message par Landéda » 18 juin 2014, 23:08

Pierre André, merci pour ton soutien
(Je me suis absenté, ce qui explique mon retard dans cette réponse)
Je continue "mes travaux"
Cordialement
Jean
Station Vantage pro
http://www.meteo-landeda.org/
Linux
WeeWX
MesoWx

Météo-Achiet
Messages : 27
Enregistré le : 03 déc. 2014, 15:44
Localisation : Pas de Calais
Contact :

Re: Tuto "Rose des Vents" HighCharts

Message par Météo-Achiet » 04 avr. 2017, 09:35

Salut Pascal
Je relance le post car j'ai suivi ton tuto sauf que j'ai un renvoi d'erreur et je ne comprends pas le problème.
il commence la boucle et plante en plein milieu:

erreur:

Notice: Undefined variable: gust in /media/......./websites/meteo-achiet.tk/SQL/rose_des_vents.php on line 32
Fatal error: Unsupported operand types in /media/......./websites/meteo-achiet.tk/SQL/rose_des_vents.php on line 32

code:

if ($dir[$i]==0) {$gustN1=round($gust[$i]/$nombre*100,2);}
elseif ($dir[$i]==22) {$gustNNE1=round($gust[$i]/$nombre*100,2);}
elseif ($dir[$i]==45) {$gustNE1=round($gust[$i]/$nombre*100,2);}
elseif ($dir[$i]==68) {$gustENE1=round($gust[$i]/$nombre*100,2);}
elseif ($dir[$i]==90) {$gustE1=round($gust[$i]/$nombre*100,2);}
elseif ($dir[$i]==112) {$gustESE1=round($gust[$i]/$nombre*100,2);}
elseif ($dir[$i]==135) {$gustSE1=round($gust[$i]/$nombre*100,2);}
elseif ($dir[$i]==158) {$gustSSE1=round($gust[$i]/$nombre*100,2);} <--- ligne 32
elseif ($dir[$i]==180) {$gustS1=round($gust[$i]/$nombre*100,2);}
elseif ($dir[$i]==202) {$gustSSO1=round($gust[$i]/$nombre*100,2);}
elseif ($dir[$i]==225){$gustSO1=round($gust[$i]/$nombre*100,2);}
elseif ($dir[$i]==248){$gustOSO1=round($gust[$i]/$nombre*100,2);}
elseif ($dir[$i]==270){$gustO1=round($gust[$i]/$nombre*100,2);}
elseif ($dir[$i]==292){$gustONO1=round($gust[$i]/$nombre*100,2);}
elseif ($dir[$i]==315){$gustNO1=round($gust[$i]/$nombre*100,2);}
else {$gustNNO1=round($gust[$i]/$nombre*100,2);}

Merci d'éclairer ma vieille lanterne
Pierre
Davis VP2 6152EU
data logger+VirtualVP1.2.5+cumulus 1.9.4+Cumulus2SQL_1_0_4_19+NOAAtableNew_1_0_1_4
WampServer Version 3.1.9
http://www.meteo-achiet.infos.st/index.php

Avatar du membre
jturlier
Administrateur du site
Messages : 393
Enregistré le : 10 déc. 2014, 10:20
Localisation : Sérignan 34410
Contact :

Re: Tuto "Rose des Vents" HighCharts

Message par jturlier » 05 avr. 2017, 19:35

Bonsoir Pierre,
il est probable que tu n'as eu aucune rafale en provenance du SSE, ce qui fait que $gust[$i] ne contient rien et est undefined.
De plus si tu prends les données dans la base de données, il est probable que 158° n'existe pas et que ce soit la même chose pour toutes les valeurs non divisibles par 22.5.
Ma base de données a été quelque peu modifiée par rapport aux versions disponibles et qu'ici, j'ai des décimales pour les points cardinaux intermédiaires.
Jean

Station :
VP2pro + anémomètre ultrasons et console Vue
Cumulus 1.9.4 + Cumulus2SQL + MySQL

Audio :
FR
PC :
W10 64bits migré
http://meteoserignan.ddns.net
Image

Météo-Achiet
Messages : 27
Enregistré le : 03 déc. 2014, 15:44
Localisation : Pas de Calais
Contact :

Re: Tuto "Rose des Vents" HighCharts

Message par Météo-Achiet » 10 avr. 2017, 10:48

Salut Jean
Merci. J'y avais pensé à cette histoire de décimale.
Je vais y regarder de plus près.
Bonne journée
Davis VP2 6152EU
data logger+VirtualVP1.2.5+cumulus 1.9.4+Cumulus2SQL_1_0_4_19+NOAAtableNew_1_0_1_4
WampServer Version 3.1.9
http://www.meteo-achiet.infos.st/index.php

Avatar du membre
PascalWMR
Messages : 323
Enregistré le : 16 févr. 2014, 09:28
Localisation : CONFLANS EN JARNISY (F54800)
Contact :

Re: Tuto "Rose des Vents" HighCharts

Message par PascalWMR » 11 avr. 2017, 17:44

Salut tous le monde.

J'ai eu ce problème. Effectivement, je ne sait pas pourquoi, weatherlink nous sort des directions bizarres.
Il n'y a pas que 158 qui est concerné mais 22, 68, 112, 158, 202, 248, 292, 338
voici comment j'ai résolu le problème.

Code : Tout sélectionner

// Initialisation (mise à 0 des forces et directions)
$gustN1 = "0.00" ;
$gustN2 = "0.00" ;
$gustN3 = "0.00" ;
$gustN4 = "0.00" ;
$gustN5 = "0.00" ;
$gustN6 = "0.00" ;
$gustN7 = "0.00" ;
$gustNNE1 = "0.00";
$gustNNE2 = "0.00";
$gustNNE3 = "0.00";
$gustNNE4 = "0.00";
$gustNNE5 = "0.00";
$gustNNE6 = "0.00";
$gustNNE7 = "0.00";
$gustNE1 = "0.00";
$gustNE2 = "0.00";
$gustNE3 = "0.00";
$gustNE4 = "0.00";
$gustNE5 = "0.00";
$gustNE6 = "0.00";
$gustNE7 = "0.00";
$gustENE1 = "0.00";
$gustENE2 = "0.00";
$gustENE3 = "0.00";
$gustENE4 = "0.00";
$gustENE5 = "0.00";
$gustENE6 = "0.00";
$gustENE7 = "0.00";
$gustE1 = "0.00";
$gustE2 = "0.00";
$gustE3 = "0.00";
$gustE4 = "0.00";
$gustE5 = "0.00";
$gustE6 = "0.00";
$gustE7 = "0.00";
$gustESE1 = "0.00";
$gustESE2 = "0.00";
$gustESE3 = "0.00";
$gustESE4 = "0.00";
$gustESE5 = "0.00";
$gustESE6 = "0.00";
$gustESE7 = "0.00";
$gustSE1 = "0.00";
$gustSE2 = "0.00";
$gustSE3 = "0.00";
$gustSE4 = "0.00";
$gustSE5 = "0.00";
$gustSE6 = "0.00";
$gustSE7 = "0.00";
$gustSSE1 = "0.00";
$gustSSE2 = "0.00";
$gustSSE3 = "0.00";
$gustSSE4 = "0.00";
$gustSSE5 = "0.00";
$gustSSE6 = "0.00";
$gustSSE7 = "0.00";
$gustS1 = "0.00";
$gustS2 = "0.00";
$gustS3 = "0.00";
$gustS4 = "0.00";
$gustS5 = "0.00";
$gustS6 = "0.00";
$gustS7 = "0.00";
$gustSSO1 = "0.00";
$gustSSO2 = "0.00";
$gustSSO3 = "0.00";
$gustSSO4 = "0.00";
$gustSSO5 = "0.00";
$gustSSO6 = "0.00";
$gustSSO7 = "0.00";
$gustSO1 = "0.00";
$gustSO2 = "0.00";
$gustSO3 = "0.00";
$gustSO4 = "0.00";
$gustSO5 = "0.00";
$gustSO6 = "0.00";
$gustSO7 = "0.00";
$gustOSO1 = "0.00";
$gustOSO2 = "0.00";
$gustOSO3 = "0.00";
$gustOSO4 = "0.00";
$gustOSO5 = "0.00";
$gustOSO6 = "0.00";
$gustOSO7 = "0.00";
$gustO1 = "0.00";
$gustO2 = "0.00";
$gustO3 = "0.00";
$gustO4 = "0.00";
$gustO5 = "0.00";
$gustO6 = "0.00";
$gustO7 = "0.00";
$gustONO1 = "0.00";
$gustONO2 = "0.00";
$gustONO3 = "0.00";
$gustONO4 = "0.00";
$gustONO5 = "0.00";
$gustONO6 = "0.00";
$gustONO7 = "0.00";
$gustNO1 = "0.00";
$gustNO2 = "0.00";
$gustNO3 = "0.00";
$gustNO4 = "0.00";
$gustNO5 = "0.00";
$gustNO6 = "0.00";
$gustNO7 = "0.00";
$gustNNO1 = "0.00";
$gustNNO2 = "0.00";
$gustNNO3 = "0.00";
$gustNNO4 = "0.00";
$gustNNO5 = "0.00";
$gustNNO6 = "0.00";
$gustNNO7 = "0.00";

// Pour chaque directions (1ère boucle if) et pour chaque forces (2ème boucle if) on compte le nombre d'enregistrements
while ($list = mysqli_fetch_assoc($query)) {      
	$dirvent[$i]=$list['winddir']*1;
	$gust[$i]=$list['windgust']*1;
		if (($dirvent[$i]==0)||($dirvent[$i]==360)) { // Vent -> N
			if ($gust[$i] < 5 ) {$ventN1++ ;}
			elseif ($gust[$i]>=5 and $gust[$i]<16) {$ventN2++ ;}
			elseif ($gust[$i]>15 and $gust[$i]<26) {$ventN3++ ;}
			elseif ($gust[$i]>25 and $gust[$i]<36) {$ventN4++ ;}
			elseif ($gust[$i]>35 and $gust[$i]<51) {$ventN5++ ;}
			elseif ($gust[$i]>50 and $gust[$i]<81) {$ventN6++ ;}
			elseif ($gust[$i]>80) {$gustN7++ ;}
			;}
			
		elseif (($dirvent[$i]==22) || ($dirvent[$i]==22.5)) { // Vent NNE
			if ($gust[$i] < 5 ) {$ventNNE1++ ;}
			elseif ($gust[$i]>=5 and $gust[$i]<16) {$ventNNE2++ ;}
			elseif ($gust[$i]>15 and $gust[$i]<26) {$ventNNE3++ ;}
			elseif ($gust[$i]>25 and $gust[$i]<36) {$ventNNE4++ ;}
			elseif ($gust[$i]>35 and $gust[$i]<51) {$ventNNE5++ ;}
			elseif ($gust[$i]>50 and $gust[$i]<81) {$ventNNE6++ ;}
			elseif ($gust[$i]>80) {$ventNNE7++ ;}
			;}
			
		elseif ($dirvent[$i]==45) { // Vent NE
			if ($gust[$i] < 5 ) {$ventNE1++ ;}
			elseif ($gust[$i]>=5 and $gust[$i]<16) {$ventNE2++ ;}
			elseif ($gust[$i]>15 and $gust[$i]<26) {$ventNE3++ ;}
			elseif ($gust[$i]>25 and $gust[$i]<36) {$ventNE4++ ;}
			elseif ($gust[$i]>35 and $gust[$i]<51) {$ventNE5++ ;}
			elseif ($gust[$i]>50 and $gust[$i]<81) {$ventNE6++ ;}
			elseif ($gust[$i]>80) {$ventNE7++ ;}
			;}
			
		elseif (($dirvent[$i]==67.5) || ($dirvent[$i]==68)) { // Vent ENE
			if ($gust[$i] < 5 ) {$ventENE1++ ;}
			elseif ($gust[$i]>=5 and $gust[$i]<16) {$ventENE2++ ;}
			elseif ($gust[$i]>15 and $gust[$i]<26) {$ventENE3++ ;}
			elseif ($gust[$i]>25 and $gust[$i]<36) {$ventENE4++ ;}
			elseif ($gust[$i]>35 and $gust[$i]<51) {$ventENE5++ ;}
			elseif ($gust[$i]>50 and $gust[$i]<81) {$ventENE6++ ;}
			elseif ($gust[$i]>80) {$ventENE7++ ;}
			;}
			
		elseif ($dirvent[$i]==90) { // Vent E
			if ($gust[$i] < 5 ) {$ventE1++ ;}
			elseif ($gust[$i]>=5 and $gust[$i]<16) {$ventE2++ ;}
			elseif ($gust[$i]>15 and $gust[$i]<26) {$ventE3++ ;}
			elseif ($gust[$i]>25 and $gust[$i]<36) {$ventE4++ ;}
			elseif ($gust[$i]>35 and $gust[$i]<51) {$ventE5++ ;}
			elseif ($gust[$i]>50 and $gust[$i]<81) {$ventE6++ ;}
			elseif ($gust[$i]>80) {$ventE7++ ;}
			;}
			
		elseif (($dirvent[$i]==112) || ($dirvent[$i]==112.5)) { // Vent ESE
			if ($gust[$i] < 5 ) {$ventESE1++ ;}
			elseif ($gust[$i]>=5 and $gust[$i]<16) {$ventESE2++ ;}
			elseif ($gust[$i]>15 and $gust[$i]<26) {$ventESE3++ ;}
			elseif ($gust[$i]>25 and $gust[$i]<36) {$ventESE4++ ;}
			elseif ($gust[$i]>35 and $gust[$i]<51) {$ventESE5++ ;}
			elseif ($gust[$i]>50 and $gust[$i]<81) {$ventESE6++ ;}
			elseif ($gust[$i]>80) {$ventESE7++ ;}
			;}
			
		elseif ($dirvent[$i]==135) { // Vent SE
			if ($gust[$i] < 5 ) {$ventSE1++ ;}
			elseif ($gust[$i]>=5 and $gust[$i]<16) {$ventSE2++ ;}
			elseif ($gust[$i]>15 and $gust[$i]<26) {$ventSE3++ ;}
			elseif ($gust[$i]>25 and $gust[$i]<36) {$ventSE4++ ;}
			elseif ($gust[$i]>35 and $gust[$i]<51) {$ventSE5++ ;}
			elseif ($gust[$i]>50 and $gust[$i]<81) {$ventSE6++ ;}
			elseif ($gust[$i]>80) {$ventSE7++ ;}
			;}
			
		elseif (($dirvent[$i]==157.5) || ($dirvent[$i]==158)) { // Vent SSE
			if ($gust[$i] < 5 ) {$ventSSE1++ ;}
			elseif ($gust[$i]>=5 and $gust[$i]<16) {$ventSSE2++ ;}
			elseif ($gust[$i]>15 and $gust[$i]<26) {$ventSSE3++ ;}
			elseif ($gust[$i]>25 and $gust[$i]<36) {$ventSSE4++ ;}
			elseif ($gust[$i]>35 and $gust[$i]<51) {$ventSSE5++ ;}
			elseif ($gust[$i]>50 and $gust[$i]<81) {$ventSSE6++ ;}
			elseif ($gust[$i]>80) {$ventSSE7++ ;}
			;}
			
		elseif ($dirvent[$i]==180) { // Vent S
			if ($gust[$i] < 5 ) {$ventS1++ ;}
			elseif ($gust[$i]>=5 and $gust[$i]<16) {$ventS2++ ;}
			elseif ($gust[$i]>15 and $gust[$i]<26) {$ventS3++ ;}
			elseif ($gust[$i]>25 and $gust[$i]<36) {$ventS4++ ;}
			elseif ($gust[$i]>35 and $gust[$i]<51) {$ventS5++ ;}
			elseif ($gust[$i]>50 and $gust[$i]<81) {$ventS6++ ;}
			elseif ($gust[$i]>80) {$ventS7++ ;}
			;}
			
		elseif (($dirvent[$i]==202) || ($dirvent[$i]==202.5)) { // Vent SSO
			if ($gust[$i] < 5 ) {$ventSSO1++ ;}
			elseif ($gust[$i]>=5 and $gust[$i]<16) {$ventSSO2++ ;}
			elseif ($gust[$i]>15 and $gust[$i]<26) {$ventSSO3++ ;}
			elseif ($gust[$i]>25 and $gust[$i]<36) {$ventSSO4++ ;}
			elseif ($gust[$i]>35 and $gust[$i]<51) {$ventSSO5++ ;}
			elseif ($gust[$i]>50 and $gust[$i]<81) {$ventSSO6++ ;}
			elseif ($gust[$i]>80) {$ventSSO7++ ;}
			;}
			
		elseif ($dirvent[$i]==225) { // Vent SO
			if ($gust[$i] < 5 ) {$ventSO1++ ;}
			elseif ($gust[$i]>=5 and $gust[$i]<16) {$ventSO2++ ;}
			elseif ($gust[$i]>15 and $gust[$i]<26) {$ventSO3++ ;}
			elseif ($gust[$i]>25 and $gust[$i]<36) {$ventSO4++ ;}
			elseif ($gust[$i]>35 and $gust[$i]<51) {$ventSO5++ ;}
			elseif ($gust[$i]>50 and $gust[$i]<81) {$ventSO6++ ;}
			elseif ($gust[$i]>80) {$ventSO7++ ;}
			;}
			
		elseif (($dirvent[$i]==247.5) || ($dirvent[$i]==248)) { // Vent OSO
			if ($gust[$i] < 5 ) {$ventOSO1++ ;}
			elseif ($gust[$i]>=5 and $gust[$i]<16) {$ventOSO2++ ;}
			elseif ($gust[$i]>15 and $gust[$i]<26) {$ventOSO3++ ;}
			elseif ($gust[$i]>25 and $gust[$i]<36) {$ventOSO4++ ;}
			elseif ($gust[$i]>35 and $gust[$i]<51) {$ventOSO5++ ;}
			elseif ($gust[$i]>50 and $gust[$i]<81) {$ventOSO6++ ;}
			elseif ($gust[$i]>80) {$ventOSO7++ ;}
			;}
			
		elseif ($dirvent[$i]==270) { // Vent O
			if ($gust[$i] < 5 ) {$ventO1++ ;}
			elseif ($gust[$i]>=5 and $gust[$i]<16) {$ventO2++ ;}
			elseif ($gust[$i]>15 and $gust[$i]<26) {$ventO3++ ;}
			elseif ($gust[$i]>25 and $gust[$i]<36) {$ventO4++ ;}
			elseif ($gust[$i]>35 and $gust[$i]<51) {$ventO5++ ;}
			elseif ($gust[$i]>50 and $gust[$i]<81) {$ventO6++ ;}
			elseif ($gust[$i]>80) {$ventO7++ ;}
			;}
			
		elseif (($dirvent[$i]==292) || ($dirvent[$i]==292.5)) { // Vent ONO
			if ($gust[$i] < 5 ) {$ventONO1++ ;}
			elseif ($gust[$i]>=5 and $gust[$i]<16) {$ventONO2++ ;}
			elseif ($gust[$i]>15 and $gust[$i]<26) {$ventONO3++ ;}
			elseif ($gust[$i]>25 and $gust[$i]<36) {$ventONO4++ ;}
			elseif ($gust[$i]>35 and $gust[$i]<51) {$ventONO5++ ;}
			elseif ($gust[$i]>50 and $gust[$i]<81) {$ventONO6++ ;}
			elseif ($gust[$i]>80) {$ventONO7++ ;}
			;}
			
		elseif ($dirvent[$i]==315) { // Vent NO
			if ($gust[$i] < 5 ) {$ventNO1++ ;}
			elseif ($gust[$i]>=5 and $gust[$i]<16) {$ventNO2++ ;}
			elseif ($gust[$i]>15 and $gust[$i]<26) {$ventNO3++ ;}
			elseif ($gust[$i]>25 and $gust[$i]<36) {$ventNO4++ ;}
			elseif ($gust[$i]>35 and $gust[$i]<51) {$ventNO5++ ;}
			elseif ($gust[$i]>50 and $gust[$i]<81) {$ventNO6++ ;}
			elseif ($gust[$i]>80) {$ventNO7++ ;}
			;}
		elseif (($dirvent[$i]==337.5) || ($dirvent[$i]==338)) { // Vent NNO
			if ($gust[$i] < 5 ) {$ventNNO1++ ;}
			elseif ($gust[$i]>=5 and $gust[$i]<16) {$ventNNO2++ ;}
			elseif ($gust[$i]>15 and $gust[$i]<26) {$ventNNO3++ ;}
			elseif ($gust[$i]>25 and $gust[$i]<36) {$ventNNO4++ ;}
			elseif ($gust[$i]>35 and $gust[$i]<51) {$ventNNO5++ ;}
			elseif ($gust[$i]>50 and $gust[$i]<81) {$ventNNO6++ ;}
			elseif ($gust[$i]>80) {$ventNNO7++ ;}
			;}
$i++;
};

// On calcule la répartition en pourcentage pour chaque directions et chaque forces avec 2 chiffres après la virgule
$gustN1 = round($ventN1/$nombre*100,2) ;
$gustN2 = round($ventN2/$nombre*100,2) ;
$gustN3 = round($ventN3/$nombre*100,2) ;
$gustN4 = round($ventN4/$nombre*100,2) ;
$gustN5 = round($ventN5/$nombre*100,2) ;
$gustN6 = round($ventN6/$nombre*100,2) ;
$gustN7 = round($ventN7/$nombre*100,2) ;
$gustNNE1 = round($ventNNE1/$nombre*100,2) ;
$gustNNE2 = round($ventNNE2/$nombre*100,2);
$gustNNE3 = round($ventNNE3/$nombre*100,2);
$gustNNE4 = round($ventNNE4/$nombre*100,2);
$gustNNE5 = round($ventNNE5/$nombre*100,2);
$gustNNE6 = round($ventNNE6/$nombre*100,2);
$gustNNE7 = round($ventNNE7/$nombre*100,2);
$gustNE1 = round($ventNE1/$nombre*100,2) ;
$gustNE2 = round($ventNE2/$nombre*100,2);
$gustNE3 = round($ventNE3/$nombre*100,2);
$gustNE4 = round($ventNE4/$nombre*100,2);
$gustNE5 = round($ventNE5/$nombre*100,2);
$gustNE6 = round($ventNE6/$nombre*100,2);
$gustNE7 = round($ventNE7/$nombre*100,2);
$gustENE1 = round($ventENE1/$nombre*100,2) ;
$gustENE2 = round($ventENE2/$nombre*100,2);
$gustENE3 = round($ventENE3/$nombre*100,2);
$gustENE4 = round($ventENE4/$nombre*100,2);
$gustENE5 = round($ventENE5/$nombre*100,2);
$gustENE6 = round($ventENE6/$nombre*100,2);
$gustENE7 = round($ventENE7/$nombre*100,2);
$gustE1 = round($ventE1/$nombre*100,2) ;
$gustE2 = round($ventE2/$nombre*100,2);
$gustE3 = round($ventE3/$nombre*100,2);
$gustE4 = round($ventE4/$nombre*100,2);
$gustE5 = round($ventE5/$nombre*100,2);
$gustE6 = round($ventE6/$nombre*100,2);
$gustE7 = round($ventE7/$nombre*100,2);
$gustESE1 = round($ventESE1/$nombre*100,2) ;
$gustESE2 = round($ventESE2/$nombre*100,2);
$gustESE3 = round($ventESE3/$nombre*100,2);
$gustESE4 = round($ventESE4/$nombre*100,2);
$gustESE5 = round($ventESE5/$nombre*100,2);
$gustESE6 = round($ventESE6/$nombre*100,2);
$gustESE7 = round($ventESE7/$nombre*100,2);
$gustSE1 = round($ventSE1/$nombre*100,2) ;
$gustSE2 = round($ventSE2/$nombre*100,2);
$gustSE3 = round($ventSE3/$nombre*100,2);
$gustSE4 = round($ventSE4/$nombre*100,2);
$gustSE5 = round($ventSE5/$nombre*100,2);
$gustSE6 = round($ventSE6/$nombre*100,2);
$gustSE7 = round($ventSE7/$nombre*100,2);
$gustSSE1 = round($ventSSE1/$nombre*100,2) ;
$gustSSE2 = round($ventSSE2/$nombre*100,2);
$gustSSE3 = round($ventSSE3/$nombre*100,2);
$gustSSE4 = round($ventSSE4/$nombre*100,2);
$gustSSE5 = round($ventSSE5/$nombre*100,2);
$gustSSE6 = round($ventSSE6/$nombre*100,2);
$gustSSE7 = round($ventSSE7/$nombre*100,2);
$gustS1 = round($ventS1/$nombre*100,2) ;
$gustS2 = round($ventS2/$nombre*100,2);
$gustS3 = round($ventS3/$nombre*100,2);
$gustS4 = round($ventS4/$nombre*100,2);
$gustS5 = round($ventS5/$nombre*100,2);
$gustS6 = round($ventS6/$nombre*100,2);
$gustS7 = round($ventS7/$nombre*100,2);
$gustSSO1 = round($ventSSO1/$nombre*100,2) ;
$gustSSO2 = round($ventSSO2/$nombre*100,2);
$gustSSO3 = round($ventSSO3/$nombre*100,2);
$gustSSO4 = round($ventSSO4/$nombre*100,2);
$gustSSO5 = round($ventSSO5/$nombre*100,2);
$gustSSO6 = round($ventSSO6/$nombre*100,2);
$gustSSO7 = round($ventSSO7/$nombre*100,2);
$gustSO1 = round($ventSO1/$nombre*100,2) ;
$gustSO2 = round($ventSO2/$nombre*100,2);
$gustSO3 = round($ventSO3/$nombre*100,2);
$gustSO4 = round($ventSO4/$nombre*100,2);
$gustSO5 = round($ventSO5/$nombre*100,2);
$gustSO6 = round($ventSO6/$nombre*100,2);
$gustSO7 = round($ventSO7/$nombre*100,2);
$gustOSO1 = round($ventOSO1/$nombre*100,2) ;
$gustOSO2 = round($ventOSO2/$nombre*100,2);
$gustOSO3 = round($ventOSO3/$nombre*100,2);
$gustOSO4 = round($ventOSO4/$nombre*100,2);
$gustOSO5 = round($ventOSO5/$nombre*100,2);
$gustOSO6 = round($ventOSO6/$nombre*100,2);
$gustOSO7 = round($ventOSO7/$nombre*100,2);
$gustO1 = round($ventO1/$nombre*100,2) ;
$gustO2 = round($ventO2/$nombre*100,2);
$gustO3 = round($ventO3/$nombre*100,2);
$gustO4 = round($ventO4/$nombre*100,2);
$gustO5 = round($ventO5/$nombre*100,2);
$gustO6 = round($ventO6/$nombre*100,2);
$gustO7 = round($ventO7/$nombre*100,2);
$gustONO1 = round($ventONO1/$nombre*100,2) ;
$gustONO2 = round($ventONO2/$nombre*100,2);
$gustONO3 = round($ventONO3/$nombre*100,2);
$gustONO4 = round($ventONO4/$nombre*100,2);
$gustONO5 = round($ventONO5/$nombre*100,2);
$gustONO6 = round($ventONO6/$nombre*100,2);
$gustONO7 = round($ventONO7/$nombre*100,2);
$gustNO1 = round($ventNO1/$nombre*100,2) ;
$gustNO2 = round($ventNO2/$nombre*100,2);
$gustNO3 = round($ventNO3/$nombre*100,2);
$gustNO4 = round($ventNO4/$nombre*100,2);
$gustNO5 = round($ventNO5/$nombre*100,2);
$gustNO6 = round($ventNO6/$nombre*100,2);
$gustNO7 = round($ventNO7/$nombre*100,2);
$gustNNO1 = round($ventNNO1/$nombre*100,2) ;
$gustNNO2 = round($ventNNO2/$nombre*100,2);
$gustNNO3 = round($ventNNO3/$nombre*100,2);
$gustNNO4 = round($ventNNO4/$nombre*100,2);
$gustNNO5 = round($ventNNO5/$nombre*100,2);
$gustNNO6 = round($ventNNO6/$nombre*100,2);
$gustNNO7 = round($ventNNO7/$nombre*100,2);
Ce code est pour ce graphique Force et provenance des vents dominants ces dernières 48 heures à Conflans en Jarnisy

et

Code : Tout sélectionner

// On initialise les directions
$provN=0; 	$dirN=0;
$provNNE=0; $dirNNE=0;
$provNE=0; 	$dirNE=0;
$provENE=0; $dirENE=0;
$provE=0; 	$dirE=0;
$provESE=0; $dirESE=0;
$provSE=0; 	$dirSE=0;
$provSSE=0;	$dirSSE=0;
$provS=0;	$dirS=0;
$provSSO=0;	$dirSSO=0;
$provSO=0;	$dirSO=0;
$provOSO=0;	$dirOSO=0;
$provO=0;	$dirO=0;
$provONO=0;	$dirONO=0;
$provNO=0;	$dirNO=0;
$provNNO=0;	$dirNNO=0;

// Pour la plage horaire déterminée, on compte le nombre total d'enregistrements avec vent non nul (wingust>0) et on ne selectionne que les enregistrements avec vent non nul (traitement des données plus rapide).
$sql = "Select COUNT(*) as Total from data where tstamp > '$start' and tstamp <= '$stop' and windgust > 0";
$query = mysqli_query($conn,$sql);                   
$list=mysqli_fetch_array($query);
$nombre=$list['Total'];
$i=0;

$sql = "SELECT winddir FROM data where tstamp >= '$start' and  tstamp <= '$stop' and windgust > 0";  
$query = mysqli_query($conn,$sql);                   

// On compte le nombre d'enregistrements pour chaque directions
while ($list = mysqli_fetch_assoc($query)) {      
	$dirvent[$i]=$list['winddir']*1;
		if (($dirvent[$i]==0)||($dirvent[$i]==360)) {$provN++ ;}
		elseif (($dirvent[$i]==22) || ($dirvent[$i]==22.5)) {$provNNE++ ;}
		elseif ($dirvent[$i]==45) {$provNE++ ;}
		elseif (($dirvent[$i]==67.5) || ($dirvent[$i]==68)) {$provENE++ ;}
		elseif ($dirvent[$i]==90) {$provE++ ;}
		elseif (($dirvent[$i]==112) || ($dirvent[$i]==112.5)) {$provESE++ ;}
		elseif ($dirvent[$i]==135) {$provSE++ ;}
		elseif (($dirvent[$i]==157.5) || ($dirvent[$i]==158)) {$provSSE++ ;}
		elseif ($dirvent[$i]==180) {$provS++ ;}
		elseif (($dirvent[$i]==202) || ($dirvent[$i]==202.5)) {$provSSO++ ;}
		elseif ($dirvent[$i]==225) {$provSO++ ;}
		elseif (($dirvent[$i]==247.5) || ($dirvent[$i]==248)) {$provOSO++ ;}
		elseif ($dirvent[$i]==270) {$provO++ ;}
		elseif (($dirvent[$i]==292) || ($dirvent[$i]==292.5)) {$provONO++ ;}
		elseif ($dirvent[$i]==315) {$provNO++ ;}
		elseif (($dirvent[$i]==337.5) || ($dirvent[$i]==338)) {$provNNO++ ;}
$i++;		
};
// On calcule la répartition en pourcentage pour chaque directions avec 2 chiffres après la virgule.
$dirN=round($provN/$nombre*100,2);
$dirNNE=round($provNNE/$nombre*100,2);
$dirNE=round($provNE/$nombre*100,2);
$dirENE=round($provENE/$nombre*100,2);
$dirE=round($provE/$nombre*100,2);
$dirESE=round($provESE/$nombre*100,2);
$dirSE=round($provSE/$nombre*100,2);
$dirSSE=round($provSSE/$nombre*100,2);
$dirS=round($provS/$nombre*100,2);
$dirSSO=round($provSSO/$nombre*100,2);
$dirSO=round($provSO/$nombre*100,2);
$dirOSO=round($provOSO/$nombre*100,2);
$dirO=round($provO/$nombre*100,2);
$dirONO=round($provONO/$nombre*100,2);
$dirNO=round($provNO/$nombre*100,2);
$dirNNO=round($provNNO/$nombre*100,2);
pour ce graphique Provenance des vents dominants ces dernières 48 heures à Conflans en Jarnisy

Bonne soirée

Pascal
Station VP2Plus, Windows 10 64 bits,WeatherLink 6.0.5, VP2SQL, Graphiques Dynamiques à partir d'une BDD MySQL
Météo Conflans-en-Jarnisy
Image

Répondre