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.
Files changed (147) hide show
  1. pvlib/__init__.py +1 -0
  2. pvlib/atmosphere.py +40 -40
  3. pvlib/bifacial/infinite_sheds.py +4 -3
  4. pvlib/bifacial/utils.py +2 -1
  5. pvlib/iotools/__init__.py +6 -0
  6. pvlib/iotools/psm3.py +1 -1
  7. pvlib/iotools/psm4.py +819 -0
  8. pvlib/iotools/pvgis.py +10 -2
  9. pvlib/iotools/tmy.py +3 -69
  10. pvlib/irradiance.py +38 -15
  11. pvlib/ivtools/sdm/__init__.py +20 -0
  12. pvlib/ivtools/sdm/_fit_desoto_pvsyst_sandia.py +585 -0
  13. pvlib/ivtools/sdm/cec.py +93 -0
  14. pvlib/ivtools/sdm/desoto.py +401 -0
  15. pvlib/ivtools/sdm/pvsyst.py +630 -0
  16. pvlib/location.py +73 -33
  17. pvlib/modelchain.py +19 -36
  18. pvlib/pvsystem.py +114 -65
  19. pvlib/snow.py +64 -28
  20. pvlib/spectrum/__init__.py +0 -1
  21. pvlib/spectrum/irradiance.py +2 -64
  22. pvlib/spectrum/mismatch.py +3 -3
  23. pvlib/tools.py +6 -5
  24. {pvlib-0.11.2.dist-info → pvlib-0.12.1a1.dist-info}/METADATA +6 -5
  25. pvlib-0.12.1a1.dist-info/RECORD +80 -0
  26. {pvlib-0.11.2.dist-info → pvlib-0.12.1a1.dist-info}/WHEEL +1 -1
  27. pvlib/data/BIRD_08_16_2012.csv +0 -8761
  28. pvlib/data/BIRD_08_16_2012_patm.csv +0 -8761
  29. pvlib/data/Burlington, United States SolarAnywhere Time Series 2021 Lat_44_465 Lon_-73_205 TMY3 format.csv +0 -8762
  30. pvlib/data/Burlington, United States SolarAnywhere Time Series 20210101 to 20210103 Lat_44_4675 Lon_-73_2075 SA format.csv +0 -578
  31. pvlib/data/Burlington, United States SolarAnywhere Typical GHI Year Lat_44_465 Lon_-73_205 SA format.csv +0 -74
  32. pvlib/data/CPS SCH275KTL-DO-US-800-250kW_275kVA_1.OND +0 -146
  33. pvlib/data/CRNS0101-05-2019-AZ_Tucson_11_W.txt +0 -4
  34. pvlib/data/CRN_with_problems.txt +0 -3
  35. pvlib/data/ET-M772BH550GL.PAN +0 -75
  36. pvlib/data/NLD_Amsterdam062400_IWEC.epw +0 -8768
  37. pvlib/data/PVsyst_demo.csv +0 -10757
  38. pvlib/data/PVsyst_demo_model.csv +0 -3588
  39. pvlib/data/SRML-day-EUPO1801.txt +0 -1441
  40. pvlib/data/abq19056.dat +0 -6
  41. pvlib/data/bishop88_numerical_precision.csv +0 -101
  42. pvlib/data/bsrn-lr0100-pay0616.dat +0 -86901
  43. pvlib/data/bsrn-pay0616.dat.gz +0 -0
  44. pvlib/data/cams_mcclear_1min_verbose.csv +0 -60
  45. pvlib/data/cams_mcclear_monthly.csv +0 -42
  46. pvlib/data/cams_radiation_1min_verbose.csv +0 -72
  47. pvlib/data/cams_radiation_monthly.csv +0 -47
  48. pvlib/data/detect_clearsky_data.csv +0 -35
  49. pvlib/data/detect_clearsky_threshold_data.csv +0 -126
  50. pvlib/data/greensboro_kimber_soil_manwash.dat +0 -8761
  51. pvlib/data/greensboro_kimber_soil_nowash.dat +0 -8761
  52. pvlib/data/inverter_fit_snl_meas.csv +0 -127
  53. pvlib/data/inverter_fit_snl_sim.csv +0 -19
  54. pvlib/data/ivtools_numdiff.csv +0 -52
  55. pvlib/data/midc_20181014.txt +0 -1441
  56. pvlib/data/midc_raw_20181018.txt +0 -1441
  57. pvlib/data/midc_raw_short_header_20191115.txt +0 -1441
  58. pvlib/data/msn19056.dat +0 -6
  59. pvlib/data/precise_iv_curves1.json +0 -10251
  60. pvlib/data/precise_iv_curves2.json +0 -10251
  61. pvlib/data/precise_iv_curves_parameter_sets1.csv +0 -33
  62. pvlib/data/precise_iv_curves_parameter_sets2.csv +0 -33
  63. pvlib/data/pvgis_hourly_Timeseries_45.000_8.000_SA2_10kWp_CIS_5_2a_2013_2014.json +0 -1
  64. pvlib/data/pvgis_hourly_Timeseries_45.000_8.000_SA_30deg_0deg_2016_2016.csv +0 -35
  65. pvlib/data/pvgis_tmy_meta.json +0 -32
  66. pvlib/data/pvgis_tmy_test.csv +0 -8761
  67. pvlib/data/pvwatts_8760_rackmount.csv +0 -8779
  68. pvlib/data/pvwatts_8760_roofmount.csv +0 -8779
  69. pvlib/data/singleaxis_tracker_wslope.csv +0 -8761
  70. pvlib/data/spectrl2_example_spectra.csv +0 -123
  71. pvlib/data/surfrad-slv16001.dat +0 -1442
  72. pvlib/data/test_psm3_2017.csv +0 -17521
  73. pvlib/data/test_psm3_2019_5min.csv +0 -289
  74. pvlib/data/test_psm3_tmy-2017.csv +0 -8761
  75. pvlib/data/test_read_psm3.csv +0 -17523
  76. pvlib/data/test_read_pvgis_horizon.csv +0 -49
  77. pvlib/data/tmy_45.000_8.000_2005_2023.csv +0 -8789
  78. pvlib/data/tmy_45.000_8.000_2005_2023.epw +0 -8768
  79. pvlib/data/tmy_45.000_8.000_2005_2023.json +0 -1
  80. pvlib/data/tmy_45.000_8.000_2005_2023.txt +0 -8761
  81. pvlib/data/tmy_45.000_8.000_userhorizon.json +0 -1
  82. pvlib/ivtools/sdm.py +0 -1379
  83. pvlib/spa_c_files/README.md +0 -81
  84. pvlib/spa_c_files/cspa_py.pxd +0 -43
  85. pvlib/spa_c_files/spa_py.pyx +0 -30
  86. pvlib/tests/__init__.py +0 -0
  87. pvlib/tests/bifacial/__init__.py +0 -0
  88. pvlib/tests/bifacial/test_infinite_sheds.py +0 -317
  89. pvlib/tests/bifacial/test_losses_models.py +0 -54
  90. pvlib/tests/bifacial/test_pvfactors.py +0 -82
  91. pvlib/tests/bifacial/test_utils.py +0 -192
  92. pvlib/tests/conftest.py +0 -476
  93. pvlib/tests/iotools/__init__.py +0 -0
  94. pvlib/tests/iotools/test_acis.py +0 -213
  95. pvlib/tests/iotools/test_bsrn.py +0 -131
  96. pvlib/tests/iotools/test_crn.py +0 -95
  97. pvlib/tests/iotools/test_epw.py +0 -23
  98. pvlib/tests/iotools/test_midc.py +0 -89
  99. pvlib/tests/iotools/test_panond.py +0 -32
  100. pvlib/tests/iotools/test_psm3.py +0 -198
  101. pvlib/tests/iotools/test_pvgis.py +0 -644
  102. pvlib/tests/iotools/test_sodapro.py +0 -298
  103. pvlib/tests/iotools/test_solaranywhere.py +0 -287
  104. pvlib/tests/iotools/test_solargis.py +0 -68
  105. pvlib/tests/iotools/test_solcast.py +0 -324
  106. pvlib/tests/iotools/test_solrad.py +0 -152
  107. pvlib/tests/iotools/test_srml.py +0 -124
  108. pvlib/tests/iotools/test_surfrad.py +0 -75
  109. pvlib/tests/iotools/test_tmy.py +0 -133
  110. pvlib/tests/ivtools/__init__.py +0 -0
  111. pvlib/tests/ivtools/test_sde.py +0 -230
  112. pvlib/tests/ivtools/test_sdm.py +0 -429
  113. pvlib/tests/ivtools/test_utils.py +0 -173
  114. pvlib/tests/spectrum/__init__.py +0 -0
  115. pvlib/tests/spectrum/conftest.py +0 -40
  116. pvlib/tests/spectrum/test_irradiance.py +0 -138
  117. pvlib/tests/spectrum/test_mismatch.py +0 -304
  118. pvlib/tests/spectrum/test_response.py +0 -124
  119. pvlib/tests/spectrum/test_spectrl2.py +0 -72
  120. pvlib/tests/test__deprecation.py +0 -97
  121. pvlib/tests/test_albedo.py +0 -84
  122. pvlib/tests/test_atmosphere.py +0 -351
  123. pvlib/tests/test_clearsky.py +0 -884
  124. pvlib/tests/test_conftest.py +0 -37
  125. pvlib/tests/test_iam.py +0 -555
  126. pvlib/tests/test_inverter.py +0 -213
  127. pvlib/tests/test_irradiance.py +0 -1487
  128. pvlib/tests/test_location.py +0 -356
  129. pvlib/tests/test_modelchain.py +0 -2020
  130. pvlib/tests/test_numerical_precision.py +0 -124
  131. pvlib/tests/test_pvarray.py +0 -71
  132. pvlib/tests/test_pvsystem.py +0 -2511
  133. pvlib/tests/test_scaling.py +0 -207
  134. pvlib/tests/test_shading.py +0 -391
  135. pvlib/tests/test_singlediode.py +0 -608
  136. pvlib/tests/test_snow.py +0 -212
  137. pvlib/tests/test_soiling.py +0 -230
  138. pvlib/tests/test_solarposition.py +0 -966
  139. pvlib/tests/test_spa.py +0 -454
  140. pvlib/tests/test_temperature.py +0 -470
  141. pvlib/tests/test_tools.py +0 -146
  142. pvlib/tests/test_tracking.py +0 -474
  143. pvlib/tests/test_transformer.py +0 -60
  144. pvlib-0.11.2.dist-info/RECORD +0 -191
  145. {pvlib-0.11.2.dist-info → pvlib-0.12.1a1.dist-info/licenses}/AUTHORS.md +0 -0
  146. {pvlib-0.11.2.dist-info → pvlib-0.12.1a1.dist-info/licenses}/LICENSE +0 -0
  147. {pvlib-0.11.2.dist-info → pvlib-0.12.1a1.dist-info}/top_level.txt +0 -0
@@ -1,213 +0,0 @@
1
- """
2
- tests for :mod:`pvlib.iotools.acis`
3
- """
4
-
5
- import pandas as pd
6
- import numpy as np
7
- import pytest
8
- from pvlib.iotools import (
9
- get_acis_prism, get_acis_nrcc, get_acis_mpe,
10
- get_acis_station_data, get_acis_available_stations
11
- )
12
- from ..conftest import RERUNS, RERUNS_DELAY, assert_frame_equal
13
- from requests import HTTPError
14
-
15
-
16
- @pytest.mark.remote_data
17
- @pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
18
- def test_get_acis_prism():
19
- # map_variables=True
20
- df, meta = get_acis_prism(40.001, -80.001, '2020-01-01', '2020-01-02')
21
- expected = pd.DataFrame(
22
- [
23
- [0.5, 5, 0, 2.5, 0, 62, 0],
24
- [0, 5, -3, 1, 0, 64, 0]
25
- ],
26
- columns=['precipitation', 'temp_air_max', 'temp_air_min',
27
- 'temp_air_average', 'cooling_degree_days',
28
- 'heating_degree_days', 'growing_degree_days'],
29
- index=pd.to_datetime(['2020-01-01', '2020-01-02']),
30
- )
31
- assert_frame_equal(df, expected)
32
- expected_meta = {'latitude': 40, 'longitude': -80, 'altitude': 298.0944}
33
- assert meta == expected_meta
34
-
35
- # map_variables=False
36
- df, meta = get_acis_prism(40.001, -80.001, '2020-01-01', '2020-01-02',
37
- map_variables=False)
38
- expected.columns = ['pcpn', 'maxt', 'mint', 'avgt', 'cdd', 'hdd', 'gdd']
39
- assert_frame_equal(df, expected)
40
- expected_meta = {'lat': 40, 'lon': -80, 'elev': 298.0944}
41
- assert meta == expected_meta
42
-
43
-
44
- @pytest.mark.remote_data
45
- @pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
46
- @pytest.mark.parametrize('grid, expected', [
47
- (1, [[0.51, 5, 0, 2.5, 0, 62, 0]]),
48
- (3, [[0.51, 5, -1, 2.0, 0, 63, 0]])
49
- ])
50
- def test_get_acis_nrcc(grid, expected):
51
- # map_variables=True
52
- df, meta = get_acis_nrcc(40.001, -80.001, '2020-01-01', '2020-01-01', grid)
53
- expected = pd.DataFrame(
54
- expected,
55
- columns=['precipitation', 'temp_air_max', 'temp_air_min',
56
- 'temp_air_average', 'cooling_degree_days',
57
- 'heating_degree_days', 'growing_degree_days'],
58
- index=pd.to_datetime(['2020-01-01']),
59
- )
60
- assert_frame_equal(df, expected)
61
- expected_meta = {'latitude': 40., 'longitude': -80., 'altitude': 356.9208}
62
- assert meta == pytest.approx(expected_meta)
63
-
64
- # map_variables=False
65
- df, meta = get_acis_nrcc(40.001, -80.001, '2020-01-01', '2020-01-01', grid,
66
- map_variables=False)
67
- expected.columns = ['pcpn', 'maxt', 'mint', 'avgt', 'cdd', 'hdd', 'gdd']
68
- assert_frame_equal(df, expected)
69
- expected_meta = {'lat': 40., 'lon': -80., 'elev': 356.9208}
70
- assert meta == pytest.approx(expected_meta)
71
-
72
-
73
- @pytest.mark.remote_data
74
- @pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
75
- def test_get_acis_nrcc_error():
76
- with pytest.raises(HTTPError, match='invalid grid'):
77
- # 50 is not a valid dataset (or "grid", in ACIS lingo)
78
- _ = get_acis_nrcc(40, -80, '2012-01-01', '2012-01-01', 50)
79
-
80
-
81
- @pytest.mark.remote_data
82
- @pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
83
- def test_get_acis_mpe():
84
- # map_variables=True
85
- df, meta = get_acis_mpe(40.001, -80.001, '2020-01-01', '2020-01-02')
86
- expected = pd.DataFrame(
87
- {'precipitation': [0.4, 0.0]},
88
- index=pd.to_datetime(['2020-01-01', '2020-01-02']),
89
- )
90
- assert_frame_equal(df, expected)
91
- expected_meta = {'latitude': 40.0083, 'longitude': -79.9653}
92
- assert meta == expected_meta
93
-
94
- # map_variables=False
95
- df, meta = get_acis_mpe(40.001, -80.001, '2020-01-01', '2020-01-02',
96
- map_variables=False)
97
- expected.columns = ['pcpn']
98
- assert_frame_equal(df, expected)
99
- expected_meta = {'lat': 40.0083, 'lon': -79.9653}
100
- assert meta == expected_meta
101
-
102
-
103
- @pytest.mark.remote_data
104
- @pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
105
- def test_get_acis_station_data():
106
- # map_variables=True
107
- df, meta = get_acis_station_data('ORD', '2020-01-10', '2020-01-12',
108
- trace_val=-99)
109
- expected = pd.DataFrame(
110
- [[10., 2., 6., np.nan, 21.34, 0., 0., 0., 59., 0.],
111
- [3., -4., -0.5, np.nan, 9.4, 5.3, 0., 0., 65., 0.],
112
- [-1., -5., -3., np.nan, -99, -99, 5., 0., 68., 0.]],
113
- columns=['temp_air_max', 'temp_air_min', 'temp_air_average',
114
- 'temp_air_observation', 'precipitation', 'snowfall',
115
- 'snowdepth', 'cooling_degree_days',
116
- 'heating_degree_days', 'growing_degree_days'],
117
- index=pd.to_datetime(['2020-01-10', '2020-01-11', '2020-01-12']),
118
- )
119
- assert_frame_equal(df, expected)
120
- expected_meta = {
121
- 'uid': 48,
122
- 'state': 'IL',
123
- 'name': 'CHICAGO OHARE INTL AP',
124
- 'altitude': 204.8256,
125
- 'latitude': 41.96017,
126
- 'longitude': -87.93164
127
- }
128
- expected_meta = {
129
- 'valid_daterange': [
130
- ['1958-11-01', '2023-06-15'],
131
- ['1958-11-01', '2023-06-15'],
132
- ['1958-11-01', '2023-06-15'],
133
- [],
134
- ['1958-11-01', '2023-06-15'],
135
- ['1958-11-01', '2023-06-15'],
136
- ['1958-11-01', '2023-06-15'],
137
- ['1958-11-01', '2023-06-15'],
138
- ['1958-11-01', '2023-06-15'],
139
- ['1958-11-01', '2023-06-15']
140
- ],
141
- 'name': 'CHICAGO OHARE INTL AP',
142
- 'sids': ['94846 1', '111549 2', 'ORD 3', '72530 4', 'KORD 5',
143
- 'USW00094846 6', 'ORD 7', 'USW00094846 32'],
144
- 'county': '17031',
145
- 'state': 'IL',
146
- 'climdiv': 'IL02',
147
- 'uid': 48,
148
- 'tzo': -6.0,
149
- 'sid_dates': [
150
- ['94846 1', '1989-01-19', '9999-12-31'],
151
- ['94846 1', '1958-10-30', '1989-01-01'],
152
- ['111549 2', '1989-01-19', '9999-12-31'],
153
- ['111549 2', '1958-10-30', '1989-01-01'],
154
- ['ORD 3', '1989-01-19', '9999-12-31'],
155
- ['ORD 3', '1958-10-30', '1989-01-01'],
156
- ['72530 4', '1989-01-19', '9999-12-31'],
157
- ['72530 4', '1958-10-30', '1989-01-01'],
158
- ['KORD 5', '1989-01-19', '9999-12-31'],
159
- ['KORD 5', '1958-10-30', '1989-01-01'],
160
- ['USW00094846 6', '1989-01-19', '9999-12-31'],
161
- ['USW00094846 6', '1958-10-30', '1989-01-01'],
162
- ['ORD 7', '1989-01-19', '9999-12-31'],
163
- ['ORD 7', '1958-10-30', '1989-01-01'],
164
- ['USW00094846 32', '1989-01-19', '9999-12-31'],
165
- ['USW00094846 32', '1958-10-30', '1989-01-01']],
166
- 'altitude': 204.8256,
167
- 'longitude': -87.93164,
168
- 'latitude': 41.96017
169
- }
170
- # don't check valid dates since they get extended every day
171
- meta.pop("valid_daterange")
172
- expected_meta.pop("valid_daterange")
173
- assert meta == expected_meta
174
-
175
- # map_variables=False
176
- df, meta = get_acis_station_data('ORD', '2020-01-10', '2020-01-12',
177
- trace_val=-99, map_variables=False)
178
- expected.columns = ['maxt', 'mint', 'avgt', 'obst', 'pcpn', 'snow',
179
- 'snwd', 'cdd', 'hdd', 'gdd']
180
- assert_frame_equal(df, expected)
181
- expected_meta['lat'] = expected_meta.pop('latitude')
182
- expected_meta['lon'] = expected_meta.pop('longitude')
183
- expected_meta['elev'] = expected_meta.pop('altitude')
184
- meta.pop("valid_daterange")
185
- assert meta == expected_meta
186
-
187
-
188
- @pytest.mark.remote_data
189
- @pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
190
- def test_get_acis_available_stations():
191
- # use a very narrow bounding box to hopefully make this test less likely
192
- # to fail due to new stations being added in the future
193
- lat, lon = 39.8986, -80.1656
194
- stations = get_acis_available_stations([lat - 0.0001, lat + 0.0001],
195
- [lon - 0.0001, lon + 0.0001])
196
- assert len(stations) == 1
197
- station = stations.iloc[0]
198
-
199
- # test the more relevant values
200
- assert station['name'] == 'WAYNESBURG 1 E'
201
- assert station['sids'] == ['369367 2', 'USC00369367 6', 'WYNP1 7']
202
- assert station['state'] == 'PA'
203
- assert station['altitude'] == 940.
204
- assert station['tzo'] == -5.0
205
- assert station['latitude'] == lat
206
- assert station['longitude'] == lon
207
-
208
- # check that start/end work as filters
209
- stations = get_acis_available_stations([lat - 0.0001, lat + 0.0001],
210
- [lon - 0.0001, lon + 0.0001],
211
- start='1900-01-01',
212
- end='1900-01-02')
213
- assert stations.empty
@@ -1,131 +0,0 @@
1
- """
2
- tests for :mod:`pvlib.iotools.bsrn`
3
- """
4
-
5
- import pandas as pd
6
- import pytest
7
- import os
8
- import tempfile
9
- from pvlib.iotools import read_bsrn, get_bsrn
10
- from ..conftest import (DATA_DIR, RERUNS, RERUNS_DELAY, assert_index_equal,
11
- requires_bsrn_credentials)
12
-
13
-
14
- @pytest.fixture(scope="module")
15
- def bsrn_credentials():
16
- """Supplies the BSRN FTP credentials for testing purposes.
17
-
18
- Users should obtain their own credentials as described in the `read_bsrn`
19
- documentation."""
20
- bsrn_username = os.environ["BSRN_FTP_USERNAME"]
21
- bsrn_password = os.environ["BSRN_FTP_PASSWORD"]
22
- return bsrn_username, bsrn_password
23
-
24
-
25
- @pytest.fixture
26
- def expected_index():
27
- return pd.date_range(start='20160601', periods=43200, freq='1min',
28
- tz='UTC')
29
-
30
-
31
- @pytest.mark.parametrize('testfile', [
32
- ('bsrn-pay0616.dat.gz'),
33
- ('bsrn-lr0100-pay0616.dat'),
34
- ])
35
- def test_read_bsrn(testfile, expected_index):
36
- data, metadata = read_bsrn(DATA_DIR / testfile)
37
- assert_index_equal(expected_index, data.index)
38
- assert 'ghi' in data.columns
39
- assert 'dni_std' in data.columns
40
- assert 'dhi_min' in data.columns
41
- assert 'lwd_max' in data.columns
42
- assert 'relative_humidity' in data.columns
43
-
44
-
45
- def test_read_bsrn_logical_records(expected_index):
46
- # Test if logical records 0300 and 0500 are correct parsed
47
- # and that 0100 is not passed when not specified
48
- data, metadata = read_bsrn(DATA_DIR / 'bsrn-pay0616.dat.gz',
49
- logical_records=['0300', '0500'])
50
- assert_index_equal(expected_index, data.index)
51
- assert 'lwu' in data.columns
52
- assert 'uva_global' in data.columns
53
- assert 'uvb_reflected_std' in data.columns
54
- assert 'ghi' not in data.columns
55
-
56
-
57
- def test_read_bsrn_bad_logical_record():
58
- # Test if ValueError is raised if an unsupported logical record is passed
59
- with pytest.raises(ValueError, match='not in'):
60
- read_bsrn(DATA_DIR / 'bsrn-lr0100-pay0616.dat',
61
- logical_records=['dummy'])
62
-
63
-
64
- def test_read_bsrn_logical_records_not_found():
65
- # Test if an empty dataframe is returned if specified LRs are not present
66
- data, metadata = read_bsrn(DATA_DIR / 'bsrn-lr0100-pay0616.dat',
67
- logical_records=['0300', '0500'])
68
- assert data.empty # assert that the dataframe is empty
69
- assert 'uva_global' in data.columns
70
- assert 'uvb_reflected_std' in data.columns
71
- assert 'uva_global_max' in data.columns
72
- assert 'dni' not in data.columns
73
- assert 'day' not in data.columns
74
-
75
-
76
- @requires_bsrn_credentials
77
- @pytest.mark.remote_data
78
- @pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
79
- def test_get_bsrn(expected_index, bsrn_credentials):
80
- # Retrieve irradiance data from the BSRN FTP server
81
- # the TAM station is chosen due to its small file sizes
82
- temp_dir = tempfile.TemporaryDirectory() # create temporary directory
83
- username, password = bsrn_credentials
84
- data, metadata = get_bsrn(
85
- start=pd.Timestamp(2016, 6, 1),
86
- end=pd.Timestamp(2016, 6, 29),
87
- station='tam',
88
- username=username,
89
- password=password,
90
- save_path=temp_dir.name)
91
- assert_index_equal(expected_index, data.index)
92
- assert 'ghi' in data.columns
93
- assert 'dni_std' in data.columns
94
- assert 'dhi_min' in data.columns
95
- assert 'lwd_max' in data.columns
96
- assert 'relative_humidity' in data.columns
97
- # test that a local file was saved and is read correctly
98
- data2, metadata2 = read_bsrn(os.path.join(temp_dir.name, 'tam0616.dat.gz'))
99
- assert_index_equal(expected_index, data2.index)
100
- assert 'ghi' in data2.columns
101
- temp_dir.cleanup() # explicitly remove temporary directory
102
-
103
-
104
- @requires_bsrn_credentials
105
- @pytest.mark.remote_data
106
- @pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
107
- def test_get_bsrn_bad_station(bsrn_credentials):
108
- # Test if KeyError is raised if a bad station name is passed
109
- username, password = bsrn_credentials
110
- with pytest.raises(KeyError, match='sub-directory does not exist'):
111
- get_bsrn(
112
- start=pd.Timestamp(2016, 6, 1),
113
- end=pd.Timestamp(2016, 6, 29),
114
- station='not_a_station_name',
115
- username=username,
116
- password=password)
117
-
118
-
119
- @requires_bsrn_credentials
120
- @pytest.mark.remote_data
121
- @pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
122
- def test_get_bsrn_no_files(bsrn_credentials):
123
- username, password = bsrn_credentials
124
- # Test if Warning is given if no files are found for the entire time frame
125
- with pytest.warns(UserWarning, match='No files'):
126
- get_bsrn(
127
- start=pd.Timestamp(1990, 6, 1),
128
- end=pd.Timestamp(1990, 6, 29),
129
- station='tam',
130
- username=username,
131
- password=password)
@@ -1,95 +0,0 @@
1
- import pandas as pd
2
- import numpy as np
3
- from numpy import dtype, nan
4
- import pytest
5
- from pvlib.iotools import crn
6
- from ..conftest import DATA_DIR, assert_frame_equal, assert_index_equal
7
-
8
-
9
- @pytest.fixture
10
- def columns_mapped():
11
- return [
12
- 'WBANNO', 'UTC_DATE', 'UTC_TIME', 'LST_DATE', 'LST_TIME', 'CRX_VN',
13
- 'longitude', 'latitude', 'temp_air', 'PRECIPITATION', 'ghi',
14
- 'ghi_flag',
15
- 'SURFACE_TEMPERATURE', 'ST_TYPE', 'ST_FLAG', 'relative_humidity',
16
- 'relative_humidity_flag', 'SOIL_MOISTURE_5', 'SOIL_TEMPERATURE_5',
17
- 'WETNESS', 'WET_FLAG', 'wind_speed', 'wind_speed_flag']
18
-
19
-
20
- @pytest.fixture
21
- def columns_unmapped():
22
- return [
23
- 'WBANNO', 'UTC_DATE', 'UTC_TIME', 'LST_DATE', 'LST_TIME', 'CRX_VN',
24
- 'LONGITUDE', 'LATITUDE', 'AIR_TEMPERATURE', 'PRECIPITATION',
25
- 'SOLAR_RADIATION', 'SR_FLAG', 'SURFACE_TEMPERATURE', 'ST_TYPE',
26
- 'ST_FLAG', 'RELATIVE_HUMIDITY', 'RH_FLAG', 'SOIL_MOISTURE_5',
27
- 'SOIL_TEMPERATURE_5', 'WETNESS', 'WET_FLAG', 'WIND_1_5', 'WIND_FLAG']
28
-
29
-
30
- @pytest.fixture
31
- def dtypes():
32
- return [
33
- dtype('int64'), dtype('int64'), dtype('int64'), dtype('int64'),
34
- dtype('int64'), dtype('O'), dtype('float64'), dtype('float64'),
35
- dtype('float64'), dtype('float64'), dtype('float64'),
36
- dtype('int64'), dtype('float64'), dtype('O'), dtype('int64'),
37
- dtype('float64'), dtype('int64'), dtype('float64'),
38
- dtype('float64'), dtype('int64'), dtype('int64'), dtype('float64'),
39
- dtype('int64')]
40
-
41
-
42
- @pytest.fixture
43
- def testfile():
44
- return DATA_DIR / 'CRNS0101-05-2019-AZ_Tucson_11_W.txt'
45
-
46
-
47
- @pytest.fixture
48
- def testfile_problems():
49
- return DATA_DIR / 'CRN_with_problems.txt'
50
-
51
-
52
- def test_read_crn(testfile, columns_mapped, dtypes):
53
- index = pd.DatetimeIndex(['2019-01-01 16:10:00',
54
- '2019-01-01 16:15:00',
55
- '2019-01-01 16:20:00',
56
- '2019-01-01 16:25:00'],
57
- freq=None).tz_localize('UTC')
58
- values = np.array([
59
- [53131, 20190101, 1610, 20190101, 910, 3, -111.17, 32.24, nan,
60
- 0.0, 296.0, 0, 4.4, 'C', 0, 90.0, 0, nan, nan, 24, 0, 0.78, 0],
61
- [53131, 20190101, 1615, 20190101, 915, 3, -111.17, 32.24, 3.3,
62
- 0.0, 183.0, 0, 4.0, 'C', 0, 87.0, 0, nan, nan, 1182, 0, 0.36, 0],
63
- [53131, 20190101, 1620, 20190101, 920, 3, -111.17, 32.24, 3.5,
64
- 0.0, 340.0, 0, 4.3, 'C', 0, 83.0, 0, nan, nan, 1183, 0, 0.53, 0],
65
- [53131, 20190101, 1625, 20190101, 925, 3, -111.17, 32.24, 4.0,
66
- 0.0, 393.0, 0, 4.8, 'C', 0, 81.0, 0, nan, nan, 1223, 0, 0.64, 0]])
67
- expected = pd.DataFrame(values, columns=columns_mapped, index=index)
68
- for (col, _dtype) in zip(expected.columns, dtypes):
69
- expected[col] = expected[col].astype(_dtype)
70
- out = crn.read_crn(testfile)
71
- assert_frame_equal(out, expected)
72
-
73
-
74
- # Test map_variables=False returns correct column names
75
- def test_read_crn_map_variables(testfile, columns_unmapped, dtypes):
76
- out = crn.read_crn(testfile, map_variables=False)
77
- assert_index_equal(out.columns, pd.Index(columns_unmapped))
78
-
79
-
80
- def test_read_crn_problems(testfile_problems, columns_mapped, dtypes):
81
- # GH1025
82
- index = pd.DatetimeIndex(['2020-07-06 12:00:00',
83
- '2020-07-06 13:10:00'],
84
- freq=None).tz_localize('UTC')
85
- values = np.array([
86
- [92821, 20200706, 1200, 20200706, 700, '3', -80.69, 28.62, 24.9,
87
- 0.0, np.nan, 0, 25.5, 'C', 0, 93.0, 0, nan, nan, 990, 0, 1.57, 0],
88
- [92821, 20200706, 1310, 20200706, 810, '2.623', -80.69, 28.62,
89
- 26.9, 0.0, 430.0, 0, 30.2, 'C', 0, 87.0, 0, nan, nan, 989, 0,
90
- 1.64, 0]])
91
- expected = pd.DataFrame(values, columns=columns_mapped, index=index)
92
- for (col, _dtype) in zip(expected.columns, dtypes):
93
- expected[col] = expected[col].astype(_dtype)
94
- out = crn.read_crn(testfile_problems)
95
- assert_frame_equal(out, expected)
@@ -1,23 +0,0 @@
1
- import pytest
2
-
3
- from pvlib.iotools import epw
4
- from ..conftest import DATA_DIR, RERUNS, RERUNS_DELAY
5
-
6
- epw_testfile = DATA_DIR / 'NLD_Amsterdam062400_IWEC.epw'
7
-
8
-
9
- def test_read_epw():
10
- epw.read_epw(epw_testfile)
11
-
12
-
13
- @pytest.mark.remote_data
14
- @pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
15
- def test_read_epw_remote():
16
- url = 'https://energyplus-weather.s3.amazonaws.com/europe_wmo_region_6/NLD/NLD_Amsterdam.062400_IWEC/NLD_Amsterdam.062400_IWEC.epw'
17
- epw.read_epw(url)
18
-
19
-
20
- def test_read_epw_coerce_year():
21
- coerce_year = 1987
22
- data, _ = epw.read_epw(epw_testfile, coerce_year=coerce_year)
23
- assert (data.index.year == 1987).all()
@@ -1,89 +0,0 @@
1
- import pandas as pd
2
- import pytest
3
- import pytz
4
-
5
- from pvlib.iotools import midc
6
- from ..conftest import DATA_DIR, RERUNS, RERUNS_DELAY
7
-
8
-
9
- @pytest.fixture
10
- def test_mapping():
11
- return {
12
- 'Direct Normal [W/m^2]': 'dni',
13
- 'Global PSP [W/m^2]': 'ghi',
14
- 'Rel Humidity [%]': 'relative_humidity',
15
- 'Temperature @ 2m [deg C]': 'temp_air',
16
- 'Non Existant': 'variable',
17
- }
18
-
19
-
20
- MIDC_TESTFILE = DATA_DIR / 'midc_20181014.txt'
21
- MIDC_RAW_TESTFILE = DATA_DIR / 'midc_raw_20181018.txt'
22
- MIDC_RAW_SHORT_HEADER_TESTFILE = (
23
- DATA_DIR / 'midc_raw_short_header_20191115.txt')
24
-
25
- # TODO: not used, remove?
26
- # midc_network_testfile = ('https://midcdmz.nrel.gov/apps/data_api.pl'
27
- # '?site=UAT&begin=20181018&end=20181019')
28
-
29
-
30
- def test_midc__format_index():
31
- data = pd.read_csv(MIDC_TESTFILE)
32
- data = midc._format_index(data)
33
- start = pd.Timestamp("20181014 00:00")
34
- start = start.tz_localize("MST")
35
- end = pd.Timestamp("20181014 23:59")
36
- end = end.tz_localize("MST")
37
- assert type(data.index) == pd.DatetimeIndex
38
- assert data.index[0] == start
39
- assert data.index[-1] == end
40
-
41
-
42
- def test_midc__format_index_tz_conversion():
43
- data = pd.read_csv(MIDC_TESTFILE)
44
- data = data.rename(columns={'MST': 'PST'})
45
- data = midc._format_index(data)
46
- assert data.index[0].tz == pytz.timezone('Etc/GMT+8')
47
-
48
-
49
- def test_midc__format_index_raw():
50
- data = pd.read_csv(MIDC_RAW_TESTFILE)
51
- data = midc._format_index_raw(data)
52
- start = pd.Timestamp('20181018 00:00')
53
- start = start.tz_localize('MST')
54
- end = pd.Timestamp('20181018 23:59')
55
- end = end.tz_localize('MST')
56
- assert data.index[0] == start
57
- assert data.index[-1] == end
58
-
59
-
60
- def test_read_midc_var_mapping_as_arg(test_mapping):
61
- data = midc.read_midc(MIDC_TESTFILE, variable_map=test_mapping)
62
- assert 'ghi' in data.columns
63
- assert 'temp_air' in data.columns
64
-
65
-
66
- @pytest.mark.remote_data
67
- @pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
68
- def test_read_midc_raw_data_from_nrel():
69
- start_ts = pd.Timestamp('20181018')
70
- end_ts = pd.Timestamp('20181019')
71
- var_map = midc.MIDC_VARIABLE_MAP['UAT']
72
- data = midc.read_midc_raw_data_from_nrel('UAT', start_ts, end_ts, var_map)
73
- for k, v in var_map.items():
74
- assert v in data.columns
75
- assert data.index.size == 2880
76
-
77
-
78
- def test_read_midc_header_length_mismatch(mocker):
79
- mock_data = mocker.MagicMock()
80
- with MIDC_RAW_SHORT_HEADER_TESTFILE.open() as f:
81
- mock_data.text = f.read()
82
- mocker.patch('pvlib.iotools.midc.requests.get',
83
- return_value=mock_data)
84
- start = pd.Timestamp('2019-11-15T00:00:00-06:00')
85
- end = pd.Timestamp('2019-11-15T23:59:00-06:00')
86
- data = midc.read_midc_raw_data_from_nrel('', start, end)
87
- assert isinstance(data.index, pd.DatetimeIndex)
88
- assert data.index[0] == start
89
- assert data.index[-1] == end
@@ -1,32 +0,0 @@
1
- """
2
- test iotools for panond
3
- """
4
-
5
- from pvlib.iotools import read_panond
6
- from pvlib.tests.conftest import DATA_DIR
7
-
8
- PAN_FILE = DATA_DIR / 'ET-M772BH550GL.PAN'
9
- OND_FILE = DATA_DIR / 'CPS SCH275KTL-DO-US-800-250kW_275kVA_1.OND'
10
-
11
-
12
- def test_read_panond():
13
- # test that returned contents have expected keys, types, and structure
14
-
15
- pan = read_panond(PAN_FILE, encoding='utf-8-sig')
16
- assert list(pan.keys()) == ['PVObject_']
17
- pan = pan['PVObject_']
18
- assert pan['PVObject_Commercial']['Model'] == 'ET-M772BH550GL'
19
- assert pan['Voc'] == 49.9
20
- assert pan['PVObject_IAM']['IAMProfile']['Point_5'] == [50.0, 0.98]
21
- assert pan['BifacialityFactor'] == 0.7
22
- assert pan['FrontSurface'] == 'fsARCoating'
23
- assert pan['Technol'] == 'mtSiMono'
24
-
25
- ond = read_panond(OND_FILE, encoding='utf-8-sig')
26
- assert list(ond.keys()) == ['PVObject_']
27
- ond = ond['PVObject_']
28
- assert ond['PVObject_Commercial']['Model'] == 'CPS SCH275KTL-DO/US-800'
29
- assert ond['TanPhiMin'] == -0.75
30
- assert ond['NbMPPT'] == 12
31
- assert ond['Converter']['ModeOper'] == 'MPPT'
32
- assert ond['Converter']['ProfilPIOV2']['Point_5'] == [75795.9, 75000.0]