Recommend this page to a friend! |
![]() |
Info | Example | ![]() |
![]() |
![]() |
Reputation | Support forum | Blog | Links |
Ratings | Unique User Downloads | Download Rankings | ||||
Not yet rated by the users | Total: 166 | All time: 8,899 This week: 42![]() |
Version | License | PHP version | Categories | |||
sun-position-spa-php 1.0.1 | Custom (specified... | 5 | Algorithms, PHP 5, Physics |
Collaborate with this project | Author | |
sun-position-spa-php - github.com Description This package can calculate the Sun position based on observations. |
|
<?php |
SPA Sun Position Calc Library for PHP
This library is based on the work of Ibrahim Reda and Afshin Andreas (SPA) Solar Position Algorithm for Solar Radiation Applications ( 2008 National Renewable Energy Laboratory )
There have been many published articles describing solar position algorithms for solar radiation applications. The best uncertainty achieved in most of these articles is greater than ±0.01 / in calculating the solar zenith and azimuth angles. For some, the algorithm is valid for a limited number of years varying from 15 years to a hundred years. This report is a step by step procedure for implementing an algorithm to calculate the solar zenith and azimuth angles in the period from the year -2000 to 6000, with uncertainties of ±0.0003°
Library test data vs Table A.4 of the original study
http://www.nrel.gov/midc/spa/
- PHP 5.6 - PHP 7
composer require abbadon1334/sun-position-spa-php
$SD = new SolarData\SolarData();
/ARGS : observer latitude, observer longitude, observer altitude/
$SD->setObserverPosition(39.742476,-105.1786,1830.14);
/ARGS : Observer Date : Year, Month, Day/
$SD->setObserverDate(2003, 10, 17);
/ARGS : Observer Time : Hours, Minutes, Seconds/
$SD->setObserverTime(12, 30,30);
/ARGS : difference in seconds between the Earth rotation time and the Terrestrial Time (TT)/
$SD->setDeltaTime(67);
/ARGS : Observer Timezone/
$SD->setObserverTimezone(-7);
/ARGS : Observer mean pressure in Millibar/
$SD->object->setObserverAtmosphericPressure(820);
/ARGS : Observer mean temperature in Celsius/
$SD->object->setObserverAtmosphericTemperature(11.0);
/calculate sun position/
$SunPosition = $SD->calculate();
I know this attributes names are not so ortodox. Formulas that are present in the original document are really complex and using the same name for variables is a big aid for debugging
Example to get angle H° - Observer hour angle (degrees)
$SD = new SolarData\SolarData();
/ARGS : observer latitude, observer longitude, observer altitude/
$SD->setObserverPosition(39.742476,-105.1786,1830.14);
/ARGS : Observer Date : Year, Month, Day/
$SD->setObserverDate(2003, 10, 17);
/ARGS : Observer Time : Hours, Minutes, Seconds/
$SD->setObserverTime(12, 30,30);
/ARGS : difference in seconds between the Earth rotation time and the Terrestrial Time (TT)/
$SD->setDeltaTime(67);
/ARGS : Observer Timezone/
$SD->setObserverTimezone(-7);
/ARGS : Observer mean pressure in Millibar/
$SD->object->setObserverAtmosphericPressure(820);
/ARGS : Observer mean temperature in Celsius/
$SD->object->setObserverAtmosphericTemperature(11.0);
/calculate sun position/
$SunPosition = $SD->calculate();
to get H° Observer hour angle (degrees)
echo $SunPosition->H°;
Example to get fraction day for sunrise - transit - sunset
$SD = new SolarData\SolarData();
/ARGS : observer latitude, observer longitude, observer altitude/
$SD->setObserverPosition(39.742476,-105.1786,1830.14);
/ARGS : Observer Date : Year, Month, Day/
$SD->setObserverDate(2003, 10, 17);
/ARGS : Observer Time : Hours, Minutes, Seconds/
$SD->setObserverTime(12, 30,30);
/ARGS : difference in seconds between the Earth rotation time and the Terrestrial Time (TT)/
$SD->setDeltaTime(67);
/ARGS : Observer Timezone/
$SD->setObserverTimezone(-7);
/ARGS : Observer mean pressure in Millibar/
$SD->object->setObserverAtmosphericPressure(820);
/ARGS : Observer mean temperature in Celsius/
$SD->object->setObserverAtmosphericTemperature(11.0);
/* calculate sun position and calculate sun rise transit set angles
ARGS : true = call ->calculate()
*/
$SunPosition = $SD->calculateSunRiseTransitSet(true);
$SunRiseDayFraction = $SunPosition->DayFractionSunrise;
$TransitDayFraction = $SunPosition->DayFractionTransit;
$SunsetDayFraction = $SunPosition->DayFractionSunset;
$SD = new SolarData\SolarData();
/ARGS : observer latitude, observer longitude, observer altitude/
$SD->setObserverPosition(39.742476,-105.1786,1830.14);
/ARGS : Observer Date : Year, Month, Day/
$SD->setObserverDate(2003, 10, 17);
/ARGS : Observer Time : Hours, Minutes, Seconds/
$SD->setObserverTime(12, 30,30);
/ARGS : difference in seconds between the Earth rotation time and the Terrestrial Time (TT)/
$SD->setDeltaTime(67);
/ARGS : Observer Timezone/
$SD->setObserverTimezone(-7);
/ARGS : Observer mean pressure in Millibar/
$SD->object->setObserverAtmosphericPressure(820);
/ARGS : Observer mean temperature in Celsius/
$SD->object->setObserverAtmosphericTemperature(11.0);
no need of calling calculate *
/ARGS : tilt angle from horizontal plane, rotation angle from real south/
$Surface2SunAngleOfIncidence = $SD->getSurfaceIncidenceAngle(30,-10)
![]() |
File | Role | Description | ||
---|---|---|---|---|
![]() |
||||
![]() |
||||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Example | Example script | ||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Example | Example script | ||
![]() ![]() |
Lic. | License text | ||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Doc. | Documentation | ||
![]() ![]() |
Data | Auxiliary data |
The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
![]() |
![]() | sun-position-spa-php-2019-07-15.zip 37KB |
![]() | sun-position-spa-php-2019-07-15.tar.gz 33KB |
![]() | Install with Composer |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.