Forum eedomus
https://forum.eedomus.com/

calcul position du soleil
https://forum.eedomus.com/viewtopic.php?f=50&t=2238
Page 1 sur 8  Suivant »
Auteur:  bubu [ 09 Déc 2014 16:28 ]
Sujet du message:  calcul position du soleil

Bonjour à tous,

Je voudrais remonter dans la box la position du soleil (azimuth et hauteur).

La 1ere idée de ceci serait de pouvoir calculer l'énergie solaire pour savoir si c'est rentable ou non d'installer des panneaux solaire ( il faut le coupler à la couverture nuageuse)

(super site sur le sujet
http://www.energieplus-lesite.be/index.php?id=16759)

La 2eme idée est de domotiser les volets roulants pour capter de la chaleur en hiver/ proteger de la chaleur l'été.
J'ai un UV mètre mais la valeur retournée n'est pas très exploitable l'hiver.

J'ai déjà fait ces formules de calcul sur excel mais je ne sais pas programmer en .php
Le top serait de faire un script directement dans l'eedomus (ou dans le synology si ca n'est pas possible).
(pour info il n'y a que des SIN et arcSIN dans les formules

Au pire sur google drive avec un fichier excel mais c'est moins "indépendant".

Est ce que quelqu'un serait intéressé pour programmer ca?
Auteur:  Madoma73 [ 09 Déc 2014 16:52 ]
Sujet du message:  Re: calcul position du soleil

ça dépend de la rémunération :mrgreen:
Auteur:  bubu [ 09 Déc 2014 18:21 ]
Sujet du message:  Re: calcul position du soleil

la reconnaissance éternelle de la communauté eedomus... ;)
Auteur:  dplein [ 09 Déc 2014 19:37 ]
Sujet du message:  Re: calcul position du soleil

bubu a écrit:la reconnaissance éternelle de la communauté eedomus... ;)


Déjà acquis !!!! :lol: :lol:
Auteur:  bubu [ 09 Déc 2014 21:46 ]
Sujet du message:  Re: calcul position du soleil

vais tenter le script...
Auteur:  Madoma73 [ 10 Déc 2014 14:16 ]
Sujet du message:  Re: calcul position du soleil

je peux regarder mais pas tout de suite, j'essaie de sortir un truc sympa pour la communauté justement.....
après je peux t'aider à finaliser, si tu fais déjà une ébauche de script, c'est plus rapide ça.
Auteur:  Blanchard [ 15 Fév 2015 16:48 ]
Sujet du message:  Re: calcul position du soleil

Avez vous abandonné ?
J'avais pleins d'idée (volets roulants mode persiennes, banne, etc...)
Auteur:  Tinto [ 15 Fév 2015 18:21 ]
Sujet du message:  Re: calcul position du soleil

dplein a écrit:
bubu a écrit:la reconnaissance éternelle de la communauté eedomus... ;)


Déjà acquis !!!! :lol: :lol:


effectivement :)
Auteur:  vva [ 25 Mars 2015 16:05 ]
Sujet du message:  Re: calcul position du soleil

Salut,

J'ai réalisé un p'tit script qui pourrait correspondre au besoin exprimé dans ce post (j'me suis bien pris la tête car certaines fonctions ne sont pas dispo avec la version php de nos box et le support a pu en débloquer d'autres).

Je le teste depuis quelques jours et il semble bien fonctionné.
Il est basé sur une étude faite par le National Oceanic and Atmospheric Administration.
Le résultat est au format xml (xpath très facile).
- Elevation
- Azimut + Point Cardinal
- ...

Je peux envoyé en mp le script à ceux intéressés afin de beta testé !

Nota: Pour l'instant le script ne prend pas en compte le changement d'heure
Auteur:  dplein [ 25 Mars 2015 19:05 ]
Sujet du message:  Re: calcul position du soleil

Y a ps de soucis pour tester si tu nous dit "comment ça marche " !!!
Auteur:  vva [ 25 Mars 2015 21:31 ]
Sujet du message:  Re: calcul position du soleil

dplein a écrit:Y a ps de soucis pour tester si tu nous dit "comment ça marche " !!!

Et bien ça fonctionne tout simplement avec un capteur http pour appeller le script et avec les 3 variables:
http://[VAR1]/script/?exec=position_soleil.php&latitude=[VAR2]&longitude=[VAR3]

[VAR1] = @IP DE LA BOX
[VAR2] = Latitude (+ => N) de la maison
[VAR3] = Longitude (+ => E) de la maison

Ensuite le xpath dépend de ce que tu veux obtenir (élévation / azimut en degré / point cardinal /...)
Auteur:  Chacks [ 25 Mars 2015 23:24 ]
Sujet du message:  Re: calcul position du soleil

Moi je suis bien intéressé par ton script, ça peut permettre pas mal de choses l'été pour régler les volets roulants en fonction de la position du soleil.

@+
Auteur:  vva [ 26 Mars 2015 09:15 ]
Sujet du message:  Re: calcul position du soleil

Bonjour à tous,

Je vous donne le contenu du script. Le code n'est pas encore optimisé.

Code : Tout sélectionner
<?php

// Version v0.9
// CE SCRIPT EXPERIMENTAL REALISE EN PHP PERMET DE DETERMINER LA POSITION DU SOLEIL (AZIMUT + ELEVATION, ...)
// L'ALGORYTHME EST BASÉ SUR UNE ÉTUDE FAITE PAR LE National Oceanic and Atmospheric Administration

// LES VARIABLES DE LA BOX EEDOMUS:
// [VAR1] = @IP DE LA BOX
// [VAR2] = Latitude (+ => N)
// [VAR3] = Longitude (+ => E)

// Les latitude et longitude doivent contenir des "." (PAS DE VIRGULE)
// EXEMPLE: Latitude = 48.858346
//          Longitude = 2.294496
// OU
//
// EXEMPLE: Latitude = 48.387942
//          Longitude = -4.484993

// EXEMPLE APPEL DE SCRIPT avec variables: http://[VAR1]/script/?exec=position_soleil.php&latitude=[VAR2]&longitude=[VAR3]
// EXEMPLE APPEL DE SCRIPT dans navigateur: http://@IP_BOX_EEDOMUS/script/?exec=position_soleil.php&latitude=48.858346&longitude=2.294496

// LE RESULTAT EST SOUS FORME XML
// L'ELEVATION CORRESPOND A L'ANGLE ENTRE L'HORIZON ET LE SOLEIL
// XPATH ELEVATION: /Data/Soleil/Solar_Elevation_corrected_for_atm_refraction_deg

// L'AZIMUT CORRESPOND A L'ANGLE ENTRE LE NORD ET LE SOLEIL
// XPATH AZIMUT: /Data/Soleil/Solar_Azimuth_round
// 0°/ 360° = NORD
// 90° = EST
// 180° = SUD
// 270° = OUEST

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

// Stocker les variables passées en argument
$ma_latitude = getArg('latitude');
$ma_longitude = getArg('longitude');
$date = date('Y/m/d H:i:s');

// mktime calcule en secondes la différence entre le 01/01/1970 et aujourd'hui
$date_mk = mktime(0, 0, 0, date('d'), date('m'), date('Y'));
// Correction UNIX /EXCEL = 2208297600 correspond en seconde à la différence en 1900 et 1970
$date_mk = $date_mk + 2079840600;

// 84600 = 3600 * 24 (nombre de seconde en 1 jour)
$date_mk = $date_mk / 84600;
//$date_mk = round($date_mk);

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

$heure = date('H');
$heure_mk = $heure / 24;
$time_zone = 1;

$Julian_Day = $date_mk + '2415018.5' + $heure_mk;
$Julian_Day_2 = $time_zone / 24;
$Julian_Day = $Julian_Day - $Julian_Day_2;

$Julian_Century = $Julian_Day - 2451545;
$Julian_Century = $Julian_Century / 36525;

$Geom_Mean_Long_Sun_deg_1 = $Julian_Century * '0.0003032';
$Geom_Mean_Long_Sun_deg_1 = '36000.76983' + $Geom_Mean_Long_Sun_deg_1;
$Geom_Mean_Long_Sun_deg_1 = $Julian_Century * $Geom_Mean_Long_Sun_deg_1;
$Geom_Mean_Long_Sun_deg = fmod('280.46646' + $Geom_Mean_Long_Sun_deg_1,360);

$Geom_Mean_Anom_Sun_deg = '0.0001537' * $Julian_Century;
$Geom_Mean_Anom_Sun_deg = '35999.05029' - $Geom_Mean_Anom_Sun_deg;
$Geom_Mean_Anom_Sun_deg = $Julian_Century * $Geom_Mean_Anom_Sun_deg;
$Geom_Mean_Anom_Sun_deg = '357.52911' + $Geom_Mean_Anom_Sun_deg;

$Eccent_Earth_Orbit = '0.0000001267'*$Julian_Century;
$Eccent_Earth_Orbit = '0.000042037' + $Eccent_Earth_Orbit;
$Eccent_Earth_Orbit = $Julian_Century * $Eccent_Earth_Orbit;
$Eccent_Earth_Orbit = '0.016708634' - $Eccent_Earth_Orbit;

$Sun_Eq_of_Ctr_1 = deg2rad(3 * $Geom_Mean_Anom_Sun_deg);
$Sun_Eq_of_Ctr_1 = sin($Sun_Eq_of_Ctr_1);
$Sun_Eq_of_Ctr_1 = $Sun_Eq_of_Ctr_1 * '0.000289';
$Sun_Eq_of_Ctr_2 = '0.000101' * $Julian_Century;
$Sun_Eq_of_Ctr_2 = '0.019993' - $Sun_Eq_of_Ctr_2;
$Sun_Eq_of_Ctr_3 = deg2rad(2* $Geom_Mean_Anom_Sun_deg);
$Sun_Eq_of_Ctr_3 = sin($Sun_Eq_of_Ctr_3);
$Sun_Eq_of_Ctr = $Sun_Eq_of_Ctr_2 * $Sun_Eq_of_Ctr_3;
$Sun_Eq_of_Ctr = $Sun_Eq_of_Ctr + $Sun_Eq_of_Ctr_1;
$Sun_Eq_of_Ctr_3 = '0.000014' * $Julian_Century;
$Sun_Eq_of_Ctr_3 = $Sun_Eq_of_Ctr_3 + '0.004817';
$Sun_Eq_of_Ctr_3 = $Julian_Century * $Sun_Eq_of_Ctr_3;
$Sun_Eq_of_Ctr_3 = '1.914602' - $Sun_Eq_of_Ctr_3;
$Sun_Eq_of_Ctr_2 = deg2rad( $Geom_Mean_Anom_Sun_deg);
$Sun_Eq_of_Ctr_2 = sin($Sun_Eq_of_Ctr_2);
$Sun_Eq_of_Ctr_2 = $Sun_Eq_of_Ctr_2*$Sun_Eq_of_Ctr_3;
$Sun_Eq_of_Ctr = $Sun_Eq_of_Ctr_2 + $Sun_Eq_of_Ctr;

$Sun_True_Long_deg = $Geom_Mean_Long_Sun_deg + $Sun_Eq_of_Ctr;

$Sun_True_Anom_deg = $Geom_Mean_Anom_Sun_deg + $Sun_Eq_of_Ctr;

$Sun_Rad_Vector_AUs_1 = deg2rad($Sun_True_Anom_deg);
$Sun_Rad_Vector_AUs_1 = cos($Sun_Rad_Vector_AUs_1);
$Sun_Rad_Vector_AUs_1 = $Eccent_Earth_Orbit * $Sun_Rad_Vector_AUs_1;
$Sun_Rad_Vector_AUs = 1 + $Sun_Rad_Vector_AUs_1;
$Sun_Rad_Vector_AUs_1  = $Eccent_Earth_Orbit*$Eccent_Earth_Orbit;
$Sun_Rad_Vector_AUs_1 = 1-$Sun_Rad_Vector_AUs_1;
$Sun_Rad_Vector_AUs_1 = '1.000001018'*$Sun_Rad_Vector_AUs_1;
$Sun_Rad_Vector_AUs = $Sun_Rad_Vector_AUs_1 / $Sun_Rad_Vector_AUs;

$Sun_App_Long_deg_1 = '1934.136'*$Julian_Century;
$Sun_App_Long_deg_1 = '125.04'-$Sun_App_Long_deg_1;
$Sun_App_Long_deg_1 = deg2rad($Sun_App_Long_deg_1);
$Sun_App_Long_deg_1 = sin($Sun_App_Long_deg_1);
$Sun_App_Long_deg_1 = '0.00478'*$Sun_App_Long_deg_1;
$Sun_App_Long_deg = $Sun_True_Long_deg - '0.00569'-$Sun_App_Long_deg_1;

$Mean_Obliq_Ecliptic_deg = $Julian_Century * '0.001813';
$Mean_Obliq_Ecliptic_deg = '0.00059'- $Mean_Obliq_Ecliptic_deg;
$Mean_Obliq_Ecliptic_deg = $Julian_Century * $Mean_Obliq_Ecliptic_deg;
$Mean_Obliq_Ecliptic_deg = '46.815' + $Mean_Obliq_Ecliptic_deg;
$Mean_Obliq_Ecliptic_deg = $Julian_Century * $Mean_Obliq_Ecliptic_deg;
$Mean_Obliq_Ecliptic_deg = '21.448' - $Mean_Obliq_Ecliptic_deg;
$Mean_Obliq_Ecliptic_deg = $Mean_Obliq_Ecliptic_deg / 60;
$Mean_Obliq_Ecliptic_deg = '26' + $Mean_Obliq_Ecliptic_deg;
$Mean_Obliq_Ecliptic_deg = $Mean_Obliq_Ecliptic_deg / 60;
$Mean_Obliq_Ecliptic_deg = 23 + $Mean_Obliq_Ecliptic_deg;

$Obliq_Corr_deg = '1934.136'*$Julian_Century;
$Obliq_Corr_deg = '125.04'-$Obliq_Corr_deg;
$Obliq_Corr_deg = deg2rad($Obliq_Corr_deg);
$Obliq_Corr_deg = cos($Obliq_Corr_deg);
$Obliq_Corr_deg = $Obliq_Corr_deg*'0.00256';
$Obliq_Corr_deg = $Mean_Obliq_Ecliptic_deg + $Obliq_Corr_deg;

$Sun_Declin_deg_1 = deg2rad($Sun_App_Long_deg);
$Sun_Declin_deg_1 = sin($Sun_Declin_deg_1);
$Sun_Declin_deg_2 = deg2rad($Obliq_Corr_deg);
$Sun_Declin_deg_2 = sin($Sun_Declin_deg_2);
$Sun_Declin_deg = asin($Sun_Declin_deg_1*$Sun_Declin_deg_2);
$Sun_Declin_deg = rad2deg($Sun_Declin_deg);

$SunRt_Ascen_deg_1 = deg2rad($Sun_App_Long_deg);
$SunRt_Ascen_deg_1 = sin($SunRt_Ascen_deg_1);
$SunRt_Ascen_deg_2 = deg2rad($Obliq_Corr_deg);
$SunRt_Ascen_deg_2 = cos($SunRt_Ascen_deg_2);
$SunRt_Ascen_deg_1 = $SunRt_Ascen_deg_2 * $SunRt_Ascen_deg_1;
$SunRt_Ascen_deg_2 = deg2rad($Sun_App_Long_deg);
$SunRt_Ascen_deg_2 = cos($SunRt_Ascen_deg_2);
$SunRt_Ascen_deg = atan2($SunRt_Ascen_deg_1, $SunRt_Ascen_deg_2);
$SunRt_Ascen_deg = rad2deg($SunRt_Ascen_deg);

$y_1 = $Obliq_Corr_deg/2;
$y_1 = deg2rad($y_1);
$y_1 = tan($y_1);
$y = $Obliq_Corr_deg/2;
$y = deg2rad($y);
$y = tan($y);
$y = $y * $y_1;

$Eq_of_Time_minutes_1 = deg2rad($Geom_Mean_Anom_Sun_deg);
$Eq_of_Time_minutes_1 = 2 * $Eq_of_Time_minutes_1;
$Eq_of_Time_minutes_1 = sin($Eq_of_Time_minutes_1);
$Eq_of_Time_minutes_1 = '1.25' * $Eccent_Earth_Orbit * $Eccent_Earth_Orbit * $Eq_of_Time_minutes_1;
$Eq_of_Time_minutes_2 = deg2rad($Geom_Mean_Long_Sun_deg);
$Eq_of_Time_minutes_2 = 4 * $Eq_of_Time_minutes_2;
$Eq_of_Time_minutes_2 = sin($Eq_of_Time_minutes_2);
$Eq_of_Time_minutes_2 = '0.5' * $y * $y * $Eq_of_Time_minutes_2;
$Eq_of_Time_minutes_3 = deg2rad($Geom_Mean_Long_Sun_deg);
$Eq_of_Time_minutes_3 = 2 * $Eq_of_Time_minutes_3;
$Eq_of_Time_minutes_3 = cos($Eq_of_Time_minutes_3);
$Eq_of_Time_minutes_4 = deg2rad($Geom_Mean_Anom_Sun_deg);
$Eq_of_Time_minutes_4 = sin($Eq_of_Time_minutes_4);
$Eq_of_Time_minutes_4 = 4 * $Eccent_Earth_Orbit * $y * $Eq_of_Time_minutes_4 * $Eq_of_Time_minutes_3;
$Eq_of_Time_minutes_5 = deg2rad($Geom_Mean_Anom_Sun_deg);
$Eq_of_Time_minutes_5 = sin($Eq_of_Time_minutes_5);
$Eq_of_Time_minutes_5 = 2 * $Eccent_Earth_Orbit * $Eq_of_Time_minutes_5;
$Eq_of_Time_minutes_6 = deg2rad($Geom_Mean_Long_Sun_deg);
$Eq_of_Time_minutes_6 = 2 * $Eq_of_Time_minutes_6;
$Eq_of_Time_minutes_6 = sin($Eq_of_Time_minutes_6);
$Eq_of_Time_minutes_6 = $y * $Eq_of_Time_minutes_6;

$Eq_of_Time_minutes = $Eq_of_Time_minutes_6 - $Eq_of_Time_minutes_5 + $Eq_of_Time_minutes_4 - $Eq_of_Time_minutes_2 - $Eq_of_Time_minutes_1;
$Eq_of_Time_minutes = 4 * rad2deg($Eq_of_Time_minutes);

$HA_Sunrise_deg_1 = deg2rad($Sun_Declin_deg);
$HA_Sunrise_deg_1 = tan($HA_Sunrise_deg_1);
$HA_Sunrise_deg_2 = deg2rad($ma_latitude);
$HA_Sunrise_deg_2 = tan($HA_Sunrise_deg_2);
$HA_Sunrise_deg_1 = $HA_Sunrise_deg_1 * $HA_Sunrise_deg_2;
$HA_Sunrise_deg_2 = deg2rad($Sun_Declin_deg);
$HA_Sunrise_deg_5 = cos($HA_Sunrise_deg_2);
$HA_Sunrise_deg_3 = deg2rad($ma_latitude);
$HA_Sunrise_deg_3 = cos($HA_Sunrise_deg_3);
$HA_Sunrise_deg_3 = $HA_Sunrise_deg_3 * $HA_Sunrise_deg_5;
$HA_Sunrise_deg_4 = deg2rad('90.833');
$HA_Sunrise_deg_4 = cos($HA_Sunrise_deg_4);
$HA_Sunrise_deg = $HA_Sunrise_deg_4 / $HA_Sunrise_deg_3;
$HA_Sunrise_deg = $HA_Sunrise_deg - $HA_Sunrise_deg_1;
$HA_Sunrise_deg = acos($HA_Sunrise_deg);
$HA_Sunrise_deg = rad2deg($HA_Sunrise_deg);

$Solar_Noon_LST = $time_zone * 60;
$Solar_Noon_LST_1 = 4 * $ma_longitude;
$Solar_Noon_LST = 720 - $Solar_Noon_LST_1 - $Eq_of_Time_minutes + $Solar_Noon_LST;
$Solar_Noon_LST = $Solar_Noon_LST / 1440;

$Sunrise_Time_LST = $HA_Sunrise_deg*4;
$Sunrise_Time_LST = $Sunrise_Time_LST / 1440;
$Sunrise_Time_LST = $Solar_Noon_LST - $Sunrise_Time_LST;

$Sunset_Time_LST = $HA_Sunrise_deg*4;
$Sunset_Time_LST = $Sunset_Time_LST / 1440;
$Sunset_Time_LST = $Solar_Noon_LST + $Sunset_Time_LST;

$Sunlight_Duration_minutes = 8* $HA_Sunrise_deg;


$True_Solar_Time_min_1 = 60 * $time_zone;
$True_Solar_Time_min_2 = 4 * $ma_longitude;
$True_Solar_Time_min_3 = $heure_mk * 1440;
$True_Solar_Time_min = $True_Solar_Time_min_3 + $Eq_of_Time_minutes + $True_Solar_Time_min_2 - $True_Solar_Time_min_1;
$True_Solar_Time_min = fmod($True_Solar_Time_min, 1440);

if ($True_Solar_Time_min/4 < 0)
{
   $Hour_Angle_deg = $True_Solar_Time_min / 4;
   $Hour_Angle_deg = $Hour_Angle_deg +180;
}
else
{
   $Hour_Angle_deg = $True_Solar_Time_min / 4;
   $Hour_Angle_deg = $Hour_Angle_deg -180;
}

$Solar_Zenith_Angle_deg_1 = deg2rad($Hour_Angle_deg);
$Solar_Zenith_Angle_deg_1  = cos($Solar_Zenith_Angle_deg_1 );
$Solar_Zenith_Angle_deg_2 = deg2rad($Sun_Declin_deg);
$Solar_Zenith_Angle_deg_2  = cos($Solar_Zenith_Angle_deg_2 );
$Solar_Zenith_Angle_deg_3 = deg2rad($ma_latitude);
$Solar_Zenith_Angle_deg_3  = cos($Solar_Zenith_Angle_deg_3 );
$Solar_Zenith_Angle_deg_3 = $Solar_Zenith_Angle_deg_1 * $Solar_Zenith_Angle_deg_2 * $Solar_Zenith_Angle_deg_3;
$Solar_Zenith_Angle_deg_4 = deg2rad($Sun_Declin_deg);
$Solar_Zenith_Angle_deg_4 = sin($Solar_Zenith_Angle_deg_4);
$Solar_Zenith_Angle_deg_5 = deg2rad($ma_latitude);
$Solar_Zenith_Angle_deg_5 = sin($Solar_Zenith_Angle_deg_5);
$Solar_Zenith_Angle_deg_5 = $Solar_Zenith_Angle_deg_5  * $Solar_Zenith_Angle_deg_4;   
$Solar_Zenith_Angle_deg = $Solar_Zenith_Angle_deg_5 + $Solar_Zenith_Angle_deg_3;
$Solar_Zenith_Angle_deg = acos($Solar_Zenith_Angle_deg);
$Solar_Zenith_Angle_deg = rad2deg($Solar_Zenith_Angle_deg);

$Solar_Elevation_Angle_deg = 90 - $Solar_Zenith_Angle_deg;

// A FAIRE
$Approx_Atmospheric_Refraction_deg = 0;

$Solar_Elevation_corrected_for_atm_refraction_deg = $Solar_Elevation_Angle_deg + $Approx_Atmospheric_Refraction_deg;

if ($Hour_Angle_deg > 0)
{
   $Solar_Azimuth_Angle_deg_cw_from_N_1 = deg2rad($Solar_Zenith_Angle_deg);
   $Solar_Azimuth_Angle_deg_cw_from_N_1 = sin($Solar_Azimuth_Angle_deg_cw_from_N_1);
   $Solar_Azimuth_Angle_deg_cw_from_N_2 = deg2rad($ma_latitude);
   $Solar_Azimuth_Angle_deg_cw_from_N_2 = cos($Solar_Azimuth_Angle_deg_cw_from_N_2 );
   $Solar_Azimuth_Angle_deg_cw_from_N_1 = $Solar_Azimuth_Angle_deg_cw_from_N_1 * $Solar_Azimuth_Angle_deg_cw_from_N_2;
   $Solar_Azimuth_Angle_deg_cw_from_N_3 = deg2rad($Sun_Declin_deg);
   $Solar_Azimuth_Angle_deg_cw_from_N_3 = sin($Solar_Azimuth_Angle_deg_cw_from_N_3);
   $Solar_Azimuth_Angle_deg_cw_from_N_4 = deg2rad($Solar_Zenith_Angle_deg);
   $Solar_Azimuth_Angle_deg_cw_from_N_4 = cos($Solar_Azimuth_Angle_deg_cw_from_N_4);
   $Solar_Azimuth_Angle_deg_cw_from_N_5 = deg2rad($ma_latitude);
   $Solar_Azimuth_Angle_deg_cw_from_N_5 = cos($Solar_Azimuth_Angle_deg_cw_from_N_5 );
   $Solar_Azimuth_Angle_deg_cw_from_N_5 = $Solar_Azimuth_Angle_deg_cw_from_N_5 * $Solar_Azimuth_Angle_deg_cw_from_N_4;
   $Solar_Azimuth_Angle_deg_cw_from_N_5 = $Solar_Azimuth_Angle_deg_cw_from_N_5 - $Solar_Azimuth_Angle_deg_cw_from_N_3;   
   $Solar_Azimuth_Angle_deg_cw_from_N = acos($Solar_Azimuth_Angle_deg_cw_from_N_5 / $Solar_Azimuth_Angle_deg_cw_from_N_1);   
   $Solar_Azimuth_Angle_deg_cw_from_N = rad2deg($Solar_Azimuth_Angle_deg_cw_from_N) + 180;
   $Solar_Azimuth_Angle_deg_cw_from_N = fmod($Solar_Azimuth_Angle_deg_cw_from_N,360);
}
else
{
   $Solar_Azimuth_Angle_deg_cw_from_N_1 = deg2rad($Solar_Zenith_Angle_deg);
   $Solar_Azimuth_Angle_deg_cw_from_N_1 = sin($Solar_Azimuth_Angle_deg_cw_from_N_1);
   $Solar_Azimuth_Angle_deg_cw_from_N_2 = deg2rad($ma_latitude);
   $Solar_Azimuth_Angle_deg_cw_from_N_2 = cos($Solar_Azimuth_Angle_deg_cw_from_N_2 );
   $Solar_Azimuth_Angle_deg_cw_from_N_1 = $Solar_Azimuth_Angle_deg_cw_from_N_1 * $Solar_Azimuth_Angle_deg_cw_from_N_2;   
   $Solar_Azimuth_Angle_deg_cw_from_N_3 = deg2rad($Sun_Declin_deg);
   $Solar_Azimuth_Angle_deg_cw_from_N_3 = sin($Solar_Azimuth_Angle_deg_cw_from_N_3);
   $Solar_Azimuth_Angle_deg_cw_from_N_4 = deg2rad($Solar_Zenith_Angle_deg);
   $Solar_Azimuth_Angle_deg_cw_from_N_4 = cos($Solar_Azimuth_Angle_deg_cw_from_N_4);
   $Solar_Azimuth_Angle_deg_cw_from_N_5 = deg2rad($ma_latitude);
   $Solar_Azimuth_Angle_deg_cw_from_N_5 = cos($Solar_Azimuth_Angle_deg_cw_from_N_5 );
   $Solar_Azimuth_Angle_deg_cw_from_N_5 = $Solar_Azimuth_Angle_deg_cw_from_N_5 * $Solar_Azimuth_Angle_deg_cw_from_N_4;
   $Solar_Azimuth_Angle_deg_cw_from_N_5 = $Solar_Azimuth_Angle_deg_cw_from_N_5 - $Solar_Azimuth_Angle_deg_cw_from_N_3;   
   $Solar_Azimuth_Angle_deg_cw_from_N = acos($Solar_Azimuth_Angle_deg_cw_from_N_5 / $Solar_Azimuth_Angle_deg_cw_from_N_1);   
   $Solar_Azimuth_Angle_deg_cw_from_N = 540 - rad2deg($Solar_Azimuth_Angle_deg_cw_from_N);
   $Solar_Azimuth_Angle_deg_cw_from_N = fmod($Solar_Azimuth_Angle_deg_cw_from_N,360);
}

$Solar_Azimuth_Angle_deg = round($Solar_Azimuth_Angle_deg_cw_from_N);

// Associé le point cardinal à l'angle
if ($Solar_Azimuth_Angle_deg == 0)
{
    $Solar_Cardinal_point = 1;   // NORD
}
if ($Solar_Azimuth_Angle_deg > '22.4')
{
    $Solar_Cardinal_point = 2;   // NORD-NORD-EST
}
 if ($Solar_Azimuth_Angle_deg > '44.9')
{
   $Solar_Cardinal_point = 3;   //NORD-EST
}
 if ($Solar_Azimuth_Angle_deg > '67.4')
{
   $Solar_Cardinal_point = 4;   //EST-NORD-EST
}
 if ($Solar_Azimuth_Angle_deg > 90)
{
   $Solar_Cardinal_point = 5;   //EST
}
 if ($Solar_Azimuth_Angle_deg > '112.5')
{
   $Solar_Cardinal_point = 6;   //EST-SUD-EST
}
 if ($Solar_Azimuth_Angle_deg > '134.9')
{
   $Solar_Cardinal_point = 7;   //SUD-EST
}
 if ($Solar_Azimuth_Angle_deg > '157.4')
{
   $Solar_Cardinal_point = 8;   //SUD-SUD-EST
}
 if ($Solar_Azimuth_Angle_deg > '179.9')
{
   $Solar_Cardinal_point = 9;   //SUD
}
 if ($Solar_Azimuth_Angle_deg > '202.4')
{
   $Solar_Cardinal_point = 10;   //SUD-SUD-OUEST
}
 if ($Solar_Azimuth_Angle_deg > '224.9')
{
   $Solar_Cardinal_point = 11;   //SUD-OUEST
}
 if ($Solar_Azimuth_Angle_deg > '247.4')
{
   $Solar_Cardinal_point = 12;   //OUEST-SUD-OUEST
}
 if ($Solar_Azimuth_Angle_deg > '269.9')
{
   $Solar_Cardinal_point = 13;   //OUEST
}
 if ($Solar_Azimuth_Angle_deg > '292.4')
{
   $Solar_Cardinal_point = 14;   // OUEST-NORD-OUEST
}
 if ($Solar_Azimuth_Angle_deg > '314.9')
{
   $Solar_Cardinal_point = 15;   // NOORD-OUEST
}
 if ($Solar_Azimuth_Angle_deg > '337.4')
{
   $Solar_Cardinal_point = 16;   //NORD-NORD-OUEST
}
 if ($Solar_Azimuth_Angle_deg > 360)
{
   $Solar_Cardinal_point = 1;   //NORD
}


$content_type = 'text/xml';
sdk_header($content_type);

echo "<Data>";
echo "<Parametres>";
echo "<Latitude>".$ma_latitude."</Latitude>";
echo "<Longitude>".$ma_longitude."</Longitude>";
echo "<Date>".$date."</Date>";
echo "<Date_mk>".$date_mk."</Date_mk>";
echo "<Heure_mk>".$heure_mk."</Heure_mk>";
echo "<Time_zone>".$time_zone."</Time_zone>";
echo "</Parametres>";

echo "<Soleil>";
echo "<Julian_Day>".$Julian_Day."</Julian_Day>";
echo "<Julian_Century>".$Julian_Century."</Julian_Century>";
echo "<Geom_Mean_Long_Sun_deg>".$Geom_Mean_Long_Sun_deg."</Geom_Mean_Long_Sun_deg>";
echo "<Geom_Mean_Anom_Sun_deg>".$Geom_Mean_Anom_Sun_deg."</Geom_Mean_Anom_Sun_deg>";
echo "<Sun_Eq_of_Ctr>".$Sun_Eq_of_Ctr."</Sun_Eq_of_Ctr>";
echo "<Sun_True_Long_deg>".$Sun_True_Long_deg."</Sun_True_Long_deg>";
echo "<Sun_True_Anom_deg>".$Sun_True_Anom_deg."</Sun_True_Anom_deg>";
echo "<Eccent_Earth_Orbit>".$Eccent_Earth_Orbit."</Eccent_Earth_Orbit>";
echo "<Sun_Rad_Vector_AUs>".$Sun_Rad_Vector_AUs."</Sun_Rad_Vector_AUs>";
echo "<Sun_App_Long_deg>".$Sun_App_Long_deg."</Sun_App_Long_deg>";
echo "<Mean_Obliq_Ecliptic_deg>".$Mean_Obliq_Ecliptic_deg."</Mean_Obliq_Ecliptic_deg>";
echo "<Obliq_Corr_deg>".$Obliq_Corr_deg."</Obliq_Corr_deg>";
echo "<SunRt_Ascen_deg>".$SunRt_Ascen_deg."</SunRt_Ascen_deg>";
echo "<Sun_Declin_deg>".$Sun_Declin_deg."</Sun_Declin_deg>";
echo "<y>".$y."</y>";
echo "<Eq_of_Time_minutes>".$Eq_of_Time_minutes."</Eq_of_Time_minutes>";
echo "<HA_Sunrise_deg_1>".$HA_Sunrise_deg."</HA_Sunrise_deg_1>";
echo "<Solar_Noon_LST>".$Solar_Noon_LST."</Solar_Noon_LST>";
echo "<Sunrise_Time_LST>".$Sunrise_Time_LST."</Sunrise_Time_LST>";
echo "<Sunset_Time_LST>".$Sunset_Time_LST."</Sunset_Time_LST>";
echo "<Sunlight_Duration_minutes>".$Sunlight_Duration_minutes."</Sunlight_Duration_minutes>";
echo "<True_Solar_Time_min>".$True_Solar_Time_min."</True_Solar_Time_min>";
echo "<Hour_Angle_deg>".$Hour_Angle_deg."</Hour_Angle_deg>";
echo "<Solar_Zenith_Angle_deg>".$Solar_Zenith_Angle_deg."</Solar_Zenith_Angle_deg>";

echo "<Solar_Elevation_Angle_deg>".$Solar_Elevation_Angle_deg."</Solar_Elevation_Angle_deg>";
echo "<Approx_Atmospheric_Refraction_deg>".$Approx_Atmospheric_Refraction_deg."</Approx_Atmospheric_Refraction_deg>";
echo "<Solar_Elevation_corrected_for_atm_refraction_deg>".$Solar_Elevation_corrected_for_atm_refraction_deg."</Solar_Elevation_corrected_for_atm_refraction_deg>";
echo "<Solar_Azimuth>".$Solar_Azimuth_Angle_deg_cw_from_N."</Solar_Azimuth>";
echo "<Solar_Azimuth_round>".$Solar_Azimuth_Angle_deg."</Solar_Azimuth_round>";
echo "<Solar_Cardinal_point>".$Solar_Cardinal_point."</Solar_Cardinal_point>";


echo "</Soleil>";
echo "</Data>";

?>


Pensez à nommer le fichier "position_soleil.php"

j'utilise "notepad++" pour éditer mes scripts.
Auteur:  dplein [ 26 Mars 2015 12:05 ]
Sujet du message:  Re: calcul position du soleil

Merci !!!!!
Auteur:  vva [ 26 Mars 2015 21:49 ]
Sujet du message:  Re: calcul position du soleil

J'ai apporté quelques modif au précédent script:
Il prend en charge la passage à l'heure d'été et est plus précis au niveau de l'élévation.

Code : Tout sélectionner
<?php

// Version v0.10
// CE SCRIPT EXPERIMENTAL REALISE EN PHP PERMET DE DETERMINER LA POSITION DU SOLEIL (AZIMUT + ELEVATION, ...)
// L'ALGORYTHME EST BASÉ SUR UNE ÉTUDE FAITE PAR LE National Oceanic and Atmospheric Administration

// LES VARIABLES DE LA BOX EEDOMUS:
// [VAR1] = @IP DE LA BOX
// [VAR2] = Latitude (+ => N)
// [VAR3] = Longitude (+ => E)

// Les latitude et longitude doivent contenir des "." (PAS DE VIRGULE)
// EXEMPLE: Latitude = 48.858346
//          Longitude = 2.294496
// OU
//
// EXEMPLE: Latitude = 48.387942
//          Longitude = -4.484993

// EXEMPLE APPEL DE SCRIPT avec variables: http://[VAR1]/script/?exec=position_soleil.php&latitude=[VAR2]&longitude=[VAR3]
// EXEMPLE APPEL DE SCRIPT dans navigateur: http://@IP_BOX_EEDOMUS/script/?exec=position_soleil.php&latitude=48.858346&longitude=2.294496

// LE RESULTAT EST SOUS FORME XML
// L'ELEVATION CORRESPOND A L'ANGLE ENTRE L'HORIZON ET LE SOLEIL
// XPATH ELEVATION: /Data/Soleil/Solar_Elevation_corrected_for_atm_refraction_deg

// L'AZIMUT CORRESPOND A L'ANGLE ENTRE LE NORD ET LE SOLEIL
// XPATH AZIMUT: /Data/Soleil/Solar_Azimuth_round
// 0°/ 360° = NORD
// 90° = EST
// 180° = SUD
// 270° = OUEST

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

// Stocker les variables passées en argument
$ma_latitude = getArg('latitude');
$ma_longitude = getArg('longitude');
$date = date('Y/m/d H:i:s');
$day_year = date('z');
$year = date('Y');

// mktime calcule en secondes la différence entre le 01/01/1970 et aujourd'hui
$date_mk_unix = mktime(0, 0, 0, date('d'), date('m'), date('Y'));
// Correction EXCEL / UNIX: 2161530000 correspond en seconde à la différence en 1900 et 1970
$correction_unix = 2161530000 /84600;

// 84600 = 3600 * 24 (nombre de seconde en 1 jour)
$date_mk = round($date_mk_unix / 84600);
$date_mk_unix = round($date_mk_unix / 84600 );

$date_mk = $date_mk + $correction_unix;

// Recalcul avec correction
$correction_dephasage = round($date_mk * '0.0238');
$date_mk = $date_mk - $correction_dephasage;

// Time zone par défaut = Heure d'hiver
$time_zone = 1;

// SI JOUR > A 86 ET < A 297 = HEURE D'ETE: TIME_ZONE = 2 SINON = TIME_ZONE = 1
if ($day_year > 86)
{
   if ($day_year < 297)
   {
      // Heure d'été
      $time_zone = 2;
   }
}

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

$heure = date('H');
$heure_mk = $heure / 24;

$Julian_Day = $date_mk + '2415018.5' + $heure_mk;

$Julian_Day_2 = $time_zone / 24;
$Julian_Day = $Julian_Day - $Julian_Day_2;

$Julian_Century = $Julian_Day - 2451545;
$Julian_Century = $Julian_Century / 36525;

$Geom_Mean_Long_Sun_deg_1 = $Julian_Century * '0.0003032';
$Geom_Mean_Long_Sun_deg_1 = '36000.76983' + $Geom_Mean_Long_Sun_deg_1;
$Geom_Mean_Long_Sun_deg_1 = $Julian_Century * $Geom_Mean_Long_Sun_deg_1;
$Geom_Mean_Long_Sun_deg = fmod('280.46646' + $Geom_Mean_Long_Sun_deg_1,360);

$Geom_Mean_Anom_Sun_deg = '0.0001537' * $Julian_Century;
$Geom_Mean_Anom_Sun_deg = '35999.05029' - $Geom_Mean_Anom_Sun_deg;
$Geom_Mean_Anom_Sun_deg = $Julian_Century * $Geom_Mean_Anom_Sun_deg;
$Geom_Mean_Anom_Sun_deg = '357.52911' + $Geom_Mean_Anom_Sun_deg;

$Eccent_Earth_Orbit = '0.0000001267'*$Julian_Century;
$Eccent_Earth_Orbit = '0.000042037' + $Eccent_Earth_Orbit;
$Eccent_Earth_Orbit = $Julian_Century * $Eccent_Earth_Orbit;
$Eccent_Earth_Orbit = '0.016708634' - $Eccent_Earth_Orbit;

$Sun_Eq_of_Ctr_1 = deg2rad(3 * $Geom_Mean_Anom_Sun_deg);
$Sun_Eq_of_Ctr_1 = sin($Sun_Eq_of_Ctr_1);
$Sun_Eq_of_Ctr_1 = $Sun_Eq_of_Ctr_1 * '0.000289';
$Sun_Eq_of_Ctr_2 = '0.000101' * $Julian_Century;
$Sun_Eq_of_Ctr_2 = '0.019993' - $Sun_Eq_of_Ctr_2;
$Sun_Eq_of_Ctr_3 = deg2rad(2* $Geom_Mean_Anom_Sun_deg);
$Sun_Eq_of_Ctr_3 = sin($Sun_Eq_of_Ctr_3);
$Sun_Eq_of_Ctr = $Sun_Eq_of_Ctr_2 * $Sun_Eq_of_Ctr_3;
$Sun_Eq_of_Ctr = $Sun_Eq_of_Ctr + $Sun_Eq_of_Ctr_1;
$Sun_Eq_of_Ctr_3 = '0.000014' * $Julian_Century;
$Sun_Eq_of_Ctr_3 = $Sun_Eq_of_Ctr_3 + '0.004817';
$Sun_Eq_of_Ctr_3 = $Julian_Century * $Sun_Eq_of_Ctr_3;
$Sun_Eq_of_Ctr_3 = '1.914602' - $Sun_Eq_of_Ctr_3;
$Sun_Eq_of_Ctr_2 = deg2rad( $Geom_Mean_Anom_Sun_deg);
$Sun_Eq_of_Ctr_2 = sin($Sun_Eq_of_Ctr_2);
$Sun_Eq_of_Ctr_2 = $Sun_Eq_of_Ctr_2*$Sun_Eq_of_Ctr_3;
$Sun_Eq_of_Ctr = $Sun_Eq_of_Ctr_2 + $Sun_Eq_of_Ctr;

$Sun_True_Long_deg = $Geom_Mean_Long_Sun_deg + $Sun_Eq_of_Ctr;

$Sun_True_Anom_deg = $Geom_Mean_Anom_Sun_deg + $Sun_Eq_of_Ctr;

$Sun_Rad_Vector_AUs_1 = deg2rad($Sun_True_Anom_deg);
$Sun_Rad_Vector_AUs_1 = cos($Sun_Rad_Vector_AUs_1);
$Sun_Rad_Vector_AUs_1 = $Eccent_Earth_Orbit * $Sun_Rad_Vector_AUs_1;
$Sun_Rad_Vector_AUs = 1 + $Sun_Rad_Vector_AUs_1;
$Sun_Rad_Vector_AUs_1  = $Eccent_Earth_Orbit*$Eccent_Earth_Orbit;
$Sun_Rad_Vector_AUs_1 = 1-$Sun_Rad_Vector_AUs_1;
$Sun_Rad_Vector_AUs_1 = '1.000001018'*$Sun_Rad_Vector_AUs_1;
$Sun_Rad_Vector_AUs = $Sun_Rad_Vector_AUs_1 / $Sun_Rad_Vector_AUs;

$Sun_App_Long_deg_1 = '1934.136'*$Julian_Century;
$Sun_App_Long_deg_1 = '125.04'-$Sun_App_Long_deg_1;
$Sun_App_Long_deg_1 = deg2rad($Sun_App_Long_deg_1);
$Sun_App_Long_deg_1 = sin($Sun_App_Long_deg_1);
$Sun_App_Long_deg_1 = '0.00478'*$Sun_App_Long_deg_1;
$Sun_App_Long_deg = $Sun_True_Long_deg - '0.00569'-$Sun_App_Long_deg_1;

$Mean_Obliq_Ecliptic_deg = $Julian_Century * '0.001813';
$Mean_Obliq_Ecliptic_deg = '0.00059'- $Mean_Obliq_Ecliptic_deg;
$Mean_Obliq_Ecliptic_deg = $Julian_Century * $Mean_Obliq_Ecliptic_deg;
$Mean_Obliq_Ecliptic_deg = '46.815' + $Mean_Obliq_Ecliptic_deg;
$Mean_Obliq_Ecliptic_deg = $Julian_Century * $Mean_Obliq_Ecliptic_deg;
$Mean_Obliq_Ecliptic_deg = '21.448' - $Mean_Obliq_Ecliptic_deg;
$Mean_Obliq_Ecliptic_deg = $Mean_Obliq_Ecliptic_deg / 60;
$Mean_Obliq_Ecliptic_deg = '26' + $Mean_Obliq_Ecliptic_deg;
$Mean_Obliq_Ecliptic_deg = $Mean_Obliq_Ecliptic_deg / 60;
$Mean_Obliq_Ecliptic_deg = 23 + $Mean_Obliq_Ecliptic_deg;

$Obliq_Corr_deg = '1934.136'*$Julian_Century;
$Obliq_Corr_deg = '125.04'-$Obliq_Corr_deg;
$Obliq_Corr_deg = deg2rad($Obliq_Corr_deg);
$Obliq_Corr_deg = cos($Obliq_Corr_deg);
$Obliq_Corr_deg = $Obliq_Corr_deg*'0.00256';
$Obliq_Corr_deg = $Mean_Obliq_Ecliptic_deg + $Obliq_Corr_deg;

$Sun_Declin_deg_1 = deg2rad($Sun_App_Long_deg);
$Sun_Declin_deg_1 = sin($Sun_Declin_deg_1);
$Sun_Declin_deg_2 = deg2rad($Obliq_Corr_deg);
$Sun_Declin_deg_2 = sin($Sun_Declin_deg_2);
$Sun_Declin_deg = asin($Sun_Declin_deg_1*$Sun_Declin_deg_2);
$Sun_Declin_deg = rad2deg($Sun_Declin_deg);

$SunRt_Ascen_deg_1 = deg2rad($Sun_App_Long_deg);
$SunRt_Ascen_deg_1 = sin($SunRt_Ascen_deg_1);
$SunRt_Ascen_deg_2 = deg2rad($Obliq_Corr_deg);
$SunRt_Ascen_deg_2 = cos($SunRt_Ascen_deg_2);
$SunRt_Ascen_deg_1 = $SunRt_Ascen_deg_2 * $SunRt_Ascen_deg_1;
$SunRt_Ascen_deg_2 = deg2rad($Sun_App_Long_deg);
$SunRt_Ascen_deg_2 = cos($SunRt_Ascen_deg_2);
$SunRt_Ascen_deg = atan2($SunRt_Ascen_deg_1, $SunRt_Ascen_deg_2);
$SunRt_Ascen_deg = rad2deg($SunRt_Ascen_deg);

$y_1 = $Obliq_Corr_deg/2;
$y_1 = deg2rad($y_1);
$y_1 = tan($y_1);
$y = $Obliq_Corr_deg/2;
$y = deg2rad($y);
$y = tan($y);
$y = $y * $y_1;

$Eq_of_Time_minutes_1 = deg2rad($Geom_Mean_Anom_Sun_deg);
$Eq_of_Time_minutes_1 = 2 * $Eq_of_Time_minutes_1;
$Eq_of_Time_minutes_1 = sin($Eq_of_Time_minutes_1);
$Eq_of_Time_minutes_1 = '1.25' * $Eccent_Earth_Orbit * $Eccent_Earth_Orbit * $Eq_of_Time_minutes_1;
$Eq_of_Time_minutes_2 = deg2rad($Geom_Mean_Long_Sun_deg);
$Eq_of_Time_minutes_2 = 4 * $Eq_of_Time_minutes_2;
$Eq_of_Time_minutes_2 = sin($Eq_of_Time_minutes_2);
$Eq_of_Time_minutes_2 = '0.5' * $y * $y * $Eq_of_Time_minutes_2;
$Eq_of_Time_minutes_3 = deg2rad($Geom_Mean_Long_Sun_deg);
$Eq_of_Time_minutes_3 = 2 * $Eq_of_Time_minutes_3;
$Eq_of_Time_minutes_3 = cos($Eq_of_Time_minutes_3);
$Eq_of_Time_minutes_4 = deg2rad($Geom_Mean_Anom_Sun_deg);
$Eq_of_Time_minutes_4 = sin($Eq_of_Time_minutes_4);
$Eq_of_Time_minutes_4 = 4 * $Eccent_Earth_Orbit * $y * $Eq_of_Time_minutes_4 * $Eq_of_Time_minutes_3;
$Eq_of_Time_minutes_5 = deg2rad($Geom_Mean_Anom_Sun_deg);
$Eq_of_Time_minutes_5 = sin($Eq_of_Time_minutes_5);
$Eq_of_Time_minutes_5 = 2 * $Eccent_Earth_Orbit * $Eq_of_Time_minutes_5;
$Eq_of_Time_minutes_6 = deg2rad($Geom_Mean_Long_Sun_deg);
$Eq_of_Time_minutes_6 = 2 * $Eq_of_Time_minutes_6;
$Eq_of_Time_minutes_6 = sin($Eq_of_Time_minutes_6);
$Eq_of_Time_minutes_6 = $y * $Eq_of_Time_minutes_6;

$Eq_of_Time_minutes = $Eq_of_Time_minutes_6 - $Eq_of_Time_minutes_5 + $Eq_of_Time_minutes_4 - $Eq_of_Time_minutes_2 - $Eq_of_Time_minutes_1;
$Eq_of_Time_minutes = 4 * rad2deg($Eq_of_Time_minutes);

$HA_Sunrise_deg_1 = deg2rad($Sun_Declin_deg);
$HA_Sunrise_deg_1 = tan($HA_Sunrise_deg_1);
$HA_Sunrise_deg_2 = deg2rad($ma_latitude);
$HA_Sunrise_deg_2 = tan($HA_Sunrise_deg_2);
$HA_Sunrise_deg_1 = $HA_Sunrise_deg_1 * $HA_Sunrise_deg_2;
$HA_Sunrise_deg_2 = deg2rad($Sun_Declin_deg);
$HA_Sunrise_deg_5 = cos($HA_Sunrise_deg_2);
$HA_Sunrise_deg_3 = deg2rad($ma_latitude);
$HA_Sunrise_deg_3 = cos($HA_Sunrise_deg_3);
$HA_Sunrise_deg_3 = $HA_Sunrise_deg_3 * $HA_Sunrise_deg_5;
$HA_Sunrise_deg_4 = deg2rad('90.833');
$HA_Sunrise_deg_4 = cos($HA_Sunrise_deg_4);
$HA_Sunrise_deg = $HA_Sunrise_deg_4 / $HA_Sunrise_deg_3;
$HA_Sunrise_deg = $HA_Sunrise_deg - $HA_Sunrise_deg_1;
$HA_Sunrise_deg = acos($HA_Sunrise_deg);
$HA_Sunrise_deg = rad2deg($HA_Sunrise_deg);

$Solar_Noon_LST = $time_zone * 60;
$Solar_Noon_LST_1 = 4 * $ma_longitude;
$Solar_Noon_LST = 720 - $Solar_Noon_LST_1 - $Eq_of_Time_minutes + $Solar_Noon_LST;
$Solar_Noon_LST = $Solar_Noon_LST / 1440;

$Sunrise_Time_LST = $HA_Sunrise_deg*4;
$Sunrise_Time_LST = $Sunrise_Time_LST / 1440;
$Sunrise_Time_LST = $Solar_Noon_LST - $Sunrise_Time_LST;

$Sunset_Time_LST = $HA_Sunrise_deg*4;
$Sunset_Time_LST = $Sunset_Time_LST / 1440;
$Sunset_Time_LST = $Solar_Noon_LST + $Sunset_Time_LST;

$Sunlight_Duration_minutes = 8* $HA_Sunrise_deg;


$True_Solar_Time_min_1 = 60 * $time_zone;
$True_Solar_Time_min_2 = 4 * $ma_longitude;
$True_Solar_Time_min_3 = $heure_mk * 1440;
$True_Solar_Time_min = $True_Solar_Time_min_3 + $Eq_of_Time_minutes + $True_Solar_Time_min_2 - $True_Solar_Time_min_1;
$True_Solar_Time_min = fmod($True_Solar_Time_min, 1440);

if ($True_Solar_Time_min/4 < 0)
{
   $Hour_Angle_deg = $True_Solar_Time_min / 4;
   $Hour_Angle_deg = $Hour_Angle_deg +180;
}
else
{
   $Hour_Angle_deg = $True_Solar_Time_min / 4;
   $Hour_Angle_deg = $Hour_Angle_deg -180;
}

$Solar_Zenith_Angle_deg_1 = deg2rad($Hour_Angle_deg);
$Solar_Zenith_Angle_deg_1  = cos($Solar_Zenith_Angle_deg_1 );
$Solar_Zenith_Angle_deg_2 = deg2rad($Sun_Declin_deg);
$Solar_Zenith_Angle_deg_2  = cos($Solar_Zenith_Angle_deg_2 );
$Solar_Zenith_Angle_deg_3 = deg2rad($ma_latitude);
$Solar_Zenith_Angle_deg_3  = cos($Solar_Zenith_Angle_deg_3 );
$Solar_Zenith_Angle_deg_3 = $Solar_Zenith_Angle_deg_1 * $Solar_Zenith_Angle_deg_2 * $Solar_Zenith_Angle_deg_3;
$Solar_Zenith_Angle_deg_4 = deg2rad($Sun_Declin_deg);
$Solar_Zenith_Angle_deg_4 = sin($Solar_Zenith_Angle_deg_4);
$Solar_Zenith_Angle_deg_5 = deg2rad($ma_latitude);
$Solar_Zenith_Angle_deg_5 = sin($Solar_Zenith_Angle_deg_5);
$Solar_Zenith_Angle_deg_5 = $Solar_Zenith_Angle_deg_5  * $Solar_Zenith_Angle_deg_4;   
$Solar_Zenith_Angle_deg = $Solar_Zenith_Angle_deg_5 + $Solar_Zenith_Angle_deg_3;
$Solar_Zenith_Angle_deg = acos($Solar_Zenith_Angle_deg);
$Solar_Zenith_Angle_deg = rad2deg($Solar_Zenith_Angle_deg);

$Solar_Elevation_Angle_deg = 90 - $Solar_Zenith_Angle_deg;

// A FAIRE
$Approx_Atmospheric_Refraction_deg = 0;

$Solar_Elevation_corrected_for_atm_refraction_deg = $Solar_Elevation_Angle_deg + $Approx_Atmospheric_Refraction_deg;

if ($Hour_Angle_deg > 0)
{
   $Solar_Azimuth_Angle_deg_cw_from_N_1 = deg2rad($Solar_Zenith_Angle_deg);
   $Solar_Azimuth_Angle_deg_cw_from_N_1 = sin($Solar_Azimuth_Angle_deg_cw_from_N_1);
   $Solar_Azimuth_Angle_deg_cw_from_N_2 = deg2rad($ma_latitude);
   $Solar_Azimuth_Angle_deg_cw_from_N_2 = cos($Solar_Azimuth_Angle_deg_cw_from_N_2 );
   $Solar_Azimuth_Angle_deg_cw_from_N_1 = $Solar_Azimuth_Angle_deg_cw_from_N_1 * $Solar_Azimuth_Angle_deg_cw_from_N_2;
   $Solar_Azimuth_Angle_deg_cw_from_N_3 = deg2rad($Sun_Declin_deg);
   $Solar_Azimuth_Angle_deg_cw_from_N_3 = sin($Solar_Azimuth_Angle_deg_cw_from_N_3);
   $Solar_Azimuth_Angle_deg_cw_from_N_4 = deg2rad($Solar_Zenith_Angle_deg);
   $Solar_Azimuth_Angle_deg_cw_from_N_4 = cos($Solar_Azimuth_Angle_deg_cw_from_N_4);
   $Solar_Azimuth_Angle_deg_cw_from_N_5 = deg2rad($ma_latitude);
   $Solar_Azimuth_Angle_deg_cw_from_N_5 = cos($Solar_Azimuth_Angle_deg_cw_from_N_5 );
   $Solar_Azimuth_Angle_deg_cw_from_N_5 = $Solar_Azimuth_Angle_deg_cw_from_N_5 * $Solar_Azimuth_Angle_deg_cw_from_N_4;
   $Solar_Azimuth_Angle_deg_cw_from_N_5 = $Solar_Azimuth_Angle_deg_cw_from_N_5 - $Solar_Azimuth_Angle_deg_cw_from_N_3;   
   $Solar_Azimuth_Angle_deg_cw_from_N = acos($Solar_Azimuth_Angle_deg_cw_from_N_5 / $Solar_Azimuth_Angle_deg_cw_from_N_1);   
   $Solar_Azimuth_Angle_deg_cw_from_N = rad2deg($Solar_Azimuth_Angle_deg_cw_from_N) + 180;
   $Solar_Azimuth_Angle_deg_cw_from_N = fmod($Solar_Azimuth_Angle_deg_cw_from_N,360);
}
else
{
   $Solar_Azimuth_Angle_deg_cw_from_N_1 = deg2rad($Solar_Zenith_Angle_deg);
   $Solar_Azimuth_Angle_deg_cw_from_N_1 = sin($Solar_Azimuth_Angle_deg_cw_from_N_1);
   $Solar_Azimuth_Angle_deg_cw_from_N_2 = deg2rad($ma_latitude);
   $Solar_Azimuth_Angle_deg_cw_from_N_2 = cos($Solar_Azimuth_Angle_deg_cw_from_N_2 );
   $Solar_Azimuth_Angle_deg_cw_from_N_1 = $Solar_Azimuth_Angle_deg_cw_from_N_1 * $Solar_Azimuth_Angle_deg_cw_from_N_2;   
   $Solar_Azimuth_Angle_deg_cw_from_N_3 = deg2rad($Sun_Declin_deg);
   $Solar_Azimuth_Angle_deg_cw_from_N_3 = sin($Solar_Azimuth_Angle_deg_cw_from_N_3);
   $Solar_Azimuth_Angle_deg_cw_from_N_4 = deg2rad($Solar_Zenith_Angle_deg);
   $Solar_Azimuth_Angle_deg_cw_from_N_4 = cos($Solar_Azimuth_Angle_deg_cw_from_N_4);
   $Solar_Azimuth_Angle_deg_cw_from_N_5 = deg2rad($ma_latitude);
   $Solar_Azimuth_Angle_deg_cw_from_N_5 = cos($Solar_Azimuth_Angle_deg_cw_from_N_5 );
   $Solar_Azimuth_Angle_deg_cw_from_N_5 = $Solar_Azimuth_Angle_deg_cw_from_N_5 * $Solar_Azimuth_Angle_deg_cw_from_N_4;
   $Solar_Azimuth_Angle_deg_cw_from_N_5 = $Solar_Azimuth_Angle_deg_cw_from_N_5 - $Solar_Azimuth_Angle_deg_cw_from_N_3;   
   $Solar_Azimuth_Angle_deg_cw_from_N = acos($Solar_Azimuth_Angle_deg_cw_from_N_5 / $Solar_Azimuth_Angle_deg_cw_from_N_1);   
   $Solar_Azimuth_Angle_deg_cw_from_N = 540 - rad2deg($Solar_Azimuth_Angle_deg_cw_from_N);
   $Solar_Azimuth_Angle_deg_cw_from_N = fmod($Solar_Azimuth_Angle_deg_cw_from_N,360);
}

$Solar_Azimuth_Angle_deg = round($Solar_Azimuth_Angle_deg_cw_from_N);

// Associé le point cardinal à l'angle
if ($Solar_Azimuth_Angle_deg == 0)
{
    $Solar_Cardinal_point = 1;   // NORD
}
if ($Solar_Azimuth_Angle_deg > '22.4')
{
    $Solar_Cardinal_point = 2;   // NORD-NORD-EST
}
 if ($Solar_Azimuth_Angle_deg > '44.9')
{
   $Solar_Cardinal_point = 3;   //NORD-EST
}
 if ($Solar_Azimuth_Angle_deg > '67.4')
{
   $Solar_Cardinal_point = 4;   //EST-NORD-EST
}
 if ($Solar_Azimuth_Angle_deg > 90)
{
   $Solar_Cardinal_point = 5;   //EST
}
 if ($Solar_Azimuth_Angle_deg > '112.5')
{
   $Solar_Cardinal_point = 6;   //EST-SUD-EST
}
 if ($Solar_Azimuth_Angle_deg > '134.9')
{
   $Solar_Cardinal_point = 7;   //SUD-EST
}
 if ($Solar_Azimuth_Angle_deg > '157.4')
{
   $Solar_Cardinal_point = 8;   //SUD-SUD-EST
}
 if ($Solar_Azimuth_Angle_deg > '179.9')
{
   $Solar_Cardinal_point = 9;   //SUD
}
 if ($Solar_Azimuth_Angle_deg > '202.4')
{
   $Solar_Cardinal_point = 10;   //SUD-SUD-OUEST
}
 if ($Solar_Azimuth_Angle_deg > '224.9')
{
   $Solar_Cardinal_point = 11;   //SUD-OUEST
}
 if ($Solar_Azimuth_Angle_deg > '247.4')
{
   $Solar_Cardinal_point = 12;   //OUEST-SUD-OUEST
}
 if ($Solar_Azimuth_Angle_deg > '269.9')
{
   $Solar_Cardinal_point = 13;   //OUEST
}
 if ($Solar_Azimuth_Angle_deg > '292.4')
{
   $Solar_Cardinal_point = 14;   // OUEST-NORD-OUEST
}
 if ($Solar_Azimuth_Angle_deg > '314.9')
{
   $Solar_Cardinal_point = 15;   // NOORD-OUEST
}
 if ($Solar_Azimuth_Angle_deg > '337.4')
{
   $Solar_Cardinal_point = 16;   //NORD-NORD-OUEST
}
 if ($Solar_Azimuth_Angle_deg > 360)
{
   $Solar_Cardinal_point = 1;   //NORD
}


$content_type = 'text/xml';
sdk_header($content_type);

echo "<Data>";
echo "<Parametres>";
echo "<Latitude>".$ma_latitude."</Latitude>";
echo "<Longitude>".$ma_longitude."</Longitude>";
echo "<Date>".$date."</Date>";
echo "<Jour_annee>".$day_year."</Jour_annee>";
echo "<Date_mk_unix>".$date_mk_unix."</Date_mk_unix>";
echo "<Correction_unix>".$correction_unix."</Correction_unix>";
echo "<correction_dephasage>".$correction_dephasage."</correction_dephasage>";
echo "<Date_mk>".$date_mk."</Date_mk>";
echo "<Heure_mk>".$heure_mk."</Heure_mk>";
echo "<Time_zone>".$time_zone."</Time_zone>";
echo "</Parametres>";

echo "<Soleil>";
echo "<Julian_Day>".$Julian_Day."</Julian_Day>";
echo "<Julian_Century>".$Julian_Century."</Julian_Century>";
echo "<Geom_Mean_Long_Sun_deg>".$Geom_Mean_Long_Sun_deg."</Geom_Mean_Long_Sun_deg>";
echo "<Geom_Mean_Anom_Sun_deg>".$Geom_Mean_Anom_Sun_deg."</Geom_Mean_Anom_Sun_deg>";
echo "<Sun_Eq_of_Ctr>".$Sun_Eq_of_Ctr."</Sun_Eq_of_Ctr>";
echo "<Sun_True_Long_deg>".$Sun_True_Long_deg."</Sun_True_Long_deg>";
echo "<Sun_True_Anom_deg>".$Sun_True_Anom_deg."</Sun_True_Anom_deg>";
echo "<Eccent_Earth_Orbit>".$Eccent_Earth_Orbit."</Eccent_Earth_Orbit>";
echo "<Sun_Rad_Vector_AUs>".$Sun_Rad_Vector_AUs."</Sun_Rad_Vector_AUs>";
echo "<Sun_App_Long_deg>".$Sun_App_Long_deg."</Sun_App_Long_deg>";
echo "<Mean_Obliq_Ecliptic_deg>".$Mean_Obliq_Ecliptic_deg."</Mean_Obliq_Ecliptic_deg>";
echo "<Obliq_Corr_deg>".$Obliq_Corr_deg."</Obliq_Corr_deg>";
echo "<SunRt_Ascen_deg>".$SunRt_Ascen_deg."</SunRt_Ascen_deg>";
echo "<Sun_Declin_deg>".$Sun_Declin_deg."</Sun_Declin_deg>";
echo "<y>".$y."</y>";
echo "<Eq_of_Time_minutes>".$Eq_of_Time_minutes."</Eq_of_Time_minutes>";
echo "<HA_Sunrise_deg_1>".$HA_Sunrise_deg."</HA_Sunrise_deg_1>";
echo "<Solar_Noon_LST>".$Solar_Noon_LST."</Solar_Noon_LST>";
echo "<Sunrise_Time_LST>".$Sunrise_Time_LST."</Sunrise_Time_LST>";
echo "<Sunset_Time_LST>".$Sunset_Time_LST."</Sunset_Time_LST>";
echo "<Sunlight_Duration_minutes>".$Sunlight_Duration_minutes."</Sunlight_Duration_minutes>";
echo "<True_Solar_Time_min>".$True_Solar_Time_min."</True_Solar_Time_min>";
echo "<Hour_Angle_deg>".$Hour_Angle_deg."</Hour_Angle_deg>";
echo "<Solar_Zenith_Angle_deg>".$Solar_Zenith_Angle_deg."</Solar_Zenith_Angle_deg>";
echo "<Solar_Elevation_Angle_deg>".$Solar_Elevation_Angle_deg."</Solar_Elevation_Angle_deg>";
echo "<Approx_Atmospheric_Refraction_deg>".$Approx_Atmospheric_Refraction_deg."</Approx_Atmospheric_Refraction_deg>";
echo "<Solar_Elevation_corrected_for_atm_refraction_deg>".$Solar_Elevation_corrected_for_atm_refraction_deg."</Solar_Elevation_corrected_for_atm_refraction_deg>";
echo "<Solar_Azimuth>".$Solar_Azimuth_Angle_deg_cw_from_N."</Solar_Azimuth>";
echo "<Solar_Azimuth_round>".$Solar_Azimuth_Angle_deg."</Solar_Azimuth_round>";
echo "<Solar_Cardinal_point>".$Solar_Cardinal_point."</Solar_Cardinal_point>";


echo "</Soleil>";
echo "</Data>";

?>
Auteur:  Blanchard [ 27 Mars 2015 10:43 ]
Sujet du message:  Re: calcul position du soleil

Encore merci, je teste...
Auteur:  vva [ 27 Mars 2015 10:53 ]
Sujet du message:  Re: calcul position du soleil

Pour info: Il y un a une petite erreur de calcul qui décale de quelques degrés l'élévation (rien de bien grave). Je vais y remédier rapidement ...
Auteur:  dplein [ 27 Mars 2015 12:20 ]
Sujet du message:  Re: calcul position du soleil

Heu, il est midi chez moi (comme chez vous :D :D :D ), et ma position du soleil est 49°(?). On ne devrait pas être aux alentours de 90° ???
Auteur:  vva [ 27 Mars 2015 13:17 ]
Sujet du message:  Re: calcul position du soleil

:D
si tu habites au niveau de l'équateur (latitute = 0) : oui mais dans nos latitudes (entre 30 et 50°), le soleil ne dépasse pas les 70° (même en plein été).
Auteur:  dplein [ 27 Mars 2015 13:31 ]
Sujet du message:  Re: calcul position du soleil

Ah d'accord, j'avais pas vu ça comme çà !!!!

Alors on peut en tirer quoi de concret sur les résultats que l'on trouve....
Page 1 sur 8 Le fuseau horaire est UTC+1 heure