-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Improvements and correction to snow.loss_townsend #1653
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
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3d8e181
add limit to gamma term, string_factor, tests
cwhanse 082dbfa
adjust existing test, whatsnew
cwhanse 63265c7
spacing
cwhanse 933f63f
remove extra line
cwhanse 4798f75
review
cwhanse 35896af
trailing space
cwhanse 2a9090c
Merge branch 'main' of https://github.com/pvlib/pvlib-python into sno…
cwhanse File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,8 @@ | |
from pvlib import snow | ||
from pvlib.tools import sind | ||
|
||
import pytest | ||
|
||
|
||
def test_fully_covered_nrel(): | ||
dt = pd.date_range(start="2019-1-1 12:00:00", end="2019-1-1 18:00:00", | ||
|
@@ -108,6 +110,7 @@ def test__townsend_effective_snow(): | |
|
||
|
||
def test_loss_townsend(): | ||
# hand-calculated solution | ||
snow_total = np.array([25.4, 25.4, 12.7, 2.54, 0, 0, 0, 0, 0, 0, 12.7, | ||
25.4]) | ||
snow_events = np.array([2, 2, 1, 0, 0, 0, 0, 0, 0, 0, 2, 3]) | ||
|
@@ -118,12 +121,92 @@ def test_loss_townsend(): | |
poa_global = np.array([350000, 350000, 350000, 350000, 350000, 350000, | ||
350000, 350000, 350000, 350000, 350000, 350000]) | ||
angle_of_repose = 40 | ||
string_factor = 1.0 | ||
slant_height = 2.54 | ||
lower_edge_height = 0.254 | ||
expected = np.array([0.07696253, 0.07992262, 0.06216201, 0.01715392, 0, 0, | ||
0, 0, 0, 0, 0.02643821, 0.06068194]) | ||
actual = snow.loss_townsend(snow_total, snow_events, surface_tilt, | ||
relative_humidity, temp_air, | ||
poa_global, slant_height, | ||
lower_edge_height, angle_of_repose) | ||
lower_edge_height, string_factor, | ||
angle_of_repose) | ||
np.testing.assert_allclose(expected, actual, rtol=1e-05) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
'poa_global,surface_tilt,slant_height,lower_edge_height,string_factor,expected', # noQA: E501 | ||
[ | ||
(np.asarray( | ||
[60., 80., 100., 125., 175., 225., 225., 210., 175., 125., 90., | ||
60.], dtype=float) * 1000., | ||
2., | ||
79. / 39.37, | ||
3. / 39.37, | ||
1.0, | ||
np.asarray( | ||
[44, 34, 20, 9, 3, 1, 0, 0, 0, 2, 6, 25], dtype=float) | ||
), | ||
(np.asarray( | ||
[60., 80., 100., 125., 175., 225., 225., 210., 175., 125., 90., | ||
60.], dtype=float) * 1000., | ||
5., | ||
316 / 39.37, | ||
120. / 39.37, | ||
0.75, | ||
np.asarray( | ||
[22, 16, 9, 4, 1, 0, 0, 0, 0, 1, 2, 12], dtype=float) | ||
), | ||
(np.asarray( | ||
[60., 80., 100., 125., 175., 225., 225., 210., 175., 125., 90., | ||
60.], dtype=float) * 1000., | ||
23., | ||
158 / 39.27, | ||
12 / 39.37, | ||
0.75, | ||
np.asarray( | ||
[28, 21, 13, 6, 2, 0, 0, 0, 0, 1, 4, 16], dtype=float) | ||
), | ||
(np.asarray( | ||
[80., 100., 125., 150., 225., 300., 300., 275., 225., 150., 115., | ||
80.], dtype=float) * 1000., | ||
52., | ||
39.5 / 39.37, | ||
34. / 39.37, | ||
0.75, | ||
np.asarray( | ||
[7, 5, 3, 1, 0, 0, 0, 0, 0, 0, 1, 4], dtype=float) | ||
), | ||
(np.asarray( | ||
[80., 100., 125., 150., 225., 300., 300., 275., 225., 150., 115., | ||
80.], dtype=float) * 1000., | ||
60., | ||
39.5 / 39.37, | ||
25. / 39.37, | ||
1., | ||
np.asarray( | ||
[7, 5, 3, 1, 0, 0, 0, 0, 0, 0, 1, 3], dtype=float) | ||
) | ||
] | ||
) | ||
def test_loss_townsend_cases(poa_global, surface_tilt, slant_height, | ||
lower_edge_height, string_factor, expected): | ||
# test cases from Townsend, 1/27/2023, addeed by cwh | ||
# snow_total in inches, convert to cm for pvlib | ||
snow_total = np.asarray( | ||
[20, 15, 10, 4, 1.5, 0, 0, 0, 0, 1.5, 4, 15], dtype=float) * 2.54 | ||
# snow events are an average for each month | ||
snow_events = np.asarray( | ||
[5, 4.2, 2.8, 1.3, 0.8, 0, 0, 0, 0, 0.5, 1.5, 4.5], dtype=float) | ||
# air temperature in C | ||
temp_air = np.asarray( | ||
[-6., -2., 1., 4., 7., 10., 13., 16., 14., 12., 7., -3.], dtype=float) | ||
# relative humidity in % | ||
relative_humidity = np.asarray( | ||
[78., 80., 75., 65., 60., 55., 55., 55., 50., 55., 60., 70.], | ||
dtype=float) | ||
actual = snow.loss_townsend( | ||
snow_total, snow_events, surface_tilt, relative_humidity, temp_air, | ||
poa_global, slant_height, lower_edge_height, string_factor) | ||
actual = np.around(actual * 100) | ||
assert np.allclose(expected, actual) | ||
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.
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.