{"id":17144184,"url":"https://github.com/abbadon1334/sun-position-spa-php","last_synced_at":"2025-08-01T14:11:46.511Z","repository":{"id":20648369,"uuid":"90516655","full_name":"abbadon1334/sun-position-spa-php","owner":"abbadon1334","description":"SPA Sun Position Calc Library for PHP","archived":false,"fork":false,"pushed_at":"2023-03-19T01:55:53.000Z","size":103,"stargazers_count":7,"open_issues_count":10,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-15T12:09:23.456Z","etag":null,"topics":["algorithm","azimuth-angles","degrees","longitude","php","sidereal","solar-position-algorithms","solar-radiation-applications","spa"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/abbadon1334.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-05-07T07:40:38.000Z","updated_at":"2024-05-06T07:20:13.000Z","dependencies_parsed_at":"2023-10-20T16:13:35.351Z","dependency_job_id":null,"html_url":"https://github.com/abbadon1334/sun-position-spa-php","commit_stats":{"total_commits":42,"total_committers":2,"mean_commits":21.0,"dds":"0.26190476190476186","last_synced_commit":"d68d9ee33f8899938801f269ede5a81574fdc2c7"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/abbadon1334/sun-position-spa-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abbadon1334%2Fsun-position-spa-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abbadon1334%2Fsun-position-spa-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abbadon1334%2Fsun-position-spa-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abbadon1334%2Fsun-position-spa-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abbadon1334","download_url":"https://codeload.github.com/abbadon1334/sun-position-spa-php/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abbadon1334%2Fsun-position-spa-php/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268240966,"owners_count":24218373,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-01T02:00:08.611Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithm","azimuth-angles","degrees","longitude","php","sidereal","solar-position-algorithms","solar-radiation-applications","spa"],"created_at":"2024-10-14T20:43:18.475Z","updated_at":"2025-08-01T14:11:46.465Z","avatar_url":"https://github.com/abbadon1334.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sun-Position-SPA-php\nSPA Sun Position Calc Library for PHP\n\n[![Build Status](https://travis-ci.org/abbadon1334/sun-position-spa-php.svg?branch=master)](https://travis-ci.org/abbadon1334/sun-position-spa-php)\n[![Coverage Status](https://coveralls.io/repos/github/abbadon1334/sun-position-spa-php/badge.svg?branch=upgrade-to-unit-8)](https://coveralls.io/github/abbadon1334/sun-position-spa-php?branch=upgrade-to-unit-8)\n[![Maintainability](https://api.codeclimate.com/v1/badges/fe0c85053b434e296254/maintainability)](https://codeclimate.com/github/abbadon1334/sun-position-spa-php/maintainability)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/fe0c85053b434e296254/test_coverage)](https://codeclimate.com/github/abbadon1334/sun-position-spa-php/test_coverage)\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/a3898544085a45b097a08cf01bff3131)](https://www.codacy.com/app/abbadon1334/sun-position-spa-php?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=abbadon1334/sun-position-spa-php\u0026amp;utm_campaign=Badge_Grade)\n[![Codacy Badge](https://api.codacy.com/project/badge/Coverage/a3898544085a45b097a08cf01bff3131)](https://www.codacy.com/app/abbadon1334/sun-position-spa-php?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=abbadon1334/sun-position-spa-php\u0026amp;utm_campaign=Badge_Coverage)\n\nThis library is based on the work of Ibrahim Reda and Afshin Andreas\n(SPA) Solar Position Algorithm for Solar Radiation Applications ( 2008 National Renewable Energy Laboratory )\n\n## Abstract from the original study\nThere have been many published articles describing solar position algorithms for solar radiation\napplications. The best uncertainty achieved in most of these articles is greater than ±0.01 / in\ncalculating the solar zenith and azimuth angles. For some, the algorithm is valid for a limited\nnumber of years varying from 15 years to a hundred years. This report is a step by step procedure\nfor implementing an algorithm to calculate the solar zenith and azimuth angles in the period from\nthe year -2000 to 6000, with uncertainties of ±0.0003°\n\n### PHPUNIT TEST\nLibrary test data vs Table A.4 of the original study\n\n### C Source code for Solar Position Algorithm (SPA) \nhttp://www.nrel.gov/midc/spa/\n\n### Requirements\n - PHP 7.2\n - PHP 7.3\n - PHP 7.4\n\n### Composer install\n```\ncomposer require abbadon1334/sun-position-spa-php\n```\n\n### Simple Usage\n```\n$SD = new SolarData\\SolarData();\n\n/* ARGS : observer latitude, observer longitude, observer altitude */\n$SD-\u003esetObserverPosition(39.742476,-105.1786,1830.14);\n\n/* ARGS : Observer Date : Year, Month, Day */\n$SD-\u003esetObserverDate(2003, 10, 17);\n\n/* ARGS : Observer Time : Hours, Minutes, Seconds */\n$SD-\u003esetObserverTime(12, 30,30);\n\n/* ARGS : difference in seconds between the Earth rotation time and the Terrestrial Time (TT) */\n$SD-\u003esetDeltaTime(67);\n/* ARGS : Observer Timezone */\n$SD-\u003esetObserverTimezone(-7);\n\n/* ARGS : Observer mean pressure in Millibar */\n$SD-\u003eobject-\u003esetObserverAtmosphericPressure(820);\n\n/* ARGS : Observer mean temperature in Celsius */\n$SD-\u003eobject-\u003esetObserverAtmosphericTemperature(11.0);\n\n/* calculate sun position */\n$SunPosition = $SD-\u003ecalculate();\n```\n#### Available attributes after calculate() :\n\n*I know this attributes names are not so ortodox.*\n*Formulas that are present in the original document are really complex and using the same name for variables is a big aid for debugging*\n\n* `L°` Earth heliocentric longitude (degrees)\n* `B°` Earth heliocentric latitude (degrees)\n* `R` Earth radius vector, R (in Astronomical Units, AU)\n* `Θ°` geocentric longitude (degrees)\n* `β°` geocentric longitude (degrees)\n* `X` nutation in longitude and obliquity\n* `ε°` true obliquity of the ecliptic (degrees)\n* `Δτ` aberration correction (degrees)\n* `λ°` apparent sun longitude (degrees)\n* `ν°` apparent sidereal time at Greenwich (degrees)\n* `ν0°` apparent mean sidereal time at Greenwich (degrees)\n* `α°` geocentric sun right ascension (degrees)\n* `α´°` topocentric sun right ascension (degrees)\n* `δ°` geocentric sun declination (degrees)\n* `δ´°` topocentric sun declination (degrees)\n* `H°` Observer hour angle (degrees)\n* `H´°` topocentric hour angle (degrees)\n* `ξ°` equatorial horizontal parallax of the sun (degrees)\n* `Z°` topocentric zenith angle (degrees)\n* `Γ°` topocentric astronomers azimuth angle (degrees)\n* `Φ°` topocentric azimuth angle, M for navigators and solar radiation users (in degrees)\n* `e0°` topocentric elevation angle without atmospheric refraction (in degrees)\n* `e°` topocentric elevation angle (in degrees)\n* `Eot` Equation Of Time\n\n*Example to get angle H° - Observer hour angle (degrees)*\n```\n$SD = new SolarData\\SolarData();\n\n/* ARGS : observer latitude, observer longitude, observer altitude */\n$SD-\u003esetObserverPosition(39.742476,-105.1786,1830.14);\n\n/* ARGS : Observer Date : Year, Month, Day */\n$SD-\u003esetObserverDate(2003, 10, 17);\n\n/* ARGS : Observer Time : Hours, Minutes, Seconds */\n$SD-\u003esetObserverTime(12, 30,30);\n\n/* ARGS : difference in seconds between the Earth rotation time and the Terrestrial Time (TT) */\n$SD-\u003esetDeltaTime(67);\n/* ARGS : Observer Timezone */\n$SD-\u003esetObserverTimezone(-7);\n\n/* ARGS : Observer mean pressure in Millibar */\n$SD-\u003eobject-\u003esetObserverAtmosphericPressure(820);\n\n/* ARGS : Observer mean temperature in Celsius */\n$SD-\u003eobject-\u003esetObserverAtmosphericTemperature(11.0);\n\n/* calculate sun position */\n$SunPosition = $SD-\u003ecalculate();\n```\nto get H° Observer hour angle (degrees)\n```\necho $SunPosition-\u003eH°;\n```\n\n*Example to get fraction day for sunrise - transit - sunset *\n```\n\n$SD = new SolarData\\SolarData();\n\n/* ARGS : observer latitude, observer longitude, observer altitude */\n$SD-\u003esetObserverPosition(39.742476,-105.1786,1830.14);\n\n/* ARGS : Observer Date : Year, Month, Day */\n$SD-\u003esetObserverDate(2003, 10, 17);\n\n/* ARGS : Observer Time : Hours, Minutes, Seconds */\n$SD-\u003esetObserverTime(12, 30,30);\n\n/* ARGS : difference in seconds between the Earth rotation time and the Terrestrial Time (TT) */\n$SD-\u003esetDeltaTime(67);\n/* ARGS : Observer Timezone */\n$SD-\u003esetObserverTimezone(-7);\n\n/* ARGS : Observer mean pressure in Millibar */\n$SD-\u003eobject-\u003esetObserverAtmosphericPressure(820);\n\n/* ARGS : Observer mean temperature in Celsius */\n$SD-\u003eobject-\u003esetObserverAtmosphericTemperature(11.0);\n\n/* calculate sun position and calculate sun rise transit set angles \nARGS : true = call -\u003ecalculate()\n*/\n$SunPosition = $SD-\u003ecalculateSunRiseTransitSet(true);\n\n$SunRiseDayFraction = $SunPosition-\u003eDayFractionSunrise;\n$TransitDayFraction = $SunPosition-\u003eDayFractionTransit;\n$SunsetDayFraction  = $SunPosition-\u003eDayFractionSunset;\n\n```\n### Get Sun Incidence Angle\n```\n\n$SD = new SolarData\\SolarData();\n\n/* ARGS : observer latitude, observer longitude, observer altitude */\n$SD-\u003esetObserverPosition(39.742476,-105.1786,1830.14);\n\n/* ARGS : Observer Date : Year, Month, Day */\n$SD-\u003esetObserverDate(2003, 10, 17);\n\n/* ARGS : Observer Time : Hours, Minutes, Seconds */\n$SD-\u003esetObserverTime(12, 30,30);\n\n/* ARGS : difference in seconds between the Earth rotation time and the Terrestrial Time (TT) */\n$SD-\u003esetDeltaTime(67);\n/* ARGS : Observer Timezone */\n$SD-\u003esetObserverTimezone(-7);\n\n/* ARGS : Observer mean pressure in Millibar */\n$SD-\u003eobject-\u003esetObserverAtmosphericPressure(820);\n\n/* ARGS : Observer mean temperature in Celsius */\n$SD-\u003eobject-\u003esetObserverAtmosphericTemperature(11.0);\n\n```\n* no need of calling calculate *\n```\n/* ARGS : tilt angle from horizontal plane, rotation angle from real south  */\n$Surface2SunAngleOfIncidence = $SD-\u003egetSurfaceIncidenceAngle(30,-10)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabbadon1334%2Fsun-position-spa-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabbadon1334%2Fsun-position-spa-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabbadon1334%2Fsun-position-spa-php/lists"}