8000 ENH: infinite sheds by mikofski · Pull Request #717 · pvlib/pvlib-python · GitHub
[go: up one dir, main page]

Skip to content

ENH: infinite sheds #717

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 133 commits into from
Feb 22, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
133 commits
Select commit Hold shift + click to select a range
865cbfa
WIP: ENH: infinite sheds
mikofski May 10, 2019
2d77d82
DOC: add infinite_sheds to api.rst, docstrings form sky_angle
mikofski May 16, 2019
7b5def1
ENH: functions for infinite sheds
mikofski May 16, 2019
246dd2b
ENH: clean up docstrings, add 4-quad arctan2, add api docs, more get_…
mikofski May 17, 2019
29333dd
DOC: fix latex math, use psi_t for top, psi_b for bottom
mikofski May 17, 2019
51fe74d
STY: don't use get_* for standard functions
mikofski May 19, 2019
0af1fc2
ENH: create class methods to get irradiance, FIXME: front/back poa no…
mikofski May 19, 2019
9690938
TST: add infinite_sheads test, add infinite_sheds to pvlib-api
mikofski May 19, 2019
6d5c2cb
TST: ground illumination test
mikofski May 19, 2019
99fdc69
TST: coerce df to float, replace div/0 with nan
mikofski May 19, 2019
680b700
TST: set atol to 1e-6 to compare to CSV
mikofski May 19, 2019
97d9664
TST: test for shade line
mikofski May 19, 2019
4931446
TST: fix diffuse fraction NaN and Inf, consolidate front+back = 1 test
mikofski May 20, 2019
7ec812b
TST: add tests for sky angle, psi_top
mikofski May 20, 2019
7e97fcb
ENH: STY: fix stickler, ignore binary operator breaks
mikofski May 20, 2019
4a4e22e
add fixmes for ground illumination and ground view factor
mikofski May 24, 2019
3045928
ENH: BUG: DOC: change "ground-illumination" to "unshaded-ground-fract…
mikofski Jul 1, 2019
b2d0496
Merge branch 'master' into infinite_sheds
mikofski Jul 2, 2019
4c2b3cd
Merge branch 'infinite_sheds' of github.com:mikofski/pvlib-python int…
mikofski Jul 2, 2019
135e074
ENH: BUG: calculate angles and VF from ground between panels to sky
mikofski Jul 4, 2019
d32c144
ENH: BUG: remove gcr_prime from vf calc, not used
mikofski Jul 4, 2019
da7611b
BUG: fix view factors formulas
mikofski Jul 4, 2019
fde1851
STY: shorten line in test_infinite_sheds for sum of angles at z1 limit
mikofski Jul 4, 2019
8247fbe
Merge branch 'master' into infinite_sheds
mikofski Jul 10, 2019
f9eb300
DOC: update module docstring with process from Marion, et al.
mikofski Jul 10, 2019
15822ab
BUG: revert changes to ground and sky to pv surface view factors
mikofski Jul 12, 2019
04a4039
ENH: integrate Fgnd-pv and Fsky-z
mikofski Jul 15, 2019
c87148a
Merge branch 'master' into infinite_sheds
mikofski Sep 20, 2019
5453527
Merge branch 'master' into infinite_sheds
mikofski Nov 11, 2019
5798343
Merge branch 'master' into infinite_sheds
mikofski Nov 27, 2019
9ee9486
Merge branch 'infinite_sheds' of github.com:mikofski/pvlib-python int…
mikofski Nov 27, 2019
d4cdd20
Merge branch 'master' into infinite_sheds
mikofski Aug 27, 2020
ae0c651
Merge branch 'master' into infinite_sheds
mikofski Jan 17, 2021
0f08cb7
fix references
mikofski Jan 17, 2021
0559e57
update infinite sheds
mikofski Jan 17, 2021
6db7104
remove discretized angles for fgndsky
mikofski Feb 6, 2021
b211037
don't discretize z
mikofski Feb 8, 2021
d137f04
clarify what next, prev mean
mikofski Feb 8, 2021
6a583cf
clarify what z0 and z1 limits mean
mikofski Feb 8, 2021
089a355
clean up outputs for get_irradiance
mikofski Feb 8, 2021
1671e7e
consolidate solar projection tests
mikofski Feb 8, 2021
6d5776b
use fraction of pvsurface fx
mikofski Feb 9, 2021
2a38dfd
Merge branch 'master' into infinite_sheds
mikofski Feb 9, 2021
2f3ffcf
Merge branch 'master' of https://github.com/pvlib/pvlib-python into i…
cwhanse Oct 4, 2021
dddae59
be quiet stickler
cwhanse Oct 4, 2021
71a6fa0
TODO inserts, docstring edits
cwhanse Oct 5, 2021
2a174dc
re-organize
cwhanse Oct 8, 2021
cd0d114
create test files, move two functions to utils
cwhanse Oct 8, 2021
8f11255
adjust test paths
cwhanse Oct 8, 2021
d2c1448
fix testing
cwhanse Oct 9, 2021
144489f
adjustments to sky_angle_tangent
cwhanse Oct 11, 2021
a55f587
adjustments to get tests to run
cwhanse Nov 12, 2021
b6ee09a
move shade_line to shading.shaded_fraction
cwhanse Nov 12, 2021
517c303
remove shade_line from infinite_sheds
cwhanse Nov 12, 2021
c2fdc56
remove functions that have moved to utils, shading
cwhanse Nov 12, 2021
5aef380
move several functions to private
cwhanse Nov 12, 2021
60ed926
move more functions to private
cwhanse Nov 12, 2021
0d088db
update test_utils.py
cwhanse Nov 16, 2021
e689377
linting
cwhanse Nov 16, 2021
3e45cd4
tilt to surface_tilt, docstring work
cwhanse Nov 16, 2021
80cd517
consolidate some functions, docstring work
cwhanse Nov 17, 2021
9744776
sky diffuse view factors
cwhanse Nov 18, 2021
923a014
finish editing get_irradiance and supporting functions
cwhanse Dec 3, 2021
e62d4a6
rework public functions
cwhanse Dec 6, 2021
cdc4153
formatting
cwhanse Dec 7, 2021
d1d4005
remove old test file
cwhanse Dec 7, 2021
56eb655
add tests for sky_angle functions, remove diffuse_ratio
cwhanse Dec 8, 2021
b6c60b1
more tests, fix error in _sky_angle
cwhanse Dec 9, 2021
66f0350
more tests and docstring work
cwhanse Dec 13, 2021
aae4d12
stickler
cwhanse Dec 13, 2021
76a2066
space, merge upstream
cwhanse Dec 13, 2021
e87cc03
remove old test file, test fixes
cwhanse Dec 13, 2021
2ac6639
test fixes
cwhanse Dec 13, 2021
b556c55
remove axis from linspace usage
cwhanse Dec 13, 2021
a7ee923
documentation
cwhanse Dec 13, 2021
682f23c
docstrings
cwhanse Dec 13, 2021
4b035da
height = 0 and surface_tilt = 0 cases
cwhanse Dec 14, 2021
64a7f95
vectorize _vf_ground_sky
cwhanse Dec 16, 2021
336ad62
overhaul ground to sky view factors, add function to utils
cwhanse Dec 31, 2021
ea5ea20
lint, handle floats
cwhanse Dec 31, 2021
c5a9d61
improve test fixture, remove unused
cwhanse Jan 1, 2022
6156dca
loop over rotations in _vf_ground_sky_integ, test get_irradiance_poa
cwhanse Jan 1, 2022
c574262
more tests
cwhanse Jan 1, 2022
c581c88
lint
cwhanse Jan 1, 2022
b0ba9f5
complete coverage
cwhanse Jan 1, 2022
6127c4f
progress on testing get_irradiance
cwhanse Jan 1, 2022
186d670
more testing
cwhanse Jan 2, 2022
e25a113
whoops
cwhanse Jan 2, 2022
466cde7
Merge branch 'master' of https://github.com/pvlib/pvlib-python into i…
cwhanse Jan 4, 2022
460714a
merge upstream
cwhanse Jan 4, 2022
f0eb172
remove local test hack
cwhanse Jan 4, 2022
3dbed5f
correction to unshaded_ground_fraction
cwhanse Jan 5, 2022
296b137
move pvfactors tests
cwhanse Jan 6, 2022
a9e139a
additional testing
cwhanse Jan 7, 2022
992d428
add max_zenith to unshaded_ground_fraction
cwhanse Jan 7, 2022
0b81a92
docstring work
cwhanse Jan 13, 2022
2bc3a10
use shading function, extend shading.shaded_fraction
cwhanse Jan 13, 2022
49958df
documentation
cwhanse Jan 13, 2022
224e5b4
clarifications, consistent argument order
cwhanse Jan 15, 2022
d71c9cd
fix errors
cwhanse Jan 16, 2022
b084c34
use numeric instead of array-like
cwhanse Jan 16, 2022
3ccd302
docstring sanding
cwhanse Jan 17, 2022
3e16964
more docstring work, reorder arguments for consistency
cwhanse Jan 17, 2022
8adf64e
edits from review
cwhanse Jan 23, 2022
337262c
fix tests
cwhanse Jan 24, 2022
e5fb113
fix test
cwhanse Jan 24, 2022
b316d3b
remove max_rows from public
cwhanse Jan 31, 2022
371c407
move shaded_fraction from shading.py to infinite_sheds private
cwhanse Feb 1, 2022
f161dce
Merge branch 'master' of https://github.com/pvlib/pvlib-python into i…
cwhanse Feb 2, 2022
679731a
move shading_fraction
cwhanse Feb 2, 2022
a90a045
repair test, stickler
cwhanse Feb 2, 2022
6c1f12c
remove axis_azimuth
cwhanse Feb 2, 2022
eff490c
redo tests without axis_azimuth, few corrections
cwhanse Feb 2, 2022
eb6daa7
trailing spaces
cwhanse Feb 2, 2022
525078f
behind the array criteria, return names
cwhanse Feb 3, 2022
1564a40
changes from review
cwhanse Feb 8, 2022
aaa7262
diffuse fraction when ghi is 0
cwhanse Feb 8, 2022
5814085
clean up
cwhanse Feb 8, 2022
d64ea79
Merge branch 'master' of https://github.com/pvlib/pvlib-python into i…
cwhanse Feb 8, 2022
01a5fc1
Merge branch 'master' of https://github.com/pvlib/pvlib-python into i…
cwhanse Feb 11, 2022
5b1357b
Apply suggestions from code review
cwhanse Feb 13, 2022
5d1b778
changes solar_zenith, solar_azimuth names
cwhanse Feb 13, 2022
03c49c0
Update pvlib/bifacial/infinite_sheds.py
cwhanse Feb 13, 2022
764f807
DOI directive in infinite_sheds.get_irradiance
mikofski Feb 14, 2022
da34555
Merge branch 'master' into infinite_sheds
mikofski Feb 17, 2022
5688240
change back to solar_zenith, solar_azimuth
cwhanse Feb 21, 2022
80fb2b6
Merge branch 'infinite_sheds' of https://github.com/mikofski/pvlib-py…
cwhanse Feb 21, 2022
60fa642
rename in test_utils
cwhanse Feb 21, 2022
8bc1d1d
OrderedDict to dict
cwhanse Feb 21, 2022
87d472a
create bifacial.rst
cwhanse Feb 21, 2022
2c9d4c9
Update docs/sphinx/source/user_guide/bifacial.rst
cwhanse Feb 21, 2022
1a7c33c
Apply suggestions from code review
cwhanse Feb 21, 2022
b2c19a7
remove OrderedDict
cwhanse Feb 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ENH: BUG: calculate angles and VF from ground between panels to sky
- calculate ground-sky angles to previous and next rows, assuming height
 is nonzero
- calculate limits on ground where it can see the sky
- calculate the view factor as a function of z on the ground to the sky
- fix places where it still says degrees, bad, no!
- add fixme for pv-sky view factor, still has wrong formula
- add tests for angles from point z on the ground to tops of current
 row, and limits of previous and next rows
- add a script to make the plot of ground-sky view factor versus z
  • Loading branch information
mikofski committed Jul 4, 2019
commit 135e074813ca1eac369eca08e3910323c741e471
171 changes: 159 additions & 12 deletions pvlib/infinite_sheds.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ def _gcr_prime(gcr, height, tilt, pitch):
# : \\ \\
# :.....\\......................\\........ module lower edge
# : \ \ :
# : \ /\ h = height above ground
# : \ tilt \ :
# +----------\<---------P--------|-->\---- ground
# : \ \ h = height above ground
# : \ tilt \ :
# +----------\<---------P----------->\---- ground

return gcr + height / np.sin(tilt) / pitch

Expand Down Expand Up @@ -184,13 +184,159 @@ def ground_sky_angles(f_z, gcr, height, tilt, pitch):
return psi_0, psi_1


def ground_diffuse_view_factor():
def ground_sky_angles_prev(f_z, gcr, height, tilt, pitch):
"""
Angles from point z on ground to top and bottom of previous rows beyond.

.. math::

\\tan{\\psi_0} = \\frac{\\sin{\\beta^\\prime}}{\\frac{F_z}
{\\text{GCR}^\\prime} + \\cos{\\beta^\\prime}}

0 < F_z < F_{z0,limit}

\\tan \\psi_1 = \\frac{h}{\\frac{h}{\\tan\\beta} - z}

Parameters
----------
f_z : numeric
fraction of ground from previous to next row
gcr : numeric
ground coverage ratio
height : numeric
height of module lower edge above the ground
tilt : numeric
module tilt in radians, between 0 and 180-degrees
pitch : numeric
row spacing
"""
gcr_prime = _gcr_prime(gcr, height, tilt, pitch)
tilt_prime = np.pi - tilt
# angle to bottom of panel looking at sky between rows beyond
psi_0 = np.arctan2(
np.sin(tilt_prime), (1+f_z)/gcr_prime + np.cos(tilt_prime))
# angle to front edge of row beyond
z = f_z*pitch
# other forms raise division by zero errors
# avoid division by zero errors
psi_1 = np.arctan2(height, height/np.tan(tilt) - z)
return psi_0, psi_1


def f_z0_limit(gcr, height, tilt, pitch):
"""
Limit from :math:`z_0` where sky is visible between previous rows.

.. math::
F_{z0,limit} = \\frac{h}{P} \\left(
\\frac{1}{\\tan \\beta} + \\frac{1}{\\tan \\psi_t}\\right)

< 8000 span class='blob-code-inner blob-code-marker ' data-code-marker="+"> Parameters
----------
gcr : numeric
ground coverage ratio
height : numeric
height of module lower edge above the ground
tilt : numeric
module tilt in radians, between 0 and 180-degrees
pitch : numeric
row spacing
"""
tan_psi_t_x0 = sky_angle_0_tangent(gcr, tilt)
# tan_psi_t_x0 = gcr * np.sin(tilt) / (1.0 - gcr * np.cos(tilt))
return height/pitch * (1/np.tan(tilt) + 1/tan_psi_t_x0)


def ground_sky_angles_next(f_z, gcr, height, tilt, pitch):
"""
Angles from point z on the ground to top and bottom of next row beyond.

.. math::
\\tan \\psi_0 = \\frac{h}{\\frac{h}{\\tan\\beta^\\prime}
- \\left(P-z\\right)}

\\tan{\\psi_1} = \\frac{\\sin{\\beta}}
{\\frac{F_z^\\prime}{\\text{GCR}^\\prime} + \\cos{\\beta}}
"""
gcr_prime = _gcr_prime(gcr, height, tilt, pitch)
tilt_prime = np.pi - tilt
# angle to bottom of panel looking at sky between rows beyond
fzprime = 1-f_z
zprime = fzprime*pitch
# other forms raise division by zero errors
# avoid division by zero errors
psi_0 = np.arctan2(height, height/np.tan(tilt_prime) - zprime)
# angle to front edge of row beyond
psi_1 = np.arctan2(np.sin(tilt), (1+fzprime)/gcr_prime + np.cos(tilt))
return psi_0, psi_1


def f_z1_limit(gcr, height, tilt, pitch):
"""
Limit from :math:`z_1^\\prime` where sky is visible between next rows.

.. math::
F_{z1,limit} = \\frac{h}{P} \\left(
\\frac{1}{\\tan \\psi_t} - \\frac{1}{\\tan \\beta}\\right)

Parameters
----------
gcr : numeric
ground coverage ratio
height : numeric
height of module lower edge above the ground
tilt : numeric
module tilt in radians, between 0 and 180-degrees
pitch : numeric
row spacing
"""
8000 tan_psi_t_x1 = sky_angle_0_tangent(gcr, np.pi-tilt)
# tan_psi_t_x1 = gcr * np.sin(pi-tilt) / (1.0 - gcr * np.cos(pi-tilt))
return height/pitch * (1/tan_psi_t_x1 - 1/np.tan(tilt))


def calc_fx_sky(psi_0, psi_1):
return (np.cos(psi_0) + np.cos(psi_1))/2


def ground_sky_diffuse_view_factor(gcr, height, tilt, pitch, npoints=100):
"""
Calculate the fraction of diffuse irradiance from the sky incident on the
ground.
:return:
"""
pass
args = gcr, height, tilt, pitch
gcr_prime = _gcr_prime(*args)
fz0_limit = f_z0_limit(*args)
fz1_limit = f_z1_limit(*args)
# divide the space between rows into N points, but include extra
# space to account for sky visible from adjacent rows
anyx = np.linspace(
0.0 if (1-fz1_limit) > 0 else (1-fz1_limit),
1.0 if fz0_limit < 1 else fz0_limit,
npoints)
# calculate the angles psi_0 and psi_1 that subtend the sky visible
# from between rows
psi_x = ground_sky_angles(anyx, *args)
# front edge
psi_x0 = ground_sky_angles_prev(anyx, *args)
fx0_sky_next = []
next_row = 0.0
while (fz0_limit - next_row) > 0:
fx0_sky_next.append(
np.interp(anyx + next_row, anyx, calc_fx_sky(*psi_x0)))
next_row += 1.0
# back edge
psi_x1 = ground_sky_angles_next(anyx, *args)
fx1_sky_prev = []
prev_row = 0.0
while (fz1_limit - prev_row) > 0:
fx1_sky_prev.append(
np.interp(anyx - prev_row, anyx, calc_fx_sky(*psi_x1)))
prev_row += 1.0
fx_sky = calc_fx_sky(*psi_x) + np.sum(fx0_sky_next, axis=0) + np.sum(fx1_sky_prev, axis=0)
x = np.linspace(0, 1, npoints)
return x, np.interp(x, anyx, fx_sky)


def diffuse_fraction(ghi, dhi):
Expand Down Expand Up @@ -305,7 +451,7 @@ def sky_angle_tangent(gcr, tilt, f_x):
gcr : numeric
ratio of module length versus row spacing
tilt : numeric
angle of surface normal from vertical in degrees
angle of surface normal from vertical in radians
f_x : numeric
fraction of module shaded from bottom

Expand Down Expand Up @@ -333,7 +479,7 @@ def sky_angle_0_tangent(gcr, tilt):
gcr : numeric
ratio of module length to row spacing
tilt : numeric
angle of surface normal from vertical in degrees
angle of surface normal from vertical in radians

Returns
-------
Expand All @@ -352,7 +498,7 @@ def f_sky_diffuse_pv(tilt, tan_psi_top, tan_psi_top_0):
Parameters
----------
tilt : numeric
angle of surface normal from vertical in degrees
angle of surface normal from vertical in radians
tan_psi_top : numeric
tangent of angle from shade line to top of next row
tan_psi_top_0 : numeric
Expand Down Expand Up @@ -385,6 +531,7 @@ def f_sky_diffuse_pv(tilt, tan_psi_top, tan_psi_top_0):
\\large{F_{sky \\rightarrow no\\ shade} = \\frac{1 + \\frac{1 +
\\cos \\left(\\psi_t + \\beta \\right)}{1 + \\cos \\beta} }{2}}
"""
# FIXME: according to Marion, should be difference of cosines
psi_top = np.arctan(tan_psi_top)
psi_top_0 = np.arctan(tan_psi_top_0)
f_sky_pv_shade = (
Expand Down Expand Up @@ -429,7 +576,7 @@ def ground_angle(gcr, tilt, f_x):
gcr : numeric
ratio of module length to row spacing
tilt : numeric
angle of surface normal from vertical in degrees
angle of surface normal from vertical in radians
f_x : numeric
fraction of module shaded from bottom, ``f_x = 0`` if shade line at
bottom and no shade, ``f_x = 1`` if shade line at top and all shade
Expand Down Expand Up @@ -461,7 +608,7 @@ def ground_angle_tangent(gcr, tilt, f_x):
gcr : numeric
ratio of module length to row spacing
tilt : numeric
angle of surface normal from vertical in degrees
angle of surface normal from vertical in radians
f_x : numeric
fraction of module shaded from bottom, ``f_x = 0`` if shade line at
bottom and no shade, ``f_x = 1`` if shade line at top and all shade
Expand Down Expand Up @@ -489,7 +636,7 @@ def ground_angle_1_tangent(gcr, tilt):
gcr : numeric
ratio of module length to row spacing
tilt : numeric
angle of surface normal from vertical in degrees
angle of surface normal from vertical in radians

Returns
-------
Expand All @@ -507,7 +654,7 @@ def f_ground_pv(tilt, tan_psi_bottom, tan_psi_bottom_1):
Parameters
----------
tilt : numeric
angle of surface normal from vertical in degrees
angle of surface normal from vertical in radians
tan_psi_bottom : numeric
tangent of angle from shade line to bottom of next row
tan_psi_bottom_1 : numeric
Expand Down
94 changes: 94 additions & 0 deletions pvlib/test/test_infinite_sheds.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
# system-azimuth: positive counter-clockwise from north
TILT, SYSAZ = 20.0, 250.0
GCR = 0.5 # ground coverage ratio
HEIGHT = 1 # height above ground
PITCH = 4 # row spacing

# IAM parameters
B0 = 0.05
Expand Down Expand Up @@ -97,6 +99,87 @@ def test_unshaded_ground_fraction():
assert np.allclose(f_sky_gnd, F_GND_SKY)


ARGS = (GCR, HEIGHT, TILT_RAD, PITCH)
GCR_PRIME = pvlib.infinite_sheds._gcr_prime(*ARGS)


def calc_ground_sky_angles_at_edges(tilt_rad=TILT_RAD, gcr_prime=GCR_PRIME):
back_tilt_rad = np.pi - tilt_rad
psi_0_x0 = back_tilt_rad
opposite_side = gcr_prime * np.sin(back_tilt_rad)
adjacent_side = 1 - gcr_prime * np.cos(back_tilt_rad)
# tan_psi_1_x0 = opposite_side / adjacent_side
psi_1_x0 = np.arctan2(opposite_side, adjacent_side)
opposite_side = gcr_prime * np.sin(tilt_rad)
adjacent_side = 1 - gcr_prime * np.cos(tilt_rad)
# tan_psi_0_x1 = opposite_side / adjacent_side
psi_0_x1 = np.arctan2(opposite_side, adjacent_side)
psi_1_x1 = tilt_rad
return psi_0_x0, psi_1_x0, psi_0_x1, psi_1_x1


PSI_0_X0, PSI_1_X0, PSI_0_X1, PSI_1_X1 = calc_ground_sky_angles_at_edges()


def test_ground_sky_angles():
# check limit at x=0, these are the same as the back edge of the row beyond
assert np.allclose(
pvlib.infinite_sheds.ground_sky_angles(0, *ARGS), (PSI_0_X0, PSI_1_X0))
assert np.allclose(
pvlib.infinite_sheds.ground_sky_angles(1, *ARGS), (PSI_0_X1, PSI_1_X1))


FZ0_LIMIT = pvlib.infinite_sheds.f_z0_limit(*ARGS)
PSI_TOP = np.arctan2(GCR * np.sin(TILT_RAD), (1.0 - GCR * np.cos(TILT_RAD)))


def test_ground_sky_angles_prev():
if HEIGHT > 0:
# check limit at z=0, these are the same as z=1 of the previous row
assert np.allclose(
pvlib.infinite_sheds.ground_sky_angles_prev(0, *ARGS),
(PSI_0_X1, PSI_1_X1))
# check limit at z=z0_limit, angles must sum to 180
assert np.isclose(
sum(pvlib.infinite_sheds.ground_sky_angles_prev(FZ0_LIMIT, *ARGS)),
np.pi)
# directly under panel, angle should be 90 straight upward!
z_panel = HEIGHT / PITCH / np.tan(TILT_RAD)
assert np.isclose(
pvlib.infinite_sheds.ground_sky_angles_prev(z_panel, *ARGS)[1],
np.pi / 2.)
# angles must be the same as psi_top
assert np.isclose(
pvlib.infinite_sheds.ground_sky_angles_prev(FZ0_LIMIT, *ARGS)[0],
PSI_TOP)


FZ1_LIMIT = pvlib.infinite_sheds.f_z1_limit(*ARGS)
PSI_TOP_BACK = np.arctan2(
GCR * np.sin(BACK_TILT_RAD), (1.0 - GCR * np.cos(BACK_TILT_RAD)))


def test_ground_sky_angles_next():
if HEIGHT > 0:
# check limit at z=1, these are the same as z=0 of the next row beyond
assert np.allclose(
pvlib.infinite_sheds.ground_sky_angles_next(1, *ARGS),
(PSI_0_X0, PSI_1_X0))
# check limit at zprime=z1_limit, angles must sum to 180
assert np.isclose(
sum(pvlib.infinite_sheds.ground_sky_angles_next(1 - FZ1_LIMIT, *ARGS)),
np.pi)
# directly under panel, angle should be 90 straight upward!
z_panel = 1 + HEIGHT / PITCH / np.tan(TILT_RAD)
assert np.isclose(
pvlib.infinite_sheds.ground_sky_angles_next(z_panel, *ARGS)[0],
np.pi / 2.)
# angles must be the same as psi_top
assert np.isclose(
pvlib.infinite_sheds.ground_sky_angles_next(1 - FZ1_LIMIT, *ARGS)[1],
PSI_TOP_BACK)


def test_diffuse_fraction():
df = pvlib.infinite_sheds.diffuse_fraction(GHI, DHI)
assert np.allclose(df, DF, equal_nan=True)
Expand Down Expand Up @@ -156,3 +239,14 @@ def test_sky_angle_0_tangent():
# backside
tan_psi_top = pvlib.infinite_sheds.sky_angle_0_tangent(GCR, BACK_TILT_RAD)
assert np.allclose(tan_psi_top, TAN_PSI_TOP0_B)


if __name__ == '__main__':
from matplotlib import pyplot as plt
plt.ion()
plt.plot(*pvlib.infinite_sheds.ground_sky_diffuse_view_factor(*ARGS))
plt.title(
'combined sky view factor, not including horizon and first/last row')
plt.xlabel('fraction of pitch from front to back')
plt.ylabel('view factor')
plt.grid()
0