10
10
from pvlib .irradiance import beam_component , aoi , haydavies
11
11
12
12
def _vf_ground_sky_integ (surface_tilt , surface_azimuth , gcr , height ,
13
- pitch , max_rows = 10 , npoints = 100 ):
13
+ pitch , max_rows = 10 , npoints = 100 , vectorize = False ):
14
14
"""
15
- Integrated and per-point view factors from the ground to the sky at points
16
- between interior rows of the array.
15
+ Integrated view factor to the sky from the ground underneath
16
+ interior rows of the array.
17
17
18
18
Parameters
19
19
----------
@@ -35,20 +35,16 @@ def _vf_ground_sky_integ(surface_tilt, surface_azimuth, gcr, height,
35
35
Maximum number of rows to consider in front and behind the current row.
36
36
npoints : int, default 100
37
37
Number of points used to discretize distance along the ground.
38
+ vectorize : bool, default False
39
+ If True, vectorize the view factor calculation across ``surface_tilt``.
40
+ This increases speed with the cost of increased memory usage.
38
41
39
42
Returns
40
43
-------
41
- fgnd_sky : float
44
+ fgnd_sky : numeric
42
45
Integration of view factor over the length between adjacent, interior
43
- rows. [unitless]
44
- fz : ndarray
45
- Fraction of distance from the previous row to the next row. [unitless]
46
- fz_sky : ndarray
47
- View factors at discrete points between adjacent, interior rows.
48
- [unitless]
49
-
46
+ rows. Shape matches that of ``surface_tilt``. [unitless]
50
47
"""
51
- # TODO: vectorize over surface_tilt
52
48
# Abuse utils._vf_ground_sky_2d by supplying surface_tilt in place
53
49
# of a signed rotation. This is OK because
54
50
# 1) z span the full distance between 2 rows, and
@@ -57,12 +53,16 @@ def _vf_ground_sky_integ(surface_tilt, surface_azimuth, gcr, height,
57
53
# The VFs to the sky will thus be symmetric around z=0.5
58
54
z = np .linspace (0 , 1 , npoints )
59
55
rotation = np .atleast_1d (surface_tilt )
60
- fz_sky = np .zeros ((len (rotation ), npoints ))
61
- for k , r in enumerate (rotation ):
62
- vf , _ = utils ._vf_ground_sky_2d (z , r , gcr , pitch , height , max_rows )
63
- fz_sky [k , :] = vf
56
+ if vectorize :
57
+ fz_sky = utils ._vf_ground_sky_2d (z , rotation , gcr , pitch , height ,
58
+ max_rows )
59
+ else :
60
+ fz_sky = np .zeros ((npoints , len (rotation )))
61
+ for k , r in enumerate (rotation ):
62
+ vf = utils ._vf_ground_sky_2d (z , r , gcr , pitch , height , max_rows )
63
+ fz_sky [:, k ] = vf [:, 0 ] # remove spurious rotation dimension
64
64
# calculate the integrated view factor for all of the ground between rows
65
- return np .trapz (fz_sky , z , axis = 1 )
65
+ return np .trapz (fz_sky , z , axis = 0 )
66
66
67
67
68
68
def _poa_ground_shadows (poa_ground , f_gnd_beam , df , vf_gnd_sky ):
@@ -401,7 +401,7 @@ def _shaded_fraction(solar_zenith, solar_azimuth, surface_tilt,
401
401
def get_irradiance_poa (surface_tilt , surface_azimuth , solar_zenith ,
402
402
solar_azimuth , gcr , height , pitch , ghi , dhi , dni ,
403
403
albedo , model = 'isotropic' , dni_extra = None , iam = 1.0 ,
404
- npoints = 100 ):
404
+ npoints = 100 , vectorize = False ):
405
405
r"""
406
406
Calculate plane-of-array (POA) irradiance on one side of a row of modules.
407
407
@@ -469,7 +469,12 @@ def get_irradiance_poa(surface_tilt, surface_azimuth, solar_zenith,
469
469
on the surface that is not reflected away. [unitless]
470
470
471
471
npoints : int, default 100
472
- Number of points used to discretize distance along the ground.
472
+ Number of discretization points for calculating integrated view
473
+ factors.
474
+
475
+ vectorize : bool, default False
476
+ If True, vectorize the view factor calculation across ``surface_tilt``.
477
+ This increases speed with the cost of increased memory usage.
473
478
474
479
Returns
475
480
-------
@@ -537,7 +542,8 @@ def get_irradiance_poa(surface_tilt, surface_azimuth, solar_zenith,
537
542
# method differs from [1], Eq. 7 and Eq. 8; height is defined at row
538
543
# center rather than at row lower edge as in [1].
539
544
vf_gnd_sky = _vf_ground_sky_integ (
540
- surface_tilt , surface_azimuth , gcr , height , pitch , max_rows , npoints )
545
+ surface_tilt , surface_azimuth , gcr , height , pitch , max_rows , npoints ,
546
+ vectorize )
541
547
# fraction of row slant height that is shaded from direct irradiance
542
548
f_x = _shaded_fraction (solar_zenith , solar_azimuth , surface_tilt ,
543
549
surface_azimuth , gcr )
@@ -610,7 +616,7 @@ def get_irradiance(surface_tilt, surface_azimuth, solar_zenith, solar_azimuth,
610
616
gcr , height , pitch , ghi , dhi , dni ,
611
617
albedo , model = 'isotropic' , dni_extra = None , iam_front = 1.0 ,
612
618
iam_back = 1.0 , bifaciality = 0.8 , shade_factor = - 0.02 ,
613
- transmission_factor = 0 , npoints = 100 ):
619
+ transmission_factor = 0 , npoints = 100 , vectorize = False ):
614
620
"""
615
621
Get front and rear irradiance using the infinite sheds model.
616
622
@@ -701,7 +707,12 @@ def get_irradiance(surface_tilt, surface_azimuth, solar_zenith, solar_azimuth,
701
707
etc. A negative value is a reduction in back irradiance. [unitless]
702
708
703
709
npoints : int, default 100
704
- Number of points used to discretize distance along the ground.
710
+ Number of discretization points for calculating integrated view
711
+ factors.
712
+
713
+ vectorize : bool, default False
714
+ If True, vectorize the view factor calculation across ``surface_tilt``.
715
+ This increases speed with the cost of increased memory usage.
705
716
706
717
Returns
707
718
-------
@@ -756,14 +767,14 @@ def get_irradiance(surface_tilt, surface_azimuth, solar_zenith, solar_azimuth,
756
767
solar_zenith = solar_zenith , solar_azimuth = solar_azimuth ,
757
768
gcr = gcr , height = height , pitch = pitch , ghi = ghi , dhi = dhi , dni = dni ,
758
769
albedo = albedo , model = model , dni_extra = dni_extra , iam = iam_front ,
759
- npoints = npoints )
770
+ npoints = npoints , vectorize = vectorize )
760
771
# back side POA irradiance
761
772
irrad_back = get_irradiance_poa (
762
773
surface_tilt = backside_tilt , surface_azimuth = backside_sysaz ,
763
774
solar_zenith = solar_zenith , solar_azimuth = solar_azimuth ,
764
775
gcr = gcr , height = height , pitch = pitch , ghi = ghi , dhi = dhi , dni = dni ,
765
776
albedo = albedo , model = model , dni_extra = dni_extra , iam = iam_back ,
766
- npoints = npoints )
777
+ npoints = npoints , vectorize = vectorize )
767
778
768
779
colmap_front = {
769
780
'poa_global' : 'poa_front' ,
0 commit comments