-
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
Add albedo function for inland water bodies #2079
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An initial review. I like the docs redaction.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments. Nice and clean code!
Co-authored-by: Kevin Anderson <[email protected]>
Update table format Co-authored-by: Kevin Anderson <[email protected]>
Co-authored-by: Adam R. Jensen <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no comments beyond those made by other reviewers. Approving pending resolution of other comments.
…naios/pvlib-python into water_albedo_function
Co-authored-by: Adam R. Jensen <[email protected]>
Co-authored-by: Adam R. Jensen <[email protected]>
Co-authored-by: Adam R. Jensen <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few last comments :)
solar_elevation = np.where(solar_elevation < 0, 0, solar_elevation) | ||
|
||
albedo = color_coeff ** (wave_roughness_coeff * sind(solar_elevation) + 1) | ||
return albedo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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 np.where
. Our usual workaround is to fix up the types at the end of the function like this:
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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Type checking has some tricky edge cases (e.g. isinstance(np.array([45.])[0], (int, float))
is False
because it is an np.float64
, not a float
). A test based on np.isscalar
might be ok.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
@kandersolar the problem is that np.where
returns an array (even if you pass a pd.Series for the solar_elevation) - so the if statement is never true. I did a fix, but it might not be the prettiest one... can you approve it (or suggest an alternative)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comments. Merging feels close 🚀
Co-authored-by: Kevin Anderson <[email protected]>
Co-authored-by: Echedey Luis <[email protected]>
…naios/pvlib-python into water_albedo_function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with the changes down below 🚀
Co-authored-by: Echedey Luis <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks @IoannisSifnaios and everyone that reviewed!
docs/sphinx/source/reference
for API changes.docs/sphinx/source/whatsnew
for all changes. Includes link to the GitHub Issue with:issue:`num`
or this Pull Request with:pull:`num`
. Includes contributor name and/or GitHub username (link with:ghuser:`user`
).remote-data
) and Milestone are assigned to the Pull Request and linked Issue.This PR adds a function for calculating the albedo of inland water bodies as described in the paper: 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.
You can contact me if you would like me to send you the paper.