-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add albedo function for inland water bodies #2079
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
Changes from 7 commits
0e87325
163cf82
47efb47
7e44696
c3c2fc1
357cb38
55b9271
187b6f6
2a20e8c
75ae142
5c93bfe
e487893
b5cef90
d8b214d
0e5b464
79406e2
0340389
f469db3
d2e83f3
c9ef664
4a089ab
7595216
93b6ff8
7c99fd2
2fce253
98a5006
94b3f03
7738020
7d55e30
4bfc6d1
eaaced0
7776c33
0645463
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.. currentmodule:: pvlib | ||
|
||
Albedo | ||
------ | ||
|
||
.. autosummary:: | ||
:toctree: ../generated/ | ||
|
||
albedo.albedo_water |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,4 @@ Irradiance | |
transposition | ||
decomposition | ||
clearness-index | ||
albedo |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
""" | ||
The ``albedo`` module contains functions for modeling albedo. | ||
""" | ||
|
||
from pvlib.tools import sind | ||
|
||
WATER_COLOR_COEFFS = { | ||
'clear_water_no_waves': 0.13, | ||
'clear_water_ripples_up_to_2.5cm': 0.16, | ||
'clear_water_ripples_larger_than_2.5cm_occasional_whitecaps': 0.23, | ||
'clear_water_frequent_whitecaps': 0.3, | ||
'green_water_ripples_up_to_2.5cm': 0.22, | ||
'muddy_water_no_waves': 0.19 | ||
} | ||
|
||
WATER_ROUGHNESS_COEFFS = { | ||
'clear_water_no_waves': 0.29, | ||
'clear_water_ripples_up_to_2.5cm': 0.7, | ||
'clear_water_ripples_larger_than_2.5cm_occasional_whitecaps': 1.23, | ||
IoannisSifnaios marked this conversation as resolved.
Show resolved
Hide resolved
|
||
'clear_water_frequent_whitecaps': 2, | ||
'green_water_ripples_up_to_2.5cm': 0.7, | ||
'muddy_water_no_waves': 0.29 | ||
} | ||
|
||
|
||
def albedo_water(solar_elevation, color_coeff=None, wave_roughness_coeff=None, | ||
surface_condition=None): | ||
IoannisSifnaios marked this conversation as resolved.
Show resolved
Hide resolved
|
||
r""" | ||
Estimation of albedo for inland water bodies. | ||
|
||
The available surface conditions are for inland water bodies, e.g., lakes | ||
and ponds. For ocean/open sea, an albedo value of 0.06 is recommended. | ||
See :const:`pvlib.irradiance.SURFACE_ALBEDOS`. | ||
IoannisSifnaios marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Parameters | ||
---------- | ||
solar_elevation : numeric | ||
Sun elevation angle. [degrees] | ||
|
||
color_coeff : float, optional | ||
Water color coefficient. [-] | ||
|
||
wave_roughness_coeff : float, optional | ||
Water wave roughness coefficient. [-] | ||
|
||
surface_condition : string, optional | ||
If supplied, overrides ``color_coeff`` and ``wave_roughness_coeff``. | ||
IoannisSifnaios marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``surface_condition`` can be one of the following: | ||
'clear_water_no_waves', 'clear_water_ripples_up_to_2.5cm', | ||
'clear_water_ripples_larger_than_2.5cm_occasional_whitecaps', | ||
'clear_water_frequent_whitecaps', 'green_water_ripples_up_to_2.5cm', | ||
'muddy_water_no_waves'. | ||
IoannisSifnaios marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Returns | ||
------- | ||
albedo : numeric | ||
Albedo for inland water bodies. | ||
IoannisSifnaios marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
IoannisSifnaios marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Notes | ||
----- | ||
The equation for calculating the albedo :math:`\rho` is given by | ||
|
||
.. math:: | ||
:label: albedo | ||
|
||
\rho = c^{(r sin(\alpha) + 1)} | ||
IoannisSifnaios marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Inputs to the model are the water color coefficient :math:`c` [-], the | ||
water wave roughness coefficient :math:`r` [-] and the solar elevation | ||
:math:`\alpha` [degrees]. Parameters are provided in [1]_ , and are coded | ||
for convenience in :data:`~pvlib.albedo.WATER_COLOR_COEFFS` and | ||
:data:`~pvlib.albedo.WATER_ROUGHNESS_COEFFS`. The values of these | ||
coefficients are experimentally determined. | ||
|
||
+---------------------------------------------------------------+-------------------------------+----------------------------------------+ | ||
IoannisSifnaios marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Surface and condition | Color coefficient (:math:`c`) | Wave roughness coefficient (:math:`r`) | | ||
+===============================================================+===============================+========================================+ | ||
| Clear water no waves | 0.13 | 0.29 | | ||
+---------------------------------------------------------------+-------------------------------+----------------------------------------+ | ||
| Clear water ripples up to 2.5 cm | 0.16 | 0.70 | | ||
+---------------------------------------------------------------+-------------------------------+----------------------------------------+ | ||
| Clear water ripples larger than 2.5 cm (occasional whitecaps) | 0.23 | 1.23 | | ||
+---------------------------------------------------------------+-------------------------------+----------------------------------------+ | ||
| Clear water frequent whitecaps | 0.30 | 2.00 | | ||
+---------------------------------------------------------------+-------------------------------+----------------------------------------+ | ||
| Green water ripples up to 2.5cm | 0.22 | 0.70 | | ||
+---------------------------------------------------------------+-------------------------------+----------------------------------------+ | ||
| Muddy water no waves | 0.19 | 0.29 | | ||
+---------------------------------------------------------------+-------------------------------+----------------------------------------+ | ||
IoannisSifnaios marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
References | ||
---------- | ||
.. [1] Dvoracek M.J., Hannabas B. (1990). "Prediction of albedo for use in | ||
evapotranspiration and irrigation scheduling." IN: Visions of the Future | ||
American Society of Agricultural Engineers 04-90: 692-699. | ||
""" # noqa: E501 | ||
|
||
if surface_condition is not None: | ||
color_coeff = WATER_COLOR_COEFFS[surface_condition] | ||
IoannisSifnaios marked this conversation as resolved.
Show resolved
Hide resolved
|
||
wave_roughness_coeff = WATER_ROUGHNESS_COEFFS[surface_condition] | ||
|
||
albedo = color_coeff ** (wave_roughness_coeff * sind(solar_elevation) + 1) | ||
IoannisSifnaios marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return albedo | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's possible to get an array out despite putting a Series in: In [399]: inland_water_dvoracek(pd.Series([45]), "muddy_water_no_waves")
Out[399]: array([0.13516185]) This is not an uncommon problem when using numpy tricks like if isinstance(solar_elevation, pd.Series):
albedo = pd.Series(albedo, index=solar_elevation.index)
return albedo A little inelegant, but it gets the job done. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't the type check of int/floats I suggested earlier do the job? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Type checking has some tricky edge cases (e.g. But I think it is generally better to fix up types at the end instead of following different calculation paths based on type. Less chance of accidentally calculating different output values for different types. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kandersolar the problem is that |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import numpy as np | ||
import pandas as pd | ||
from pvlib import albedo | ||
|
||
from .conftest import assert_series_equal | ||
from numpy.testing import assert_allclose | ||
|
||
|
||
def test_albedo_water_default(): | ||
IoannisSifnaios marked this conversation as resolved.
Show resolved
Hide resolved
|
||
result = albedo.albedo_water(solar_elevation=90, | ||
color_coeff=0.13, | ||
wave_roughness_coeff=0.29) | ||
assert_allclose(result, 0.072, 0.001) | ||
|
||
|
||
def test_albedo_water_string_surface_condition(): | ||
result = albedo.albedo_water(solar_elevation=90, | ||
surface_condition='clear_water_no_waves') | ||
assert_allclose(result, 0.072, 0.001) | ||
|
||
|
||
def test_albedo_water_ndarray(): | ||
solar_elevs = np.array([0, 20, 60, 90]) | ||
color_coeffs = np.array([0.1, 0.2, 0.3, 0.4]) | ||
roughness_coeffs = np.array([0.3, 0.8, 1.5, 2]) | ||
result = albedo.albedo_water(solar_elevation=solar_elevs, | ||
color_coeff=color_coeffs, | ||
wave_roughness_coeff=roughness_coeffs) | ||
expected = np.array([0.1, 0.12875, 0.06278, 0.064]) | ||
assert_allclose(expected, result, atol=1e-5) | ||
|
||
|
||
def test_albedo_water_series(): | ||
times = pd.date_range(start="2015-01-01 00:00", end="2015-01-01 18:00", | ||
freq="6h") | ||
solar_elevs = pd.Series([0, 20, 60, 90], index=times) | ||
color_coeffs = pd.Series([0.1, 0.2, 0.3, 0.4], index=times) | ||
roughness_coeffs = pd.Series([0.3, 0.8, 1.5, 2], index=times) | ||
result = albedo.albedo_water(solar_elevation=solar_elevs, | ||
color_coeff=color_coeffs, | ||
wave_roughness_coeff=roughness_coeffs) | ||
expected = pd.Series([0.1, 0.12875, 0.06278, 0.064], index=times) | ||
assert_series_equal(expected, result, atol=1e-5) |
Uh oh!
There was an error while loading. Please reload this page.