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.
Files changed (149) hide show
  1. pvlib/__init__.py +1 -0
  2. pvlib/_deprecation.py +73 -0
  3. pvlib/atmosphere.py +77 -7
  4. pvlib/bifacial/infinite_sheds.py +4 -3
  5. pvlib/bifacial/utils.py +2 -1
  6. pvlib/clearsky.py +35 -22
  7. pvlib/iam.py +4 -4
  8. pvlib/iotools/midc.py +1 -1
  9. pvlib/iotools/psm3.py +1 -1
  10. pvlib/iotools/pvgis.py +10 -12
  11. pvlib/iotools/tmy.py +3 -69
  12. pvlib/irradiance.py +112 -55
  13. pvlib/ivtools/sdm.py +75 -52
  14. pvlib/location.py +73 -33
  15. pvlib/modelchain.py +18 -35
  16. pvlib/pvsystem.py +139 -94
  17. pvlib/snow.py +64 -28
  18. pvlib/solarposition.py +46 -30
  19. pvlib/spa.py +4 -2
  20. pvlib/spectrum/__init__.py +0 -1
  21. pvlib/spectrum/irradiance.py +2 -64
  22. pvlib/spectrum/mismatch.py +3 -3
  23. pvlib/spectrum/spectrl2.py +2 -1
  24. pvlib/temperature.py +49 -3
  25. pvlib/tools.py +6 -5
  26. {pvlib-0.11.1.dist-info → pvlib-0.12.0.dist-info}/METADATA +14 -11
  27. pvlib-0.12.0.dist-info/RECORD +75 -0
  28. {pvlib-0.11.1.dist-info → pvlib-0.12.0.dist-info}/WHEEL +1 -1
  29. pvlib/data/BIRD_08_16_2012.csv +0 -8761
  30. pvlib/data/BIRD_08_16_2012_patm.csv +0 -8761
  31. pvlib/data/Burlington, United States SolarAnywhere Time Series 2021 Lat_44_465 Lon_-73_205 TMY3 format.csv +0 -8762
  32. pvlib/data/Burlington, United States SolarAnywhere Time Series 20210101 to 20210103 Lat_44_4675 Lon_-73_2075 SA format.csv +0 -578
  33. pvlib/data/Burlington, United States SolarAnywhere Typical GHI Year Lat_44_465 Lon_-73_205 SA format.csv +0 -74
  34. pvlib/data/CPS SCH275KTL-DO-US-800-250kW_275kVA_1.OND +0 -146
  35. pvlib/data/CRNS0101-05-2019-AZ_Tucson_11_W.txt +0 -4
  36. pvlib/data/CRN_with_problems.txt +0 -3
  37. pvlib/data/ET-M772BH550GL.PAN +0 -75
  38. pvlib/data/NLD_Amsterdam062400_IWEC.epw +0 -8768
  39. pvlib/data/PVsyst_demo.csv +0 -10757
  40. pvlib/data/PVsyst_demo_model.csv +0 -3588
  41. pvlib/data/SRML-day-EUPO1801.txt +0 -1441
  42. pvlib/data/abq19056.dat +0 -6
  43. pvlib/data/aod550_tcwv_20121101_test.nc +0 -0
  44. pvlib/data/bishop88_numerical_precision.csv +0 -101
  45. pvlib/data/bsrn-lr0100-pay0616.dat +0 -86901
  46. pvlib/data/bsrn-pay0616.dat.gz +0 -0
  47. pvlib/data/cams_mcclear_1min_verbose.csv +0 -60
  48. pvlib/data/cams_mcclear_monthly.csv +0 -42
  49. pvlib/data/cams_radiation_1min_verbose.csv +0 -72
  50. pvlib/data/cams_radiation_monthly.csv +0 -47
  51. pvlib/data/detect_clearsky_data.csv +0 -35
  52. pvlib/data/detect_clearsky_threshold_data.csv +0 -126
  53. pvlib/data/greensboro_kimber_soil_manwash.dat +0 -8761
  54. pvlib/data/greensboro_kimber_soil_nowash.dat +0 -8761
  55. pvlib/data/inverter_fit_snl_meas.csv +0 -127
  56. pvlib/data/inverter_fit_snl_sim.csv +0 -19
  57. pvlib/data/ivtools_numdiff.csv +0 -52
  58. pvlib/data/midc_20181014.txt +0 -1441
  59. pvlib/data/midc_raw_20181018.txt +0 -1441
  60. pvlib/data/midc_raw_short_header_20191115.txt +0 -1441
  61. pvlib/data/msn19056.dat +0 -6
  62. pvlib/data/precise_iv_curves1.json +0 -10251
  63. pvlib/data/precise_iv_curves2.json +0 -10251
  64. pvlib/data/precise_iv_curves_parameter_sets1.csv +0 -33
  65. pvlib/data/precise_iv_curves_parameter_sets2.csv +0 -33
  66. pvlib/data/pvgis_hourly_Timeseries_45.000_8.000_SA2_10kWp_CIS_5_2a_2013_2014.json +0 -1
  67. pvlib/data/pvgis_hourly_Timeseries_45.000_8.000_SA_30deg_0deg_2016_2016.csv +0 -35
  68. pvlib/data/pvgis_tmy_meta.json +0 -32
  69. pvlib/data/pvgis_tmy_test.dat +0 -8761
  70. pvlib/data/pvwatts_8760_rackmount.csv +0 -8779
  71. pvlib/data/pvwatts_8760_roofmount.csv +0 -8779
  72. pvlib/data/singleaxis_tracker_wslope.csv +0 -8761
  73. pvlib/data/spectrl2_example_spectra.csv +0 -123
  74. pvlib/data/surfrad-slv16001.dat +0 -1442
  75. pvlib/data/test_psm3_2017.csv +0 -17521
  76. pvlib/data/test_psm3_2019_5min.csv +0 -289
  77. pvlib/data/test_psm3_tmy-2017.csv +0 -8761
  78. pvlib/data/test_read_psm3.csv +0 -17523
  79. pvlib/data/test_read_pvgis_horizon.csv +0 -49
  80. pvlib/data/tmy_45.000_8.000_2005_2020.csv +0 -8789
  81. pvlib/data/tmy_45.000_8.000_2005_2020.epw +0 -8768
  82. pvlib/data/tmy_45.000_8.000_2005_2020.json +0 -1
  83. pvlib/data/tmy_45.000_8.000_2005_2020.txt +0 -8761
  84. pvlib/data/tmy_45.000_8.000_userhorizon.json +0 -1
  85. pvlib/data/variables_style_rules.csv +0 -56
  86. pvlib/spa_c_files/README.md +0 -81
  87. pvlib/spa_c_files/cspa_py.pxd +0 -43
  88. pvlib/spa_c_files/spa_py.pyx +0 -30
  89. pvlib/tests/__init__.py +0 -0
  90. pvlib/tests/bifacial/__init__.py +0 -0
  91. pvlib/tests/bifacial/test_infinite_sheds.py +0 -317
  92. pvlib/tests/bifacial/test_losses_models.py +0 -54
  93. pvlib/tests/bifacial/test_pvfactors.py +0 -82
  94. pvlib/tests/bifacial/test_utils.py +0 -192
  95. pvlib/tests/conftest.py +0 -476
  96. pvlib/tests/iotools/__init__.py +0 -0
  97. pvlib/tests/iotools/test_acis.py +0 -213
  98. pvlib/tests/iotools/test_bsrn.py +0 -131
  99. pvlib/tests/iotools/test_crn.py +0 -95
  100. pvlib/tests/iotools/test_epw.py +0 -23
  101. pvlib/tests/iotools/test_midc.py +0 -89
  102. pvlib/tests/iotools/test_panond.py +0 -32
  103. pvlib/tests/iotools/test_psm3.py +0 -198
  104. pvlib/tests/iotools/test_pvgis.py +0 -644
  105. pvlib/tests/iotools/test_sodapro.py +0 -298
  106. pvlib/tests/iotools/test_solaranywhere.py +0 -287
  107. pvlib/tests/iotools/test_solargis.py +0 -68
  108. pvlib/tests/iotools/test_solcast.py +0 -324
  109. pvlib/tests/iotools/test_solrad.py +0 -152
  110. pvlib/tests/iotools/test_srml.py +0 -124
  111. pvlib/tests/iotools/test_surfrad.py +0 -75
  112. pvlib/tests/iotools/test_tmy.py +0 -133
  113. pvlib/tests/ivtools/__init__.py +0 -0
  114. pvlib/tests/ivtools/test_sde.py +0 -230
  115. pvlib/tests/ivtools/test_sdm.py +0 -407
  116. pvlib/tests/ivtools/test_utils.py +0 -173
  117. pvlib/tests/spectrum/__init__.py +0 -0
  118. pvlib/tests/spectrum/conftest.py +0 -40
  119. pvlib/tests/spectrum/test_irradiance.py +0 -138
  120. pvlib/tests/spectrum/test_mismatch.py +0 -304
  121. pvlib/tests/spectrum/test_response.py +0 -124
  122. pvlib/tests/spectrum/test_spectrl2.py +0 -72
  123. pvlib/tests/test_albedo.py +0 -84
  124. pvlib/tests/test_atmosphere.py +0 -204
  125. pvlib/tests/test_clearsky.py +0 -878
  126. pvlib/tests/test_conftest.py +0 -81
  127. pvlib/tests/test_iam.py +0 -555
  128. pvlib/tests/test_inverter.py +0 -213
  129. pvlib/tests/test_irradiance.py +0 -1441
  130. pvlib/tests/test_location.py +0 -356
  131. pvlib/tests/test_modelchain.py +0 -2020
  132. pvlib/tests/test_numerical_precision.py +0 -124
  133. pvlib/tests/test_pvarray.py +0 -71
  134. pvlib/tests/test_pvsystem.py +0 -2495
  135. pvlib/tests/test_scaling.py +0 -207
  136. pvlib/tests/test_shading.py +0 -391
  137. pvlib/tests/test_singlediode.py +0 -608
  138. pvlib/tests/test_snow.py +0 -212
  139. pvlib/tests/test_soiling.py +0 -230
  140. pvlib/tests/test_solarposition.py +0 -933
  141. pvlib/tests/test_spa.py +0 -425
  142. pvlib/tests/test_temperature.py +0 -470
  143. pvlib/tests/test_tools.py +0 -146
  144. pvlib/tests/test_tracking.py +0 -474
  145. pvlib/tests/test_transformer.py +0 -60
  146. pvlib-0.11.1.dist-info/RECORD +0 -192
  147. {pvlib-0.11.1.dist-info → pvlib-0.12.0.dist-info/licenses}/AUTHORS.md +0 -0
  148. {pvlib-0.11.1.dist-info → pvlib-0.12.0.dist-info/licenses}/LICENSE +0 -0
  149. {pvlib-0.11.1.dist-info → pvlib-0.12.0.dist-info}/top_level.txt +0 -0
@@ -1,878 +0,0 @@
1
- from collections import OrderedDict
2
-
3
- import numpy as np
4
- from numpy import nan
5
- import pandas as pd
6
- import pytz
7
- from scipy.linalg import hankel
8
-
9
- import pytest
10
- from numpy.testing import assert_allclose
11
- from .conftest import assert_frame_equal, assert_series_equal
12
-
13
- from pvlib.location import Location
14
- from pvlib import clearsky
15
- from pvlib import solarposition
16
- from pvlib import atmosphere
17
- from pvlib import irradiance
18
-
19
- from .conftest import DATA_DIR
20
-
21
-
22
- def test_ineichen_series():
23
- times = pd.date_range(start='2014-06-24', end='2014-06-25', freq='3h',
24
- tz='America/Phoenix')
25
- apparent_zenith = pd.Series(np.array(
26
- [124.0390863, 113.38779941, 82.85457044, 46.0467599, 10.56413562,
27
- 34.86074109, 72.41687122, 105.69538659, 124.05614124]),
28
- index=times)
29
- am = pd.Series(np.array(
30
- [nan, nan, 6.97935524, 1.32355476, 0.93527685,
31
- 1.12008114, 3.01614096, nan, nan]),
32
- index=times)
33
- expected = pd.DataFrame(np.
34
- array([[ 0. , 0. , 0. ],
35
- [ 0. , 0. , 0. ],
36
- [ 65.49426624, 321.16092181, 25.54562017],
37
- [ 704.6968125 , 888.90147035, 87.73601277],
38
- [1044.1230677 , 953.24925854, 107.03109696],
39
- [ 853.02065704, 922.06124712, 96.42909484],
40
- [ 251.99427693, 655.44925241, 53.9901349 ],
41
- [ 0. , 0. , 0. ],
42
- [ 0. , 0. , 0. ]]),
43
- columns=['ghi', 'dni', 'dhi'],
44
- index=times)
45
-
46
- out = clearsky.ineichen(apparent_zenith, am, 3)
47
- assert_frame_equal(expected, out)
48
-
49
-
50
- def test_ineichen_series_perez_enhancement():
51
- times = pd.date_range(start='2014-06-24', end='2014-06-25', freq='3h',
52
- tz='America/Phoenix')
53
- apparent_zenith = pd.Series(np.array(
54
- [124.0390863, 113.38779941, 82.85457044, 46.0467599, 10.56413562,
55
- 34.86074109, 72.41687122, 105.69538659, 124.05614124]),
56
- index=times)
57
- am = pd.Series(np.array(
58
- [nan, nan, 6.97935524, 1.32355476, 0.93527685,
59
- 1.12008114, 3.01614096, nan, nan]),
60
- index=times)
61
- expected = pd.DataFrame(np.
62
- array([[ 0. , 0. , 0. ],
63
- [ 0. , 0. , 0. ],
64
- [ 91.1249279 , 321.16092171, 51.17628184],
65
- [ 716.46580547, 888.9014706 , 99.50500553],
66
- [1053.42066073, 953.24925905, 116.3286895 ],
67
- [ 863.54692748, 922.06124652, 106.9553658 ],
68
- [ 271.06382275, 655.44925213, 73.05968076],
69
- [ 0. , 0. , 0. ],
70
- [ 0. , 0. , 0. ]]),
71
- columns=['ghi', 'dni', 'dhi'],
72
- index=times)
73
-
74
- out = clearsky.ineichen(apparent_zenith, am, 3, perez_enhancement=True)
75
- assert_frame_equal(expected, out)
76
-
77
-
78
- def test_ineichen_scalar_input():
79
- expected = OrderedDict()
80
- expected['ghi'] = 1038.159219
81
- expected['dni'] = 942.2081860378344
82
- expected['dhi'] = 110.26529293612793
83
-
84
- out = clearsky.ineichen(10., 1., 3.)
85
- for k, v in expected.items():
86
- assert_allclose(expected[k], out[k])
87
-
88
-
89
- def test_ineichen_nans():
90
- length = 4
91
-
92
- apparent_zenith = np.full(length, 10.)
93
- apparent_zenith[0] = np.nan
94
-
95
- linke_turbidity = np.full(length, 3.)
96
- linke_turbidity[1] = np.nan
97
-
98
- dni_extra = np.full(length, 1370.)
99
- dni_extra[2] = np.nan
100
-
101
- airmass_absolute = np.full(length, 1.)
102
-
103
- expected = OrderedDict()
104
- expected['ghi'] = np.full(length, np.nan)
105
- expected['dni'] = np.full(length, np.nan)
106
- expected['dhi'] = np.full(length, np.nan)
107
-
108
- expected['ghi'][length-1] = 1042.72590228
109
- expected['dni'][length-1] = 946.35279683
110
- expected['dhi'][length-1] = 110.75033088
111
-
112
- out = clearsky.ineichen(apparent_zenith, airmass_absolute,
113
- linke_turbidity, dni_extra=dni_extra)
114
-
115
- for k, v in expected.items():
116
- assert_allclose(expected[k], out[k])
117
-
118
-
119
- def test_ineichen_arrays():
120
- expected = OrderedDict()
121
-
122
- expected['ghi'] = (np.
123
- array([[[1095.77074798, 1054.17449885, 1014.15727338],
124
- [ 839.40909243, 807.54451692, 776.88954373],
125
- [ 190.27859353, 183.05548067, 176.10656239]],
126
-
127
- [[ 773.49041181, 625.19479557, 505.33080493],
128
- [ 592.52803177, 478.92699901, 387.10585505],
129
- [ 134.31520045, 108.56393694, 87.74977339]],
130
-
131
- [[ 545.9968869 , 370.78162375, 251.79449885],
132
- [ 418.25788117, 284.03520249, 192.88577665],
133
- [ 94.81136442, 64.38555328, 43.72365587]]]))
134
-
135
- expected['dni'] = (np.
136
- array([[[1014.38807396, 942.20818604, 861.11344424],
137
- [1014.38807396, 942.20818604, 861.11344424],
138
- [1014.38807396, 942.20818604, 861.11344424]],
139
-
140
- [[ 687.61305142, 419.14891162, 255.50098235],
141
- [ 687.61305142, 419.14891162, 255.50098235],
142
- [ 687.61305142, 419.14891162, 255.50098235]],
143
-
144
- [[ 458.62196014, 186.46177428, 75.80970012],
145
- [ 458.62196014, 186.46177428, 75.80970012],
146
- [ 458.62196014, 186.46177428, 75.80970012]]]))
147
-
148
- expected['dhi'] = (np.
149
- array([[[ 81.38267402, 111.96631281, 153.04382915],
150
- [ 62.3427452 , 85.77117175, 117.23837487],
151
- [ 14.13195304, 19.44274618, 26.57578203]],
152
-
153
- [[ 85.87736039, 206.04588395, 249.82982258],
154
- [ 65.78587472, 157.84030442, 191.38074731],
155
- [ 14.91244713, 35.77949226, 43.38249342]],
156
-
157
- [[ 87.37492676, 184.31984947, 175.98479873],
158
- [ 66.93307711, 141.19719644, 134.81217714],
159
- [ 15.17249681, 32.00680597, 30.5594396 ]]]))
160
-
161
- apparent_zenith = np.linspace(0, 80, 3)
162
- airmass_absolute = np.linspace(1, 10, 3)
163
- linke_turbidity = np.linspace(2, 4, 3)
164
-
165
- apparent_zenith, airmass_absolute, linke_turbidity = \
166
- np.meshgrid(apparent_zenith, airmass_absolute, linke_turbidity)
167
-
168
- out = clearsky.ineichen(apparent_zenith, airmass_absolute, linke_turbidity)
169
-
170
- for k, v in expected.items():
171
- assert_allclose(expected[k], out[k])
172
-
173
-
174
- def test_ineichen_dni_extra():
175
- expected = pd.DataFrame(
176
- np.array([[1042.72590228, 946.35279683, 110.75033088]]),
177
- columns=['ghi', 'dni', 'dhi'])
178
-
179
- out = clearsky.ineichen(10, 1, 3, dni_extra=pd.Series(1370))
180
- assert_frame_equal(expected, out)
181
-
182
-
183
- def test_ineichen_altitude():
184
- expected = pd.DataFrame(
185
- np.array([[1134.24312405, 994.95377835, 154.40492924]]),
186
- columns=['ghi', 'dni', 'dhi'])
187
-
188
- out = clearsky.ineichen(10, 1, 3, altitude=pd.Series(2000))
189
- assert_frame_equal(expected, out)
190
-
191
-
192
- def test_lookup_linke_turbidity():
193
- times = pd.date_range(start='2014-06-24', end='2014-06-25',
194
- freq='12h', tz='America/Phoenix')
195
- # expect same value on 2014-06-24 0000 and 1200, and
196
- # diff value on 2014-06-25
197
- expected = pd.Series(
198
- np.array([3.11803278689, 3.11803278689, 3.13114754098]), index=times
199
- )
200
- out = clearsky.lookup_linke_turbidity(times, 32.125, -110.875)
201
- assert_series_equal(expected, out)
202
-
203
-
204
- def test_lookup_linke_turbidity_leapyear():
205
- times = pd.date_range(start='2016-06-24', end='2016-06-25',
206
- freq='12h', tz='America/Phoenix')
207
- # expect same value on 2016-06-24 0000 and 1200, and
208
- # diff value on 2016-06-25
209
- expected = pd.Series(
210
- np.array([3.11803278689, 3.11803278689, 3.13114754098]), index=times
211
- )
212
- out = clearsky.lookup_linke_turbidity(times, 32.125, -110.875)
213
- assert_series_equal(expected, out)
214
-
215
-
216
- def test_lookup_linke_turbidity_nointerp():
217
- times = pd.date_range(start='2014-06-24', end='2014-06-25',
218
- freq='12h', tz='America/Phoenix')
219
- # expect same value for all days
220
- expected = pd.Series(np.array([3., 3., 3.]), index=times)
221
- out = clearsky.lookup_linke_turbidity(times, 32.125, -110.875,
222
- interp_turbidity=False)
223
- assert_series_equal(expected, out)
224
-
225
-
226
- def test_lookup_linke_turbidity_months():
227
- times = pd.date_range(start='2014-04-01', end='2014-07-01',
228
- freq='1M', tz='America/Phoenix')
229
- expected = pd.Series(
230
- np.array([2.89918032787, 2.97540983607, 3.19672131148]), index=times
231
- )
232
- out = clearsky.lookup_linke_turbidity(times, 32.125, -110.875)
233
- assert_series_equal(expected, out)
234
-
235
-
236
- def test_lookup_linke_turbidity_months_leapyear():
237
- times = pd.date_range(start='2016-04-01', end='2016-07-01',
238
- freq='1M', tz='America/Phoenix')
239
- expected = pd.Series(
240
- np.array([2.89918032787, 2.97540983607, 3.19672131148]), index=times
241
- )
242
- out = clearsky.lookup_linke_turbidity(times, 32.125, -110.875)
243
- assert_series_equal(expected, out)
244
-
245
-
246
- def test_lookup_linke_turbidity_nointerp_months():
247
- times = pd.date_range(start='2014-04-10', end='2014-07-10',
248
- freq='1M', tz='America/Phoenix')
249
- expected = pd.Series(np.array([2.85, 2.95, 3.]), index=times)
250
- out = clearsky.lookup_linke_turbidity(times, 32.125, -110.875,
251
- interp_turbidity=False)
252
- assert_series_equal(expected, out)
253
- # changing the dates shouldn't matter if interp=False
254
- times = pd.date_range(start='2014-04-05', end='2014-07-05',
255
- freq='1M', tz='America/Phoenix')
256
- out = clearsky.lookup_linke_turbidity(times, 32.125, -110.875,
257
- interp_turbidity=False)
258
- assert_series_equal(expected, out)
259
-
260
-
261
- def test_haurwitz():
262
- apparent_solar_elevation = np.array([-20, -0.05, -0.001, 5, 10, 30, 50, 90])
263
- apparent_solar_zenith = 90 - apparent_solar_elevation
264
- data_in = pd.DataFrame(data=apparent_solar_zenith,
265
- index=apparent_solar_zenith,
266
- columns=['apparent_zenith'])
267
- expected = pd.DataFrame(np.array([0.,
268
- 0.,
269
- 0.,
270
- 48.6298687941956,
271
- 135.741748091813,
272
- 487.894132885425,
273
- 778.766689344363,
274
- 1035.09203253450]),
275
- columns=['ghi'],
276
- index=apparent_solar_zenith)
277
- out = clearsky.haurwitz(data_in['apparent_zenith'])
278
- assert_frame_equal(expected, out)
279
-
280
-
281
- def test_simplified_solis_scalar_elevation():
282
- expected = OrderedDict()
283
- expected['ghi'] = 1064.653145
284
- expected['dni'] = 959.335463
285
- expected['dhi'] = 129.125602
286
-
287
- out = clearsky.simplified_solis(80)
288
- for k, v in expected.items():
289
- assert_allclose(expected[k], out[k])
290
-
291
-
292
- def test_simplified_solis_scalar_neg_elevation():
293
- expected = OrderedDict()
294
- expected['ghi'] = 0
295
- expected['dni'] = 0
296
- expected['dhi'] = 0
297
-
298
- out = clearsky.simplified_solis(-10)
299
- for k, v in expected.items():
300
- assert_allclose(expected[k], out[k])
301
-
302
-
303
- def test_simplified_solis_series_elevation():
304
- expected = pd.DataFrame(
305
- np.array([[959.335463, 1064.653145, 129.125602]]),
306
- columns=['dni', 'ghi', 'dhi'])
307
- expected = expected[['ghi', 'dni', 'dhi']]
308
-
309
- out = clearsky.simplified_solis(pd.Series(80))
310
- assert_frame_equal(expected, out)
311
-
312
-
313
- def test_simplified_solis_dni_extra():
314
- expected = pd.DataFrame(np.array([[963.555414, 1069.33637, 129.693603]]),
315
- columns=['dni', 'ghi', 'dhi'])
316
- expected = expected[['ghi', 'dni', 'dhi']]
317
-
318
- out = clearsky.simplified_solis(80, dni_extra=pd.Series(1370))
319
- assert_frame_equal(expected, out)
320
-
321
-
322
- def test_simplified_solis_pressure():
323
- expected = pd.DataFrame(np.
324
- array([[ 964.26930718, 1067.96543669, 127.22841797],
325
- [ 961.88811874, 1066.36847963, 128.1402539 ],
326
- [ 959.58112234, 1064.81837558, 129.0304193 ]]),
327
- columns=['dni', 'ghi', 'dhi'])
328
- expected = expected[['ghi', 'dni', 'dhi']]
329
-
330
- out = clearsky.simplified_solis(
331
- 80, pressure=pd.Series([95000, 98000, 101000]))
332
- assert_frame_equal(expected, out)
333
-
334
-
335
- def test_simplified_solis_aod700():
336
- expected = pd.DataFrame(np.
337
- array([[ 1056.61710493, 1105.7229086 , 64.41747323],
338
- [ 1007.50558875, 1085.74139063, 102.96233698],
339
- [ 959.3354628 , 1064.65314509, 129.12560167],
340
- [ 342.45810926, 638.63409683, 77.71786575],
341
- [ 55.24140911, 7.5413313 , 0. ]]),
342
- columns=['dni', 'ghi', 'dhi'])
343
- expected = expected[['ghi', 'dni', 'dhi']]
344
-
345
- aod700 = pd.Series([0.0, 0.05, 0.1, 1, 10])
346
- out = clearsky.simplified_solis(80, aod700=aod700)
347
- assert_frame_equal(expected, out)
348
-
349
-
350
- def test_simplified_solis_precipitable_water():
351
- expected = pd.DataFrame(np.
352
- array([[ 1001.15353307, 1107.84678941, 128.58887606],
353
- [ 1001.15353307, 1107.84678941, 128.58887606],
354
- [ 983.51027357, 1089.62306672, 129.08755996],
355
- [ 959.3354628 , 1064.65314509, 129.12560167],
356
- [ 872.02335029, 974.18046717, 125.63581346]]),
357
- columns=['dni', 'ghi', 'dhi'])
358
- expected = expected[['ghi', 'dni', 'dhi']]
359
-
360
- out = clearsky.simplified_solis(
361
- 80, precipitable_water=pd.Series([0.0, 0.2, 0.5, 1.0, 5.0]))
362
- assert_frame_equal(expected, out)
363
-
364
-
365
- def test_simplified_solis_small_scalar_pw():
366
-
367
- expected = OrderedDict()
368
- expected['ghi'] = 1107.84678941
369
- expected['dni'] = 1001.15353307
370
- expected['dhi'] = 128.58887606
371
-
372
- out = clearsky.simplified_solis(80, precipitable_water=0.1)
373
- for k, v in expected.items():
374
- assert_allclose(expected[k], out[k])
375
-
376
-
377
- def test_simplified_solis_return_arrays():
378
- expected = OrderedDict()
379
-
380
- expected['ghi'] = np.array([[ 1148.40081325, 913.42330823],
381
- [ 965.48550828, 760.04527609]])
382
-
383
- expected['dni'] = np.array([[ 1099.25706525, 656.24601381],
384
- [ 915.31689149, 530.31697378]])
385
-
386
- expected['dhi'] = np.array([[ 64.1063074 , 254.6186615 ],
387
- [ 62.75642216, 232.21931597]])
388
-
389
- aod700 = np.linspace(0, 0.5, 2)
390
- precipitable_water = np.linspace(0, 10, 2)
391
-
392
- aod700, precipitable_water = np.meshgrid(aod700, precipitable_water)
393
-
394
- out = clearsky.simplified_solis(80, aod700, precipitable_water)
395
-
396
- for k, v in expected.items():
397
- assert_allclose(expected[k], out[k])
398
-
399
-
400
- def test_simplified_solis_nans_arrays():
401
-
402
- # construct input arrays that each have 1 nan offset from each other,
403
- # the last point is valid for all arrays
404
-
405
- length = 6
406
-
407
- apparent_elevation = np.full(length, 80.)
408
- apparent_elevation[0] = np.nan
409
-
410
- aod700 = np.full(length, 0.1)
411
- aod700[1] = np.nan
412
-
413
- precipitable_water = np.full(length, 0.5)
414
- precipitable_water[2] = np.nan
415
-
416
- pressure = np.full(length, 98000.)
417
- pressure[3] = np.nan
418
-
419
- dni_extra = np.full(length, 1370.)
420
- dni_extra[4] = np.nan
421
-
422
- expected = OrderedDict()
423
- expected['ghi'] = np.full(length, np.nan)
424
- expected['dni'] = np.full(length, np.nan)
425
- expected['dhi'] = np.full(length, np.nan)
426
-
427
- expected['ghi'][length-1] = 1096.022736
428
- expected['dni'][length-1] = 990.306854
429
- expected['dhi'][length-1] = 128.664594
430
-
431
- out = clearsky.simplified_solis(apparent_elevation, aod700,
432
- precipitable_water, pressure, dni_extra)
433
-
434
- for k, v in expected.items():
435
- assert_allclose(expected[k], out[k])
436
-
437
-
438
- def test_simplified_solis_nans_series():
439
-
440
- # construct input arrays that each have 1 nan offset from each other,
441
- # the last point is valid for all arrays
442
-
443
- length = 6
444
-
445
- apparent_elevation = pd.Series(np.full(length, 80.))
446
- apparent_elevation[0] = np.nan
447
-
448
- aod700 = np.full(length, 0.1)
449
- aod700[1] = np.nan
450
-
451
- precipitable_water = np.full(length, 0.5)
452
- precipitable_water[2] = np.nan
453
-
454
- pressure = np.full(length, 98000.)
455
- pressure[3] = np.nan
456
-
457
- dni_extra = np.full(length, 1370.)
458
- dni_extra[4] = np.nan
459
-
460
- expected = OrderedDict()
461
- expected['ghi'] = np.full(length, np.nan)
462
- expected['dni'] = np.full(length, np.nan)
463
- expected['dhi'] = np.full(length, np.nan)
464
-
465
- expected['ghi'][length-1] = 1096.022736
466
- expected['dni'][length-1] = 990.306854
467
- expected['dhi'][length-1] = 128.664594
468
-
469
- expected = pd.DataFrame.from_dict(expected)
470
-
471
- out = clearsky.simplified_solis(apparent_elevation, aod700,
472
- precipitable_water, pressure, dni_extra)
473
-
474
- assert_frame_equal(expected, out)
475
-
476
-
477
- def test_linke_turbidity_corners():
478
- """Test Linke turbidity corners out of bounds."""
479
- months = pd.DatetimeIndex('%d/1/2016' % (m + 1) for m in range(12))
480
-
481
- def monthly_lt_nointerp(lat, lon, time=months):
482
- """monthly Linke turbidity factor without time interpolation"""
483
- return clearsky.lookup_linke_turbidity(
484
- time, lat, lon, interp_turbidity=False
485
- )
486
-
487
- # Northwest
488
- assert np.allclose(
489
- monthly_lt_nointerp(90, -180),
490
- [1.9, 1.9, 1.9, 2.0, 2.05, 2.05, 2.1, 2.1, 2.0, 1.95, 1.9, 1.9])
491
- # Southwest
492
- assert np.allclose(
493
- monthly_lt_nointerp(-90, -180),
494
- [1.35, 1.3, 1.45, 1.35, 1.35, 1.35, 1.35, 1.35, 1.35, 1.4, 1.4, 1.3])
495
- # Northeast
496
- assert np.allclose(
497
- monthly_lt_nointerp(90, 180),
498
- [1.9, 1.9, 1.9, 2.0, 2.05, 2.05, 2.1, 2.1, 2.0, 1.95, 1.9, 1.9])
499
- # Southeast
500
- assert np.allclose(
501
- monthly_lt_nointerp(-90, 180),
502
- [1.35, 1.7, 1.35, 1.35, 1.35, 1.35, 1.35, 1.35, 1.35, 1.35, 1.35, 1.7])
503
- # test out of range exceptions at corners
504
- with pytest.raises(IndexError):
505
- monthly_lt_nointerp(91, -122) # exceeds max latitude
506
- with pytest.raises(IndexError):
507
- monthly_lt_nointerp(38.2, 181) # exceeds max longitude
508
- with pytest.raises(IndexError):
509
- monthly_lt_nointerp(-91, -122) # exceeds min latitude
510
- with pytest.raises(IndexError):
511
- monthly_lt_nointerp(38.2, -181) # exceeds min longitude
512
-
513
-
514
- @pytest.fixture
515
- def detect_clearsky_data():
516
- data_file = DATA_DIR / 'detect_clearsky_data.csv'
517
- expected = pd.read_csv(
518
- data_file, index_col=0, parse_dates=True, comment='#')
519
- expected = expected.tz_localize('UTC').tz_convert('Etc/GMT+7')
520
- metadata = {}
521
- with data_file.open() as f:
522
- for line in f:
523
- if line.startswith('#'):
524
- key, value = line.strip('# \n').split(':')
525
- metadata[key] = float(value)
526
- else:
527
- break
528
- metadata['window_length'] = int(metadata['window_length'])
529
- loc = Location(metadata['latitude'], metadata['longitude'],
530
- altitude=metadata['elevation'])
531
- # specify turbidity to guard against future lookup changes
532
- cs = loc.get_clearsky(expected.index, linke_turbidity=2.658197)
533
- return expected, cs
534
-
535
-
536
- @pytest.fixture
537
- def detect_clearsky_threshold_data():
538
- # this is (roughly) just a 2 hour period of the same data in
539
- # detect_clearsky_data (which only spans 30 minutes)
540
- data_file = DATA_DIR / 'detect_clearsky_threshold_data.csv'
541
- expected = pd.read_csv(
542
- data_file, index_col=0, parse_dates=True, comment='#')
543
- expected = expected.tz_localize('UTC').tz_convert('Etc/GMT+7')
544
- metadata = {}
545
- with data_file.open() as f:
546
- for line in f:
547
- if line.startswith('#'):
548
- key, value = line.strip('# \n').split(':')
549
- metadata[key] = float(value)
550
- else:
551
- break
552
- metadata['window_length'] = int(metadata['window_length'])
553
- loc = Location(metadata['latitude'], metadata['longitude'],
554
- altitude=metadata['elevation'])
555
- # specify turbidity to guard against future lookup changes
556
- cs = loc.get_clearsky(expected.index, linke_turbidity=2.658197)
557
- return expected, cs
558
-
559
-
560
- def test_clearsky_get_threshold():
561
- out = clearsky._clearsky_get_threshold(4.5)
562
- expected = (58.75, 75, 64.375, -45, 80.0, 0.009375, 58.75)
563
- assert np.allclose(out, expected)
564
-
565
-
566
- def test_clearsky_get_threshold_raises_error():
567
- with pytest.raises(ValueError, match='can only be used for inputs'):
568
- clearsky._clearsky_get_threshold(0.5)
569
-
570
-
571
- def test_detect_clearsky_calls_threshold(mocker, detect_clearsky_threshold_data):
572
- threshold_spy = mocker.spy(clearsky, '_clearsky_get_threshold')
573
- expected, cs = detect_clearsky_threshold_data
574
- threshold_actual = clearsky.detect_clearsky(expected['GHI'], cs['ghi'],
575
- infer_limits=True)
576
- assert threshold_spy.call_count == 1
577
-
578
-
579
- def test_detect_clearsky(detect_clearsky_data):
580
- expected, cs = detect_clearsky_data
581
- clear_samples = clearsky.detect_clearsky(
582
- expected['GHI'], cs['ghi'], times=cs.index, window_length=10)
583
- assert_series_equal(expected['Clear or not'], clear_samples,
584
- check_dtype=False, check_names=False)
585
-
586
-
587
- def test_detect_clearsky_defaults(detect_clearsky_data):
588
- expected, cs = detect_clearsky_data
589
- clear_samples = clearsky.detect_clearsky(
590
- expected['GHI'], cs['ghi'])
591
- assert_series_equal(expected['Clear or not'], clear_samples,
592
- check_dtype=False, check_names=False)
593
-
594
-
595
- def test_detect_clearsky_components(detect_clearsky_data):
596
- expected, cs = detect_clearsky_data
597
- clear_samples, components, alpha = clearsky.detect_clearsky(
598
- expected['GHI'], cs['ghi'], times=cs.index, window_length=10,
599
- return_components=True)
600
- assert_series_equal(expected['Clear or not'], clear_samples,
601
- check_dtype=False, check_names=False)
602
- assert isinstance(components, OrderedDict)
603
- assert np.allclose(alpha, 0.9633903181941296)
604
-
605
-
606
- def test_detect_clearsky_iterations(detect_clearsky_data):
607
- expected, cs = detect_clearsky_data
608
- alpha = 1.0448
609
- with pytest.warns(RuntimeWarning):
610
- clear_samples = clearsky.detect_clearsky(
611
- expected['GHI'], cs['ghi']*alpha, max_iterations=1)
612
- assert clear_samples[:'2012-04-01 10:41:00'].all()
613
- assert not clear_samples['2012-04-01 10:42:00':].any() # expected False
614
- clear_samples = clearsky.detect_clearsky(
615
- expected['GHI'], cs['ghi']*alpha, max_iterations=20)
616
- assert_series_equal(expected['Clear or not'], clear_samples,
617
- check_dtype=False, check_names=False)
618
-
619
-
620
- def test_detect_clearsky_kwargs(detect_clearsky_data):
621
- expected, cs = detect_clearsky_data
622
- clear_samples = clearsky.detect_clearsky(
623
- expected['GHI'], cs['ghi'], times=cs.index, window_length=10,
624
- mean_diff=1000, max_diff=1000, lower_line_length=-1000,
625
- upper_line_length=1000, var_diff=10, slope_dev=1000)
626
- assert clear_samples.all()
627
-
628
-
629
- def test_detect_clearsky_window(detect_clearsky_data):
630
- expected, cs = detect_clearsky_data
631
- clear_samples = clearsky.detect_clearsky(
632
- expected['GHI'], cs['ghi'], window_length=3)
633
- expected = expected['Clear or not'].copy()
634
- expected.iloc[-3:] = 1
635
- assert_series_equal(expected, clear_samples,
636
- check_dtype=False, check_names=False)
637
-
638
-
639
- def test_detect_clearsky_time_interval(detect_clearsky_data):
640
- expected, cs = detect_clearsky_data
641
- u = np.arange(0, len(cs), 2)
642
- cs2 = cs.iloc[u]
643
- expected2 = expected.iloc[u]
644
- clear_samples = clearsky.detect_clearsky(
645
- expected2['GHI'], cs2['ghi'], window_length=6)
646
- assert_series_equal(expected2['Clear or not'], clear_samples,
647
- check_dtype=False, check_names=False)
648
-
649
-
650
- def test_detect_clearsky_arrays(detect_clearsky_data):
651
- expected, cs = detect_clearsky_data
652
- clear_samples = clearsky.detect_clearsky(
653
- expected['GHI'].values, cs['ghi'].values, times=cs.index,
654
- window_length=10)
655
- assert isinstance(clear_samples, np.ndarray)
656
- assert (clear_samples == expected['Clear or not'].values).all()
657
-
658
-
659
- def test_detect_clearsky_irregular_times(detect_clearsky_data):
660
- expected, cs = detect_clearsky_data
661
- times = cs.index.values.copy()
662
- times[0] += 10**9
663
- times = pd.DatetimeIndex(times)
664
- with pytest.raises(NotImplementedError):
665
- clearsky.detect_clearsky(expected['GHI'].values, cs['ghi'].values,
666
- times, 10)
667
-
668
-
669
- def test_detect_clearsky_missing_index(detect_clearsky_data):
670
- expected, cs = detect_clearsky_data
671
- with pytest.raises(ValueError):
672
- clearsky.detect_clearsky(expected['GHI'].values, cs['ghi'].values)
673
-
674
-
675
- def test_detect_clearsky_not_enough_data(detect_clearsky_data):
676
- expected, cs = detect_clearsky_data
677
- with pytest.raises(ValueError, match='have at least'):
678
- clearsky.detect_clearsky(expected['GHI'], cs['ghi'], window_length=60)
679
-
680
-
681
- @pytest.mark.parametrize("window_length", [5, 10, 15, 20, 25])
682
- def test_detect_clearsky_optimizer_not_failed(
683
- detect_clearsky_data, window_length
684
- ):
685
- expected, cs = detect_clearsky_data
686
- clear_samples = clearsky.detect_clearsky(
687
- expected["GHI"], cs["ghi"], window_length=window_length
688
- )
689
- assert isinstance(clear_samples, pd.Series)
690
-
691
-
692
- @pytest.fixture
693
- def detect_clearsky_helper_data():
694
- samples_per_window = 3
695
- sample_interval = 1
696
- x = pd.Series(np.arange(0, 7)**2.)
697
- # line length between adjacent points
698
- sqt = pd.Series(np.sqrt(np.array([np.nan, 2., 10., 26., 50., 82, 122.])))
699
- H = hankel(np.arange(samples_per_window),
700
- np.arange(samples_per_window-1, len(sqt)))
701
- return x, samples_per_window, sample_interval, H
702
-
703
-
704
- def test__line_length_windowed(detect_clearsky_helper_data):
705
- x, samples_per_window, sample_interval, H = detect_clearsky_helper_data
706
- # sqt is hand-calculated assuming window=3
707
- # line length between adjacent points
708
- sqt = pd.Series(np.sqrt(np.array([np.nan, 2., 10., 26., 50., 82, 122.])))
709
- expected = {}
710
- expected['line_length'] = sqt + sqt.shift(-1)
711
- result = clearsky._line_length_windowed(
712
- x, H, samples_per_window, sample_interval)
713
- assert_series_equal(result, expected['line_length'])
714
-
715
-
716
- def test__max_diff_windowed(detect_clearsky_helper_data):
717
- x, samples_per_window, sample_interval, H = detect_clearsky_helper_data
718
- expected = {}
719
- expected['max_diff'] = pd.Series(
720
- data=[np.nan, 3., 5., 7., 9., 11., np.nan], index=x.index)
721
- result = clearsky._max_diff_windowed(x, H, samples_per_window)
722
- assert_series_equal(result, expected['max_diff'])
723
-
724
-
725
- def test__calc_stats(detect_clearsky_helper_data):
726
- x, samples_per_window, sample_interval, H = detect_clearsky_helper_data
727
- # stats are hand-computed assuming window = 3, sample_interval = 1,
728
- # and right-aligned labels
729
- mean_x = pd.Series(np.array([np.nan, np.nan, 5, 14, 29, 50, 77]) / 3.)
730
- max_x = pd.Series(np.array([np.nan, np.nan, 4, 9, 16, 25, 36]))
731
- diff_std = np.array([np.nan, np.nan, np.sqrt(2), np.sqrt(2), np.sqrt(2),
732
- np.sqrt(2), np.sqrt(2)])
733
- slope_nstd = diff_std / mean_x
734
- slope = x.diff().shift(-1)
735
- expected = {}
736
- expected['mean'] = mean_x.shift(-1) # shift to align to center
737
- expected['max'] = max_x.shift(-1)
738
- # slope between adjacent points
739
- expected['slope'] = slope
740
- expected['slope_nstd'] = slope_nstd.shift(-1)
741
- result = clearsky._calc_stats(
742
- x, samples_per_window, sample_interval, H)
743
- res_mean, res_max, res_slope_nstd, res_slope = result
744
- assert_series_equal(res_mean, expected['mean'])
745
- assert_series_equal(res_max, expected['max'])
746
- assert_series_equal(res_slope_nstd, expected['slope_nstd'])
747
- assert_series_equal(res_slope, expected['slope'])
748
-
749
-
750
- def test_bird():
751
- """Test Bird/Hulstrom Clearsky Model"""
752
- times = pd.date_range(start='1/1/2015 0:00', end='12/31/2015 23:00',
753
- freq='h')
754
- tz = -7 # test timezone
755
- gmt_tz = pytz.timezone('Etc/GMT%+d' % -(tz))
756
- times = times.tz_localize(gmt_tz) # set timezone
757
- times_utc = times.tz_convert('UTC')
758
- # match test data from BIRD_08_16_2012.xls
759
- latitude = 40.
760
- longitude = -105.
761
- press_mB = 840.
762
- o3_cm = 0.3
763
- h2o_cm = 1.5
764
- aod_500nm = 0.1
765
- aod_380nm = 0.15
766
- b_a = 0.85
767
- alb = 0.2
768
- eot = solarposition.equation_of_time_spencer71(times_utc.dayofyear)
769
- hour_angle = solarposition.hour_angle(times, longitude, eot) - 0.5 * 15.
770
- declination = solarposition.declination_spencer71(times_utc.dayofyear)
771
- zenith = solarposition.solar_zenith_analytical(
772
- np.deg2rad(latitude), np.deg2rad(hour_angle), declination
773
- )
774
- zenith = np.rad2deg(zenith)
775
- airmass = atmosphere.get_relative_airmass(zenith, model='kasten1966')
776
- etr = irradiance.get_extra_radiation(times)
777
- # test Bird with time series data
778
- field_names = ('dni', 'direct_horizontal', 'ghi', 'dhi')
779
- irrads = clearsky.bird(
780
- zenith, airmass, aod_380nm, aod_500nm, h2o_cm, o3_cm, press_mB * 100.,
781
- etr, b_a, alb
782
- )
783
- Eb, Ebh, Gh, Dh = (irrads[_] for _ in field_names)
784
- data_path = DATA_DIR / 'BIRD_08_16_2012.csv'
785
- testdata = pd.read_csv(data_path, usecols=range(1, 26), header=1).dropna()
786
- testdata[['DEC', 'EQT']] = testdata[['DEC', 'EQT']].shift(tz)
787
- testdata = testdata[:tz]
788
- end = 48 + tz
789
- testdata.index = times[1:end]
790
- assert np.allclose(testdata['DEC'], np.rad2deg(declination[1:end]))
791
- assert np.allclose(testdata['EQT'], eot[1:end], rtol=1e-4)
792
- assert np.allclose(testdata['Hour Angle'], hour_angle[1:end], rtol=1e-2)
793
- assert np.allclose(testdata['Zenith Ang'], zenith[1:end], rtol=1e-2)
794
- dawn = zenith < 88.
795
- dusk = testdata['Zenith Ang'] < 88.
796
- am = pd.Series(np.where(dawn, airmass, 0.), index=times).fillna(0.0)
797
- assert np.allclose(
798
- testdata['Air Mass'].where(dusk, 0.), am[1:end], rtol=1e-3
799
- )
800
- direct_beam = pd.Series(np.where(dawn, Eb, 0.), index=times).fillna(0.)
801
- assert np.allclose(
802
- testdata['Direct Beam'].where(dusk, 0.), direct_beam[1:end], rtol=1e-3
803
- )
804
- direct_horz = pd.Series(np.where(dawn, Ebh, 0.), index=times).fillna(0.)
805
- assert np.allclose(
806
- testdata['Direct Hz'].where(dusk, 0.), direct_horz[1:end], rtol=1e-3
807
- )
808
- global_horz = pd.Series(np.where(dawn, Gh, 0.), index=times).fillna(0.)
809
- assert np.allclose(
810
- testdata['Global Hz'].where(dusk, 0.), global_horz[1:end], rtol=1e-3
811
- )
812
- diffuse_horz = pd.Series(np.where(dawn, Dh, 0.), index=times).fillna(0.)
813
- assert np.allclose(
814
- testdata['Dif Hz'].where(dusk, 0.), diffuse_horz[1:end], rtol=1e-3
815
- )
816
- # repeat test with albedo as a Series
817
- alb_series = pd.Series(0.2, index=times)
818
- irrads = clearsky.bird(
819
- zenith, airmass, aod_380nm, aod_500nm, h2o_cm, o3_cm, press_mB * 100.,
820
- etr, b_a, alb_series
821
- )
822
- Eb, Ebh, Gh, Dh = (irrads[_] for _ in field_names)
823
- direct_beam = pd.Series(np.where(dawn, Eb, 0.), index=times).fillna(0.)
824
- assert np.allclose(
825
- testdata['Direct Beam'].where(dusk, 0.), direct_beam[1:end], rtol=1e-3
826
- )
827
- direct_horz = pd.Series(np.where(dawn, Ebh, 0.), index=times).fillna(0.)
828
- assert np.allclose(
829
- testdata['Direct Hz'].where(dusk, 0.), direct_horz[1:end], rtol=1e-3
830
- )
831
- global_horz = pd.Series(np.where(dawn, Gh, 0.), index=times).fillna(0.)
832
- assert np.allclose(
833
- testdata['Global Hz'].where(dusk, 0.), global_horz[1:end], rtol=1e-3
834
- )
835
- diffuse_horz = pd.Series(np.where(dawn, Dh, 0.), index=times).fillna(0.)
836
- assert np.allclose(
837
- testdata['Dif Hz'].where(dusk, 0.), diffuse_horz[1:end], rtol=1e-3
838
- )
839
-
840
- # test keyword parameters
841
- irrads2 = clearsky.bird(
842
- zenith, airmass, aod_380nm, aod_500nm, h2o_cm, dni_extra=etr
843
- )
844
- Eb2, Ebh2, Gh2, Dh2 = (irrads2[_] for _ in field_names)
845
- data_path = DATA_DIR / 'BIRD_08_16_2012_patm.csv'
846
- testdata2 = pd.read_csv(data_path, usecols=range(1, 26), header=1).dropna()
847
- testdata2[['DEC', 'EQT']] = testdata2[['DEC', 'EQT']].shift(tz)
848
- testdata2 = testdata2[:tz]
849
- testdata2.index = times[1:end]
850
- direct_beam2 = pd.Series(np.where(dawn, Eb2, 0.), index=times).fillna(0.)
851
- assert np.allclose(
852
- testdata2['Direct Beam'].where(dusk, 0.), direct_beam2[1:end],
853
- rtol=1e-3
854
- )
855
- direct_horz2 = pd.Series(np.where(dawn, Ebh2, 0.), index=times).fillna(0.)
856
- assert np.allclose(
857
- testdata2['Direct Hz'].where(dusk, 0.), direct_horz2[1:end], rtol=1e-3
858
- )
859
- global_horz2 = pd.Series(np.where(dawn, Gh2, 0.), index=times).fillna(0.)
860
- assert np.allclose(
861
- testdata2['Global Hz'].where(dusk, 0.), global_horz2[1:end], rtol=1e-3
862
- )
863
- diffuse_horz2 = pd.Series(np.where(dawn, Dh2, 0.), index=times).fillna(0.)
864
- assert np.allclose(
865
- testdata2['Dif Hz'].where(dusk, 0.), diffuse_horz2[1:end], rtol=1e-3
866
- )
867
- # test scalars just at noon
868
- # XXX: calculations start at 12am so noon is at index = 12
869
- irrads3 = clearsky.bird(
870
- zenith[12], airmass[12], aod_380nm, aod_500nm, h2o_cm,
871
- dni_extra=etr.iloc[12]
872
- )
873
- Eb3, Ebh3, Gh3, Dh3 = (irrads3[_] for _ in field_names)
874
- # XXX: testdata starts at 1am so noon is at index = 11
875
- np.allclose(
876
- [Eb3, Ebh3, Gh3, Dh3],
877
- testdata2[['Direct Beam', 'Direct Hz', 'Global Hz', 'Dif Hz']].iloc[11],
878
- rtol=1e-3)