pvlib 0.11.2__py3-none-any.whl → 0.12.1a1__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/atmosphere.py +40 -40
- pvlib/bifacial/infinite_sheds.py +4 -3
- pvlib/bifacial/utils.py +2 -1
- pvlib/iotools/__init__.py +6 -0
- pvlib/iotools/psm3.py +1 -1
- pvlib/iotools/psm4.py +819 -0
- pvlib/iotools/pvgis.py +10 -2
- pvlib/iotools/tmy.py +3 -69
- pvlib/irradiance.py +38 -15
- pvlib/ivtools/sdm/__init__.py +20 -0
- pvlib/ivtools/sdm/_fit_desoto_pvsyst_sandia.py +585 -0
- pvlib/ivtools/sdm/cec.py +93 -0
- pvlib/ivtools/sdm/desoto.py +401 -0
- pvlib/ivtools/sdm/pvsyst.py +630 -0
- pvlib/location.py +73 -33
- pvlib/modelchain.py +19 -36
- pvlib/pvsystem.py +114 -65
- pvlib/snow.py +64 -28
- pvlib/spectrum/__init__.py +0 -1
- pvlib/spectrum/irradiance.py +2 -64
- pvlib/spectrum/mismatch.py +3 -3
- pvlib/tools.py +6 -5
- {pvlib-0.11.2.dist-info → pvlib-0.12.1a1.dist-info}/METADATA +6 -5
- pvlib-0.12.1a1.dist-info/RECORD +80 -0
- {pvlib-0.11.2.dist-info → pvlib-0.12.1a1.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/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.csv +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_2023.csv +0 -8789
- pvlib/data/tmy_45.000_8.000_2005_2023.epw +0 -8768
- pvlib/data/tmy_45.000_8.000_2005_2023.json +0 -1
- pvlib/data/tmy_45.000_8.000_2005_2023.txt +0 -8761
- pvlib/data/tmy_45.000_8.000_userhorizon.json +0 -1
- pvlib/ivtools/sdm.py +0 -1379
- 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 -429
- 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__deprecation.py +0 -97
- pvlib/tests/test_albedo.py +0 -84
- pvlib/tests/test_atmosphere.py +0 -351
- pvlib/tests/test_clearsky.py +0 -884
- pvlib/tests/test_conftest.py +0 -37
- pvlib/tests/test_iam.py +0 -555
- pvlib/tests/test_inverter.py +0 -213
- pvlib/tests/test_irradiance.py +0 -1487
- 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 -2511
- 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 -966
- pvlib/tests/test_spa.py +0 -454
- 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.2.dist-info/RECORD +0 -191
- {pvlib-0.11.2.dist-info → pvlib-0.12.1a1.dist-info/licenses}/AUTHORS.md +0 -0
- {pvlib-0.11.2.dist-info → pvlib-0.12.1a1.dist-info/licenses}/LICENSE +0 -0
- {pvlib-0.11.2.dist-info → pvlib-0.12.1a1.dist-info}/top_level.txt +0 -0
|
@@ -1,324 +0,0 @@
|
|
|
1
|
-
from unittest.mock import patch
|
|
2
|
-
import pandas as pd
|
|
3
|
-
import pvlib
|
|
4
|
-
import pytest
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
@pytest.mark.parametrize("endpoint,params,api_key,json_response", [
|
|
8
|
-
(
|
|
9
|
-
"live/radiation_and_weather",
|
|
10
|
-
dict(
|
|
11
|
-
latitude=-33.856784,
|
|
12
|
-
longitude=151.215297,
|
|
13
|
-
output_parameters='dni,ghi'
|
|
14
|
-
),
|
|
15
|
-
"1234",
|
|
16
|
-
{'estimated_actuals':
|
|
17
|
-
[{'dni': 836, 'ghi': 561,
|
|
18
|
-
'period_end': '2023-09-18T05:00:00.0000000Z', 'period': 'PT30M'},
|
|
19
|
-
{'dni': 866, 'ghi': 643,
|
|
20
|
-
'period_end': '2023-09-18T04:30:00.0000000Z', 'period': 'PT30M'},
|
|
21
|
-
{'dni': 890, 'ghi': 713,
|
|
22
|
-
'period_end': '2023-09-18T04:00:00.0000000Z', 'period': 'PT30M'},
|
|
23
|
-
{'dni': 909, 'ghi': 768,
|
|
24
|
-
'period_end': '2023-09-18T03:30:00.0000000Z', 'period': 'PT30M'}]
|
|
25
|
-
}
|
|
26
|
-
),
|
|
27
|
-
])
|
|
28
|
-
def test__get_solcast(requests_mock, endpoint, params, api_key, json_response):
|
|
29
|
-
mock_url = f"https://api.solcast.com.au/data/{endpoint}?" \
|
|
30
|
-
f"latitude={params['latitude']}&" \
|
|
31
|
-
f"longitude={params['longitude']}&" \
|
|
32
|
-
f"output_parameters={params['output_parameters']}"
|
|
33
|
-
|
|
34
|
-
requests_mock.get(mock_url, json=json_response)
|
|
35
|
-
|
|
36
|
-
# with variables remapping
|
|
37
|
-
pd.testing.assert_frame_equal(
|
|
38
|
-
pvlib.iotools.solcast._get_solcast(
|
|
39
|
-
endpoint, params, api_key, True
|
|
40
|
-
),
|
|
41
|
-
pvlib.iotools.solcast._solcast2pvlib(
|
|
42
|
-
pd.DataFrame.from_dict(
|
|
43
|
-
json_response[list(json_response.keys())[0]])
|
|
44
|
-
)
|
|
45
|
-
)
|
|
46
|
-
|
|
47
|
-
# no remapping of variables
|
|
48
|
-
pd.testing.assert_frame_equal(
|
|
49
|
-
pvlib.iotools.solcast._get_solcast(
|
|
50
|
-
endpoint, params, api_key, False
|
|
51
|
-
),
|
|
52
|
-
pd.DataFrame.from_dict(
|
|
53
|
-
json_response[list(json_response.keys())[0]])
|
|
54
|
-
)
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
@pytest.mark.parametrize("map_variables", [True, False])
|
|
58
|
-
@pytest.mark.parametrize("endpoint,function,params,json_response", [
|
|
59
|
-
(
|
|
60
|
-
"live/radiation_and_weather",
|
|
61
|
-
pvlib.iotools.get_solcast_live,
|
|
62
|
-
dict(
|
|
63
|
-
api_key="1234",
|
|
64
|
-
latitude=-33.856784,
|
|
65
|
-
longitude=151.215297,
|
|
66
|
-
output_parameters='dni,ghi'
|
|
67
|
-
),
|
|
68
|
-
{'estimated_actuals':
|
|
69
|
-
[{'dni': 836, 'ghi': 561,
|
|
70
|
-
'period_end': '2023-09-18T05:00:00.0000000Z', 'period': 'PT30M'},
|
|
71
|
-
{'dni': 866, 'ghi': 643,
|
|
72
|
-
'period_end': '2023-09-18T04:30:00.0000000Z', 'period': 'PT30M'},
|
|
73
|
-
{'dni': 890, 'ghi': 713,
|
|
74
|
-
'period_end': '2023-09-18T04:00:00.0000000Z', 'period': 'PT30M'},
|
|
75
|
-
{'dni': 909, 'ghi': 768,
|
|
76
|
-
'period_end': '2023-09-18T03:30:00.0000000Z', 'period': 'PT30M'}]
|
|
77
|
-
}
|
|
78
|
-
),
|
|
79
|
-
])
|
|
80
|
-
def test_get_solcast_live(
|
|
81
|
-
requests_mock, endpoint, function, params, json_response, map_variables
|
|
82
|
-
):
|
|
83
|
-
mock_url = (
|
|
84
|
-
f"https://api.solcast.com.au/data/{endpoint}?"
|
|
85
|
-
f"&latitude={params['latitude']}&"
|
|
86
|
-
f"longitude={params['longitude']}&"
|
|
87
|
-
f"output_parameters={params['output_parameters']}&format=json"
|
|
88
|
-
)
|
|
89
|
-
|
|
90
|
-
requests_mock.get(mock_url, json=json_response)
|
|
91
|
-
|
|
92
|
-
if map_variables:
|
|
93
|
-
pd.testing.assert_frame_equal(
|
|
94
|
-
function(**params, map_variables=map_variables)[0],
|
|
95
|
-
pvlib.iotools.solcast._solcast2pvlib(
|
|
96
|
-
pd.DataFrame.from_dict(
|
|
97
|
-
json_response[list(json_response.keys())[0]]
|
|
98
|
-
)
|
|
99
|
-
),
|
|
100
|
-
)
|
|
101
|
-
else:
|
|
102
|
-
pd.testing.assert_frame_equal(
|
|
103
|
-
function(**params, map_variables=map_variables)[0],
|
|
104
|
-
pd.DataFrame.from_dict(
|
|
105
|
-
json_response[list(json_response.keys())[0]]
|
|
106
|
-
),
|
|
107
|
-
)
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
@pytest.mark.parametrize("map_variables", [True, False])
|
|
111
|
-
@pytest.mark.parametrize("endpoint,function,params,json_response", [
|
|
112
|
-
(
|
|
113
|
-
"tmy/radiation_and_weather",
|
|
114
|
-
pvlib.iotools.get_solcast_tmy,
|
|
115
|
-
dict(
|
|
116
|
-
api_key="1234",
|
|
117
|
-
latitude=-33.856784,
|
|
118
|
-
longitude=51.215297
|
|
119
|
-
),
|
|
120
|
-
{'estimated_actuals': [
|
|
121
|
-
{'dni': 151, 'ghi': 609,
|
|
122
|
-
'period_end': '2059-01-01T01:00:00.0000000Z', 'period': 'PT60M'},
|
|
123
|
-
{'dni': 0, 'ghi': 404,
|
|
124
|
-
'period_end': '2059-01-01T02:00:00.0000000Z', 'period': 'PT60M'},
|
|
125
|
-
{'dni': 0, 'ghi': 304,
|
|
126
|
-
'period_end': '2059-01-01T03:00:00.0000000Z', 'period': 'PT60M'},
|
|
127
|
-
{'dni': 0, 'ghi': 174,
|
|
128
|
-
'period_end': '2059-01-01T04:00:00.0000000Z', 'period': 'PT60M'},
|
|
129
|
-
{'dni': 0, 'ghi': 111,
|
|
130
|
-
'period_end': '2059-01-01T05:00:00.0000000Z', 'period': 'PT60M'}]
|
|
131
|
-
}
|
|
132
|
-
),
|
|
133
|
-
])
|
|
134
|
-
def test_get_solcast_tmy(
|
|
135
|
-
requests_mock, endpoint, function, params, json_response, map_variables
|
|
136
|
-
):
|
|
137
|
-
|
|
138
|
-
mock_url = f"https://api.solcast.com.au/data/{endpoint}?" \
|
|
139
|
-
f"&latitude={params['latitude']}&" \
|
|
140
|
-
f"longitude={params['longitude']}&format=json"
|
|
141
|
-
|
|
142
|
-
requests_mock.get(mock_url, json=json_response)
|
|
143
|
-
|
|
144
|
-
if map_variables:
|
|
145
|
-
pd.testing.assert_frame_equal(
|
|
146
|
-
function(**params, map_variables=map_variables)[0],
|
|
147
|
-
pvlib.iotools.solcast._solcast2pvlib(
|
|
148
|
-
pd.DataFrame.from_dict(
|
|
149
|
-
json_response[list(json_response.keys())[0]]
|
|
150
|
-
)
|
|
151
|
-
),
|
|
152
|
-
)
|
|
153
|
-
else:
|
|
154
|
-
pd.testing.assert_frame_equal(
|
|
155
|
-
function(**params, map_variables=map_variables)[0],
|
|
156
|
-
pd.DataFrame.from_dict(
|
|
157
|
-
json_response[list(json_response.keys())[0]]
|
|
158
|
-
),
|
|
159
|
-
)
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
@pytest.mark.parametrize("in_df,out_df", [
|
|
163
|
-
(
|
|
164
|
-
pd.DataFrame(
|
|
165
|
-
[[942, 843, 1017.4, 30, 7.8, 316, 1010, -2, 4.6, 16.4,
|
|
166
|
-
'2023-09-20T02:00:00.0000000Z', 'PT30M', 90],
|
|
167
|
-
[936, 832, 1017.9, 30, 7.9, 316, 996, -14, 4.5, 16.3,
|
|
168
|
-
'2023-09-20T01:30:00.0000000Z', 'PT30M', 0]],
|
|
169
|
-
columns=[
|
|
170
|
-
'dni', 'ghi', 'surface_pressure', 'air_temp', 'wind_speed_10m',
|
|
171
|
-
'wind_direction_10m', 'gti', 'azimuth', 'dewpoint_temp',
|
|
172
|
-
'precipitable_water', 'period_end', 'period', 'zenith'],
|
|
173
|
-
index=pd.RangeIndex(start=0, stop=2, step=1)
|
|
174
|
-
),
|
|
175
|
-
pd.DataFrame(
|
|
176
|
-
[[9.4200e+02, 8.4300e+02, 1.0174e+05, 3.0000e+01, 7.8000e+00,
|
|
177
|
-
3.1600e+02, 1.0100e+03, 2.0000e+00, 4.6000e+00, 1.6400e+00, 90],
|
|
178
|
-
[9.3600e+02, 8.3200e+02, 1.0179e+05, 3.0000e+01, 7.9000e+00,
|
|
179
|
-
3.1600e+02, 9.9600e+02, 1.4000e+01, 4.5000e+00, 1.6300e+00, 0]],
|
|
180
|
-
columns=[
|
|
181
|
-
'dni', 'ghi', 'pressure', 'temp_air', 'wind_speed',
|
|
182
|
-
'wind_direction', 'poa_global', 'solar_azimuth',
|
|
183
|
-
'temp_dew', 'precipitable_water', 'solar_zenith'],
|
|
184
|
-
index=pd.DatetimeIndex(
|
|
185
|
-
['2023-09-20 01:45:00+00:00', '2023-09-20 01:15:00+00:00'],
|
|
186
|
-
dtype='datetime64[ns, UTC]', name='period_mid', freq=None)
|
|
187
|
-
)
|
|
188
|
-
)
|
|
189
|
-
])
|
|
190
|
-
def test_solcast2pvlib(in_df, out_df):
|
|
191
|
-
df = pvlib.iotools.solcast._solcast2pvlib(in_df)
|
|
192
|
-
pd.testing.assert_frame_equal(df.astype(float), out_df.astype(float))
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
@pytest.mark.parametrize("map_variables", [True, False])
|
|
196
|
-
@pytest.mark.parametrize("endpoint,function,params,json_response", [
|
|
197
|
-
(
|
|
198
|
-
"historic/radiation_and_weather",
|
|
199
|
-
pvlib.iotools.get_solcast_historic,
|
|
200
|
-
dict(
|
|
201
|
-
api_key="1234",
|
|
202
|
-
latitude=-33.856784,
|
|
203
|
-
longitude=51.215297,
|
|
204
|
-
start="2023-01-01T08:00",
|
|
205
|
-
duration="P1D",
|
|
206
|
-
period="PT1H",
|
|
207
|
-
output_parameters='dni'
|
|
208
|
-
), {'estimated_actuals': [
|
|
209
|
-
{'dni': 822, 'period_end': '2023-01-01T09:00:00.0000000Z',
|
|
210
|
-
'period': 'PT60M'},
|
|
211
|
-
{'dni': 918, 'period_end': '2023-01-01T10:00:00.0000000Z',
|
|
212
|
-
'period': 'PT60M'},
|
|
213
|
-
{'dni': 772, 'period_end': '2023-01-01T11:00:00.0000000Z',
|
|
214
|
-
'period': 'PT60M'},
|
|
215
|
-
{'dni': 574, 'period_end': '2023-01-01T12:00:00.0000000Z',
|
|
216
|
-
'period': 'PT60M'},
|
|
217
|
-
{'dni': 494, 'period_end': '2023-01-01T13:00:00.0000000Z',
|
|
218
|
-
'period': 'PT60M'}
|
|
219
|
-
]}
|
|
220
|
-
),
|
|
221
|
-
])
|
|
222
|
-
def test_get_solcast_historic(
|
|
223
|
-
requests_mock, endpoint, function, params, json_response, map_variables
|
|
224
|
-
):
|
|
225
|
-
mock_url = f"https://api.solcast.com.au/data/{endpoint}?" \
|
|
226
|
-
f"&latitude={params['latitude']}&" \
|
|
227
|
-
f"longitude={params['longitude']}&format=json"
|
|
228
|
-
|
|
229
|
-
requests_mock.get(mock_url, json=json_response)
|
|
230
|
-
|
|
231
|
-
if map_variables:
|
|
232
|
-
pd.testing.assert_frame_equal(
|
|
233
|
-
function(**params, map_variables=map_variables)[0],
|
|
234
|
-
pvlib.iotools.solcast._solcast2pvlib(
|
|
235
|
-
pd.DataFrame.from_dict(
|
|
236
|
-
json_response[list(json_response.keys())[0]]
|
|
237
|
-
)
|
|
238
|
-
),
|
|
239
|
-
)
|
|
240
|
-
else:
|
|
241
|
-
pd.testing.assert_frame_equal(
|
|
242
|
-
function(**params, map_variables=map_variables)[0],
|
|
243
|
-
pd.DataFrame.from_dict(
|
|
244
|
-
json_response[list(json_response.keys())[0]]
|
|
245
|
-
),
|
|
246
|
-
)
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
@pytest.mark.parametrize("map_variables", [True, False])
|
|
250
|
-
@pytest.mark.parametrize("endpoint,function,params,json_response", [
|
|
251
|
-
(
|
|
252
|
-
"forecast/radiation_and_weather",
|
|
253
|
-
pvlib.iotools.get_solcast_forecast,
|
|
254
|
-
dict(
|
|
255
|
-
api_key="1234",
|
|
256
|
-
latitude=-33.856784,
|
|
257
|
-
longitude=51.215297,
|
|
258
|
-
hours="5",
|
|
259
|
-
period="PT1H",
|
|
260
|
-
output_parameters='dni'
|
|
261
|
-
), {
|
|
262
|
-
'forecast': [
|
|
263
|
-
{'dni': 0, 'period_end': '2023-12-13T01:00:00.0000000Z',
|
|
264
|
-
'period': 'PT1H'},
|
|
265
|
-
{'dni': 1, 'period_end': '2023-12-13T02:00:00.0000000Z',
|
|
266
|
-
'period': 'PT1H'},
|
|
267
|
-
{'dni': 2, 'period_end': '2023-12-13T03:00:00.0000000Z',
|
|
268
|
-
'period': 'PT1H'},
|
|
269
|
-
{'dni': 3, 'period_end': '2023-12-13T04:00:00.0000000Z',
|
|
270
|
-
'period': 'PT1H'},
|
|
271
|
-
{'dni': 4, 'period_end': '2023-12-13T05:00:00.0000000Z',
|
|
272
|
-
'period': 'PT1H'},
|
|
273
|
-
{'dni': 5, 'period_end': '2023-12-13T06:00:00.0000000Z',
|
|
274
|
-
'period': 'PT1H'}
|
|
275
|
-
]}
|
|
276
|
-
),
|
|
277
|
-
])
|
|
278
|
-
def test_get_solcast_forecast(
|
|
279
|
-
requests_mock, endpoint, function, params, json_response, map_variables
|
|
280
|
-
):
|
|
281
|
-
mock_url = f"https://api.solcast.com.au/data/{endpoint}?" \
|
|
282
|
-
f"&latitude={params['latitude']}&" \
|
|
283
|
-
f"longitude={params['longitude']}&format=json"
|
|
284
|
-
|
|
285
|
-
requests_mock.get(mock_url, json=json_response)
|
|
286
|
-
|
|
287
|
-
if map_variables:
|
|
288
|
-
pd.testing.assert_frame_equal(
|
|
289
|
-
function(**params, map_variables=map_variables)[0],
|
|
290
|
-
pvlib.iotools.solcast._solcast2pvlib(
|
|
291
|
-
pd.DataFrame.from_dict(
|
|
292
|
-
json_response[list(json_response.keys())[0]]
|
|
293
|
-
)
|
|
294
|
-
),
|
|
295
|
-
)
|
|
296
|
-
else:
|
|
297
|
-
pd.testing.assert_frame_equal(
|
|
298
|
-
function(**params, map_variables=map_variables)[0],
|
|
299
|
-
pd.DataFrame.from_dict(
|
|
300
|
-
json_response[list(json_response.keys())[0]]
|
|
301
|
-
),
|
|
302
|
-
)
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
@pytest.mark.parametrize(
|
|
306
|
-
"function",
|
|
307
|
-
[
|
|
308
|
-
pvlib.iotools.get_solcast_forecast,
|
|
309
|
-
pvlib.iotools.get_solcast_live,
|
|
310
|
-
pvlib.iotools.get_solcast_tmy,
|
|
311
|
-
pvlib.iotools.get_solcast_historic,
|
|
312
|
-
],
|
|
313
|
-
)
|
|
314
|
-
@patch("requests.api.request")
|
|
315
|
-
def test_raises_exception(mock_response, function):
|
|
316
|
-
dummy_args = {
|
|
317
|
-
"latitude": 0,
|
|
318
|
-
"longitude": 0,
|
|
319
|
-
"api_key": "",
|
|
320
|
-
}
|
|
321
|
-
with patch.object(mock_response, "status_code", return_value=404):
|
|
322
|
-
with pytest.raises(Exception):
|
|
323
|
-
function(**dummy_args)
|
|
324
|
-
mock_response.json.assert_called_once()
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import pandas as pd
|
|
2
|
-
import numpy as np
|
|
3
|
-
from numpy import nan
|
|
4
|
-
|
|
5
|
-
import pytest
|
|
6
|
-
|
|
7
|
-
from pvlib.iotools import solrad
|
|
8
|
-
from ..conftest import DATA_DIR, assert_frame_equal, RERUNS, RERUNS_DELAY
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
testfile = DATA_DIR / 'abq19056.dat'
|
|
12
|
-
testfile_mad = DATA_DIR / 'msn19056.dat'
|
|
13
|
-
https_testfile = ('https://gml.noaa.gov/aftp/data/radiation/solrad/msn/'
|
|
14
|
-
'2019/msn19056.dat')
|
|
15
|
-
|
|
16
|
-
columns = [
|
|
17
|
-
'year', 'julian_day', 'month', 'day', 'hour', 'minute', 'decimal_time',
|
|
18
|
-
'solar_zenith', 'ghi', 'ghi_flag', 'dni', 'dni_flag', 'dhi', 'dhi_flag',
|
|
19
|
-
'uvb', 'uvb_flag', 'uvb_temp', 'uvb_temp_flag', 'std_dw_psp', 'std_direct',
|
|
20
|
-
'std_diffuse', 'std_uvb']
|
|
21
|
-
index = pd.DatetimeIndex(['2019-02-25 00:00:00',
|
|
22
|
-
'2019-02-25 00:01:00',
|
|
23
|
-
'2019-02-25 00:02:00',
|
|
24
|
-
'2019-02-25 00:03:00'],
|
|
25
|
-
freq=None).tz_localize('UTC')
|
|
26
|
-
values = np.array([
|
|
27
|
-
[2.019e+03, 5.600e+01, 2.000e+00, 2.500e+01, 0.000e+00, 0.000e+00,
|
|
28
|
-
0.000e+00, 7.930e+01, 1.045e+02, 0.000e+00, 6.050e+01, 0.000e+00,
|
|
29
|
-
9.780e+01, 0.000e+00, 5.900e+00, 0.000e+00, 4.360e+01, 0.000e+00,
|
|
30
|
-
3.820e-01, 2.280e+00, 4.310e-01, 6.000e-02],
|
|
31
|
-
[2.019e+03, 5.600e+01, 2.000e+00, 2.500e+01, 0.000e+00, 1.000e+00,
|
|
32
|
-
1.700e-02, 7.949e+01, 1.026e+02, 0.000e+00, 5.970e+01, 0.000e+00,
|
|
33
|
-
9.620e+01, 0.000e+00, 5.700e+00, 0.000e+00, 4.360e+01, 0.000e+00,
|
|
34
|
-
7.640e-01, 1.800e+00, 4.310e-01, 6.000e-02],
|
|
35
|
-
[2.019e+03, 5.600e+01, 2.000e+00, 2.500e+01, 0.000e+00, 2.000e+00,
|
|
36
|
-
3.300e-02, 7.968e+01, 1.021e+02, 0.000e+00, 6.580e+01, 0.000e+00,
|
|
37
|
-
9.480e+01, 0.000e+00, 5.500e+00, 0.000e+00, 4.360e+01, 0.000e+00,
|
|
38
|
-
3.820e-01, 4.079e+00, 3.230e-01, 6.000e-02],
|
|
39
|
-
[2.019e+03, 5.600e+01, 2.000e+00, 2.500e+01, 0.000e+00, 3.000e+00,
|
|
40
|
-
5.000e-02, 7.987e+01, 1.026e+02, 0.000e+00, 7.630e+01, 0.000e+00,
|
|
41
|
-
nan, 0.000e+00, 5.300e+00, 0.000e+00, 4.360e+01, 0.000e+00,
|
|
42
|
-
5.090e-01, 1.920e+00, 2.150e-01, 5.000e-02]])
|
|
43
|
-
dtypes = [
|
|
44
|
-
'int64', 'int64', 'int64', 'int64', 'int64', 'int64', 'float64',
|
|
45
|
-
'float64', 'float64', 'int64', 'float64', 'int64', 'float64', 'int64',
|
|
46
|
-
'float64', 'int64', 'float64', 'int64', 'float64', 'float64',
|
|
47
|
-
'float64', 'float64']
|
|
48
|
-
|
|
49
|
-
columns_mad = [
|
|
50
|
-
'year', 'julian_day', 'month', 'day', 'hour', 'minute', 'decimal_time',
|
|
51
|
-
'solar_zenith', 'ghi', 'ghi_flag', 'dni', 'dni_flag', 'dhi', 'dhi_flag',
|
|
52
|
-
'uvb', 'uvb_flag', 'uvb_temp', 'uvb_temp_flag', 'dpir', 'dpir_flag',
|
|
53
|
-
'dpirc', 'dpirc_flag', 'dpird', 'dpird_flag', 'std_dw_psp',
|
|
54
|
-
'std_direct', 'std_diffuse', 'std_uvb', 'std_dpir', 'std_dpirc',
|
|
55
|
-
'std_dpird']
|
|
56
|
-
values_mad = np.array([
|
|
57
|
-
[ 2.019e+03, 5.600e+01, 2.000e+00, 2.500e+01, 0.000e+00,
|
|
58
|
-
0.000e+00, 0.000e+00, 9.428e+01, -2.300e+00, 0.000e+00,
|
|
59
|
-
0.000e+00, 0.000e+00, 4.000e-01, 0.000e+00, nan,
|
|
60
|
-
1.000e+00, nan, 1.000e+00, 1.872e+02, 0.000e+00,
|
|
61
|
-
2.656e+02, 0.000e+00, 2.653e+02, 0.000e+00, 0.000e+00,
|
|
62
|
-
0.000e+00, 0.000e+00, nan, 2.000e-03, 2.600e+01,
|
|
63
|
-
2.700e+01],
|
|
64
|
-
[ 2.019e+03, 5.600e+01, 2.000e+00, 2.500e+01, 0.000e+00,
|
|
65
|
-
1.000e+00, 1.700e-02, 9.446e+01, -2.300e+00, 0.000e+00,
|
|
66
|
-
0.000e+00, 0.000e+00, 1.000e-01, 0.000e+00, nan,
|
|
67
|
-
1.000e+00, nan, 1.000e+00, 1.882e+02, 0.000e+00,
|
|
68
|
-
2.656e+02, 0.000e+00, 2.653e+02, 0.000e+00, 1.330e-01,
|
|
69
|
-
1.280e-01, 2.230e-01, nan, 1.000e-03, 2.600e+01,
|
|
70
|
-
7.200e+01],
|
|
71
|
-
[ 2.019e+03, 5.600e+01, 2.000e+00, 2.500e+01, 0.000e+00,
|
|
72
|
-
2.000e+00, 3.300e-02, 9.464e+01, -2.700e+00, 0.000e+00,
|
|
73
|
-
-2.000e-01, 0.000e+00, 0.000e+00, 0.000e+00, nan,
|
|
74
|
-
1.000e+00, nan, 1.000e+00, 1.876e+02, 0.000e+00,
|
|
75
|
-
2.656e+02, 0.000e+00, 2.653e+02, 0.000e+00, 0.000e+00,
|
|
76
|
-
2.570e-01, 0.000e+00, nan, 1.000e-03, 2.400e+01,
|
|
77
|
-
4.200e+01],
|
|
78
|
-
[ 2.019e+03, 5.600e+01, 2.000e+00, 2.500e+01, 0.000e+00,
|
|
79
|
-
3.000e+00, 5.000e-02, 9.482e+01, -2.500e+00, 0.000e+00,
|
|
80
|
-
4.000e-01, 0.000e+00, 0.000e+00, 0.000e+00, nan,
|
|
81
|
-
1.000e+00, nan, 1.000e+00, 1.873e+02, 0.000e+00,
|
|
82
|
-
2.656e+02, 0.000e+00, 2.653e+02, 0.000e+00, 2.660e-01,
|
|
83
|
-
3.850e-01, 0.000e+00, nan, 1.000e-03, 2.600e+01,
|
|
84
|
-
4.800e+01]])
|
|
85
|
-
dtypes_mad = [
|
|
86
|
-
'int64', 'int64', 'int64', 'int64', 'int64', 'int64', 'float64', 'float64',
|
|
87
|
-
'float64', 'int64', 'float64', 'int64', 'float64', 'int64', 'float64',
|
|
88
|
-
'int64', 'float64', 'int64', 'float64', 'int64', 'float64', 'int64',
|
|
89
|
-
'float64', 'int64', 'float64', 'float64', 'float64', 'float64', 'float64',
|
|
90
|
-
'float64', 'float64']
|
|
91
|
-
meta = {'station_name': 'Albuquerque', 'latitude': 35.03796,
|
|
92
|
-
'longitude': -106.62211, 'altitude': 1617, 'TZ': -7}
|
|
93
|
-
meta_mad = {'station_name': 'Madison', 'latitude': 43.07250,
|
|
94
|
-
'longitude': -89.41133, 'altitude': 271, 'TZ': -6}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
@pytest.mark.parametrize('testfile,index,columns,values,dtypes,meta', [
|
|
98
|
-
(testfile, index, columns, values, dtypes, meta),
|
|
99
|
-
(testfile_mad, index, columns_mad, values_mad, dtypes_mad, meta_mad)
|
|
100
|
-
])
|
|
101
|
-
def test_read_solrad(testfile, index, columns, values, dtypes, meta):
|
|
102
|
-
expected = pd.DataFrame(values, columns=columns, index=index)
|
|
103
|
-
for (col, _dtype) in zip(expected.columns, dtypes):
|
|
104
|
-
expected[col] = expected[col].astype(_dtype)
|
|
105
|
-
out, m = solrad.read_solrad(testfile)
|
|
106
|
-
assert_frame_equal(out, expected)
|
|
107
|
-
assert m == meta
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
@pytest.mark.remote_data
|
|
111
|
-
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
|
|
112
|
-
def test_read_solrad_https():
|
|
113
|
-
# Test reading of https files.
|
|
114
|
-
# If this test begins failing, SOLRAD's data structure or data
|
|
115
|
-
# archive may have changed.
|
|
116
|
-
local_data, _ = solrad.read_solrad(testfile_mad)
|
|
117
|
-
remote_data, _ = solrad.read_solrad(https_testfile)
|
|
118
|
-
# local file only contains four rows to save space
|
|
119
|
-
assert_frame_equal(local_data, remote_data.iloc[:4])
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
@pytest.mark.remote_data
|
|
123
|
-
@pytest.mark.parametrize('testfile, station', [
|
|
124
|
-
(testfile, 'abq'),
|
|
125
|
-
(testfile_mad, 'msn'),
|
|
126
|
-
])
|
|
127
|
-
def test_get_solrad(testfile, station):
|
|
128
|
-
df, meta = solrad.get_solrad(station, "2019-02-25", "2019-02-25")
|
|
129
|
-
|
|
130
|
-
assert meta['station'] == station
|
|
131
|
-
assert isinstance(meta['filenames'], list)
|
|
132
|
-
|
|
133
|
-
assert len(df) == 1440
|
|
134
|
-
assert df.index[0] == pd.to_datetime('2019-02-25 00:00+00:00')
|
|
135
|
-
assert df.index[-1] == pd.to_datetime('2019-02-25 23:59+00:00')
|
|
136
|
-
|
|
137
|
-
expected, _ = solrad.read_solrad(testfile)
|
|
138
|
-
actual = df.reindex(expected.index)
|
|
139
|
-
# ABQ test file has an unexplained NaN in row 4; just verify first 3 rows
|
|
140
|
-
assert_frame_equal(actual.iloc[:3], expected.iloc[:3])
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
@pytest.mark.remote_data
|
|
144
|
-
def test_get_solrad_missing_day():
|
|
145
|
-
# data availability begins for ABQ on 2002-02-01 (DOY 32), so requesting
|
|
146
|
-
# data before that will raise a warning
|
|
147
|
-
message = 'The following file was not found: abq/2002/abq02031.dat'
|
|
148
|
-
with pytest.warns(UserWarning, match=message):
|
|
149
|
-
df, meta = solrad.get_solrad('abq', '2002-01-31', '2002-02-01')
|
|
150
|
-
|
|
151
|
-
# but the data for 2022-02-01 is still returned
|
|
152
|
-
assert not df.empty
|
pvlib/tests/iotools/test_srml.py
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
from numpy import isnan
|
|
2
|
-
import pandas as pd
|
|
3
|
-
import pytest
|
|
4
|
-
|
|
5
|
-
from pvlib.iotools import srml
|
|
6
|
-
from ..conftest import (DATA_DIR, RERUNS, RERUNS_DELAY, assert_index_equal,
|
|
7
|
-
assert_frame_equal)
|
|
8
|
-
|
|
9
|
-
srml_testfile = DATA_DIR / 'SRML-day-EUPO1801.txt'
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
def test_read_srml():
|
|
13
|
-
srml.read_srml(srml_testfile)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
@pytest.mark.remote_data
|
|
17
|
-
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
|
|
18
|
-
def test_read_srml_remote():
|
|
19
|
-
srml.read_srml(
|
|
20
|
-
'http://solardata.uoregon.edu/download/Archive/EUPO1801.txt'
|
|
21
|
-
)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
def test_read_srml_columns_exist():
|
|
25
|
-
data = srml.read_srml(srml_testfile)
|
|
26
|
-
assert 'ghi_0' in data.columns
|
|
27
|
-
assert 'ghi_0_flag' in data.columns
|
|
28
|
-
assert 'dni_1' in data.columns
|
|
29
|
-
assert 'dni_1_flag' in data.columns
|
|
30
|
-
assert '7008' in data.columns
|
|
31
|
-
assert '7008_flag' in data.columns
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
def test_read_srml_map_variables_false():
|
|
35
|
-
data = srml.read_srml(srml_testfile, map_variables=False)
|
|
36
|
-
assert '1000' in data.columns
|
|
37
|
-
assert '1000_flag' in data.columns
|
|
38
|
-
assert '2010' in data.columns
|
|
39
|
-
assert '2010_flag' in data.columns
|
|
40
|
-
assert '7008' in data.columns
|
|
41
|
-
assert '7008_flag' in data.columns
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
def test_read_srml_nans_exist():
|
|
45
|
-
data = srml.read_srml(srml_testfile)
|
|
46
|
-
assert isnan(data['dni_0'].iloc[1119])
|
|
47
|
-
assert data['dni_0_flag'].iloc[1119] == 99
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
@pytest.mark.parametrize('url,year,month', [
|
|
51
|
-
('http://solardata.uoregon.edu/download/Archive/EUPO1801.txt',
|
|
52
|
-
2018, 1),
|
|
53
|
-
('http://solardata.uoregon.edu/download/Archive/EUPO1612.txt',
|
|
54
|
-
2016, 12),
|
|
55
|
-
])
|
|
56
|
-
@pytest.mark.remote_data
|
|
57
|
-
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
|
|
58
|
-
def test_read_srml_dt_index(url, year, month):
|
|
59
|
-
data = srml.read_srml(url)
|
|
60
|
-
start = pd.Timestamp(f'{year:04d}{month:02d}01 00:00')
|
|
61
|
-
start = start.tz_localize('Etc/GMT+8')
|
|
62
|
-
end = pd.Timestamp(f'{year:04d}{month:02d}31 23:59')
|
|
63
|
-
end = end.tz_localize('Etc/GMT+8')
|
|
64
|
-
assert data.index[0] == start
|
|
65
|
-
assert data.index[-1] == end
|
|
66
|
-
assert (data.index[59::60].minute == 59).all()
|
|
67
|
-
assert str(year) not in data.columns
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
@pytest.mark.parametrize('column,expected', [
|
|
71
|
-
('1001', 'ghi_1'),
|
|
72
|
-
('7324', '7324'),
|
|
73
|
-
('2001', '2001'),
|
|
74
|
-
('2017', 'dni_7')
|
|
75
|
-
])
|
|
76
|
-
def test__map_columns(column, expected):
|
|
77
|
-
assert srml._map_columns(column) == expected
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
@pytest.mark.remote_data
|
|
81
|
-
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
|
|
82
|
-
def test_get_srml():
|
|
83
|
-
url = 'http://solardata.uoregon.edu/download/Archive/EUPO1801.txt'
|
|
84
|
-
file_data = srml.read_srml(url)
|
|
85
|
-
requested, _ = srml.get_srml(station='EU', start='2018-01-01',
|
|
86
|
-
end='2018-01-31')
|
|
87
|
-
assert_frame_equal(file_data, requested)
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
@pytest.mark.remote_data
|
|
91
|
-
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
|
|
92
|
-
def test_get_srml_hourly():
|
|
93
|
-
data, meta = data, meta = srml.get_srml(station='CD', start='1986-04-01',
|
|
94
|
-
end='1986-05-31', filetype='PH')
|
|
95
|
-
expected_index = pd.date_range(start='1986-04-01', end='1986-05-31 23:59',
|
|
96
|
-
freq='1h', tz='Etc/GMT+8')
|
|
97
|
-
assert_index_equal(data.index, expected_index)
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
@pytest.mark.remote_data
|
|
101
|
-
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
|
|
102
|
-
def test_get_srml_minute():
|
|
103
|
-
data_read = srml.read_srml(srml_testfile)
|
|
104
|
-
data_get, meta = srml.get_srml(station='EU', start='2018-01-01',
|
|
105
|
-
end='2018-01-31', filetype='PO')
|
|
106
|
-
expected_index = pd.date_range(start='2018-01-01', end='2018-01-31 23:59',
|
|
107
|
-
freq='1min', tz='Etc/GMT+8')
|
|
108
|
-
assert_index_equal(data_get.index, expected_index)
|
|
109
|
-
assert all(c in data_get.columns for c in data_read.columns)
|
|
110
|
-
# Check that all indices in example file are present in remote file
|
|
111
|
-
assert data_read.index.isin(data_get.index).all()
|
|
112
|
-
assert meta['station'] == 'EU'
|
|
113
|
-
assert meta['filetype'] == 'PO'
|
|
114
|
-
assert meta['filenames'] == ['EUPO1801.txt']
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
@pytest.mark.remote_data
|
|
118
|
-
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
|
|
119
|
-
def test_get_srml_nonexisting_month_warning():
|
|
120
|
-
with pytest.warns(UserWarning, match='file was not found: EUPO0912.txt'):
|
|
121
|
-
# Request data for a period where not all files exist
|
|
122
|
-
# Eugene (EU) station started reporting 1-minute data in January 2010
|
|
123
|
-
data, meta = data, meta = srml.get_srml(
|
|
124
|
-
station='EU', start='2009-12-01', end='2010-01-31', filetype='PO')
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import pandas as pd
|
|
2
|
-
import pytest
|
|
3
|
-
|
|
4
|
-
from pvlib.iotools import surfrad
|
|
5
|
-
from ..conftest import DATA_DIR, RERUNS, RERUNS_DELAY
|
|
6
|
-
|
|
7
|
-
testfile = DATA_DIR / 'surfrad-slv16001.dat'
|
|
8
|
-
network_testfile = ('ftp://aftp.cmdl.noaa.gov/data/radiation/surfrad/'
|
|
9
|
-
'Alamosa_CO/2016/slv16001.dat')
|
|
10
|
-
https_testfile = ('https://gml.noaa.gov/aftp/data/radiation/surfrad/'
|
|
11
|
-
'Alamosa_CO/2016/slv16001.dat')
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
@pytest.mark.remote_data
|
|
15
|
-
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
|
|
16
|
-
def test_read_surfrad_network():
|
|
17
|
-
# If this test begins failing, SURFRAD's data structure or data
|
|
18
|
-
# archive may have changed.
|
|
19
|
-
local_data, _ = surfrad.read_surfrad(testfile)
|
|
20
|
-
network_data, _ = surfrad.read_surfrad(network_testfile)
|
|
21
|
-
assert local_data.equals(network_data)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
@pytest.mark.remote_data
|
|
25
|
-
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
|
|
26
|
-
def test_read_surfrad_https():
|
|
27
|
-
# Test reading of https files.
|
|
28
|
-
# If this test begins failing, SURFRAD's data structure or data
|
|
29
|
-
# archive may have changed.
|
|
30
|
-
local_data, _ = surfrad.read_surfrad(testfile)
|
|
31
|
-
network_data, _ = surfrad.read_surfrad(https_testfile)
|
|
32
|
-
assert local_data.equals(network_data)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
def test_read_surfrad_columns_no_map():
|
|
36
|
-
data, _ = surfrad.read_surfrad(testfile, map_variables=False)
|
|
37
|
-
assert 'zen' in data.columns
|
|
38
|
-
assert 'temp' in data.columns
|
|
39
|
-
assert 'par' in data.columns
|
|
40
|
-
assert 'pressure' in data.columns
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
def test_read_surfrad_columns_map():
|
|
44
|
-
data, _ = surfrad.read_surfrad(testfile)
|
|
45
|
-
assert 'solar_zenith' in data.columns
|
|
46
|
-
assert 'ghi' in data.columns
|
|
47
|
-
assert 'ghi_flag' in data.columns
|
|
48
|
-
assert 'dni' in data.columns
|
|
49
|
-
assert 'dni_flag' in data.columns
|
|
50
|
-
assert 'dhi' in data.columns
|
|
51
|
-
assert 'dhi_flag' in data.columns
|
|
52
|
-
assert 'wind_direction' in data.columns
|
|
53
|
-
assert 'wind_direction_flag' in data.columns
|
|
54
|
-
assert 'wind_speed' in data.columns
|
|
55
|
-
assert 'wind_speed_flag' in data.columns
|
|
56
|
-
assert 'temp_air' in data.columns
|
|
57
|
-
assert 'temp_air_flag' in data.columns
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
def test_format_index():
|
|
61
|
-
start = pd.Timestamp('20160101 00:00')
|
|
62
|
-
expected = pd.date_range(start=start, periods=1440, freq='1min', tz='UTC')
|
|
63
|
-
actual, _ = surfrad.read_surfrad(testfile)
|
|
64
|
-
assert actual.index.equals(expected)
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
def test_read_surfrad_metadata():
|
|
68
|
-
expected = {'name': 'Alamosa',
|
|
69
|
-
'latitude': 37.70,
|
|
70
|
-
'longitude': 105.92,
|
|
71
|
-
'elevation': 2317,
|
|
72
|
-
'surfrad_version': 1,
|
|
73
|
-
'tz': 'UTC'}
|
|
74
|
-
_, metadata = surfrad.read_surfrad(testfile)
|
|
75
|
-
assert metadata == expected
|