pvlib 0.11.2__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 (139) hide show
  1. pvlib/__init__.py +1 -0
  2. pvlib/atmosphere.py +0 -9
  3. pvlib/bifacial/infinite_sheds.py +4 -3
  4. pvlib/bifacial/utils.py +2 -1
  5. pvlib/iotools/psm3.py +1 -1
  6. pvlib/iotools/pvgis.py +10 -2
  7. pvlib/iotools/tmy.py +3 -69
  8. pvlib/irradiance.py +14 -0
  9. pvlib/location.py +73 -33
  10. pvlib/modelchain.py +18 -35
  11. pvlib/pvsystem.py +7 -10
  12. pvlib/snow.py +64 -28
  13. pvlib/spectrum/__init__.py +0 -1
  14. pvlib/spectrum/irradiance.py +0 -63
  15. pvlib/spectrum/mismatch.py +3 -3
  16. pvlib/tools.py +6 -5
  17. {pvlib-0.11.2.dist-info → pvlib-0.12.0.dist-info}/METADATA +5 -3
  18. pvlib-0.12.0.dist-info/RECORD +75 -0
  19. {pvlib-0.11.2.dist-info → pvlib-0.12.0.dist-info}/WHEEL +1 -1
  20. pvlib/data/BIRD_08_16_2012.csv +0 -8761
  21. pvlib/data/BIRD_08_16_2012_patm.csv +0 -8761
  22. pvlib/data/Burlington, United States SolarAnywhere Time Series 2021 Lat_44_465 Lon_-73_205 TMY3 format.csv +0 -8762
  23. pvlib/data/Burlington, United States SolarAnywhere Time Series 20210101 to 20210103 Lat_44_4675 Lon_-73_2075 SA format.csv +0 -578
  24. pvlib/data/Burlington, United States SolarAnywhere Typical GHI Year Lat_44_465 Lon_-73_205 SA format.csv +0 -74
  25. pvlib/data/CPS SCH275KTL-DO-US-800-250kW_275kVA_1.OND +0 -146
  26. pvlib/data/CRNS0101-05-2019-AZ_Tucson_11_W.txt +0 -4
  27. pvlib/data/CRN_with_problems.txt +0 -3
  28. pvlib/data/ET-M772BH550GL.PAN +0 -75
  29. pvlib/data/NLD_Amsterdam062400_IWEC.epw +0 -8768
  30. pvlib/data/PVsyst_demo.csv +0 -10757
  31. pvlib/data/PVsyst_demo_model.csv +0 -3588
  32. pvlib/data/SRML-day-EUPO1801.txt +0 -1441
  33. pvlib/data/abq19056.dat +0 -6
  34. pvlib/data/bishop88_numerical_precision.csv +0 -101
  35. pvlib/data/bsrn-lr0100-pay0616.dat +0 -86901
  36. pvlib/data/bsrn-pay0616.dat.gz +0 -0
  37. pvlib/data/cams_mcclear_1min_verbose.csv +0 -60
  38. pvlib/data/cams_mcclear_monthly.csv +0 -42
  39. pvlib/data/cams_radiation_1min_verbose.csv +0 -72
  40. pvlib/data/cams_radiation_monthly.csv +0 -47
  41. pvlib/data/detect_clearsky_data.csv +0 -35
  42. pvlib/data/detect_clearsky_threshold_data.csv +0 -126
  43. pvlib/data/greensboro_kimber_soil_manwash.dat +0 -8761
  44. pvlib/data/greensboro_kimber_soil_nowash.dat +0 -8761
  45. pvlib/data/inverter_fit_snl_meas.csv +0 -127
  46. pvlib/data/inverter_fit_snl_sim.csv +0 -19
  47. pvlib/data/ivtools_numdiff.csv +0 -52
  48. pvlib/data/midc_20181014.txt +0 -1441
  49. pvlib/data/midc_raw_20181018.txt +0 -1441
  50. pvlib/data/midc_raw_short_header_20191115.txt +0 -1441
  51. pvlib/data/msn19056.dat +0 -6
  52. pvlib/data/precise_iv_curves1.json +0 -10251
  53. pvlib/data/precise_iv_curves2.json +0 -10251
  54. pvlib/data/precise_iv_curves_parameter_sets1.csv +0 -33
  55. pvlib/data/precise_iv_curves_parameter_sets2.csv +0 -33
  56. pvlib/data/pvgis_hourly_Timeseries_45.000_8.000_SA2_10kWp_CIS_5_2a_2013_2014.json +0 -1
  57. pvlib/data/pvgis_hourly_Timeseries_45.000_8.000_SA_30deg_0deg_2016_2016.csv +0 -35
  58. pvlib/data/pvgis_tmy_meta.json +0 -32
  59. pvlib/data/pvgis_tmy_test.csv +0 -8761
  60. pvlib/data/pvwatts_8760_rackmount.csv +0 -8779
  61. pvlib/data/pvwatts_8760_roofmount.csv +0 -8779
  62. pvlib/data/singleaxis_tracker_wslope.csv +0 -8761
  63. pvlib/data/spectrl2_example_spectra.csv +0 -123
  64. pvlib/data/surfrad-slv16001.dat +0 -1442
  65. pvlib/data/test_psm3_2017.csv +0 -17521
  66. pvlib/data/test_psm3_2019_5min.csv +0 -289
  67. pvlib/data/test_psm3_tmy-2017.csv +0 -8761
  68. pvlib/data/test_read_psm3.csv +0 -17523
  69. pvlib/data/test_read_pvgis_horizon.csv +0 -49
  70. pvlib/data/tmy_45.000_8.000_2005_2023.csv +0 -8789
  71. pvlib/data/tmy_45.000_8.000_2005_2023.epw +0 -8768
  72. pvlib/data/tmy_45.000_8.000_2005_2023.json +0 -1
  73. pvlib/data/tmy_45.000_8.000_2005_2023.txt +0 -8761
  74. pvlib/data/tmy_45.000_8.000_userhorizon.json +0 -1
  75. pvlib/spa_c_files/README.md +0 -81
  76. pvlib/spa_c_files/cspa_py.pxd +0 -43
  77. pvlib/spa_c_files/spa_py.pyx +0 -30
  78. pvlib/tests/__init__.py +0 -0
  79. pvlib/tests/bifacial/__init__.py +0 -0
  80. pvlib/tests/bifacial/test_infinite_sheds.py +0 -317
  81. pvlib/tests/bifacial/test_losses_models.py +0 -54
  82. pvlib/tests/bifacial/test_pvfactors.py +0 -82
  83. pvlib/tests/bifacial/test_utils.py +0 -192
  84. pvlib/tests/conftest.py +0 -476
  85. pvlib/tests/iotools/__init__.py +0 -0
  86. pvlib/tests/iotools/test_acis.py +0 -213
  87. pvlib/tests/iotools/test_bsrn.py +0 -131
  88. pvlib/tests/iotools/test_crn.py +0 -95
  89. pvlib/tests/iotools/test_epw.py +0 -23
  90. pvlib/tests/iotools/test_midc.py +0 -89
  91. pvlib/tests/iotools/test_panond.py +0 -32
  92. pvlib/tests/iotools/test_psm3.py +0 -198
  93. pvlib/tests/iotools/test_pvgis.py +0 -644
  94. pvlib/tests/iotools/test_sodapro.py +0 -298
  95. pvlib/tests/iotools/test_solaranywhere.py +0 -287
  96. pvlib/tests/iotools/test_solargis.py +0 -68
  97. pvlib/tests/iotools/test_solcast.py +0 -324
  98. pvlib/tests/iotools/test_solrad.py +0 -152
  99. pvlib/tests/iotools/test_srml.py +0 -124
  100. pvlib/tests/iotools/test_surfrad.py +0 -75
  101. pvlib/tests/iotools/test_tmy.py +0 -133
  102. pvlib/tests/ivtools/__init__.py +0 -0
  103. pvlib/tests/ivtools/test_sde.py +0 -230
  104. pvlib/tests/ivtools/test_sdm.py +0 -429
  105. pvlib/tests/ivtools/test_utils.py +0 -173
  106. pvlib/tests/spectrum/__init__.py +0 -0
  107. pvlib/tests/spectrum/conftest.py +0 -40
  108. pvlib/tests/spectrum/test_irradiance.py +0 -138
  109. pvlib/tests/spectrum/test_mismatch.py +0 -304
  110. pvlib/tests/spectrum/test_response.py +0 -124
  111. pvlib/tests/spectrum/test_spectrl2.py +0 -72
  112. pvlib/tests/test__deprecation.py +0 -97
  113. pvlib/tests/test_albedo.py +0 -84
  114. pvlib/tests/test_atmosphere.py +0 -351
  115. pvlib/tests/test_clearsky.py +0 -884
  116. pvlib/tests/test_conftest.py +0 -37
  117. pvlib/tests/test_iam.py +0 -555
  118. pvlib/tests/test_inverter.py +0 -213
  119. pvlib/tests/test_irradiance.py +0 -1487
  120. pvlib/tests/test_location.py +0 -356
  121. pvlib/tests/test_modelchain.py +0 -2020
  122. pvlib/tests/test_numerical_precision.py +0 -124
  123. pvlib/tests/test_pvarray.py +0 -71
  124. pvlib/tests/test_pvsystem.py +0 -2511
  125. pvlib/tests/test_scaling.py +0 -207
  126. pvlib/tests/test_shading.py +0 -391
  127. pvlib/tests/test_singlediode.py +0 -608
  128. pvlib/tests/test_snow.py +0 -212
  129. pvlib/tests/test_soiling.py +0 -230
  130. pvlib/tests/test_solarposition.py +0 -966
  131. pvlib/tests/test_spa.py +0 -454
  132. pvlib/tests/test_temperature.py +0 -470
  133. pvlib/tests/test_tools.py +0 -146
  134. pvlib/tests/test_tracking.py +0 -474
  135. pvlib/tests/test_transformer.py +0 -60
  136. pvlib-0.11.2.dist-info/RECORD +0 -191
  137. {pvlib-0.11.2.dist-info → pvlib-0.12.0.dist-info/licenses}/AUTHORS.md +0 -0
  138. {pvlib-0.11.2.dist-info → pvlib-0.12.0.dist-info/licenses}/LICENSE +0 -0
  139. {pvlib-0.11.2.dist-info → pvlib-0.12.0.dist-info}/top_level.txt +0 -0
pvlib/tests/test_spa.py DELETED
@@ -1,454 +0,0 @@
1
- import os
2
- import datetime as dt
3
- import warnings
4
- import pytest
5
- import pvlib
6
-
7
- try:
8
- from importlib import reload
9
- except ImportError:
10
- try:
11
- from imp import reload
12
- except ImportError:
13
- pass
14
-
15
- import numpy as np
16
- from numpy.testing import assert_almost_equal
17
- import pandas as pd
18
-
19
- import unittest
20
- from .conftest import requires_numba
21
-
22
-
23
- times = (pd.date_range('2003-10-17 12:30:30', periods=1, freq='D')
24
- .tz_localize('MST'))
25
- unixtimes = np.array(times.tz_convert('UTC').view(np.int64)*1.0/10**9)
26
-
27
- lat = 39.742476
28
- lon = -105.1786
29
- elev = 1830.14
30
- pressure = 820
31
- temp = 11
32
- delta_t = 67.0
33
- atmos_refract = 0.5667
34
-
35
- JD = 2452930.312847
36
- JC = 0.0379277986858
37
- JDE = 2452930.313623
38
- JCE = 0.037927819916852
39
- JME = 0.003792781991685
40
- L = 24.0182616917
41
- B = -0.0001011219
42
- R = 0.9965422974
43
- Theta = 204.0182616917
44
- beta = 0.0001011219
45
- X0 = 17185.861179
46
- X1 = 1722.893218
47
- X2 = 18234.075703
48
- X3 = 18420.071012
49
- X4 = 51.686951
50
- dPsi = -0.00399840
51
- dEpsilon = 0.00166657
52
- epsilon0 = 84379.672625
53
- epsilon = 23.440465
54
- dTau = -0.005711
55
- lamd = 204.0085519281
56
- v0 = 318.515579
57
- v = 318.511910
58
- alpha = 202.227408
59
- delta = -9.31434
60
- H = 11.10590
61
- xi = 0.002451
62
- dAlpha = -0.000369
63
- alpha_prime = 202.22704
64
- delta_prime = -9.316179
65
- H_prime = 11.10627
66
- e0 = 39.872046
67
- de = 0.016332
68
- e = 39.888378
69
- theta = 50.11162
70
- theta0 = 90 - e0
71
- Gamma = 14.340241
72
- Phi = 194.340241
73
- year = 1985
74
- month = 2
75
- year_array = np.array([-499, 500, 1000, 1500, 1800, 1860, 1900, 1950,
76
- 1970, 1985, 1990, 2000, 2005, 2050, 2150])
77
- # `month_array` is used with `year_array` in `test_calculate_deltat`.
78
- # Both arrays need to have the same length for the test, hence the duplicates.
79
- month_array = np.array([1, 2, 3, 4, 5, 6, 6, 7, 8, 9, 10, 11, 12, 12, 12])
80
- dt_actual = 54.413442486
81
- dt_actual_array = np.array([1.7184831e+04, 5.7088051e+03, 1.5730419e+03,
82
- 1.9801820e+02, 1.3596506e+01, 7.8316585e+00,
83
- -2.1171894e+00, 2.9289261e+01, 4.0824887e+01,
84
- 5.4724581e+01, 5.7426651e+01, 6.4108015e+01,
85
- 6.5038015e+01, 9.4952955e+01, 3.3050693e+02])
86
- mix_year_array = np.full((10), year)
87
- mix_month_array = np.full((10), month)
88
- mix_year_actual = np.full((10), dt_actual)
89
- mix_month_actual = mix_year_actual
90
-
91
-
92
- class SpaBase:
93
- """Test functions common to numpy and numba spa"""
94
- def test_julian_day_dt(self):
95
- # add 1us manually to the test timestamp (GH #940)
96
- dt = times.tz_convert('UTC')[0] + pd.Timedelta(1, unit='us')
97
- year = dt.year
98
- month = dt.month
99
- day = dt.day
100
- hour = dt.hour
101
- minute = dt.minute
102
- second = dt.second
103
- microsecond = dt.microsecond
104
- assert_almost_equal(JD + 1e-6 / (3600*24), # modify expected JD by 1us
105
- self.spa.julian_day_dt(
106
- year, month, day, hour,
107
- minute, second, microsecond), 6)
108
-
109
- def test_julian_ephemeris_day(self):
110
- assert_almost_equal(JDE, self.spa.julian_ephemeris_day(JD, delta_t), 5)
111
-
112
- def test_julian_century(self):
113
- assert_almost_equal(JC, self.spa.julian_century(JD), 6)
114
-
115
- def test_julian_ephemeris_century(self):
116
- assert_almost_equal(JCE, self.spa.julian_ephemeris_century(JDE), 10)
117
-
118
- def test_julian_ephemeris_millenium(self):
119
- assert_almost_equal(JME, self.spa.julian_ephemeris_millennium(JCE), 10)
120
-
121
- def test_heliocentric_longitude(self):
122
- assert_almost_equal(L, self.spa.heliocentric_longitude(JME), 6)
123
-
124
- def test_heliocentric_latitude(self):
125
- assert_almost_equal(B, self.spa.heliocentric_latitude(JME), 6)
126
-
127
- def test_heliocentric_radius_vector(self):
128
- assert_almost_equal(R, self.spa.heliocentric_radius_vector(JME), 6)
129
-
130
- def test_geocentric_longitude(self):
131
- assert_almost_equal(Theta, self.spa.geocentric_longitude(L), 6)
132
-
133
- def test_geocentric_latitude(self):
134
- assert_almost_equal(beta, self.spa.geocentric_latitude(B), 6)
135
-
136
- def test_mean_elongation(self):
137
- assert_almost_equal(X0, self.spa.mean_elongation(JCE), 5)
138
-
139
- def test_mean_anomaly_sun(self):
140
- assert_almost_equal(X1, self.spa.mean_anomaly_sun(JCE), 5)
141
-
142
- def test_mean_anomaly_moon(self):
143
- assert_almost_equal(X2, self.spa.mean_anomaly_moon(JCE), 5)
144
-
145
- def test_moon_argument_latitude(self):
146
- assert_almost_equal(X3, self.spa.moon_argument_latitude(JCE), 5)
147
-
148
- def test_moon_ascending_longitude(self):
149
- assert_almost_equal(X4, self.spa.moon_ascending_longitude(JCE), 6)
150
-
151
- def test_longitude_obliquity_nutation(self):
152
- out = np.empty((2,))
153
- self.spa.longitude_obliquity_nutation(JCE, X0, X1, X2, X3, X4, out)
154
- _dPsi, _dEpsilon = out[0], out[1]
155
- assert_almost_equal(dPsi, _dPsi, 6)
156
- assert_almost_equal(dEpsilon, _dEpsilon, 6)
157
-
158
- def test_mean_ecliptic_obliquity(self):
159
- assert_almost_equal(epsilon0, self.spa.mean_ecliptic_obliquity(JME), 6)
160
-
161
- def test_true_ecliptic_obliquity(self):
162
- assert_almost_equal(epsilon, self.spa.true_ecliptic_obliquity(
163
- epsilon0, dEpsilon), 6)
164
-
165
- def test_aberration_correction(self):
166
- assert_almost_equal(dTau, self.spa.aberration_correction(R), 6)
167
-
168
- def test_apparent_sun_longitude(self):
169
- assert_almost_equal(lamd, self.spa.apparent_sun_longitude(
170
- Theta, dPsi, dTau), 6)
171
-
172
- def test_mean_sidereal_time(self):
173
- assert_almost_equal(v0, self.spa.mean_sidereal_time(JD, JC), 3)
174
-
175
- def test_apparent_sidereal_time(self):
176
- assert_almost_equal(v, self.spa.apparent_sidereal_time(
177
- v0, dPsi, epsilon), 5)
178
-
179
- def test_geocentric_sun_right_ascension(self):
180
- assert_almost_equal(alpha, self.spa.geocentric_sun_right_ascension(
181
- lamd, epsilon, beta), 6)
182
-
183
- def test_geocentric_sun_declination(self):
184
- assert_almost_equal(delta, self.spa.geocentric_sun_declination(
185
- lamd, epsilon, beta), 6)
186
-
187
- def test_local_hour_angle(self):
188
- assert_almost_equal(H, self.spa.local_hour_angle(v, lon, alpha), 4)
189
-
190
- def test_equatorial_horizontal_parallax(self):
191
- assert_almost_equal(xi, self.spa.equatorial_horizontal_parallax(R), 6)
192
-
193
- def test_parallax_sun_right_ascension(self):
194
- u = self.spa.uterm(lat)
195
- x = self.spa.xterm(u, lat, elev)
196
- assert_almost_equal(dAlpha, self.spa.parallax_sun_right_ascension(
197
- x, xi, H, delta), 4)
198
-
199
- def test_topocentric_sun_right_ascension(self):
200
- assert_almost_equal(alpha_prime,
201
- self.spa.topocentric_sun_right_ascension(
202
- alpha, dAlpha), 5)
203
-
204
- def test_topocentric_sun_declination(self):
205
- u = self.spa.uterm(lat)
206
- x = self.spa.xterm(u, lat, elev)
207
- y = self.spa.yterm(u, lat, elev)
208
- assert_almost_equal(delta_prime, self.spa.topocentric_sun_declination(
209
- delta, x, y, xi, dAlpha, H), 5)
210
-
211
- def test_topocentric_local_hour_angle(self):
212
- assert_almost_equal(H_prime, self.spa.topocentric_local_hour_angle(
213
- H, dAlpha), 5)
214
-
215
- def test_topocentric_elevation_angle_without_atmosphere(self):
216
- assert_almost_equal(
217
- e0, self.spa.topocentric_elevation_angle_without_atmosphere(
218
- lat, delta_prime, H_prime), 6)
219
-
220
- def test_atmospheric_refraction_correction(self):
221
- assert_almost_equal(de, self.spa.atmospheric_refraction_correction(
222
- pressure, temp, e0, atmos_refract), 6)
223
-
224
- def test_topocentric_elevation_angle(self):
225
- assert_almost_equal(e, self.spa.topocentric_elevation_angle(e0, de), 6)
226
-
227
- def test_topocentric_zenith_angle(self):
228
- assert_almost_equal(theta, self.spa.topocentric_zenith_angle(e), 5)
229
-
230
- def test_topocentric_astronomers_azimuth(self):
231
- assert_almost_equal(Gamma, self.spa.topocentric_astronomers_azimuth(
232
- H_prime, delta_prime, lat), 5)
233
-
234
- def test_topocentric_azimuth_angle(self):
235
- assert_almost_equal(Phi, self.spa.topocentric_azimuth_angle(Gamma), 5)
236
-
237
- def test_solar_position(self):
238
- with warnings.catch_warnings():
239
- # don't warn on method reload
240
- warnings.simplefilter("ignore")
241
- spa_out_0 = self.spa.solar_position(
242
- unixtimes, lat, lon, elev, pressure, temp, delta_t,
243
- atmos_refract)[:-1]
244
- spa_out_1 = self.spa.solar_position(
245
- unixtimes, lat, lon, elev, pressure, temp, delta_t,
246
- atmos_refract, sst=True)[:3]
247
- assert_almost_equal(np.array([[theta, theta0, e, e0, Phi]]).T,
248
- spa_out_0, 5)
249
- assert_almost_equal(np.array([[v, alpha, delta]]).T, spa_out_1, 5)
250
-
251
- def test_equation_of_time(self):
252
- eot = 14.64
253
- M = self.spa.sun_mean_longitude(JME)
254
- assert_almost_equal(eot, self.spa.equation_of_time(
255
- M, alpha, dPsi, epsilon), 2)
256
-
257
- def test_transit_sunrise_sunset(self):
258
- # tests at greenwich
259
- times = pd.DatetimeIndex([dt.datetime(1996, 7, 5, 0),
260
- dt.datetime(2004, 12, 4, 0)]
261
- ).tz_localize(
262
- 'UTC').view(np.int64)*1.0/10**9
263
- sunrise = pd.DatetimeIndex([dt.datetime(1996, 7, 5, 7, 8, 15),
264
- dt.datetime(2004, 12, 4, 4, 38, 57)]
265
- ).tz_localize(
266
- 'UTC').view(np.int64)*1.0/10**9
267
- sunset = pd.DatetimeIndex([dt.datetime(1996, 7, 5, 17, 1, 4),
268
- dt.datetime(2004, 12, 4, 19, 2, 2)]
269
- ).tz_localize(
270
- 'UTC').view(np.int64)*1.0/10**9
271
- times = np.array(times)
272
- sunrise = np.array(sunrise)
273
- sunset = np.array(sunset)
274
- result = self.spa.transit_sunrise_sunset(times, -35.0, 0.0, 64.0, 1)
275
- assert_almost_equal(sunrise/1e3, result[1]/1e3, 3)
276
- assert_almost_equal(sunset/1e3, result[2]/1e3, 3)
277
-
278
- times = pd.DatetimeIndex([dt.datetime(1994, 1, 2), ]
279
- ).tz_localize(
280
- 'UTC').view(np.int64)*1.0/10**9
281
- sunset = pd.DatetimeIndex([dt.datetime(1994, 1, 2, 16, 59, 55), ]
282
- ).tz_localize(
283
- 'UTC').view(np.int64)*1.0/10**9
284
- sunrise = pd.DatetimeIndex([dt.datetime(1994, 1, 2, 7, 8, 12), ]
285
- ).tz_localize(
286
- 'UTC').view(np.int64)*1.0/10**9
287
- times = np.array(times)
288
- sunrise = np.array(sunrise)
289
- sunset = np.array(sunset)
290
- result = self.spa.transit_sunrise_sunset(times, 35.0, 0.0, 64.0, 1)
291
- assert_almost_equal(sunrise/1e3, result[1]/1e3, 3)
292
- assert_almost_equal(sunset/1e3, result[2]/1e3, 3)
293
-
294
- # tests from USNO
295
- # Golden
296
- times = pd.DatetimeIndex([dt.datetime(2015, 1, 2),
297
- dt.datetime(2015, 4, 2),
298
- dt.datetime(2015, 8, 2),
299
- dt.datetime(2015, 12, 2)],
300
- ).tz_localize(
301
- 'UTC').view(np.int64)*1.0/10**9
302
- sunrise = pd.DatetimeIndex([dt.datetime(2015, 1, 2, 7, 19),
303
- dt.datetime(2015, 4, 2, 5, 43),
304
- dt.datetime(2015, 8, 2, 5, 1),
305
- dt.datetime(2015, 12, 2, 7, 1)],
306
- ).tz_localize(
307
- 'MST').view(np.int64)*1.0/10**9
308
- sunset = pd.DatetimeIndex([dt.datetime(2015, 1, 2, 16, 49),
309
- dt.datetime(2015, 4, 2, 18, 24),
310
- dt.datetime(2015, 8, 2, 19, 10),
311
- dt.datetime(2015, 12, 2, 16, 38)],
312
- ).tz_localize(
313
- 'MST').view(np.int64)*1.0/10**9
314
- times = np.array(times)
315
- sunrise = np.array(sunrise)
316
- sunset = np.array(sunset)
317
- result = self.spa.transit_sunrise_sunset(times, 39.0, -105.0, 64.0, 1)
318
- assert_almost_equal(sunrise/1e3, result[1]/1e3, 1)
319
- assert_almost_equal(sunset/1e3, result[2]/1e3, 1)
320
-
321
- # Beijing
322
- times = pd.DatetimeIndex([dt.datetime(2015, 1, 2),
323
- dt.datetime(2015, 4, 2),
324
- dt.datetime(2015, 8, 2),
325
- dt.datetime(2015, 12, 2)],
326
- ).tz_localize(
327
- 'UTC').view(np.int64)*1.0/10**9
328
- sunrise = pd.DatetimeIndex([dt.datetime(2015, 1, 2, 7, 36),
329
- dt.datetime(2015, 4, 2, 5, 58),
330
- dt.datetime(2015, 8, 2, 5, 13),
331
- dt.datetime(2015, 12, 2, 7, 17)],
332
- ).tz_localize('Asia/Shanghai').view(
333
- np.int64)*1.0/10**9
334
- sunset = pd.DatetimeIndex([dt.datetime(2015, 1, 2, 17, 0),
335
- dt.datetime(2015, 4, 2, 18, 39),
336
- dt.datetime(2015, 8, 2, 19, 28),
337
- dt.datetime(2015, 12, 2, 16, 50)],
338
- ).tz_localize('Asia/Shanghai').view(
339
- np.int64)*1.0/10**9
340
- times = np.array(times)
341
- sunrise = np.array(sunrise)
342
- sunset = np.array(sunset)
343
- result = self.spa.transit_sunrise_sunset(
344
- times, 39.917, 116.383, 64.0, 1)
345
- assert_almost_equal(sunrise/1e3, result[1]/1e3, 1)
346
- assert_almost_equal(sunset/1e3, result[2]/1e3, 1)
347
-
348
- def test_earthsun_distance(self):
349
- times = (pd.date_range('2003-10-17 12:30:30', periods=1, freq='D')
350
- .tz_localize('MST'))
351
- unixtimes = times.tz_convert('UTC').view(np.int64)*1.0/10**9
352
- unixtimes = np.array(unixtimes)
353
- result = self.spa.earthsun_distance(unixtimes, 64.0, 1)
354
- assert_almost_equal(R, result, 6)
355
-
356
- def test_calculate_deltat(self):
357
- result_mix_year = self.spa.calculate_deltat(mix_year_array, month)
358
- assert_almost_equal(mix_year_actual, result_mix_year)
359
-
360
- result_mix_month = self.spa.calculate_deltat(year, mix_month_array)
361
- assert_almost_equal(mix_month_actual, result_mix_month)
362
-
363
- result_array = self.spa.calculate_deltat(year_array, month_array)
364
- assert_almost_equal(dt_actual_array, result_array, 3)
365
-
366
- result_scalar = self.spa.calculate_deltat(year, month)
367
- assert_almost_equal(dt_actual, result_scalar)
368
-
369
-
370
- class NumpySpaTest(unittest.TestCase, SpaBase):
371
- """Import spa without compiling to numba then run tests"""
372
- @classmethod
373
- def setUpClass(self):
374
- os.environ['PVLIB_USE_NUMBA'] = '0'
375
- import pvlib.spa as spa
376
- spa = reload(spa)
377
- self.spa = spa
378
-
379
- @classmethod
380
- def tearDownClass(self):
381
- del os.environ['PVLIB_USE_NUMBA']
382
-
383
- def test_julian_day(self):
384
- assert_almost_equal(JD, self.spa.julian_day(unixtimes)[0], 6)
385
-
386
-
387
- @requires_numba
388
- class NumbaSpaTest(unittest.TestCase, SpaBase):
389
- """Import spa, compiling to numba, and run tests"""
390
- @classmethod
391
- def setUpClass(self):
392
- os.environ['PVLIB_USE_NUMBA'] = '1'
393
- import pvlib.spa as spa
394
- spa = reload(spa)
395
- self.spa = spa
396
-
397
- @classmethod
398
- def tearDownClass(self):
399
- del os.environ['PVLIB_USE_NUMBA']
400
-
401
- def test_julian_day(self):
402
- assert_almost_equal(JD, self.spa.julian_day(unixtimes[0]), 6)
403
-
404
- def test_solar_position_singlethreaded(self):
405
- assert_almost_equal(
406
- np.array([[theta, theta0, e, e0, Phi]]).T, self.spa.solar_position(
407
- unixtimes, lat, lon, elev, pressure, temp, delta_t,
408
- atmos_refract, numthreads=1)[:-1], 5)
409
- assert_almost_equal(
410
- np.array([[v, alpha, delta]]).T, self.spa.solar_position(
411
- unixtimes, lat, lon, elev, pressure, temp, delta_t,
412
- atmos_refract, numthreads=1, sst=True)[:3], 5)
413
-
414
- def test_solar_position_multithreaded(self):
415
- result = np.array([theta, theta0, e, e0, Phi])
416
- nresult = np.array([result, result, result]).T
417
- times = np.array([unixtimes[0], unixtimes[0], unixtimes[0]])
418
- assert_almost_equal(
419
- nresult, self.spa.solar_position(
420
- times, lat, lon, elev, pressure, temp, delta_t,
421
- atmos_refract, numthreads=3)[:-1], 5)
422
- result = np.array([v, alpha, delta])
423
- nresult = np.array([result, result, result]).T
424
- assert_almost_equal(
425
- nresult, self.spa.solar_position(
426
- times, lat, lon, elev, pressure, temp, delta_t,
427
- atmos_refract, numthreads=3, sst=True)[:3], 5)
428
-
429
-
430
- # Define extra test cases for issue #2077
431
- test_cases_issue_2207 = [
432
- ((2000, 1, 1, 12, 0, 0), 2451545.0),
433
- ((1999, 1, 1, 0, 0, 0), 2451179.5),
434
- ((1987, 1, 27, 0, 0, 0), 2446822.5),
435
- ((1987, 6, 19, 12, 0, 0), 2446966.0),
436
- ((1988, 1, 27, 0, 0, 0), 2447187.5),
437
- ((1988, 6, 19, 12, 0, 0), 2447332.0),
438
- ((1900, 1, 1, 0, 0, 0), 2415020.5),
439
- ((1600, 1, 1, 0, 0, 0), 2305447.5),
440
- ((1600, 12, 31, 0, 0, 0), 2305812.5),
441
- ((837, 4, 10, 7, 12, 0), 2026871.8),
442
- ((-123, 12, 31, 0, 0, 0), 1676496.5),
443
- ((-122, 1, 1, 0, 0, 0), 1676497.5),
444
- ((-1000, 7, 12, 12, 0, 0), 1356001.0),
445
- ((-1000, 2, 29, 0, 0, 0), 1355866.5),
446
- ((-1001, 8, 17, 21, 36, 0), 1355671.4),
447
- ((-4712, 1, 1, 12, 0, 0), 0.0),
448
- ]
449
-
450
-
451
- @pytest.mark.parametrize("inputs, expected", test_cases_issue_2207)
452
- def test_julian_day_issue_2207(inputs, expected):
453
- result = pvlib.spa.julian_day_dt(*inputs, microsecond=0)
454
- assert result == expected, f"Failed for inputs {inputs}"