Pysolar is a collection of Python libraries for simulating the irradiation of any point on earth by the sun. It includes code for extremely precise ephemeris calculations.
Python
Switch branches/tags
Pull request Compare This branch is 1 commit ahead, 182 commits behind pingswept:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
debian
doc
images
pysolar.org
.gitignore
CONTRIBUTORS.markdown
COPYING
MANIFEST.in
README.markdown
__init__.py
constants.py
horizon.py
julian.py
pysolar_v_usno.csv
query_usno.py
radiation.py
setup.py
shade.py
shade_test.py
simulate.py
solar.py
sun_path_widget.py
testsolar.py
usno_data_6259.txt
usno_data_short_test.txt
util.py

README.markdown

Pysolar is a collection of Python libraries for simulating the irradiation of any point on earth by the sun. It includes code for extremely precise ephemeris calculations, and more.

Rough steps for use, until either forever or I have time to write more documentation:

  1. Install python.
  2. Get to a Python prompt.
  3. Execute code:
    import datetime, solar
    d = datetime.datetime.utcnow()
    lat = 42.0
    long = -71.0
    solar.GetAltitude(lat, long, d)
    solar.GetAzimuth(lat, long, d)

For better examples of usage, see the examples on Github.

Difference from PyEphem

Pysolar is similar to PyEphem, with a few key differences. Both libraries compute the location of the sun based on Bretagnon's VSOP 87 theory. Pysolar is aimed at modeling photovoltaic systems, while PyEphem is targeted at astronomers. Pysolar is written in pure Python, while PyEphem is a Python wrapper for the libastro library, written in C, which is part of XEphem.

Validation

Pysolar has recently been validated against similar ephemeris code maintained by the US Naval Observatory. In a random sampling of 6000 locations distributed across the Northern Hemisphere at random times in 2008, Pysolar matched the observatory’s predictions very accurately. The azimuth estimations correlated much more closely than the altitude estimations, but both agreed with the naval observatory’s to within less than 0.1 degrees on average.

More details on the validation page on Github.

A request

If you use Pysolar, please let me know how accurate it is. It's difficult to measure sun location with great precision, but I'd love to hear reports like, "Yeah, it worked to within a degree over the course of an afternoon in Spain."

Developer contact info

Brandon Stafford

brandon at pingswept org