diff --git a/docs/sphinx/source/whatsnew/v0.1.0.txt b/docs/sphinx/source/whatsnew/v0.1.0.txt index 66864b13e6..1b65df8210 100644 --- a/docs/sphinx/source/whatsnew/v0.1.0.txt +++ b/docs/sphinx/source/whatsnew/v0.1.0.txt @@ -40,6 +40,9 @@ Other changes * Adding logging calls, removing print calls. * Improved PEP8 compliance. * Added ``/pvlib/data`` for lookup tables, test, and tutorial data. +* Limited the scope of ``clearsky.py``'s ``scipy`` dependency. + ``clearsky.ineichen`` will work without ``scipy`` so long as + the Linke Turbidity is supplied as a keyword argument. (:issue:`13`) * Removed NREL's SPA code to comply with their license (:issue:`9`). @@ -56,7 +59,7 @@ Documentation Testing ~~~~~~~ -* Tests are cleaner and more thorough. They are still no where near complete. +* Tests are cleaner and more thorough. They are still nowhere near complete. * Using Coveralls to measure test coverage. * Using TravisCI for automated testing. * Using ``nosetests`` for more concise test code. diff --git a/pvlib/clearsky.py b/pvlib/clearsky.py index abe6b4f604..b86d9944af 100644 --- a/pvlib/clearsky.py +++ b/pvlib/clearsky.py @@ -12,7 +12,6 @@ import numpy as np import pandas as pd -import scipy.io from pvlib import tools from pvlib import irradiance @@ -127,9 +126,17 @@ def ineichen(time, location, linke_turbidity=None, # so divide the number from the file by 20 to get the # turbidity. + try: + import scipy.io + except ImportError: + raise ImportError('The Linke turbidity lookup table requires scipy. ' + + 'You can still use clearsky.ineichen if you ' + + 'supply your own turbidities.') + # consider putting this code at module level this_path = os.path.dirname(os.path.abspath(__file__)) logger.debug('this_path={}'.format(this_path)) + mat = scipy.io.loadmat(os.path.join(this_path, 'data', 'LinkeTurbidities.mat')) linke_turbidity = mat['LinkeTurbidity'] LatitudeIndex = np.round_(_linearly_scale(location.latitude,90,- 90,1,2160)) diff --git a/pvlib/test/test_clearsky.py b/pvlib/test/test_clearsky.py index 997f937c9e..d16dfb3d92 100644 --- a/pvlib/test/test_clearsky.py +++ b/pvlib/test/test_clearsky.py @@ -30,6 +30,7 @@ def test_ineichen_required(): # the clearsky function should lookup the linke turbidity on its own + # will fail without scipy clearsky.ineichen(times, tus) def test_ineichen_supply_linke(): @@ -37,11 +38,11 @@ def test_ineichen_supply_linke(): def test_ineichen_solpos(): clearsky.ineichen(times, tus, linke_turbidity=3, - solarposition_method='pyephem') + solarposition_method='pyephem') def test_ineichen_airmass(): clearsky.ineichen(times, tus, linke_turbidity=3, - airmass_model='simple') + airmass_model='simple') def test_ineichen_keys(): clearsky_data = clearsky.ineichen(times, tus, linke_turbidity=3) @@ -60,7 +61,7 @@ def test_haurwitz_keys(): # test DISC def test_disc_keys(): - clearsky_data = clearsky.ineichen(times, tus) + clearsky_data = clearsky.ineichen(times, tus, linke_turbidity=3) disc_data = clearsky.disc(clearsky_data['GHI'], ephem_data['zenith'], ephem_data.index) assert 'DNI_gen_DISC' in disc_data.columns