forked from pvlib/pvlib-python
/
pvsystem.py
3412 lines (2791 loc) · 120 KB
/
pvsystem.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""
The ``pvsystem`` module contains functions for modeling the output and
performance of PV modules and inverters.
"""
from collections import OrderedDict
import functools
import io
import itertools
import os
from urllib.request import urlopen
import numpy as np
from scipy import constants
import pandas as pd
from dataclasses import dataclass
from abc import ABC, abstractmethod
from typing import Optional
from pvlib._deprecation import deprecated, warn_deprecated
from pvlib import (atmosphere, iam, inverter, irradiance,
singlediode as _singlediode, temperature)
from pvlib.tools import _build_kwargs, _build_args
# a dict of required parameter names for each DC power model
_DC_MODEL_PARAMS = {
'sapm': {
'A0', 'A1', 'A2', 'A3', 'A4', 'B0', 'B1', 'B2', 'B3',
'B4', 'B5', 'C0', 'C1', 'C2', 'C3', 'C4', 'C5', 'C6',
'C7', 'Isco', 'Impo', 'Voco', 'Vmpo', 'Aisc', 'Aimp', 'Bvoco',
'Mbvoc', 'Bvmpo', 'Mbvmp', 'N', 'Cells_in_Series',
'IXO', 'IXXO', 'FD'},
'desoto': {
'alpha_sc', 'a_ref', 'I_L_ref', 'I_o_ref',
'R_sh_ref', 'R_s'},
'cec': {
'alpha_sc', 'a_ref', 'I_L_ref', 'I_o_ref',
'R_sh_ref', 'R_s', 'Adjust'},
'pvsyst': {
'gamma_ref', 'mu_gamma', 'I_L_ref', 'I_o_ref',
'R_sh_ref', 'R_sh_0', 'R_s', 'alpha_sc', 'EgRef',
'cells_in_series'},
'singlediode': {
'alpha_sc', 'a_ref', 'I_L_ref', 'I_o_ref',
'R_sh_ref', 'R_s'},
'pvwatts': {'pdc0', 'gamma_pdc'}
}
def _unwrap_single_value(func):
"""Decorator for functions that return iterables.
If the length of the iterable returned by `func` is 1, then
the single member of the iterable is returned. If the length is
greater than 1, then entire iterable is returned.
Adds 'unwrap' as a keyword argument that can be set to False
to force the return value to be a tuple, regardless of its length.
"""
@functools.wraps(func)
def f(*args, **kwargs):
unwrap = kwargs.pop('unwrap', True)
x = func(*args, **kwargs)
if unwrap and len(x) == 1:
return x[0]
return x
return f
def _check_deprecated_passthrough(func):
"""
Decorator to warn or error when getting and setting the "pass-through"
PVSystem properties that have been moved to Array. Emits a warning for
PVSystems with only one Array and raises an error for PVSystems with
more than one Array.
"""
@functools.wraps(func)
def wrapper(self, *args, **kwargs):
pvsystem_attr = func.__name__
class_name = self.__class__.__name__ # PVSystem or SingleAxisTracker
overrides = { # some Array attrs aren't the same as PVSystem
'strings_per_inverter': 'strings',
}
array_attr = overrides.get(pvsystem_attr, pvsystem_attr)
alternative = f'{class_name}.arrays[i].{array_attr}'
if len(self.arrays) > 1:
raise AttributeError(
f'{class_name}.{pvsystem_attr} not supported for multi-array '
f'systems. Set {array_attr} for each Array in '
f'{class_name}.arrays instead.')
wrapped = deprecated('0.9', alternative=alternative, removal='0.10',
name=f"{class_name}.{pvsystem_attr}")(func)
return wrapped(self, *args, **kwargs)
return wrapper
# not sure if this belongs in the pvsystem module.
# maybe something more like core.py? It may eventually grow to
# import a lot more functionality from other modules.
class PVSystem:
"""
The PVSystem class defines a standard set of PV system attributes
and modeling functions. This class describes the collection and
interactions of PV system components rather than an installed system
on the ground. It is typically used in combination with
:py:class:`~pvlib.location.Location` and
:py:class:`~pvlib.modelchain.ModelChain`
objects.
The class supports basic system topologies consisting of:
* `N` total modules arranged in series
(`modules_per_string=N`, `strings_per_inverter=1`).
* `M` total modules arranged in parallel
(`modules_per_string=1`, `strings_per_inverter=M`).
* `NxM` total modules arranged in `M` strings of `N` modules each
(`modules_per_string=N`, `strings_per_inverter=M`).
The class is complementary to the module-level functions.
The attributes should generally be things that don't change about
the system, such the type of module and the inverter. The instance
methods accept arguments for things that do change, such as
irradiance and temperature.
Parameters
----------
arrays : iterable of Array, optional
List of arrays that are part of the system. If not specified
a single array is created from the other parameters (e.g.
`surface_tilt`, `surface_azimuth`). Must contain at least one Array,
if length of arrays is 0 a ValueError is raised. If `arrays` is
specified the following PVSystem parameters are ignored:
- `surface_tilt`
- `surface_azimuth`
- `albedo`
- `surface_type`
- `module`
- `module_type`
- `module_parameters`
- `temperature_model_parameters`
- `modules_per_string`
- `strings_per_inverter`
surface_tilt: float or array-like, default 0
Surface tilt angles in decimal degrees.
The tilt angle is defined as degrees from horizontal
(e.g. surface facing up = 0, surface facing horizon = 90)
surface_azimuth: float or array-like, default 180
Azimuth angle of the module surface.
North=0, East=90, South=180, West=270.
albedo : None or float, default None
Ground surface albedo. If ``None``, then ``surface_type`` is used
to look up a value in ``irradiance.SURFACE_ALBEDOS``.
If ``surface_type`` is also None then a ground surface albedo
of 0.25 is used.
surface_type : None or string, default None
The ground surface type. See ``irradiance.SURFACE_ALBEDOS`` for
valid values.
module : None or string, default None
The model name of the modules.
May be used to look up the module_parameters dictionary
via some other method.
module_type : None or string, default 'glass_polymer'
Describes the module's construction. Valid strings are 'glass_polymer'
and 'glass_glass'. Used for cell and module temperature calculations.
module_parameters : None, dict or Series, default None
Module parameters as defined by the SAPM, CEC, or other.
temperature_model_parameters : None, dict or Series, default None.
Temperature model parameters as required by one of the models in
pvlib.temperature (excluding poa_global, temp_air and wind_speed).
modules_per_string: int or float, default 1
See system topology discussion above.
strings_per_inverter: int or float, default 1
See system topology discussion above.
inverter : None or string, default None
The model name of the inverters.
May be used to look up the inverter_parameters dictionary
via some other method.
inverter_parameters : None, dict or Series, default None
Inverter parameters as defined by the SAPM, CEC, or other.
racking_model : None or string, default 'open_rack'
Valid strings are 'open_rack', 'close_mount', and 'insulated_back'.
Used to identify a parameter set for the SAPM cell temperature model.
losses_parameters : None, dict or Series, default None
Losses parameters as defined by PVWatts or other.
name : None or string, default None
**kwargs
Arbitrary keyword arguments.
Included for compatibility, but not used.
Raises
------
ValueError
If `arrays` is not None and has length 0.
See also
--------
pvlib.location.Location
pvlib.tracking.SingleAxisTracker
"""
def __init__(self,
arrays=None,
surface_tilt=0, surface_azimuth=180,
albedo=None, surface_type=None,
module=None, module_type=None,
module_parameters=None,
temperature_model_parameters=None,
modules_per_string=1, strings_per_inverter=1,
inverter=None, inverter_parameters=None,
racking_model=None, losses_parameters=None, name=None):
if arrays is None:
if losses_parameters is None:
array_losses_parameters = {}
else:
array_losses_parameters = _build_kwargs(['dc_ohmic_percent'],
losses_parameters)
self.arrays = (Array(
FixedMount(surface_tilt, surface_azimuth, racking_model),
albedo,
surface_type,
module,
module_type,
module_parameters,
temperature_model_parameters,
modules_per_string,
strings_per_inverter,
array_losses_parameters,
),)
elif len(arrays) == 0:
raise ValueError("PVSystem must have at least one Array. "
"If you want to create a PVSystem instance "
"with a single Array pass `arrays=None` and pass "
"values directly to PVSystem attributes, e.g., "
"`surface_tilt=30`")
else:
self.arrays = tuple(arrays)
self.inverter = inverter
if inverter_parameters is None:
self.inverter_parameters = {}
else:
self.inverter_parameters = inverter_parameters
if losses_parameters is None:
self.losses_parameters = {}
else:
self.losses_parameters = losses_parameters
self.name = name
def __repr__(self):
repr = f'PVSystem:\n name: {self.name}\n '
for array in self.arrays:
repr += '\n '.join(array.__repr__().split('\n'))
repr += '\n '
repr += f'inverter: {self.inverter}'
return repr
def _validate_per_array(self, values, system_wide=False):
"""Check that `values` is a tuple of the same length as
`self.arrays`.
If `values` is not a tuple it is packed in to a length-1 tuple before
the check. If the lengths are not the same a ValueError is raised,
otherwise the tuple `values` is returned.
When `system_wide` is True and `values` is not a tuple, `values`
is replicated to a tuple of the same length as `self.arrays` and that
tuple is returned.
"""
if system_wide and not isinstance(values, tuple):
return (values,) * self.num_arrays
if not isinstance(values, tuple):
values = (values,)
if len(values) != len(self.arrays):
raise ValueError("Length mismatch for per-array parameter")
return values
@_unwrap_single_value
def _infer_cell_type(self):
"""
Examines module_parameters and maps the Technology key for the CEC
database and the Material key for the Sandia database to a common
list of strings for cell type.
Returns
-------
cell_type: str
"""
return tuple(array._infer_cell_type() for array in self.arrays)
@_unwrap_single_value
def get_aoi(self, solar_zenith, solar_azimuth):
"""Get the angle of incidence on the Array(s) in the system.
Parameters
----------
solar_zenith : float or Series.
Solar zenith angle.
solar_azimuth : float or Series.
Solar azimuth angle.
Returns
-------
aoi : Series or tuple of Series
The angle of incidence
"""
return tuple(array.get_aoi(solar_zenith, solar_azimuth)
for array in self.arrays)
@_unwrap_single_value
def get_irradiance(self, solar_zenith, solar_azimuth, dni, ghi, dhi,
dni_extra=None, airmass=None, albedo=None,
model='haydavies', **kwargs):
"""
Uses the :py:func:`irradiance.get_total_irradiance` function to
calculate the plane of array irradiance components on the tilted
surfaces defined by each array's ``surface_tilt`` and
``surface_azimuth``.
Parameters
----------
solar_zenith : float or Series
Solar zenith angle.
solar_azimuth : float or Series
Solar azimuth angle.
dni : float or Series or tuple of float or Series
Direct Normal Irradiance. [W/m2]
ghi : float or Series or tuple of float or Series
Global horizontal irradiance. [W/m2]
dhi : float or Series or tuple of float or Series
Diffuse horizontal irradiance. [W/m2]
dni_extra : None, float, Series or tuple of float or Series,\
default None
Extraterrestrial direct normal irradiance. [W/m2]
airmass : None, float or Series, default None
Airmass. [unitless]
albedo : None, float or Series, default None
Ground surface albedo. [unitless]
model : String, default 'haydavies'
Irradiance model.
kwargs
Extra parameters passed to :func:`irradiance.get_total_irradiance`.
Notes
-----
Each of `dni`, `ghi`, and `dni` parameters may be passed as a tuple
to provide different irradiance for each array in the system. If not
passed as a tuple then the same value is used for input to each Array.
If passed as a tuple the length must be the same as the number of
Arrays.
Returns
-------
poa_irradiance : DataFrame or tuple of DataFrame
Column names are: ``'poa_global', 'poa_direct', 'poa_diffuse',
'poa_sky_diffuse', 'poa_ground_diffuse'``.
See also
--------
pvlib.irradiance.get_total_irradiance
"""
dni = self._validate_per_array(dni, system_wide=True)
ghi = self._validate_per_array(ghi, system_wide=True)
dhi = self._validate_per_array(dhi, system_wide=True)
albedo = self._validate_per_array(albedo, system_wide=True)
return tuple(
array.get_irradiance(solar_zenith, solar_azimuth,
dni, ghi, dhi,
dni_extra=dni_extra, airmass=airmass,
albedo=albedo, model=model, **kwargs)
for array, dni, ghi, dhi, albedo in zip(
self.arrays, dni, ghi, dhi, albedo
)
)
@_unwrap_single_value
def get_iam(self, aoi, iam_model='physical'):
"""
Determine the incidence angle modifier using the method specified by
``iam_model``.
Parameters for the selected IAM model are expected to be in
``PVSystem.module_parameters``. Default parameters are available for
the 'physical', 'ashrae' and 'martin_ruiz' models.
Parameters
----------
aoi : numeric or tuple of numeric
The angle of incidence in degrees.
aoi_model : string, default 'physical'
The IAM model to be used. Valid strings are 'physical', 'ashrae',
'martin_ruiz' and 'sapm'.
Returns
-------
iam : numeric or tuple of numeric
The AOI modifier.
Raises
------
ValueError
if `iam_model` is not a valid model name.
"""
aoi = self._validate_per_array(aoi)
return tuple(array.get_iam(aoi, iam_model)
for array, aoi in zip(self.arrays, aoi))
@_unwrap_single_value
def get_cell_temperature(self, poa_global, temp_air, wind_speed, model,
effective_irradiance=None):
"""
Determine cell temperature using the method specified by ``model``.
Parameters
----------
poa_global : numeric or tuple of numeric
Total incident irradiance in W/m^2.
temp_air : numeric or tuple of numeric
Ambient dry bulb temperature in degrees C.
wind_speed : numeric or tuple of numeric
Wind speed in m/s.
model : str
Supported models include ``'sapm'``, ``'pvsyst'``,
``'faiman'``, ``'fuentes'``, and ``'noct_sam'``
effective_irradiance : numeric or tuple of numeric, optional
The irradiance that is converted to photocurrent in W/m^2.
Only used for some models.
Returns
-------
numeric or tuple of numeric
Values in degrees C.
See Also
--------
Array.get_cell_temperature
Notes
-----
The `temp_air` and `wind_speed` parameters may be passed as tuples
to provide different values for each Array in the system. If passed as
a tuple the length must be the same as the number of Arrays. If not
passed as a tuple then the same value is used for each Array.
"""
poa_global = self._validate_per_array(poa_global)
temp_air = self._validate_per_array(temp_air, system_wide=True)
wind_speed = self._validate_per_array(wind_speed, system_wide=True)
# Not used for all models, but Array.get_cell_temperature handles it
effective_irradiance = self._validate_per_array(effective_irradiance,
system_wide=True)
return tuple(
array.get_cell_temperature(poa_global, temp_air, wind_speed,
model, effective_irradiance)
for array, poa_global, temp_air, wind_speed, effective_irradiance
in zip(
self.arrays, poa_global, temp_air, wind_speed,
effective_irradiance
)
)
@_unwrap_single_value
def calcparams_desoto(self, effective_irradiance, temp_cell):
"""
Use the :py:func:`calcparams_desoto` function, the input
parameters and ``self.module_parameters`` to calculate the
module currents and resistances.
Parameters
----------
effective_irradiance : numeric or tuple of numeric
The irradiance (W/m2) that is converted to photocurrent.
temp_cell : float or Series or tuple of float or Series
The average cell temperature of cells within a module in C.
Returns
-------
See pvsystem.calcparams_desoto for details
"""
effective_irradiance = self._validate_per_array(effective_irradiance)
temp_cell = self._validate_per_array(temp_cell)
build_kwargs = functools.partial(
_build_kwargs,
['a_ref', 'I_L_ref', 'I_o_ref', 'R_sh_ref',
'R_s', 'alpha_sc', 'EgRef', 'dEgdT',
'irrad_ref', 'temp_ref']
)
return tuple(
calcparams_desoto(
effective_irradiance, temp_cell,
**build_kwargs(array.module_parameters)
)
for array, effective_irradiance, temp_cell
in zip(self.arrays, effective_irradiance, temp_cell)
)
@_unwrap_single_value
def calcparams_cec(self, effective_irradiance, temp_cell):
"""
Use the :py:func:`calcparams_cec` function, the input
parameters and ``self.module_parameters`` to calculate the
module currents and resistances.
Parameters
----------
effective_irradiance : numeric or tuple of numeric
The irradiance (W/m2) that is converted to photocurrent.
temp_cell : float or Series or tuple of float or Series
The average cell temperature of cells within a module in C.
Returns
-------
See pvsystem.calcparams_cec for details
"""
effective_irradiance = self._validate_per_array(effective_irradiance)
temp_cell = self._validate_per_array(temp_cell)
build_kwargs = functools.partial(
_build_kwargs,
['a_ref', 'I_L_ref', 'I_o_ref', 'R_sh_ref',
'R_s', 'alpha_sc', 'Adjust', 'EgRef', 'dEgdT',
'irrad_ref', 'temp_ref']
)
return tuple(
calcparams_cec(
effective_irradiance, temp_cell,
**build_kwargs(array.module_parameters)
)
for array, effective_irradiance, temp_cell
in zip(self.arrays, effective_irradiance, temp_cell)
)
@_unwrap_single_value
def calcparams_pvsyst(self, effective_irradiance, temp_cell):
"""
Use the :py:func:`calcparams_pvsyst` function, the input
parameters and ``self.module_parameters`` to calculate the
module currents and resistances.
Parameters
----------
effective_irradiance : numeric or tuple of numeric
The irradiance (W/m2) that is converted to photocurrent.
temp_cell : float or Series or tuple of float or Series
The average cell temperature of cells within a module in C.
Returns
-------
See pvsystem.calcparams_pvsyst for details
"""
effective_irradiance = self._validate_per_array(effective_irradiance)
temp_cell = self._validate_per_array(temp_cell)
build_kwargs = functools.partial(
_build_kwargs,
['gamma_ref', 'mu_gamma', 'I_L_ref', 'I_o_ref',
'R_sh_ref', 'R_sh_0', 'R_sh_exp',
'R_s', 'alpha_sc', 'EgRef',
'irrad_ref', 'temp_ref',
'cells_in_series']
)
return tuple(
calcparams_pvsyst(
effective_irradiance, temp_cell,
**build_kwargs(array.module_parameters)
)
for array, effective_irradiance, temp_cell
in zip(self.arrays, effective_irradiance, temp_cell)
)
@_unwrap_single_value
def sapm(self, effective_irradiance, temp_cell):
"""
Use the :py:func:`sapm` function, the input parameters,
and ``self.module_parameters`` to calculate
Voc, Isc, Ix, Ixx, Vmp, and Imp.
Parameters
----------
effective_irradiance : numeric or tuple of numeric
The irradiance (W/m2) that is converted to photocurrent.
temp_cell : float or Series or tuple of float or Series
The average cell temperature of cells within a module in C.
Returns
-------
See pvsystem.sapm for details
"""
effective_irradiance = self._validate_per_array(effective_irradiance)
temp_cell = self._validate_per_array(temp_cell)
return tuple(
sapm(effective_irradiance, temp_cell, array.module_parameters)
for array, effective_irradiance, temp_cell
in zip(self.arrays, effective_irradiance, temp_cell)
)
@deprecated('0.9', alternative='PVSystem.get_cell_temperature',
removal='0.10.0')
def sapm_celltemp(self, poa_global, temp_air, wind_speed):
"""Uses :py:func:`pvlib.temperature.sapm_cell` to calculate cell
temperatures.
Parameters
----------
poa_global : numeric or tuple of numeric
Total incident irradiance in W/m^2.
temp_air : numeric or tuple of numeric
Ambient dry bulb temperature in degrees C.
wind_speed : numeric or tuple of numeric
Wind speed in m/s at a height of 10 meters.
Returns
-------
numeric or tuple of numeric
values in degrees C.
Notes
-----
The `temp_air` and `wind_speed` parameters may be passed as tuples
to provide different values for each Array in the system. If not
passed as a tuple then the same value is used for input to each Array.
If passed as a tuple the length must be the same as the number of
Arrays.
"""
return self.get_cell_temperature(poa_global, temp_air, wind_speed,
model='sapm')
@_unwrap_single_value
def sapm_spectral_loss(self, airmass_absolute):
"""
Use the :py:func:`sapm_spectral_loss` function, the input
parameters, and ``self.module_parameters`` to calculate F1.
Parameters
----------
airmass_absolute : numeric
Absolute airmass.
Returns
-------
F1 : numeric or tuple of numeric
The SAPM spectral loss coefficient.
"""
return tuple(
sapm_spectral_loss(airmass_absolute, array.module_parameters)
for array in self.arrays
)
@_unwrap_single_value
def sapm_effective_irradiance(self, poa_direct, poa_diffuse,
airmass_absolute, aoi,
reference_irradiance=1000):
"""
Use the :py:func:`sapm_effective_irradiance` function, the input
parameters, and ``self.module_parameters`` to calculate
effective irradiance.
Parameters
----------
poa_direct : numeric or tuple of numeric
The direct irradiance incident upon the module. [W/m2]
poa_diffuse : numeric or tuple of numeric
The diffuse irradiance incident on module. [W/m2]
airmass_absolute : numeric
Absolute airmass. [unitless]
aoi : numeric or tuple of numeric
Angle of incidence. [degrees]
Returns
-------
effective_irradiance : numeric or tuple of numeric
The SAPM effective irradiance. [W/m2]
"""
poa_direct = self._validate_per_array(poa_direct)
poa_diffuse = self._validate_per_array(poa_diffuse)
aoi = self._validate_per_array(aoi)
return tuple(
sapm_effective_irradiance(
poa_direct, poa_diffuse, airmass_absolute, aoi,
array.module_parameters)
for array, poa_direct, poa_diffuse, aoi
in zip(self.arrays, poa_direct, poa_diffuse, aoi)
)
@deprecated('0.9', alternative='PVSystem.get_cell_temperature',
removal='0.10.0')
def pvsyst_celltemp(self, poa_global, temp_air, wind_speed=1.0):
"""Uses :py:func:`pvlib.temperature.pvsyst_cell` to calculate cell
temperature.
Parameters
----------
poa_global : numeric or tuple of numeric
Total incident irradiance in W/m^2.
temp_air : numeric or tuple of numeric
Ambient dry bulb temperature in degrees C.
wind_speed : numeric or tuple of numeric, default 1.0
Wind speed in m/s measured at the same height for which the wind
loss factor was determined. The default value is 1.0, which is
the wind speed at module height used to determine NOCT.
Returns
-------
numeric or tuple of numeric
values in degrees C.
Notes
-----
The `temp_air` and `wind_speed` parameters may be passed as tuples
to provide different values for each Array in the system. If not
passed as a tuple then the same value is used for input to each Array.
If passed as a tuple the length must be the same as the number of
Arrays.
"""
return self.get_cell_temperature(poa_global, temp_air, wind_speed,
model='pvsyst')
@deprecated('0.9', alternative='PVSystem.get_cell_temperature',
removal='0.10.0')
def faiman_celltemp(self, poa_global, temp_air, wind_speed=1.0):
"""
Use :py:func:`pvlib.temperature.faiman` to calculate cell temperature.
Parameters
----------
poa_global : numeric or tuple of numeric
Total incident irradiance [W/m^2].
temp_air : numeric or tuple of numeric
Ambient dry bulb temperature [C].
wind_speed : numeric or tuple of numeric, default 1.0
Wind speed in m/s measured at the same height for which the wind
loss factor was determined. The default value 1.0 m/s is the wind
speed at module height used to determine NOCT. [m/s]
Returns
-------
numeric or tuple of numeric
values in degrees C.
Notes
-----
The `temp_air` and `wind_speed` parameters may be passed as tuples
to provide different values for each Array in the system. If not
passed as a tuple then the same value is used for input to each Array.
If passed as a tuple the length must be the same as the number of
Arrays.
"""
return self.get_cell_temperature(poa_global, temp_air, wind_speed,
model='faiman')
@deprecated('0.9', alternative='PVSystem.get_cell_temperature',
removal='0.10.0')
def fuentes_celltemp(self, poa_global, temp_air, wind_speed):
"""
Use :py:func:`pvlib.temperature.fuentes` to calculate cell temperature.
Parameters
----------
poa_global : pandas Series or tuple of Series
Total incident irradiance [W/m^2]
temp_air : pandas Series or tuple of Series
Ambient dry bulb temperature [C]
wind_speed : pandas Series or tuple of Series
Wind speed [m/s]
Returns
-------
temperature_cell : Series or tuple of Series
The modeled cell temperature [C]
Notes
-----
The Fuentes thermal model uses the module surface tilt for convection
modeling. The SAM implementation of PVWatts hardcodes the surface tilt
value at 30 degrees, ignoring whatever value is used for irradiance
transposition. If you want to match the PVWatts behavior you can
either leave ``surface_tilt`` unspecified to use the PVWatts default
of 30, or specify a ``surface_tilt`` value in the Array's
``temperature_model_parameters``.
The `temp_air`, `wind_speed`, and `surface_tilt` parameters may be
passed as tuples
to provide different values for each Array in the system. If not
passed as a tuple then the same value is used for input to each Array.
If passed as a tuple the length must be the same as the number of
Arrays.
"""
return self.get_cell_temperature(poa_global, temp_air, wind_speed,
model='fuentes')
@deprecated('0.9', alternative='PVSystem.get_cell_temperature',
removal='0.10.0')
def noct_sam_celltemp(self, poa_global, temp_air, wind_speed,
effective_irradiance=None):
"""
Use :py:func:`pvlib.temperature.noct_sam` to calculate cell
temperature.
Parameters
----------
poa_global : numeric or tuple of numeric
Total incident irradiance in W/m^2.
temp_air : numeric or tuple of numeric
Ambient dry bulb temperature in degrees C.
wind_speed : numeric or tuple of numeric
Wind speed in m/s at a height of 10 meters.
effective_irradiance : numeric, tuple of numeric, or None.
The irradiance that is converted to photocurrent. If None,
assumed equal to ``poa_global``. [W/m^2]
Returns
-------
temperature_cell : numeric or tuple of numeric
The modeled cell temperature [C]
Notes
-----
The `temp_air` and `wind_speed` parameters may be passed as tuples
to provide different values for each Array in the system. If not
passed as a tuple then the same value is used for input to each Array.
If passed as a tuple the length must be the same as the number of
Arrays.
"""
return self.get_cell_temperature(
poa_global, temp_air, wind_speed, model='noct_sam',
effective_irradiance=effective_irradiance)
@_unwrap_single_value
def first_solar_spectral_loss(self, pw, airmass_absolute):
"""
Use :py:func:`pvlib.atmosphere.first_solar_spectral_correction` to
calculate the spectral loss modifier. The model coefficients are
specific to the module's cell type, and are determined by searching
for one of the following keys in self.module_parameters (in order):
- 'first_solar_spectral_coefficients' (user-supplied coefficients)
- 'Technology' - a string describing the cell type, can be read from
the CEC module parameter database
- 'Material' - a string describing the cell type, can be read from
the Sandia module database.
Parameters
----------
pw : array-like
atmospheric precipitable water (cm).
airmass_absolute : array-like
absolute (pressure corrected) airmass.
Returns
-------
modifier: array-like or tuple of array-like
spectral mismatch factor (unitless) which can be multiplied
with broadband irradiance reaching a module's cells to estimate
effective irradiance, i.e., the irradiance that is converted to
electrical current.
"""
pw = self._validate_per_array(pw, system_wide=True)
def _spectral_correction(array, pw):
if 'first_solar_spectral_coefficients' in \
array.module_parameters.keys():
coefficients = \
array.module_parameters[
'first_solar_spectral_coefficients'
]
module_type = None
else:
module_type = array._infer_cell_type()
coefficients = None
return atmosphere.first_solar_spectral_correction(
pw, airmass_absolute,
module_type, coefficients
)
return tuple(
itertools.starmap(_spectral_correction, zip(self.arrays, pw))
)
def singlediode(self, photocurrent, saturation_current,
resistance_series, resistance_shunt, nNsVth,
ivcurve_pnts=None):
"""Wrapper around the :py:func:`pvlib.pvsystem.singlediode` function.
See :py:func:`pvsystem.singlediode` for details
"""
return singlediode(photocurrent, saturation_current,
resistance_series, resistance_shunt, nNsVth,
ivcurve_pnts=ivcurve_pnts)
def i_from_v(self, voltage, photocurrent, saturation_current,
resistance_series, resistance_shunt, nNsVth):
"""Wrapper around the :py:func:`pvlib.pvsystem.i_from_v` function.
See :py:func:`pvlib.pvsystem.i_from_v` for details.
.. versionchanged:: 0.10.0
The function's arguments have been reordered.
"""
return i_from_v(voltage, photocurrent, saturation_current,
resistance_series, resistance_shunt, nNsVth)
def get_ac(self, model, p_dc, v_dc=None):
r"""Calculates AC power from p_dc using the inverter model indicated
by model and self.inverter_parameters.
Parameters
----------
model : str
Must be one of 'sandia', 'adr', or 'pvwatts'.
p_dc : numeric, or tuple, list or array of numeric
DC power on each MPPT input of the inverter. Use tuple, list or
array for inverters with multiple MPPT inputs. If type is array,
p_dc must be 2d with axis 0 being the MPPT inputs. [W]
v_dc : numeric, or tuple, list or array of numeric
DC voltage on each MPPT input of the inverter. Required when
model='sandia' or model='adr'. Use tuple, list or
array for inverters with multiple MPPT inputs. If type is array,
v_dc must be 2d with axis 0 being the MPPT inputs. [V]
Returns
-------
power_ac : numeric
AC power output for the inverter. [W]
Raises
------
ValueError
If model is not one of 'sandia', 'adr' or 'pvwatts'.
ValueError
If model='adr' and the PVSystem has more than one array.
See also
--------
pvlib.inverter.sandia
pvlib.inverter.sandia_multi
pvlib.inverter.adr
pvlib.inverter.pvwatts
pvlib.inverter.pvwatts_multi
"""
model = model.lower()
multiple_arrays = self.num_arrays > 1
if model == 'sandia':
p_dc = self._validate_per_array(p_dc)