Skip to content

spa license fixes #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Mar 13, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ build/
# spa_c_files builds
pvlib/spa_c_files/build*

# spa_c_files source
pvlib/spa_c_files/spa.c
pvlib/spa_c_files/spa.h
pvlib/spa_c_files/spa_tester.c

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think pvlib/spa_c_files/spa_py.so should be removed from the repo and also be added to the ignore file (also because the SPA tests are passing before SPA is installed!)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, I'll fix this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, on second thought I already removed the file and line 10 of .gitignore is *.so. You may be seeing the file because of some git oddity when switching between branches.

$ git ls-files pvlib/spa_c_files/
pvlib/spa_c_files/README.md
pvlib/spa_c_files/SPA_NOTICE.md
pvlib/spa_c_files/__init__.py
pvlib/spa_c_files/cspa_py.pxd
pvlib/spa_c_files/setup.py
pvlib/spa_c_files/spa_py.c
pvlib/spa_c_files/spa_py.pyx

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, I see. Sorry that I was causing this confusion. The problem that the so will stay in the file structure exists, because it is ignored and will stay at its place, if you switch branches.

# generated documentation
# pvlib/sphinx/Docs/build/

Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,22 @@ Hopefully you're using [virtualenv](http://virtualenv.readthedocs.org/en/latest/
pip install git+https://github.com/pvlib/pvlib-python.git
```

Alternatively, ``git clone`` this repository and run
Alternatively, ``git clone`` this repository, ``cd`` into it, and run

```
pip install .
```

Add ``-e`` to install in [develop mode](http://pip.readthedocs.org/en/latest/reference/pip_install.html#editable-installs).

To use the NREL SPA algorithm, a pip install from the web cannot be used. Instead:

1. Download the pvlib repository from https://github.com/pvlib/pvlib-python.git
2. Download the SPA files from [NREL](http://www.nrel.gov/midc/spa/)
3. Copy the SPA files into ``pvlib-python/pvlib/spa_c_files``
4. From the ``pvlib-python`` directory, run ``pip uninstall pvlib`` followed by ``pip install . ``


Usage Example
-------------
```
Expand Down
1 change: 1 addition & 0 deletions docs/sphinx/source/whatsnew/v0.1.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Other changes
* Adding logging calls, removing print calls.
* Improved PEP8 compliance.
* Added ``/pvlib/data`` for lookup tables, test, and tutorial data.
* Removed NREL's SPA code to comply with their license (:issue:`9`).


Documentation
Expand Down
46 changes: 0 additions & 46 deletions pvlib/spa_c_files/README

This file was deleted.

34 changes: 34 additions & 0 deletions pvlib/spa_c_files/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
README
------

NREL provides a C implementation of the solar position algorithm
described in
[Reda, I.; Andreas, A. (2003). Solar Position Algorithm for Solar Radiation Applications. 55 pp.; NREL Report No. TP-560-34302](
http://www.nrel.gov/docs/fy08osti/34302.pdf).

This folder contains the files required to make NREL's C code accessible
to the ``pvlib-python`` package. We use the Cython package to wrap NREL's SPA
implementation.

** Due to licensing issues, you must download the NREL C files from their
[website](http://www.nrel.gov/midc/spa) **

Download the ``spa.c`` and ``spa.h`` files from NREL,
and copy them into the ``pvlib/spa_c_files`` directory.

There are a total of 5 files needed to compile the C code, described below:

* ``spa.c``: original C code from NREL
* ``spa.h``: header file for spa.c
* ``cspa_py.pxd``: a cython header file which essentially tells cython which parts of the main header file to pay attention to
* ``spa_py.pyx``: the cython code used to define both functions in the python namespace. NOTE: It is possible to provide user access to other paramters of the SPA algorithm through modifying this file
* ``setup.py``: a distutils file which performs the compiling of the cython code

The cython compilation process produces two files:
* ``spa_py.c``: an intermediate cython c file
* ``spa_py.so``: the python module which can be imported into a namespace

To process the original 5 files,
use the following shell command inside this folder

$ python setup.py build_ext --inplace
Binary file removed pvlib/spa_c_files/a.out
Binary file not shown.
4 changes: 2 additions & 2 deletions pvlib/spa_c_files/cspa_py.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cdef extern from "spa.h":
int day
int hour
int minute
int second
double second
double delta_ut1
double delta_t
double timezone
Expand All @@ -27,7 +27,7 @@ cdef extern from "spa.h":
int function

double zenith
double azimuth180
double azimuth_astro
double azimuth
double incidence

Expand Down
Loading