pvlib 0.10.5__py3-none-any.whl → 0.11.0a1__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/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 +0 -61
- pvlib/irradiance.py +133 -95
- pvlib/location.py +13 -5
- pvlib/modelchain.py +2 -165
- pvlib/pvsystem.py +23 -63
- pvlib/shading.py +350 -0
- pvlib/spectrum/__init__.py +5 -0
- pvlib/spectrum/mismatch.py +572 -43
- pvlib/spectrum/spectrl2.py +8 -8
- 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 +11 -39
- pvlib/tests/test_shading.py +167 -1
- pvlib/tests/test_singlediode.py +0 -19
- 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-0.10.5.dist-info → pvlib-0.11.0a1.dist-info}/METADATA +1 -1
- {pvlib-0.10.5.dist-info → pvlib-0.11.0a1.dist-info}/RECORD +38 -34
- {pvlib-0.10.5.dist-info → pvlib-0.11.0a1.dist-info}/WHEEL +1 -1
- pvlib/data/astm_g173_am15g.csv +0 -2003
- {pvlib-0.10.5.dist-info → pvlib-0.11.0a1.dist-info}/AUTHORS.md +0 -0
- {pvlib-0.10.5.dist-info → pvlib-0.11.0a1.dist-info}/LICENSE +0 -0
- {pvlib-0.10.5.dist-info → pvlib-0.11.0a1.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
|
-----
|
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)
|
pvlib/tests/test_pvsystem.py
CHANGED
|
@@ -6,8 +6,7 @@ from numpy import nan, array
|
|
|
6
6
|
import pandas as pd
|
|
7
7
|
|
|
8
8
|
import pytest
|
|
9
|
-
from .conftest import
|
|
10
|
-
assert_series_equal, assert_frame_equal, fail_on_pvlib_version)
|
|
9
|
+
from .conftest import assert_series_equal, assert_frame_equal
|
|
11
10
|
from numpy.testing import assert_allclose
|
|
12
11
|
import unittest.mock as mock
|
|
13
12
|
|
|
@@ -206,7 +205,7 @@ def test_PVSystem_sapm(sapm_module_params, mocker):
|
|
|
206
205
|
out = system.sapm(effective_irradiance, temp_cell)
|
|
207
206
|
pvsystem.sapm.assert_called_once_with(effective_irradiance, temp_cell,
|
|
208
207
|
sapm_module_params)
|
|
209
|
-
assert_allclose(out['p_mp'], 100,
|
|
208
|
+
assert_allclose(out['p_mp'], 100, 10)
|
|
210
209
|
|
|
211
210
|
|
|
212
211
|
def test_PVSystem_multi_array_sapm(sapm_module_params):
|
|
@@ -487,7 +486,7 @@ def test_PVSystem_faiman_celltemp(mocker):
|
|
|
487
486
|
winds = 1
|
|
488
487
|
out = system.get_cell_temperature(irrads, temps, winds, model='faiman')
|
|
489
488
|
temperature.faiman.assert_called_once_with(irrads, temps, winds, u0, u1)
|
|
490
|
-
assert_allclose(out, 56.4, atol=1)
|
|
489
|
+
assert_allclose(out, 56.4, atol=1e-1)
|
|
491
490
|
|
|
492
491
|
|
|
493
492
|
def test_PVSystem_noct_celltemp(mocker):
|
|
@@ -1062,7 +1061,7 @@ def test_PVSystem_calcparams_desoto(cec_module_params, mocker):
|
|
|
1062
1061
|
dEgdT=module_parameters['dEgdT']
|
|
1063
1062
|
)
|
|
1064
1063
|
|
|
1065
|
-
assert_allclose(IL, np.array([0.0, 6.036]), atol=1)
|
|
1064
|
+
assert_allclose(IL, np.array([0.0, 6.036]), atol=1e-1)
|
|
1066
1065
|
assert_allclose(I0, np.array([2.0e-9, 2.0e-9]), atol=1.0e-9)
|
|
1067
1066
|
assert_allclose(Rs, np.array([0.1, 0.1]), atol=0.1)
|
|
1068
1067
|
assert_allclose(Rsh, np.array([np.inf, 20]), atol=1)
|
|
@@ -1568,27 +1567,21 @@ def test_singlediode_floats():
|
|
|
1568
1567
|
assert_allclose(v, expected[k], atol=1e-6)
|
|
1569
1568
|
|
|
1570
1569
|
|
|
1571
|
-
def
|
|
1572
|
-
|
|
1573
|
-
out = pvsystem.singlediode(7., 6e-7, .1, 20., .5, ivcurve_pnts=3,
|
|
1574
|
-
method='lambertw')
|
|
1570
|
+
def test_singlediode_floats_expected():
|
|
1571
|
+
out = pvsystem.singlediode(7., 6e-7, .1, 20., .5, method='lambertw')
|
|
1575
1572
|
expected = {'i_xx': 4.264060478,
|
|
1576
1573
|
'i_mp': 6.136267360,
|
|
1577
1574
|
'v_oc': 8.106300147,
|
|
1578
1575
|
'p_mp': 38.19421055,
|
|
1579
1576
|
'i_x': 6.7558815684,
|
|
1580
1577
|
'i_sc': 6.965172322,
|
|
1581
|
-
'v_mp': 6.224339375
|
|
1582
|
-
'i': np.array([
|
|
1583
|
-
6.965172322, 6.755881568, 2.664535259e-14]),
|
|
1584
|
-
'v': np.array([
|
|
1585
|
-
0., 4.053150073, 8.106300147])}
|
|
1578
|
+
'v_mp': 6.224339375}
|
|
1586
1579
|
assert isinstance(out, dict)
|
|
1587
1580
|
for k, v in out.items():
|
|
1588
1581
|
assert_allclose(v, expected[k], atol=1e-6)
|
|
1589
1582
|
|
|
1590
1583
|
|
|
1591
|
-
def
|
|
1584
|
+
def test_singlediode_series_expected(cec_module_params):
|
|
1592
1585
|
times = pd.date_range(start='2015-06-01', periods=3, freq='6h')
|
|
1593
1586
|
effective_irradiance = pd.Series([0.0, 400.0, 800.0], index=times)
|
|
1594
1587
|
IL, I0, Rs, Rsh, nNsVth = pvsystem.calcparams_desoto(
|
|
@@ -1603,9 +1596,7 @@ def test_singlediode_series_ivcurve(cec_module_params):
|
|
|
1603
1596
|
EgRef=1.121,
|
|
1604
1597
|
dEgdT=-0.0002677)
|
|
1605
1598
|
|
|
1606
|
-
|
|
1607
|
-
out = pvsystem.singlediode(IL, I0, Rs, Rsh, nNsVth, ivcurve_pnts=3,
|
|
1608
|
-
method='lambertw')
|
|
1599
|
+
out = pvsystem.singlediode(IL, I0, Rs, Rsh, nNsVth, method='lambertw')
|
|
1609
1600
|
|
|
1610
1601
|
expected = OrderedDict([('i_sc', array([0., 3.01079860, 6.00726296])),
|
|
1611
1602
|
('v_oc', array([0., 9.96959733, 10.29603253])),
|
|
@@ -1613,41 +1604,22 @@ def test_singlediode_series_ivcurve(cec_module_params):
|
|
|
1613
1604
|
('v_mp', array([0., 8.321092255, 8.409413795])),
|
|
1614
1605
|
('p_mp', array([0., 22.10320053, 44.49021934])),
|
|
1615
1606
|
('i_x', array([0., 2.884132006, 5.746202281])),
|
|
1616
|
-
('i_xx', array([0., 2.052691562, 3.909673879]))
|
|
1617
|
-
('v', array([[0., 0., 0.],
|
|
1618
|
-
[0., 4.984798663, 9.969597327],
|
|
1619
|
-
[0., 5.148016266, 10.29603253]])),
|
|
1620
|
-
('i', array([[0., 0., 0.],
|
|
1621
|
-
[3.0107985972, 2.8841320056, 0.],
|
|
1622
|
-
[6.0072629615, 5.7462022810, 0.]]))])
|
|
1607
|
+
('i_xx', array([0., 2.052691562, 3.909673879]))])
|
|
1623
1608
|
|
|
1624
1609
|
for k, v in out.items():
|
|
1625
1610
|
assert_allclose(v, expected[k], atol=1e-2)
|
|
1626
1611
|
|
|
1627
|
-
|
|
1628
|
-
out = pvsystem.singlediode(IL, I0, Rs, Rsh, nNsVth, ivcurve_pnts=3)
|
|
1612
|
+
out = pvsystem.singlediode(IL, I0, Rs, Rsh, nNsVth)
|
|
1629
1613
|
|
|
1630
1614
|
expected['i_mp'] = pvsystem.i_from_v(out['v_mp'], IL, I0, Rs, Rsh, nNsVth,
|
|
1631
1615
|
method='lambertw')
|
|
1632
1616
|
expected['v_mp'] = pvsystem.v_from_i(out['i_mp'], IL, I0, Rs, Rsh, nNsVth,
|
|
1633
1617
|
method='lambertw')
|
|
1634
|
-
expected['i'] = pvsystem.i_from_v(out['v'].T, IL, I0, Rs, Rsh, nNsVth,
|
|
1635
|
-
method='lambertw').T
|
|
1636
|
-
expected['v'] = pvsystem.v_from_i(out['i'].T, IL, I0, Rs, Rsh, nNsVth,
|
|
1637
|
-
method='lambertw').T
|
|
1638
1618
|
|
|
1639
1619
|
for k, v in out.items():
|
|
1640
1620
|
assert_allclose(v, expected[k], atol=1e-6)
|
|
1641
1621
|
|
|
1642
1622
|
|
|
1643
|
-
@fail_on_pvlib_version('0.11')
|
|
1644
|
-
@pytest.mark.parametrize('method', ['lambertw', 'brentq', 'newton'])
|
|
1645
|
-
def test_singlediode_ivcurvepnts_deprecation_warning(method):
|
|
1646
|
-
with pytest.warns(pvlibDeprecationWarning, match='ivcurve_pnts'):
|
|
1647
|
-
pvsystem.singlediode(7., 6e-7, .1, 20., .5, ivcurve_pnts=3,
|
|
1648
|
-
method=method)
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
1623
|
def test_scale_voltage_current_power():
|
|
1652
1624
|
data = pd.DataFrame(
|
|
1653
1625
|
np.array([[2, 1.5, 10, 8, 12, 0.5, 1.5]]),
|