pvlib 0.9.4a1__py3-none-any.whl → 0.10.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 (86) hide show
  1. pvlib/__init__.py +3 -2
  2. pvlib/atmosphere.py +23 -173
  3. pvlib/bifacial/infinite_sheds.py +88 -277
  4. pvlib/bifacial/utils.py +270 -28
  5. pvlib/data/adr-library-cec-inverters-2019-03-05.csv +5009 -0
  6. pvlib/data/precise_iv_curves1.json +10251 -0
  7. pvlib/data/precise_iv_curves2.json +10251 -0
  8. pvlib/data/precise_iv_curves_parameter_sets1.csv +33 -0
  9. pvlib/data/precise_iv_curves_parameter_sets2.csv +33 -0
  10. pvlib/data/test_psm3_2017.csv +17521 -17521
  11. pvlib/data/test_psm3_2019_5min.csv +288 -288
  12. pvlib/data/test_read_psm3.csv +17522 -17522
  13. pvlib/data/test_read_pvgis_horizon.csv +49 -0
  14. pvlib/data/variables_style_rules.csv +3 -0
  15. pvlib/iam.py +207 -51
  16. pvlib/inverter.py +6 -1
  17. pvlib/iotools/__init__.py +7 -2
  18. pvlib/iotools/acis.py +516 -0
  19. pvlib/iotools/midc.py +4 -4
  20. pvlib/iotools/psm3.py +59 -42
  21. pvlib/iotools/pvgis.py +84 -28
  22. pvlib/iotools/sodapro.py +8 -6
  23. pvlib/iotools/srml.py +121 -18
  24. pvlib/iotools/surfrad.py +2 -2
  25. pvlib/iotools/tmy.py +146 -102
  26. pvlib/irradiance.py +270 -15
  27. pvlib/ivtools/sde.py +14 -20
  28. pvlib/ivtools/sdm.py +31 -20
  29. pvlib/ivtools/utils.py +127 -6
  30. pvlib/location.py +3 -2
  31. pvlib/modelchain.py +67 -70
  32. pvlib/pvarray.py +225 -0
  33. pvlib/pvsystem.py +169 -539
  34. pvlib/shading.py +43 -2
  35. pvlib/singlediode.py +216 -66
  36. pvlib/snow.py +36 -15
  37. pvlib/soiling.py +3 -3
  38. pvlib/spa.py +327 -368
  39. pvlib/spectrum/__init__.py +8 -2
  40. pvlib/spectrum/mismatch.py +335 -0
  41. pvlib/temperature.py +124 -13
  42. pvlib/tests/bifacial/test_infinite_sheds.py +44 -106
  43. pvlib/tests/bifacial/test_utils.py +102 -5
  44. pvlib/tests/conftest.py +0 -31
  45. pvlib/tests/iotools/test_acis.py +213 -0
  46. pvlib/tests/iotools/test_midc.py +6 -6
  47. pvlib/tests/iotools/test_psm3.py +7 -5
  48. pvlib/tests/iotools/test_pvgis.py +21 -14
  49. pvlib/tests/iotools/test_sodapro.py +1 -1
  50. pvlib/tests/iotools/test_srml.py +71 -6
  51. pvlib/tests/iotools/test_tmy.py +43 -8
  52. pvlib/tests/ivtools/test_sde.py +19 -17
  53. pvlib/tests/ivtools/test_sdm.py +9 -4
  54. pvlib/tests/ivtools/test_utils.py +96 -1
  55. pvlib/tests/test_atmosphere.py +8 -64
  56. pvlib/tests/test_clearsky.py +0 -1
  57. pvlib/tests/test_iam.py +74 -1
  58. pvlib/tests/test_irradiance.py +56 -2
  59. pvlib/tests/test_location.py +1 -1
  60. pvlib/tests/test_modelchain.py +33 -76
  61. pvlib/tests/test_pvarray.py +46 -0
  62. pvlib/tests/test_pvsystem.py +366 -201
  63. pvlib/tests/test_shading.py +35 -0
  64. pvlib/tests/test_singlediode.py +306 -29
  65. pvlib/tests/test_snow.py +84 -1
  66. pvlib/tests/test_soiling.py +8 -7
  67. pvlib/tests/test_solarposition.py +7 -7
  68. pvlib/tests/test_spa.py +6 -7
  69. pvlib/tests/test_spectrum.py +145 -1
  70. pvlib/tests/test_temperature.py +29 -11
  71. pvlib/tests/test_tools.py +41 -0
  72. pvlib/tests/test_tracking.py +0 -149
  73. pvlib/tools.py +49 -25
  74. pvlib/tracking.py +1 -269
  75. pvlib-0.10.0.dist-info/AUTHORS.md +35 -0
  76. {pvlib-0.9.4a1.dist-info → pvlib-0.10.0.dist-info}/LICENSE +5 -2
  77. {pvlib-0.9.4a1.dist-info → pvlib-0.10.0.dist-info}/METADATA +3 -13
  78. {pvlib-0.9.4a1.dist-info → pvlib-0.10.0.dist-info}/RECORD +80 -75
  79. {pvlib-0.9.4a1.dist-info → pvlib-0.10.0.dist-info}/WHEEL +1 -1
  80. pvlib/data/adr-library-2013-10-01.csv +0 -1762
  81. pvlib/forecast.py +0 -1211
  82. pvlib/iotools/ecmwf_macc.py +0 -312
  83. pvlib/tests/iotools/test_ecmwf_macc.py +0 -162
  84. pvlib/tests/test_forecast.py +0 -228
  85. pvlib-0.9.4a1.dist-info/AUTHORS.md +0 -32
  86. {pvlib-0.9.4a1.dist-info → pvlib-0.10.0.dist-info}/top_level.txt +0 -0
pvlib/pvarray.py ADDED
@@ -0,0 +1,225 @@
1
+ """
2
+ This module contains implementations of PV module and array electrical models.
3
+
4
+ These models are used to predict the electrical behavior of pv modules
5
+ or collections of pv modules (arrays). The primary inputs are
6
+ effective irradiance and operating temperature and the outputs may range from
7
+ power or efficiency at the maximum power point to complete IV curves.
8
+ Supporting functions and parameter fitting functions may also be found here.
9
+ """
10
+
11
+ import numpy as np
12
+ from scipy.optimize import curve_fit
13
+ from scipy.special import exp10
14
+
15
+
16
+ def pvefficiency_adr(effective_irradiance, temp_cell,
17
+ k_a, k_d, tc_d, k_rs, k_rsh):
18
+ '''
19
+ Calculate PV module efficiency using the ADR model.
20
+
21
+ The efficiency varies with irradiance and operating temperature
22
+ and is determined by 5 model parameters as described in [1]_.
23
+
24
+ Parameters
25
+ ----------
26
+ effective_irradiance : numeric, non-negative
27
+ The effective irradiance incident on the PV module. [W/m^2]
28
+
29
+ temp_cell : numeric
30
+ The PV module operating temperature. [°C]
31
+
32
+ k_a : numeric
33
+ Absolute scaling factor, which is equal to the efficiency at
34
+ reference conditions. This factor allows the model to be used
35
+ with relative or absolute efficiencies, and to accommodate data sets
36
+ which are not perfectly normalized but have a slight bias at
37
+ the reference conditions. [unitless]
38
+
39
+ k_d : numeric, negative
40
+ “Dark irradiance” or diode coefficient which influences the voltage
41
+ increase with irradiance. [unitless]
42
+
43
+ tc_d : numeric
44
+ Temperature coefficient of the diode coefficient, which indirectly
45
+ influences voltage. Because it is the only temperature coefficient
46
+ in the model, its value will also reflect secondary temperature
47
+ dependencies that are present in the PV module. [unitless]
48
+
49
+ k_rs : numeric
50
+ Series resistance loss coefficient. Because of the normalization
51
+ it can be read as a power loss fraction at reference conditions.
52
+ For example, if ``k_rs`` is 0.05, the internal loss assigned to the
53
+ series resistance has a magnitude equal to 5% of the module output.
54
+ [unitless]
55
+
56
+ k_rsh : numeric
57
+ Shunt resistance loss coefficient. Can be interpreted as a power
58
+ loss fraction at reference conditions like ``k_rs``.
59
+ [unitless]
60
+
61
+ Returns
62
+ -------
63
+ eta : numeric
64
+ The efficiency of the module at the specified irradiance and
65
+ temperature.
66
+
67
+ Notes
68
+ -----
69
+ Efficiency values ``eta`` may be absolute or relative, and may be expressed
70
+ as percent or per unit. This is determined by the efficiency data
71
+ used to derive values for the 5 model parameters. The first model
72
+ parameter ``k_a`` is equal to the efficiency at STC and therefore
73
+ indicates the efficiency scale being used. ``k_a`` can also be changed
74
+ freely to adjust the scale, or to change the module to a slightly
75
+ higher or lower efficiency class.
76
+
77
+ All arguments may be scalars or array-like. If multiple arguments
78
+ are array-like they must be the same shape or broadcastable to the
79
+ same shape.
80
+
81
+ See also
82
+ --------
83
+ pvlib.pvarray.fit_pvefficiency_adr
84
+
85
+ References
86
+ ----------
87
+ .. [1] A. Driesse and J. S. Stein, "From IEC 61853 power measurements
88
+ to PV system simulations", Sandia Report No. SAND2020-3877, 2020.
89
+ :doi:`10.2172/1615179`
90
+
91
+ .. [2] A. Driesse, M. Theristis and J. S. Stein, "A New Photovoltaic Module
92
+ Efficiency Model for Energy Prediction and Rating," in IEEE Journal
93
+ of Photovoltaics, vol. 11, no. 2, pp. 527-534, March 2021.
94
+ :doi:`10.1109/JPHOTOV.2020.3045677`
95
+
96
+ Examples
97
+ --------
98
+ >>> pvefficiency_adr([1000, 200], 25,
99
+ k_a=100, k_d=-6.0, tc_d=0.02, k_rs=0.05, k_rsh=0.10)
100
+ array([100. , 92.79729308])
101
+
102
+ >>> pvefficiency_adr([1000, 200], 25,
103
+ k_a=1.0, k_d=-6.0, tc_d=0.02, k_rs=0.05, k_rsh=0.10)
104
+ array([1. , 0.92797293])
105
+
106
+ '''
107
+ # Contributed by Anton Driesse (@adriesse), PV Performance Labs, Dec. 2022
108
+ # Adapted from https://github.com/adriesse/pvpltools-python
109
+
110
+ k_a = np.array(k_a)
111
+ k_d = np.array(k_d)
112
+ tc_d = np.array(tc_d)
113
+ k_rs = np.array(k_rs)
114
+ k_rsh = np.array(k_rsh)
115
+
116
+ # normalize the irradiance
117
+ G_REF = np.array(1000.)
118
+ s = effective_irradiance / G_REF
119
+
120
+ # obtain the difference from reference temperature
121
+ T_REF = np.array(25.)
122
+ dt = temp_cell - T_REF
123
+
124
+ # equation 29 in JPV
125
+ s_o = exp10(k_d + (dt * tc_d)) # noQA: E221
126
+ s_o_ref = exp10(k_d)
127
+
128
+ # equation 28 and 30 in JPV
129
+ # the constant k_v does not appear here because it cancels out
130
+ v = np.log(s / s_o + 1) # noQA: E221
131
+ v /= np.log(1 / s_o_ref + 1)
132
+
133
+ # equation 25 in JPV
134
+ eta = k_a * ((1 + k_rs + k_rsh) * v - k_rs * s - k_rsh * v**2)
135
+
136
+ return eta
137
+
138
+
139
+ def fit_pvefficiency_adr(effective_irradiance, temp_cell, eta,
140
+ dict_output=True, **kwargs):
141
+ """
142
+ Determine the parameters of the ADR module efficiency model by non-linear
143
+ least-squares fit to lab or field measurements.
144
+
145
+ Parameters
146
+ ----------
147
+ effective_irradiance : numeric, non-negative
148
+ Effective irradiance incident on the PV module. [W/m^2]
149
+
150
+ temp_cell : numeric
151
+ PV module operating temperature. [°C]
152
+
153
+ eta : numeric
154
+ Efficiency of the PV module at the specified irradiance and
155
+ temperature(s). [unitless] or [%]
156
+
157
+ dict_output : boolean, optional
158
+ When True (default), return the result as a dictionary; when False,
159
+ return the result as a numpy array.
160
+
161
+ kwargs :
162
+ Optional keyword arguments passed to `scipy.optimize.curve_fit`.
163
+ These kwargs can over-ride some options set within this function,
164
+ which could be interesting for very advanced users.
165
+
166
+ Returns
167
+ -------
168
+ popt : array or dict
169
+ Optimal values for the parameters.
170
+
171
+ Notes
172
+ -----
173
+ The best fits are obtained when the lab or field data include a wide range
174
+ of both irradiance and temperature values. A minimal data set
175
+ would consist of 6 operating points covering low, medium and high
176
+ irradiance levels at two operating temperatures.
177
+
178
+ See also
179
+ --------
180
+ pvlib.pvarray.pvefficiency_adr
181
+ scipy.optimize.curve_fit
182
+
183
+ """
184
+ # Contributed by Anton Driesse (@adriesse), PV Performance Labs, Dec. 2022
185
+ # Adapted from https://github.com/adriesse/pvpltools-python
186
+
187
+ irradiance = np.asarray(effective_irradiance, dtype=float).reshape(-1)
188
+ temperature = np.asarray(temp_cell, dtype=float).reshape(-1)
189
+ eta = np.asarray(eta, dtype=float).reshape(-1)
190
+
191
+ eta_max = np.max(eta)
192
+
193
+ P_NAMES = ['k_a', 'k_d', 'tc_d', 'k_rs', 'k_rsh']
194
+ P_MAX = [+np.inf, 0, +0.1, 1, 1] # noQA: E221
195
+ P_MIN = [0, -12, -0.1, 0, 0] # noQA: E221
196
+ P0 = [eta_max, -6, 0.0, 0, 0] # noQA: E221
197
+ P_SCALE = [eta_max, 10, 0.1, 1, 1]
198
+
199
+ SIGMA = 1 / np.sqrt(irradiance / 1000)
200
+
201
+ fit_options = dict(p0=P0,
202
+ bounds=[P_MIN, P_MAX],
203
+ method='trf',
204
+ x_scale=P_SCALE,
205
+ loss='soft_l1',
206
+ f_scale=eta_max * 0.05,
207
+ sigma=SIGMA,
208
+ )
209
+
210
+ fit_options.update(kwargs)
211
+
212
+ def adr_wrapper(xdata, *params):
213
+ return pvefficiency_adr(*xdata, *params)
214
+
215
+ result = curve_fit(adr_wrapper,
216
+ xdata=[irradiance, temperature],
217
+ ydata=eta,
218
+ **fit_options,
219
+ )
220
+ popt = result[0]
221
+
222
+ if dict_output:
223
+ return dict(zip(P_NAMES, popt))
224
+ else:
225
+ return popt