pvlib 0.10.4__py3-none-any.whl → 0.11.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pvlib/__init__.py +1 -0
- pvlib/albedo.py +168 -0
- pvlib/bifacial/utils.py +2 -1
- pvlib/data/ASTMG173.csv +2004 -0
- pvlib/iam.py +28 -28
- pvlib/iotools/__init__.py +0 -1
- pvlib/iotools/midc.py +15 -10
- pvlib/iotools/psm3.py +10 -25
- pvlib/iotools/srml.py +1 -61
- pvlib/iotools/surfrad.py +1 -1
- pvlib/irradiance.py +133 -95
- pvlib/location.py +16 -6
- pvlib/modelchain.py +2 -165
- pvlib/pvarray.py +7 -5
- pvlib/pvsystem.py +75 -106
- pvlib/scaling.py +4 -2
- pvlib/shading.py +350 -0
- pvlib/singlediode.py +37 -9
- pvlib/snow.py +3 -1
- pvlib/spectrum/__init__.py +5 -0
- pvlib/spectrum/mismatch.py +573 -43
- pvlib/spectrum/spectrl2.py +8 -8
- pvlib/tests/bifacial/test_utils.py +6 -5
- pvlib/tests/iotools/test_psm3.py +0 -18
- pvlib/tests/iotools/test_srml.py +1 -43
- pvlib/tests/test_albedo.py +84 -0
- pvlib/tests/test_inverter.py +2 -2
- pvlib/tests/test_irradiance.py +35 -2
- pvlib/tests/test_location.py +26 -18
- pvlib/tests/test_modelchain.py +0 -57
- pvlib/tests/test_pvsystem.py +73 -128
- pvlib/tests/test_shading.py +167 -1
- pvlib/tests/test_singlediode.py +68 -29
- pvlib/tests/test_spectrum.py +283 -22
- pvlib/tests/test_temperature.py +7 -7
- pvlib/tests/test_tools.py +24 -0
- pvlib/tests/test_transformer.py +60 -0
- pvlib/tools.py +27 -0
- pvlib/transformer.py +117 -0
- pvlib/version.py +1 -5
- {pvlib-0.10.4.dist-info → pvlib-0.11.0.dist-info}/METADATA +3 -4
- {pvlib-0.10.4.dist-info → pvlib-0.11.0.dist-info}/RECORD +46 -42
- {pvlib-0.10.4.dist-info → pvlib-0.11.0.dist-info}/WHEEL +1 -1
- pvlib/data/astm_g173_am15g.csv +0 -2003
- {pvlib-0.10.4.dist-info → pvlib-0.11.0.dist-info}/AUTHORS.md +0 -0
- {pvlib-0.10.4.dist-info → pvlib-0.11.0.dist-info}/LICENSE +0 -0
- {pvlib-0.10.4.dist-info → pvlib-0.11.0.dist-info}/top_level.txt +0 -0
pvlib/spectrum/spectrl2.py
CHANGED
|
@@ -233,14 +233,14 @@ def spectrl2(apparent_zenith, aoi, surface_tilt, ground_albedo,
|
|
|
233
233
|
input ``apparent_zenith``. All values are spectral irradiance
|
|
234
234
|
with units W/m^2/nm except for `wavelength`, which is in nanometers.
|
|
235
235
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
236
|
+
* wavelength
|
|
237
|
+
* dni_extra
|
|
238
|
+
* dhi
|
|
239
|
+
* dni
|
|
240
|
+
* poa_sky_diffuse
|
|
241
|
+
* poa_ground_diffuse
|
|
242
|
+
* poa_direct
|
|
243
|
+
* poa_global
|
|
244
244
|
|
|
245
245
|
Notes
|
|
246
246
|
-----
|
|
@@ -6,6 +6,7 @@ import pytest
|
|
|
6
6
|
from pvlib.bifacial import utils
|
|
7
7
|
from pvlib.shading import masking_angle, ground_angle
|
|
8
8
|
from pvlib.tools import cosd
|
|
9
|
+
from scipy.integrate import trapezoid
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
@pytest.fixture
|
|
@@ -99,7 +100,7 @@ def test_vf_ground_sky_2d_integ(test_system_fixed_tilt, vectorize):
|
|
|
99
100
|
vf_integ = utils.vf_ground_sky_2d_integ(
|
|
100
101
|
ts['rotation'], ts['gcr'], ts['height'], ts['pitch'],
|
|
101
102
|
max_rows=1, npoints=3, vectorize=vectorize)
|
|
102
|
-
expected_vf_integ =
|
|
103
|
+
expected_vf_integ = trapezoid(vfs_gnd_sky, pts, axis=0)
|
|
103
104
|
assert np.isclose(vf_integ, expected_vf_integ, rtol=0.1)
|
|
104
105
|
|
|
105
106
|
|
|
@@ -134,7 +135,7 @@ def test_vf_row_sky_2d_integ(test_system_fixed_tilt):
|
|
|
134
135
|
x = np.arange(fx0[1], fx1[1], 1e-4)
|
|
135
136
|
phi_y = masking_angle(ts['surface_tilt'], ts['gcr'], x)
|
|
136
137
|
y = 0.5 * (1 + cosd(ts['surface_tilt'] + phi_y))
|
|
137
|
-
y1 =
|
|
138
|
+
y1 = trapezoid(y, x) / (fx1[1] - fx0[1])
|
|
138
139
|
expected = np.array([y0, y1])
|
|
139
140
|
assert np.allclose(vf, expected, rtol=1e-3)
|
|
140
141
|
# with defaults (0, 1)
|
|
@@ -142,7 +143,7 @@ def test_vf_row_sky_2d_integ(test_system_fixed_tilt):
|
|
|
142
143
|
x = np.arange(0, 1, 1e-4)
|
|
143
144
|
phi_y = masking_angle(ts['surface_tilt'], ts['gcr'], x)
|
|
144
145
|
y = 0.5 * (1 + cosd(ts['surface_tilt'] + phi_y))
|
|
145
|
-
y1 =
|
|
146
|
+
y1 = trapezoid(y, x) / (1 - 0)
|
|
146
147
|
assert np.allclose(vf, y1, rtol=1e-3)
|
|
147
148
|
|
|
148
149
|
|
|
@@ -179,7 +180,7 @@ def test_vf_ground_2d_integ(test_system_fixed_tilt):
|
|
|
179
180
|
x = np.arange(fx0[1], fx1[1], 1e-4)
|
|
180
181
|
phi_y = ground_angle(ts['surface_tilt'], ts['gcr'], x)
|
|
181
182
|
y = 0.5 * (1 - cosd(phi_y - ts['surface_tilt']))
|
|
182
|
-
y1 =
|
|
183
|
+
y1 = trapezoid(y, x) / (fx1[1] - fx0[1])
|
|
183
184
|
expected = np.array([y0, y1])
|
|
184
185
|
assert np.allclose(vf, expected, rtol=1e-2)
|
|
185
186
|
# with defaults (0, 1)
|
|
@@ -187,5 +188,5 @@ def test_vf_ground_2d_integ(test_system_fixed_tilt):
|
|
|
187
188
|
x = np.arange(0, 1, 1e-4)
|
|
188
189
|
phi_y = ground_angle(ts['surface_tilt'], ts['gcr'], x)
|
|
189
190
|
y = 0.5 * (1 - cosd(phi_y - ts['surface_tilt']))
|
|
190
|
-
y1 =
|
|
191
|
+
y1 = trapezoid(y, x) / (1 - 0)
|
|
191
192
|
assert np.allclose(vf, y1, rtol=1e-2)
|
pvlib/tests/iotools/test_psm3.py
CHANGED
|
@@ -196,21 +196,3 @@ def test_get_psm3_attribute_mapping(nrel_api_key):
|
|
|
196
196
|
assert 'latitude' in meta.keys()
|
|
197
197
|
assert 'longitude' in meta.keys()
|
|
198
198
|
assert 'altitude' in meta.keys()
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
@pytest.mark.remote_data
|
|
202
|
-
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
|
|
203
|
-
def test_psm3_variable_map_deprecation_warning(nrel_api_key):
|
|
204
|
-
with pytest.warns(pvlibDeprecationWarning, match='names will be renamed'):
|
|
205
|
-
_ = psm3.read_psm3(MANUAL_TEST_DATA)
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
@pytest.mark.remote_data
|
|
209
|
-
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
|
|
210
|
-
def test_psm3_leap_day_deprecation_warning(nrel_api_key):
|
|
211
|
-
with pytest.warns(pvlibDeprecationWarning,
|
|
212
|
-
match='default to leap_day=True'):
|
|
213
|
-
_, _ = psm3.get_psm3(LATITUDE, LONGITUDE, nrel_api_key, PVLIB_EMAIL,
|
|
214
|
-
names=2019, interval=60,
|
|
215
|
-
attributes=['ghi', 'wind_speed'],
|
|
216
|
-
map_variables=True)
|
pvlib/tests/iotools/test_srml.py
CHANGED
|
@@ -4,8 +4,7 @@ import pytest
|
|
|
4
4
|
|
|
5
5
|
from pvlib.iotools import srml
|
|
6
6
|
from ..conftest import (DATA_DIR, RERUNS, RERUNS_DELAY, assert_index_equal,
|
|
7
|
-
assert_frame_equal
|
|
8
|
-
from pvlib._deprecation import pvlibDeprecationWarning
|
|
7
|
+
assert_frame_equal)
|
|
9
8
|
|
|
10
9
|
srml_testfile = DATA_DIR / 'SRML-day-EUPO1801.txt'
|
|
11
10
|
|
|
@@ -88,47 +87,6 @@ def test_get_srml():
|
|
|
88
87
|
assert_frame_equal(file_data, requested)
|
|
89
88
|
|
|
90
89
|
|
|
91
|
-
@fail_on_pvlib_version('0.11')
|
|
92
|
-
@pytest.mark.remote_data
|
|
93
|
-
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
|
|
94
|
-
def test_read_srml_month_from_solardat():
|
|
95
|
-
url = 'http://solardata.uoregon.edu/download/Archive/EUPO1801.txt'
|
|
96
|
-
file_data = srml.read_srml(url)
|
|
97
|
-
with pytest.warns(pvlibDeprecationWarning, match='get_srml instead'):
|
|
98
|
-
requested = srml.read_srml_month_from_solardat('EU', 2018, 1)
|
|
99
|
-
assert file_data.equals(requested)
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
@fail_on_pvlib_version('0.11')
|
|
103
|
-
@pytest.mark.remote_data
|
|
104
|
-
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
|
|
105
|
-
def test_15_minute_dt_index():
|
|
106
|
-
with pytest.warns(pvlibDeprecationWarning, match='get_srml instead'):
|
|
107
|
-
data = srml.read_srml_month_from_solardat('TW', 2019, 4, 'RQ')
|
|
108
|
-
start = pd.Timestamp('20190401 00:00')
|
|
109
|
-
start = start.tz_localize('Etc/GMT+8')
|
|
110
|
-
end = pd.Timestamp('20190430 23:45')
|
|
111
|
-
end = end.tz_localize('Etc/GMT+8')
|
|
112
|
-
assert data.index[0] == start
|
|
113
|
-
assert data.index[-1] == end
|
|
114
|
-
assert (data.index[3::4].minute == 45).all()
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
@fail_on_pvlib_version('0.11')
|
|
118
|
-
@pytest.mark.remote_data
|
|
119
|
-
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
|
|
120
|
-
def test_hourly_dt_index():
|
|
121
|
-
with pytest.warns(pvlibDeprecationWarning, match='get_srml instead'):
|
|
122
|
-
data = srml.read_srml_month_from_solardat('CD', 1986, 4, 'PH')
|
|
123
|
-
start = pd.Timestamp('19860401 00:00')
|
|
124
|
-
start = start.tz_localize('Etc/GMT+8')
|
|
125
|
-
end = pd.Timestamp('19860430 23:00')
|
|
126
|
-
end = end.tz_localize('Etc/GMT+8')
|
|
127
|
-
assert data.index[0] == start
|
|
128
|
-
assert data.index[-1] == end
|
|
129
|
-
assert (data.index.minute == 0).all()
|
|
130
|
-
|
|
131
|
-
|
|
132
90
|
@pytest.mark.remote_data
|
|
133
91
|
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
|
|
134
92
|
def test_get_srml_hourly():
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
import pandas as pd
|
|
3
|
+
import pytest
|
|
4
|
+
from pvlib import albedo
|
|
5
|
+
|
|
6
|
+
from .conftest import assert_series_equal
|
|
7
|
+
from numpy.testing import assert_allclose
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def test_inland_water_dvoracek_default():
|
|
11
|
+
result = albedo.inland_water_dvoracek(solar_elevation=90,
|
|
12
|
+
color_coeff=0.13,
|
|
13
|
+
wave_roughness_coeff=0.29)
|
|
14
|
+
assert_allclose(result, 0.072, 0.001)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def test_inland_water_dvoracek_negative_elevation():
|
|
18
|
+
result = albedo.inland_water_dvoracek(solar_elevation=-60,
|
|
19
|
+
color_coeff=0.13,
|
|
20
|
+
wave_roughness_coeff=0.29)
|
|
21
|
+
assert_allclose(result, 0.13, 0.01)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def test_inland_water_dvoracek_string_surface_condition():
|
|
25
|
+
result = albedo.inland_water_dvoracek(solar_elevation=90,
|
|
26
|
+
surface_condition='clear_water_no_waves') # noqa: E501
|
|
27
|
+
assert_allclose(result, 0.072, 0.001)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def test_inland_water_dvoracek_ndarray():
|
|
31
|
+
solar_elevs = np.array([-50, 0, 20, 60, 90])
|
|
32
|
+
color_coeffs = np.array([0.1, 0.1, 0.2, 0.3, 0.4])
|
|
33
|
+
roughness_coeffs = np.array([0.3, 0.3, 0.8, 1.5, 2])
|
|
34
|
+
result = albedo.inland_water_dvoracek(solar_elevation=solar_elevs,
|
|
35
|
+
color_coeff=color_coeffs,
|
|
36
|
+
wave_roughness_coeff=roughness_coeffs) # noqa: E501
|
|
37
|
+
expected = np.array([0.1, 0.1, 0.12875, 0.06278, 0.064])
|
|
38
|
+
assert_allclose(expected, result, atol=1e-5)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def test_inland_water_dvoracek_series():
|
|
42
|
+
times = pd.date_range(start="2015-01-01 00:00", end="2015-01-02 00:00",
|
|
43
|
+
freq="6h")
|
|
44
|
+
solar_elevs = pd.Series([-50, 0, 20, 60, 90], index=times)
|
|
45
|
+
color_coeffs = pd.Series([0.1, 0.1, 0.2, 0.3, 0.4], index=times)
|
|
46
|
+
roughness_coeffs = pd.Series([0.1, 0.3, 0.8, 1.5, 2], index=times)
|
|
47
|
+
result = albedo.inland_water_dvoracek(solar_elevation=solar_elevs,
|
|
48
|
+
color_coeff=color_coeffs,
|
|
49
|
+
wave_roughness_coeff=roughness_coeffs) # noqa: E501
|
|
50
|
+
expected = pd.Series([0.1, 0.1, 0.12875, 0.06278, 0.064], index=times)
|
|
51
|
+
assert_series_equal(expected, result, atol=1e-5)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def test_inland_water_dvoracek_series_mix_with_array():
|
|
55
|
+
times = pd.date_range(start="2015-01-01 00:00", end="2015-01-01 06:00",
|
|
56
|
+
freq="6h")
|
|
57
|
+
solar_elevs = pd.Series([45, 60], index=times)
|
|
58
|
+
color_coeffs = 0.13
|
|
59
|
+
roughness_coeffs = 0.29
|
|
60
|
+
result = albedo.inland_water_dvoracek(solar_elevation=solar_elevs,
|
|
61
|
+
color_coeff=color_coeffs,
|
|
62
|
+
wave_roughness_coeff=roughness_coeffs) # noqa: E501
|
|
63
|
+
expected = pd.Series([0.08555, 0.07787], index=times)
|
|
64
|
+
assert_series_equal(expected, result, atol=1e-5)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def test_inland_water_dvoracek_invalid():
|
|
68
|
+
with pytest.raises(ValueError, match='Either a `surface_condition` has to '
|
|
69
|
+
'be chosen or a combination of `color_coeff` and'
|
|
70
|
+
' `wave_roughness_coeff`.'): # no surface info given
|
|
71
|
+
albedo.inland_water_dvoracek(solar_elevation=45)
|
|
72
|
+
with pytest.raises(KeyError, match='not_a_surface_type'): # invalid type
|
|
73
|
+
albedo.inland_water_dvoracek(solar_elevation=45,
|
|
74
|
+
surface_condition='not_a_surface_type')
|
|
75
|
+
with pytest.raises(ValueError, match='Either a `surface_condition` has to '
|
|
76
|
+
'be chosen or a combination of `color_coeff` and'
|
|
77
|
+
' `wave_roughness_coeff`.'): # only one coeff given
|
|
78
|
+
albedo.inland_water_dvoracek(solar_elevation=45,
|
|
79
|
+
color_coeff=0.13)
|
|
80
|
+
with pytest.raises(ValueError, match='Either a `surface_condition` has to '
|
|
81
|
+
'be chosen or a combination of `color_coeff` and'
|
|
82
|
+
' `wave_roughness_coeff`.'): # only one coeff given
|
|
83
|
+
albedo.inland_water_dvoracek(solar_elevation=45,
|
|
84
|
+
wave_roughness_coeff=0.29)
|
pvlib/tests/test_inverter.py
CHANGED
|
@@ -61,13 +61,13 @@ def test_sandia_float(cec_inverter_parameters):
|
|
|
61
61
|
idcs = 5.5
|
|
62
62
|
pdcs = idcs * vdcs
|
|
63
63
|
pacs = inverter.sandia(vdcs, pdcs, cec_inverter_parameters)
|
|
64
|
-
assert_allclose(pacs, 132.004278, 5)
|
|
64
|
+
assert_allclose(pacs, 132.004278, 1e-5)
|
|
65
65
|
# test at low power condition
|
|
66
66
|
vdcs = 25.
|
|
67
67
|
idcs = 0
|
|
68
68
|
pdcs = idcs * vdcs
|
|
69
69
|
pacs = inverter.sandia(vdcs, pdcs, cec_inverter_parameters)
|
|
70
|
-
assert_allclose(pacs, -1. * cec_inverter_parameters['Pnt'], 5)
|
|
70
|
+
assert_allclose(pacs, -1. * cec_inverter_parameters['Pnt'], 1e-5)
|
|
71
71
|
|
|
72
72
|
|
|
73
73
|
def test_sandia_Pnt_micro():
|
pvlib/tests/test_irradiance.py
CHANGED
|
@@ -9,7 +9,7 @@ import pandas as pd
|
|
|
9
9
|
import pytest
|
|
10
10
|
from numpy.testing import (assert_almost_equal,
|
|
11
11
|
assert_allclose)
|
|
12
|
-
from pvlib import irradiance
|
|
12
|
+
from pvlib import irradiance, albedo
|
|
13
13
|
|
|
14
14
|
from .conftest import (
|
|
15
15
|
assert_frame_equal,
|
|
@@ -18,6 +18,7 @@ from .conftest import (
|
|
|
18
18
|
requires_numba
|
|
19
19
|
)
|
|
20
20
|
|
|
21
|
+
from pvlib._deprecation import pvlibDeprecationWarning
|
|
21
22
|
|
|
22
23
|
# fixtures create realistic test input data
|
|
23
24
|
# test input data generated at Location(32.2, -111, 'US/Arizona', 700)
|
|
@@ -1053,7 +1054,7 @@ def test_erbs_all_scalar():
|
|
|
1053
1054
|
out = irradiance.erbs(ghi, zenith, doy)
|
|
1054
1055
|
|
|
1055
1056
|
for k, v in out.items():
|
|
1056
|
-
assert_allclose(v, expected[k],
|
|
1057
|
+
assert_allclose(v, expected[k], 1e-2)
|
|
1057
1058
|
|
|
1058
1059
|
|
|
1059
1060
|
def test_dirindex(times):
|
|
@@ -1406,3 +1407,35 @@ def test_louche():
|
|
|
1406
1407
|
out = irradiance.louche(ghi, zenith, index)
|
|
1407
1408
|
|
|
1408
1409
|
assert_frame_equal(out, expected)
|
|
1410
|
+
|
|
1411
|
+
|
|
1412
|
+
def test_SURFACE_ALBEDOS_deprecated():
|
|
1413
|
+
with pytest.warns(pvlibDeprecationWarning, match='SURFACE_ALBEDOS has been'
|
|
1414
|
+
' moved to the albedo module as of v0.11.0. Please use'
|
|
1415
|
+
' pvlib.albedo.SURFACE_ALBEDOS.'):
|
|
1416
|
+
irradiance.SURFACE_ALBEDOS
|
|
1417
|
+
|
|
1418
|
+
|
|
1419
|
+
@pytest.mark.filterwarnings("ignore:SURFACE_ALBEDOS")
|
|
1420
|
+
def test_SURFACE_ALBEDO_equals():
|
|
1421
|
+
assert irradiance.SURFACE_ALBEDOS == albedo.SURFACE_ALBEDOS
|
|
1422
|
+
|
|
1423
|
+
|
|
1424
|
+
def test_diffuse_par_spitters():
|
|
1425
|
+
solar_zenith, global_diffuse_fraction = np.meshgrid(
|
|
1426
|
+
[90, 85, 75, 60, 40, 30, 10, 0], [0.01, 0.1, 0.3, 0.6, 0.8, 0.99]
|
|
1427
|
+
)
|
|
1428
|
+
solar_zenith = solar_zenith.ravel()
|
|
1429
|
+
global_diffuse_fraction = global_diffuse_fraction.ravel()
|
|
1430
|
+
result = irradiance.diffuse_par_spitters(
|
|
1431
|
+
solar_zenith, global_diffuse_fraction
|
|
1432
|
+
)
|
|
1433
|
+
expected = np.array([
|
|
1434
|
+
0.01300, 0.01290, 0.01226, 0.01118, 0.01125, 0.01189, 0.01293, 0.01300,
|
|
1435
|
+
0.12970, 0.12874, 0.12239, 0.11174, 0.11236, 0.11868, 0.12905, 0.12970,
|
|
1436
|
+
0.38190, 0.37931, 0.36201, 0.33273, 0.33446, 0.35188, 0.38014, 0.38190,
|
|
1437
|
+
0.71520, 0.71178, 0.68859, 0.64787, 0.65033, 0.67472, 0.71288, 0.71520,
|
|
1438
|
+
0.88640, 0.88401, 0.86755, 0.83745, 0.83931, 0.85746, 0.88478, 0.88640,
|
|
1439
|
+
0.99591, 0.99576, 0.99472, 0.99270, 0.99283, 0.99406, 0.99581, 0.99591,
|
|
1440
|
+
]) # fmt: skip
|
|
1441
|
+
assert_allclose(result, expected, atol=1e-5)
|
pvlib/tests/test_location.py
CHANGED
|
@@ -12,6 +12,7 @@ import pytz
|
|
|
12
12
|
from pytz.exceptions import UnknownTimeZoneError
|
|
13
13
|
|
|
14
14
|
import pvlib
|
|
15
|
+
from pvlib import location
|
|
15
16
|
from pvlib.location import Location, lookup_altitude
|
|
16
17
|
from pvlib.solarposition import declination_spencer71
|
|
17
18
|
from pvlib.solarposition import equation_of_time_spencer71
|
|
@@ -328,21 +329,28 @@ def test_extra_kwargs():
|
|
|
328
329
|
Location(32.2, -111, arbitrary_kwarg='value')
|
|
329
330
|
|
|
330
331
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
332
|
+
@pytest.mark.parametrize('lat,lon,expected_alt', [
|
|
333
|
+
pytest.param(32.2540, -110.9742, 724, id='Tucson, USA'),
|
|
334
|
+
pytest.param(-15.3875, 28.3228, 1253, id='Lusaka, Zambia'),
|
|
335
|
+
pytest.param(35.6762, 139.6503, 40, id='Tokyo, Japan'),
|
|
336
|
+
pytest.param(-35.2802, 149.1310, 566, id='Canberra, Australia'),
|
|
337
|
+
pytest.param(4.7110, -74.0721, 2555, id='Bogota, Colombia'),
|
|
338
|
+
pytest.param(31.525849, 35.449214, -415, id='Dead Sea, West Bank'),
|
|
339
|
+
pytest.param(28.6139, 77.2090, 214, id='New Delhi, India'),
|
|
340
|
+
pytest.param(0, 0, 0, id='Null Island, Atlantic Ocean'),
|
|
341
|
+
])
|
|
342
|
+
def test_lookup_altitude(lat, lon, expected_alt):
|
|
343
|
+
alt_found = lookup_altitude(lat, lon)
|
|
344
|
+
assert alt_found == pytest.approx(expected_alt, abs=125)
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
def test_location_lookup_altitude(mocker):
|
|
348
|
+
mocker.spy(location, 'lookup_altitude')
|
|
349
|
+
tus = Location(32.2, -111, 'US/Arizona', 700, 'Tucson')
|
|
350
|
+
location.lookup_altitude.assert_not_called()
|
|
351
|
+
assert tus.altitude == 700
|
|
352
|
+
location.lookup_altitude.reset_mock()
|
|
353
|
+
|
|
354
|
+
tus = Location(32.2, -111, 'US/Arizona')
|
|
355
|
+
location.lookup_altitude.assert_called_once_with(32.2, -111)
|
|
356
|
+
assert tus.altitude == location.lookup_altitude(32.2, -111)
|
pvlib/tests/test_modelchain.py
CHANGED
|
@@ -1787,63 +1787,6 @@ def test_ModelChain_no_extra_kwargs(sapm_dc_snl_ac_system, location):
|
|
|
1787
1787
|
ModelChain(sapm_dc_snl_ac_system, location, arbitrary_kwarg='value')
|
|
1788
1788
|
|
|
1789
1789
|
|
|
1790
|
-
def test_basic_chain_alt_az(sam_data, cec_inverter_parameters,
|
|
1791
|
-
sapm_temperature_cs5p_220m):
|
|
1792
|
-
times = pd.date_range(start='20160101 1200-0700',
|
|
1793
|
-
end='20160101 1800-0700', freq='6h')
|
|
1794
|
-
latitude = 32.2
|
|
1795
|
-
longitude = -111
|
|
1796
|
-
surface_tilt = 0
|
|
1797
|
-
surface_azimuth = 0
|
|
1798
|
-
modules = sam_data['sandiamod']
|
|
1799
|
-
module_parameters = modules['Canadian_Solar_CS5P_220M___2009_']
|
|
1800
|
-
temp_model_params = sapm_temperature_cs5p_220m.copy()
|
|
1801
|
-
with pytest.warns(pvlibDeprecationWarning, match='with_pvwatts'):
|
|
1802
|
-
dc, ac = modelchain.basic_chain(times, latitude, longitude,
|
|
1803
|
-
surface_tilt, surface_azimuth,
|
|
1804
|
-
module_parameters, temp_model_params,
|
|
1805
|
-
cec_inverter_parameters)
|
|
1806
|
-
|
|
1807
|
-
expected = pd.Series(np.array([111.621405, -2.00000000e-02]),
|
|
1808
|
-
index=times)
|
|
1809
|
-
assert_series_equal(ac, expected)
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
def test_basic_chain_altitude_pressure(sam_data, cec_inverter_parameters,
|
|
1813
|
-
sapm_temperature_cs5p_220m):
|
|
1814
|
-
times = pd.date_range(start='20160101 1200-0700',
|
|
1815
|
-
end='20160101 1800-0700', freq='6h')
|
|
1816
|
-
latitude = 32.2
|
|
1817
|
-
longitude = -111
|
|
1818
|
-
altitude = 700
|
|
1819
|
-
surface_tilt = 0
|
|
1820
|
-
surface_azimuth = 0
|
|
1821
|
-
modules = sam_data['sandiamod']
|
|
1822
|
-
module_parameters = modules['Canadian_Solar_CS5P_220M___2009_']
|
|
1823
|
-
temp_model_params = sapm_temperature_cs5p_220m.copy()
|
|
1824
|
-
with pytest.warns(pvlibDeprecationWarning, match='with_pvwatts'):
|
|
1825
|
-
dc, ac = modelchain.basic_chain(times, latitude, longitude,
|
|
1826
|
-
surface_tilt, surface_azimuth,
|
|
1827
|
-
module_parameters, temp_model_params,
|
|
1828
|
-
cec_inverter_parameters,
|
|
1829
|
-
pressure=93194)
|
|
1830
|
-
|
|
1831
|
-
expected = pd.Series(np.array([113.190045, -2.00000000e-02]),
|
|
1832
|
-
index=times)
|
|
1833
|
-
assert_series_equal(ac, expected)
|
|
1834
|
-
|
|
1835
|
-
with pytest.warns(pvlibDeprecationWarning, match='with_pvwatts'):
|
|
1836
|
-
dc, ac = modelchain.basic_chain(times, latitude, longitude,
|
|
1837
|
-
surface_tilt, surface_azimuth,
|
|
1838
|
-
module_parameters, temp_model_params,
|
|
1839
|
-
cec_inverter_parameters,
|
|
1840
|
-
altitude=altitude)
|
|
1841
|
-
|
|
1842
|
-
expected = pd.Series(np.array([113.189814, -2.00000000e-02]),
|
|
1843
|
-
index=times)
|
|
1844
|
-
assert_series_equal(ac, expected)
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
1790
|
def test_complete_irradiance_clean_run(sapm_dc_snl_ac_system, location):
|
|
1848
1791
|
"""The DataFrame should not change if all columns are passed"""
|
|
1849
1792
|
mc = ModelChain(sapm_dc_snl_ac_system, location)
|