Skip to content

Commit 1c3c229

Browse files
committed
move scipy import to inside ineichen
1 parent 698c39c commit 1c3c229

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

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))

0 commit comments

Comments
 (0)