pvlib 0.11.1__py3-none-any.whl → 0.12.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/_deprecation.py +73 -0
- pvlib/atmosphere.py +77 -7
- pvlib/bifacial/infinite_sheds.py +4 -3
- pvlib/bifacial/utils.py +2 -1
- pvlib/clearsky.py +35 -22
- pvlib/iam.py +4 -4
- pvlib/iotools/midc.py +1 -1
- pvlib/iotools/psm3.py +1 -1
- pvlib/iotools/pvgis.py +10 -12
- pvlib/iotools/tmy.py +3 -69
- pvlib/irradiance.py +112 -55
- pvlib/ivtools/sdm.py +75 -52
- pvlib/location.py +73 -33
- pvlib/modelchain.py +18 -35
- pvlib/pvsystem.py +139 -94
- pvlib/snow.py +64 -28
- pvlib/solarposition.py +46 -30
- pvlib/spa.py +4 -2
- pvlib/spectrum/__init__.py +0 -1
- pvlib/spectrum/irradiance.py +2 -64
- pvlib/spectrum/mismatch.py +3 -3
- pvlib/spectrum/spectrl2.py +2 -1
- pvlib/temperature.py +49 -3
- pvlib/tools.py +6 -5
- {pvlib-0.11.1.dist-info → pvlib-0.12.0.dist-info}/METADATA +14 -11
- pvlib-0.12.0.dist-info/RECORD +75 -0
- {pvlib-0.11.1.dist-info → pvlib-0.12.0.dist-info}/WHEEL +1 -1
- pvlib/data/BIRD_08_16_2012.csv +0 -8761
- pvlib/data/BIRD_08_16_2012_patm.csv +0 -8761
- pvlib/data/Burlington, United States SolarAnywhere Time Series 2021 Lat_44_465 Lon_-73_205 TMY3 format.csv +0 -8762
- pvlib/data/Burlington, United States SolarAnywhere Time Series 20210101 to 20210103 Lat_44_4675 Lon_-73_2075 SA format.csv +0 -578
- pvlib/data/Burlington, United States SolarAnywhere Typical GHI Year Lat_44_465 Lon_-73_205 SA format.csv +0 -74
- pvlib/data/CPS SCH275KTL-DO-US-800-250kW_275kVA_1.OND +0 -146
- pvlib/data/CRNS0101-05-2019-AZ_Tucson_11_W.txt +0 -4
- pvlib/data/CRN_with_problems.txt +0 -3
- pvlib/data/ET-M772BH550GL.PAN +0 -75
- pvlib/data/NLD_Amsterdam062400_IWEC.epw +0 -8768
- pvlib/data/PVsyst_demo.csv +0 -10757
- pvlib/data/PVsyst_demo_model.csv +0 -3588
- pvlib/data/SRML-day-EUPO1801.txt +0 -1441
- pvlib/data/abq19056.dat +0 -6
- pvlib/data/aod550_tcwv_20121101_test.nc +0 -0
- pvlib/data/bishop88_numerical_precision.csv +0 -101
- pvlib/data/bsrn-lr0100-pay0616.dat +0 -86901
- pvlib/data/bsrn-pay0616.dat.gz +0 -0
- pvlib/data/cams_mcclear_1min_verbose.csv +0 -60
- pvlib/data/cams_mcclear_monthly.csv +0 -42
- pvlib/data/cams_radiation_1min_verbose.csv +0 -72
- pvlib/data/cams_radiation_monthly.csv +0 -47
- pvlib/data/detect_clearsky_data.csv +0 -35
- pvlib/data/detect_clearsky_threshold_data.csv +0 -126
- pvlib/data/greensboro_kimber_soil_manwash.dat +0 -8761
- pvlib/data/greensboro_kimber_soil_nowash.dat +0 -8761
- pvlib/data/inverter_fit_snl_meas.csv +0 -127
- pvlib/data/inverter_fit_snl_sim.csv +0 -19
- pvlib/data/ivtools_numdiff.csv +0 -52
- pvlib/data/midc_20181014.txt +0 -1441
- pvlib/data/midc_raw_20181018.txt +0 -1441
- pvlib/data/midc_raw_short_header_20191115.txt +0 -1441
- pvlib/data/msn19056.dat +0 -6
- pvlib/data/precise_iv_curves1.json +0 -10251
- pvlib/data/precise_iv_curves2.json +0 -10251
- pvlib/data/precise_iv_curves_parameter_sets1.csv +0 -33
- pvlib/data/precise_iv_curves_parameter_sets2.csv +0 -33
- pvlib/data/pvgis_hourly_Timeseries_45.000_8.000_SA2_10kWp_CIS_5_2a_2013_2014.json +0 -1
- pvlib/data/pvgis_hourly_Timeseries_45.000_8.000_SA_30deg_0deg_2016_2016.csv +0 -35
- pvlib/data/pvgis_tmy_meta.json +0 -32
- pvlib/data/pvgis_tmy_test.dat +0 -8761
- pvlib/data/pvwatts_8760_rackmount.csv +0 -8779
- pvlib/data/pvwatts_8760_roofmount.csv +0 -8779
- pvlib/data/singleaxis_tracker_wslope.csv +0 -8761
- pvlib/data/spectrl2_example_spectra.csv +0 -123
- pvlib/data/surfrad-slv16001.dat +0 -1442
- pvlib/data/test_psm3_2017.csv +0 -17521
- pvlib/data/test_psm3_2019_5min.csv +0 -289
- pvlib/data/test_psm3_tmy-2017.csv +0 -8761
- pvlib/data/test_read_psm3.csv +0 -17523
- pvlib/data/test_read_pvgis_horizon.csv +0 -49
- pvlib/data/tmy_45.000_8.000_2005_2020.csv +0 -8789
- pvlib/data/tmy_45.000_8.000_2005_2020.epw +0 -8768
- pvlib/data/tmy_45.000_8.000_2005_2020.json +0 -1
- pvlib/data/tmy_45.000_8.000_2005_2020.txt +0 -8761
- pvlib/data/tmy_45.000_8.000_userhorizon.json +0 -1
- pvlib/data/variables_style_rules.csv +0 -56
- pvlib/spa_c_files/README.md +0 -81
- pvlib/spa_c_files/cspa_py.pxd +0 -43
- pvlib/spa_c_files/spa_py.pyx +0 -30
- pvlib/tests/__init__.py +0 -0
- pvlib/tests/bifacial/__init__.py +0 -0
- pvlib/tests/bifacial/test_infinite_sheds.py +0 -317
- pvlib/tests/bifacial/test_losses_models.py +0 -54
- pvlib/tests/bifacial/test_pvfactors.py +0 -82
- pvlib/tests/bifacial/test_utils.py +0 -192
- pvlib/tests/conftest.py +0 -476
- pvlib/tests/iotools/__init__.py +0 -0
- pvlib/tests/iotools/test_acis.py +0 -213
- pvlib/tests/iotools/test_bsrn.py +0 -131
- pvlib/tests/iotools/test_crn.py +0 -95
- pvlib/tests/iotools/test_epw.py +0 -23
- pvlib/tests/iotools/test_midc.py +0 -89
- pvlib/tests/iotools/test_panond.py +0 -32
- pvlib/tests/iotools/test_psm3.py +0 -198
- pvlib/tests/iotools/test_pvgis.py +0 -644
- pvlib/tests/iotools/test_sodapro.py +0 -298
- pvlib/tests/iotools/test_solaranywhere.py +0 -287
- pvlib/tests/iotools/test_solargis.py +0 -68
- pvlib/tests/iotools/test_solcast.py +0 -324
- pvlib/tests/iotools/test_solrad.py +0 -152
- pvlib/tests/iotools/test_srml.py +0 -124
- pvlib/tests/iotools/test_surfrad.py +0 -75
- pvlib/tests/iotools/test_tmy.py +0 -133
- pvlib/tests/ivtools/__init__.py +0 -0
- pvlib/tests/ivtools/test_sde.py +0 -230
- pvlib/tests/ivtools/test_sdm.py +0 -407
- pvlib/tests/ivtools/test_utils.py +0 -173
- pvlib/tests/spectrum/__init__.py +0 -0
- pvlib/tests/spectrum/conftest.py +0 -40
- pvlib/tests/spectrum/test_irradiance.py +0 -138
- pvlib/tests/spectrum/test_mismatch.py +0 -304
- pvlib/tests/spectrum/test_response.py +0 -124
- pvlib/tests/spectrum/test_spectrl2.py +0 -72
- pvlib/tests/test_albedo.py +0 -84
- pvlib/tests/test_atmosphere.py +0 -204
- pvlib/tests/test_clearsky.py +0 -878
- pvlib/tests/test_conftest.py +0 -81
- pvlib/tests/test_iam.py +0 -555
- pvlib/tests/test_inverter.py +0 -213
- pvlib/tests/test_irradiance.py +0 -1441
- pvlib/tests/test_location.py +0 -356
- pvlib/tests/test_modelchain.py +0 -2020
- pvlib/tests/test_numerical_precision.py +0 -124
- pvlib/tests/test_pvarray.py +0 -71
- pvlib/tests/test_pvsystem.py +0 -2495
- pvlib/tests/test_scaling.py +0 -207
- pvlib/tests/test_shading.py +0 -391
- pvlib/tests/test_singlediode.py +0 -608
- pvlib/tests/test_snow.py +0 -212
- pvlib/tests/test_soiling.py +0 -230
- pvlib/tests/test_solarposition.py +0 -933
- pvlib/tests/test_spa.py +0 -425
- pvlib/tests/test_temperature.py +0 -470
- pvlib/tests/test_tools.py +0 -146
- pvlib/tests/test_tracking.py +0 -474
- pvlib/tests/test_transformer.py +0 -60
- pvlib-0.11.1.dist-info/RECORD +0 -192
- {pvlib-0.11.1.dist-info → pvlib-0.12.0.dist-info/licenses}/AUTHORS.md +0 -0
- {pvlib-0.11.1.dist-info → pvlib-0.12.0.dist-info/licenses}/LICENSE +0 -0
- {pvlib-0.11.1.dist-info → pvlib-0.12.0.dist-info}/top_level.txt +0 -0
pvlib/tests/test_albedo.py
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
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_atmosphere.py
DELETED
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
import itertools
|
|
2
|
-
|
|
3
|
-
import numpy as np
|
|
4
|
-
from numpy import nan
|
|
5
|
-
from numpy.testing import assert_allclose
|
|
6
|
-
import pandas as pd
|
|
7
|
-
from .conftest import assert_series_equal
|
|
8
|
-
import pytest
|
|
9
|
-
|
|
10
|
-
from pvlib import atmosphere
|
|
11
|
-
|
|
12
|
-
from pvlib._deprecation import pvlibDeprecationWarning
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
def test_pres2alt():
|
|
16
|
-
out = atmosphere.pres2alt(np.array([10000, 90000, 101325]))
|
|
17
|
-
expected = np.array([15797.638, 988.637, 0.124])
|
|
18
|
-
assert_allclose(out, expected, atol=0.001)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
def test_alt2pres():
|
|
22
|
-
out = atmosphere.alt2pres(np.array([-100, 0, 1000, 8000]))
|
|
23
|
-
expected = np.array([102532.073, 101324.999, 89874.750, 35600.496])
|
|
24
|
-
assert_allclose(out, expected, atol=0.001)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
@pytest.fixture
|
|
28
|
-
def zeniths():
|
|
29
|
-
return np.array([100, 89.9, 80, 0])
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
@pytest.mark.parametrize("model,expected",
|
|
33
|
-
[['simple', [nan, 572.958, 5.759, 1.000]],
|
|
34
|
-
['kasten1966', [nan, 35.365, 5.580, 0.999]],
|
|
35
|
-
['youngirvine1967', [
|
|
36
|
-
nan, -2.251358367165932e+05, 5.5365, 1.0000]],
|
|
37
|
-
['kastenyoung1989', [nan, 36.467, 5.586, 1.000]],
|
|
38
|
-
['gueymard1993', [nan, 36.431, 5.581, 1.000]],
|
|
39
|
-
['young1994', [nan, 30.733, 5.541, 1.000]],
|
|
40
|
-
['pickering2002', [nan, 37.064, 5.581, 1.000]],
|
|
41
|
-
['gueymard2003', [nan, 36.676, 5.590, 1.000]]])
|
|
42
|
-
def test_airmass(model, expected, zeniths):
|
|
43
|
-
out = atmosphere.get_relative_airmass(zeniths, model)
|
|
44
|
-
expected = np.array(expected)
|
|
45
|
-
assert_allclose(out, expected, equal_nan=True, atol=0.001)
|
|
46
|
-
# test series in/out. index does not matter
|
|
47
|
-
# hits the isinstance() block in get_relative_airmass
|
|
48
|
-
times = pd.date_range(start='20180101', periods=len(zeniths), freq='1s')
|
|
49
|
-
zeniths = pd.Series(zeniths, index=times)
|
|
50
|
-
expected = pd.Series(expected, index=times)
|
|
51
|
-
out = atmosphere.get_relative_airmass(zeniths, model)
|
|
52
|
-
assert_series_equal(out, expected, check_less_precise=True)
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
def test_airmass_scalar():
|
|
56
|
-
assert not np.isnan(atmosphere.get_relative_airmass(10))
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
def test_airmass_invalid():
|
|
60
|
-
with pytest.raises(ValueError):
|
|
61
|
-
atmosphere.get_relative_airmass(0, 'invalid')
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
def test_get_absolute_airmass():
|
|
65
|
-
# input am
|
|
66
|
-
relative_am = np.array([nan, 40, 2, .999])
|
|
67
|
-
# call without pressure kwarg
|
|
68
|
-
out = atmosphere.get_absolute_airmass(relative_am)
|
|
69
|
-
expected = np.array([nan, 40., 2., 0.999])
|
|
70
|
-
assert_allclose(out, expected, equal_nan=True, atol=0.001)
|
|
71
|
-
# call with pressure kwarg
|
|
72
|
-
out = atmosphere.get_absolute_airmass(relative_am, pressure=90000)
|
|
73
|
-
expected = np.array([nan, 35.529, 1.776, 0.887])
|
|
74
|
-
assert_allclose(out, expected, equal_nan=True, atol=0.001)
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
def test_gueymard94_pw():
|
|
78
|
-
temp_air = np.array([0, 20, 40])
|
|
79
|
-
relative_humidity = np.array([0, 30, 100])
|
|
80
|
-
temps_humids = np.array(
|
|
81
|
-
list(itertools.product(temp_air, relative_humidity)))
|
|
82
|
-
pws = atmosphere.gueymard94_pw(temps_humids[:, 0], temps_humids[:, 1])
|
|
83
|
-
|
|
84
|
-
expected = np.array(
|
|
85
|
-
[ 0.1 , 0.33702061, 1.12340202, 0.1 ,
|
|
86
|
-
1.12040963, 3.73469877, 0.1 , 3.44859767, 11.49532557])
|
|
87
|
-
|
|
88
|
-
assert_allclose(pws, expected, atol=0.01)
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
def test_first_solar_spectral_correction_deprecated():
|
|
92
|
-
with pytest.warns(pvlibDeprecationWarning,
|
|
93
|
-
match='Use pvlib.spectrum.spectral_factor_firstsolar'):
|
|
94
|
-
atmosphere.first_solar_spectral_correction(1, 1, 'cdte')
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
def test_kasten96_lt():
|
|
98
|
-
"""Test Linke turbidity factor calculated from AOD, Pwat and AM"""
|
|
99
|
-
amp = np.array([1, 3, 5])
|
|
100
|
-
pwat = np.array([0, 2.5, 5])
|
|
101
|
-
aod_bb = np.array([0, 0.1, 1])
|
|
102
|
-
lt_expected = np.array(
|
|
103
|
-
[[[1.3802, 2.4102, 11.6802],
|
|
104
|
-
[1.16303976, 2.37303976, 13.26303976],
|
|
105
|
-
[1.12101907, 2.51101907, 15.02101907]],
|
|
106
|
-
|
|
107
|
-
[[2.95546945, 3.98546945, 13.25546945],
|
|
108
|
-
[2.17435443, 3.38435443, 14.27435443],
|
|
109
|
-
[1.99821967, 3.38821967, 15.89821967]],
|
|
110
|
-
|
|
111
|
-
[[3.37410769, 4.40410769, 13.67410769],
|
|
112
|
-
[2.44311797, 3.65311797, 14.54311797],
|
|
113
|
-
[2.23134152, 3.62134152, 16.13134152]]]
|
|
114
|
-
)
|
|
115
|
-
lt = atmosphere.kasten96_lt(*np.meshgrid(amp, pwat, aod_bb))
|
|
116
|
-
assert np.allclose(lt, lt_expected, 1e-3)
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
def test_angstrom_aod():
|
|
120
|
-
"""Test Angstrom turbidity model functions."""
|
|
121
|
-
aod550 = 0.15
|
|
122
|
-
aod1240 = 0.05
|
|
123
|
-
alpha = atmosphere.angstrom_alpha(aod550, 550, aod1240, 1240)
|
|
124
|
-
assert np.isclose(alpha, 1.3513924317859232)
|
|
125
|
-
aod700 = atmosphere.angstrom_aod_at_lambda(aod550, 550, alpha)
|
|
126
|
-
assert np.isclose(aod700, 0.10828110997681031)
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
def test_bird_hulstrom80_aod_bb():
|
|
130
|
-
"""Test Bird_Hulstrom broadband AOD."""
|
|
131
|
-
aod380, aod500 = 0.22072480948195175, 0.1614279181106312
|
|
132
|
-
bird_hulstrom = atmosphere.bird_hulstrom80_aod_bb(aod380, aod500)
|
|
133
|
-
assert np.isclose(0.11738229553812768, bird_hulstrom)
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
@pytest.fixture
|
|
137
|
-
def windspeeds_data_powerlaw():
|
|
138
|
-
data = pd.DataFrame(
|
|
139
|
-
index=pd.date_range(start="2015-01-01 00:00", end="2015-01-01 05:00",
|
|
140
|
-
freq="1h"),
|
|
141
|
-
columns=["wind_ref", "height_ref", "height_desired", "wind_calc"],
|
|
142
|
-
data=[
|
|
143
|
-
(10, -2, 5, np.nan),
|
|
144
|
-
(-10, 2, 5, np.nan),
|
|
145
|
-
(5, 4, 5, 5.067393209486324),
|
|
146
|
-
(7, 6, 10, 7.2178684911195905),
|
|
147
|
-
(10, 8, 20, 10.565167835216586),
|
|
148
|
-
(12, 10, 30, 12.817653329393977)
|
|
149
|
-
]
|
|
150
|
-
)
|
|
151
|
-
return data
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
def test_windspeed_powerlaw_ndarray(windspeeds_data_powerlaw):
|
|
155
|
-
# test wind speed estimation by passing in surface_type
|
|
156
|
-
result_surface = atmosphere.windspeed_powerlaw(
|
|
157
|
-
windspeeds_data_powerlaw["wind_ref"].to_numpy(),
|
|
158
|
-
windspeeds_data_powerlaw["height_ref"],
|
|
159
|
-
windspeeds_data_powerlaw["height_desired"],
|
|
160
|
-
surface_type='unstable_air_above_open_water_surface')
|
|
161
|
-
assert_allclose(windspeeds_data_powerlaw["wind_calc"].to_numpy(),
|
|
162
|
-
result_surface)
|
|
163
|
-
# test wind speed estimation by passing in the exponent corresponding
|
|
164
|
-
# to the surface_type above
|
|
165
|
-
result_exponent = atmosphere.windspeed_powerlaw(
|
|
166
|
-
windspeeds_data_powerlaw["wind_ref"].to_numpy(),
|
|
167
|
-
windspeeds_data_powerlaw["height_ref"],
|
|
168
|
-
windspeeds_data_powerlaw["height_desired"],
|
|
169
|
-
exponent=0.06)
|
|
170
|
-
assert_allclose(windspeeds_data_powerlaw["wind_calc"].to_numpy(),
|
|
171
|
-
result_exponent)
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
def test_windspeed_powerlaw_series(windspeeds_data_powerlaw):
|
|
175
|
-
result = atmosphere.windspeed_powerlaw(
|
|
176
|
-
windspeeds_data_powerlaw["wind_ref"],
|
|
177
|
-
windspeeds_data_powerlaw["height_ref"],
|
|
178
|
-
windspeeds_data_powerlaw["height_desired"],
|
|
179
|
-
surface_type='unstable_air_above_open_water_surface')
|
|
180
|
-
assert_series_equal(windspeeds_data_powerlaw["wind_calc"],
|
|
181
|
-
result, check_names=False)
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
def test_windspeed_powerlaw_invalid():
|
|
185
|
-
with pytest.raises(ValueError, match="Either a 'surface_type' or an "
|
|
186
|
-
"'exponent' parameter must be given"):
|
|
187
|
-
# no exponent or surface_type given
|
|
188
|
-
atmosphere.windspeed_powerlaw(wind_speed_reference=10,
|
|
189
|
-
height_reference=5,
|
|
190
|
-
height_desired=10)
|
|
191
|
-
with pytest.raises(ValueError, match="Either a 'surface_type' or an "
|
|
192
|
-
"'exponent' parameter must be given"):
|
|
193
|
-
# no exponent or surface_type given
|
|
194
|
-
atmosphere.windspeed_powerlaw(wind_speed_reference=10,
|
|
195
|
-
height_reference=5,
|
|
196
|
-
height_desired=10,
|
|
197
|
-
exponent=1.2,
|
|
198
|
-
surface_type="surf")
|
|
199
|
-
with pytest.raises(KeyError, match='not_an_exponent'):
|
|
200
|
-
# invalid surface_type
|
|
201
|
-
atmosphere.windspeed_powerlaw(wind_speed_reference=10,
|
|
202
|
-
height_reference=5,
|
|
203
|
-
height_desired=10,
|
|
204
|
-
surface_type='not_an_exponent')
|