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