-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fix omission in snow_coverage_nrel #2292
base: main
Are you sure you want to change the base?
Changes from 6 commits
3594450
9716bc8
cd579f2
c11aee4
7194e3c
11cf12e
b6424e3
d46837c
0ef3d7a
57f5eef
81c44d7
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 |
---|---|---|
|
@@ -19,6 +19,18 @@ def test_fully_covered_nrel(): | |
assert_series_equal(expected, fully_covered) | ||
|
||
|
||
def test_fully_covered_nrel_with_snow_depth(): | ||
dt = pd.date_range(start="2019-1-1 12:00:00", end="2019-1-1 18:00:00", | ||
freq='1h') | ||
snowfall_data = pd.Series([1, 5, .6, 4, .23, -5, 19], index=dt) | ||
snow_depth = pd.Series([0., 1, 6, 6.6, 10.6, 10., -2], index=dt) | ||
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. I guess if a negative snow_depth is given, it is handled as 0, right? Maybe there should be a warning about this. Or should an error be raised instead? 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. I think in general pvlib doesn't do quality checks of user input data unless bad data affects the output of the function. |
||
expected = pd.Series([False, True, False, True, False, False, False], | ||
index=dt) | ||
fully_covered = snow.fully_covered_nrel(snowfall_data, | ||
snow_depth=snow_depth) | ||
assert_series_equal(expected, fully_covered) | ||
|
||
|
||
def test_coverage_nrel_hourly(): | ||
surface_tilt = 45 | ||
slide_amount_coefficient = 0.197 | ||
|
@@ -38,6 +50,27 @@ def test_coverage_nrel_hourly(): | |
assert_series_equal(expected, snow_coverage) | ||
|
||
|
||
def test_coverage_nrel_hourly_with_snow_depth(): | ||
surface_tilt = 45 | ||
slide_amount_coefficient = 0.197 | ||
dt = pd.date_range(start="2019-1-1 10:00:00", end="2019-1-1 17:00:00", | ||
freq='1h') | ||
poa_irradiance = pd.Series([400, 200, 100, 1234, 134, 982, 100, 100], | ||
index=dt) | ||
temp_air = pd.Series([10, 2, 10, 1234, 34, 982, 10, 10], index=dt) | ||
snowfall_data = pd.Series([1, .5, .6, .4, .23, -5, .1, .1], index=dt) | ||
snow_depth = pd.Series([1, 1, 1, 1, 0, 1, 0, .1], index=dt) | ||
snow_coverage = snow.coverage_nrel( | ||
snowfall_data, poa_irradiance, temp_air, surface_tilt, | ||
snow_depth=snow_depth, threshold_snowfall=0.6) | ||
|
||
slide_amt = slide_amount_coefficient * sind(surface_tilt) | ||
covered = 1.0 - slide_amt * np.array([0, 1, 2, 3, 4, 5, 6, 7]) | ||
expected = pd.Series(covered, index=dt) | ||
expected[snow_depth <= 0] = 0 | ||
assert_series_equal(expected, snow_coverage) | ||
|
||
|
||
def test_coverage_nrel_subhourly(): | ||
surface_tilt = 45 | ||
slide_amount_coefficient = 0.197 | ||
|
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 don't think this check can be applied at the end like this. In cases where the check takes effect (snow_depth = 0 --> coverage = 0), that effect should propagate forward in time and influence values for future timestamps. As it is now, I don't think this code allows that.
See for example this input:
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 think you are correct. The SAM implementation appears to iterate over timesteps.
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.
In the SAM algorithm, these lines set coverage to full if both of two conditions are met:
So change in snow depth exceeds deltaThreshold (*dt converts to hourly), and snowDepth exceeds a different threshold so the snow is "sticking" around.