public
Description: 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.
Homepage: http://pysolar.org
Clone URL: git://github.com/pingswept/pysolar.git
name age message
file CONTRIBUTORS.markdown Mon Nov 09 18:41:46 -0800 2009 Removed extra image, added Brent Pedersen to co... [pingswept]
file COPYING Sat Mar 01 15:36:54 -0800 2008 Initial import from SVN tag 0.2.0 [Brandon Stafford]
file MANIFEST.in Thu Jun 18 20:29:58 -0700 2009 Added setup.py and MANIFEST.in [pingswept]
file README.markdown Fri Apr 10 20:34:58 -0700 2009 Updated README and CONTRIBUTORS. [pingswept]
file __init__.py Thu Jun 18 14:42:42 -0700 2009 Updated sun path code, added __init__.py [pingswept]
file constants.py Sat Mar 08 17:06:06 -0800 2008 Broke code out into smaller files. Updated copy... [Brandon Stafford]
directory doc/ Tue Jan 27 20:19:03 -0800 2009 Started documentation folder using Sphinx [pingswept]
file horizon.py Thu Jun 18 14:42:42 -0700 2009 Updated sun path code, added __init__.py [pingswept]
directory images/ Fri Apr 10 21:52:13 -0700 2009 Added images for examples and documentation. [pingswept]
file julian.py Fri May 23 05:49:49 -0700 2008 julian.py: added missing parens [pingswept]
file poly.py Sat Mar 08 17:06:06 -0800 2008 Broke code out into smaller files. Updated copy... [Brandon Stafford]
directory pysolar.org/ Mon Nov 09 18:19:10 -0800 2009 Updated web page with other releases [pingswept]
file pysolar_v_usno.csv Sun Jan 11 17:39:44 -0800 2009 Updated validation data. [pingswept]
file query_usno.py Sun Jan 11 17:34:39 -0800 2009 Added corrections from Sean Taylor to GetParall... [pingswept]
file radiation.py Fri Sep 18 07:42:20 -0700 2009 Fixed accidental integer division; thanks to Br... [pingswept]
file setup.py Thu Jun 18 20:29:58 -0700 2009 Added setup.py and MANIFEST.in [pingswept]
file shade.py Sat Mar 01 15:36:54 -0800 2008 Initial import from SVN tag 0.2.0 [Brandon Stafford]
file shade_test.py Sat Mar 01 15:36:54 -0800 2008 Initial import from SVN tag 0.2.0 [Brandon Stafford]
file simulate.py Fri Apr 10 20:44:58 -0700 2009 Added code for overlaying sun paths. [pingswept]
file solar.py Sun Jan 11 17:34:39 -0800 2009 Added corrections from Sean Taylor to GetParall... [pingswept]
file sun_path_widget.py Thu Jun 18 14:42:42 -0700 2009 Updated sun path code, added __init__.py [pingswept]
file testsolar.py Sun Jan 11 17:34:39 -0800 2009 Added corrections from Sean Taylor to GetParall... [pingswept]
file usno_data_6259.txt Sat Jul 19 18:41:04 -0700 2008 query_usno.py: added code to validate Pysolar a... [pingswept]
file usno_data_short_test.txt Sat Jul 19 18:41:04 -0700 2008 query_usno.py: added code to validate Pysolar a... [pingswept]
file util.py Tue Nov 10 20:18:59 -0800 2009 Fixed missing hash [pingswept]
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