|
1 |
| -PVLIB_Python |
2 |
| -============ |
| 1 | +pythonic-PVLIB |
| 2 | +============== |
| 3 | + |
| 4 | +pythonic-PVLIB is a fork of the [PVLIB_Python](https://github.com/Sandia-Labs/PVLIB_Python) project. |
| 5 | + |
| 6 | +It provides a set of sometimes-well-documented and usually correct functions for simulating the performance of photovoltaic energy systems. The toolbox was originally developed at Sandia National Laboratories and it implements many of the models and methods developed at the Labs. |
| 7 | + |
| 8 | +We make some contributions to the PVLIB\_Python develop branch, and we pull some commits to PVLIB\_Python back into our fork. We hope that the Sandia PVLIB_Python becomes the community standard, but we had some different ideas about how things should be done and we needed to make progress faster than the collaborative cycle would allow. See below for a partial list of differences. |
3 | 9 |
|
4 |
| -The PV_LIB Toolbox provides a set of well-documented functions for simulating the performance of photovoltaic energy systems. The toolbox was developed at Sandia National Laboratories and it implements many of the models and methods developed at the Labs. |
| 10 | +We use this library to generate solar power forecasts for TEP, APS, and SVERI utilities, and to perform grid integration and variability studies for SVERI utilities. For more information, see [https://forecasting.uaren.org](https://forecasting.uaren.org) and [https://sveri.uaren.org](https://sveri.uaren.org). |
5 | 11 |
|
6 |
| -Compatibility |
7 |
| -============= |
| 12 | +The primary drawback to using this library over the official library is that, well, it's not the official Sandia library. If you use this library you need to attribute both UA and Sandia. Another drawback is that the structure of this library will look a lot different to people coming from the MATLAB world, which is either a good thing or a bad thing depending on your perspective. |
8 | 13 |
|
9 |
| -PV_LIB is currently compatible with python 2.7.X |
10 | 14 |
|
11 |
| -Getting Started |
| 15 | +Key differences |
12 | 16 | ===============
|
| 17 | +Here are some of the major differences between our fork and PVLIB\_Python. Note that some of these differences have been resolved in the PVLIB\_Python [develop branch](https://github.com/Sandia-Labs/PVLIB_Python/tree/develop). |
| 18 | + |
| 19 | +* Remove pvl_ from module names. |
| 20 | +* Locations are now referred to as objects, not structs. |
| 21 | +* Return one DataFrame instead of a tuple of DataFrames. |
| 22 | +* Specify time zones using a string from the standard IANA Time Zone Database naming conventions or using a pytz.timezone instead of an integer GMT offset. |
| 23 | +* Add PyEphem option to solar position calculations. |
| 24 | +* Consolidation of similar modules. For example, functions from ``pvl_clearsky_ineichen.py`` and ``pvl_clearsky_haurwitz.py``` have been consolidated into ``clearsky.py``. Similar consolidations have occured for airmass, solar position, and diffuse irradiance modules. |
| 25 | +* Created ``planeofarray.py`` module with AOI, projection, and irradiance sum and calculation functions |
| 26 | +* Removing Vars=Locals(); Expect...; var=pvl\_tools.Parse(Vars,Expect); pattern. Very few tests of input validitity remain. Garbage in, garbage out. |
| 27 | +* Removing unnecssary and sometimes undesired behavior such as setting maximum zenith=90. |
| 28 | +* ```__init__.py``` imports have been removed. |
| 29 | +* Adding logging calls, removing print calls. |
| 30 | +* Code in reviewed modules is mostly PEP8 compliant. |
| 31 | +* Code in reviewed modules is mostly python 3 compatible. |
| 32 | +* Changing function and module names so that they do not conflict. |
| 33 | +* Not bothering with boilerplate unit test code such as ```unittest.main()```. |
| 34 | +* No wildcard imports. |
| 35 | +* Improved documentation here and there. |
| 36 | +* TMY data is not forced to 1987. |
| 37 | + |
| 38 | +Pythonic code is easier to use, easier to maintain, and faster to develop. Adhering to PEP8 guidelines allows other python developers read code more quickly and accurately. |
| 39 | + |
| 40 | +Quick Start |
| 41 | +============ |
| 42 | +Hopefully you're using [virtualenv](http://virtualenv.readthedocs.org/en/latest/) and [virtualenvwrapper](http://virtualenvwrapper.readthedocs.org). To install, clone this library and run |
13 | 43 |
|
14 |
| -After cloning the directory onto your local computer, the best place to start is running the example ipython notebook files (.ipynb) |
| 44 | +``` |
| 45 | +pip install . |
| 46 | +``` |
15 | 47 |
|
16 |
| -To start a notebook session, enter the local directory of the PV_LIB library and run |
| 48 | +Add ``-e`` to install in [develop mode](http://pip.readthedocs.org/en/latest/reference/pip_install.html#editable-installs). |
17 | 49 |
|
18 |
| - ipython notebook --pylab |
| 50 | +``` |
| 51 | +# built-in imports |
| 52 | +import sys |
| 53 | +import datetime |
19 | 54 |
|
20 |
| -Notebooks to run |
21 |
| ---------------------- |
| 55 | +# add-on imports |
| 56 | +import pandas as pd |
22 | 57 |
|
23 |
| -* /tutorial/Tutorial.ipynb for an introduction to the overall functionality |
| 58 | +# pvlib imports |
| 59 | +from pvlib.location import Location |
| 60 | +import pvlib.solarposition |
| 61 | +import pvlib.clearsky |
24 | 62 |
|
25 |
| -* /pvlib/Test_scripts_1.ipynb an example of a complete workflow |
| 63 | +# make a location |
| 64 | +tus = Location(32.2, -111, 700, 'MST') |
| 65 | +
|
| 66 | +# make a pandas DatetimeIndex for some day |
| 67 | +times = pd.date_range(start=datetime.datetime(2014,6,24), end=datetime.datetime(2014,6,25), freq='1Min') |
| 68 | +
|
| 69 | +# calculate the solar position |
| 70 | +solpos = pvlib.solarposition.get_solarposition(times, tus, method='pyephem') |
| 71 | +solpos.plot() |
| 72 | +
|
| 73 | +# calculate clear sky data |
| 74 | +tus_cs = pvlib.clearsky.ineichen(times, tus, airmass_model='young1994') |
| 75 | +tus_cs.plot() |
| 76 | +``` |
| 77 | + |
| 78 | +Until the code is tested more thoroughly, you might find it useful to add: |
| 79 | +``` |
| 80 | +import logging |
| 81 | +logging.getLogger('pvlib').setLevel(logging.DEBUG) |
| 82 | +``` |
| 83 | + |
| 84 | + |
| 85 | +Testing |
| 86 | +============ |
| 87 | +Testing can be accomplished by running nosetests on the pvlib directory (or pvlib/tests): |
| 88 | +``` |
| 89 | +nosetests -v pvlib |
| 90 | +``` |
| 91 | +Unit test code should be placed in the ```pvlib/test``` directory. Each module should have its own test module. |
26 | 92 |
|
27 |
| -* /pvlib/TS_2_irradiance_functions.ipynb an example of implementing the included irradiance translation functions |
28 |
| - |
|
0 commit comments