Skip to content

Commit 4a36bb2

Browse files
committed
Merge pull request #31 from wholmgren/cs-scipy
Should be ok.
2 parents 4186b75 + 54e1eaf commit 4a36bb2

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

docs/sphinx/source/whatsnew/v0.1.0.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ Other changes
4040
* Adding logging calls, removing print calls.
4141
* Improved PEP8 compliance.
4242
* Added ``/pvlib/data`` for lookup tables, test, and tutorial data.
43+
* Limited the scope of ``clearsky.py``'s ``scipy`` dependency.
44+
``clearsky.ineichen`` will work without ``scipy`` so long as
45+
the Linke Turbidity is supplied as a keyword argument. (:issue:`13`)
4346
* Removed NREL's SPA code to comply with their license (:issue:`9`).
4447

4548

@@ -56,7 +59,7 @@ Documentation
5659
Testing
5760
~~~~~~~
5861

59-
* Tests are cleaner and more thorough. They are still no where near complete.
62+
* Tests are cleaner and more thorough. They are still nowhere near complete.
6063
* Using Coveralls to measure test coverage.
6164
* Using TravisCI for automated testing.
6265
* Using ``nosetests`` for more concise test code.

pvlib/clearsky.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
import numpy as np
1414
import pandas as pd
15-
import scipy.io
1615

1716
from pvlib import tools
1817
from pvlib import irradiance
@@ -127,9 +126,17 @@ def ineichen(time, location, linke_turbidity=None,
127126
# so divide the number from the file by 20 to get the
128127
# turbidity.
129128

129+
try:
130+
import scipy.io
131+
except ImportError:
132+
raise ImportError('The Linke turbidity lookup table requires scipy. ' +
133+
'You can still use clearsky.ineichen if you ' +
134+
'supply your own turbidities.')
135+
130136
# consider putting this code at module level
131137
this_path = os.path.dirname(os.path.abspath(__file__))
132138
logger.debug('this_path={}'.format(this_path))
139+
133140
mat = scipy.io.loadmat(os.path.join(this_path, 'data', 'LinkeTurbidities.mat'))
134141
linke_turbidity = mat['LinkeTurbidity']
135142
LatitudeIndex = np.round_(_linearly_scale(location.latitude,90,- 90,1,2160))

pvlib/test/test_clearsky.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,19 @@
3030

3131
def test_ineichen_required():
3232
# the clearsky function should lookup the linke turbidity on its own
33+
# will fail without scipy
3334
clearsky.ineichen(times, tus)
3435

3536
def test_ineichen_supply_linke():
3637
clearsky.ineichen(times, tus, linke_turbidity=3)
3738

3839
def test_ineichen_solpos():
3940
clearsky.ineichen(times, tus, linke_turbidity=3,
40-
solarposition_method='pyephem')
41+
solarposition_method='pyephem')
4142

4243
def test_ineichen_airmass():
4344
clearsky.ineichen(times, tus, linke_turbidity=3,
44-
airmass_model='simple')
45+
airmass_model='simple')
4546

4647
def test_ineichen_keys():
4748
clearsky_data = clearsky.ineichen(times, tus, linke_turbidity=3)
@@ -60,7 +61,7 @@ def test_haurwitz_keys():
6061

6162
# test DISC
6263
def test_disc_keys():
63-
clearsky_data = clearsky.ineichen(times, tus)
64+
clearsky_data = clearsky.ineichen(times, tus, linke_turbidity=3)
6465
disc_data = clearsky.disc(clearsky_data['GHI'], ephem_data['zenith'],
6566
ephem_data.index)
6667
assert 'DNI_gen_DISC' in disc_data.columns

0 commit comments

Comments
 (0)