diff --git a/pvlib/snow.py b/pvlib/snow.py index 4927b326d..aab63fdf6 100644 --- a/pvlib/snow.py +++ b/pvlib/snow.py @@ -155,6 +155,14 @@ def coverage_nrel(snowfall, poa_irradiance, temp_air, surface_tilt, # don't slide in the interval preceding the snowfall data slide_amt.iloc[0] = 0 + if snow_depth is not None: + # all slides off if there is no snow on the ground + # described in [2] to avoid non-sliding snow for low-tilt systems. + # default threshold_depth of 1cm is from SAM's implementation and + # is different than the value of 0cm implied in [2]. + # https://github.com.mcas-gov.ms/NREL/ssc/issues/1265 + slide_amt[snow_depth < threshold_depth] = 1. + # build time series of cumulative slide amounts sliding_period_ID = new_snowfall.cumsum() cumulative_sliding = slide_amt.groupby(sliding_period_ID).cumsum() @@ -166,13 +174,13 @@ def coverage_nrel(snowfall, poa_irradiance, temp_air, surface_tilt, snow_coverage.ffill(inplace=True) snow_coverage -= cumulative_sliding - if snow_depth is not None: - # no coverage when there's no snow on the ground - # described in [2] to avoid non-sliding snow for low-tilt systems. - # default threshold_depth of 1cm is from SAM's implementation and - # is different than the value of 0cm implied in [2]. - # https://github.com.mcas-gov.ms/NREL/ssc/issues/1265 - snow_coverage[snow_depth < threshold_depth] = 0. + # if snow_depth is not None: + # # no coverage when there's no snow on the ground + # # described in [2] to avoid non-sliding snow for low-tilt systems. + # # default threshold_depth of 1cm is from SAM's implementation and + # # is different than the value of 0cm implied in [2]. + # # https://github.com.mcas-gov.ms/NREL/ssc/issues/1265 + # snow_coverage[snow_depth < threshold_depth] = 0. # clean up periods where row is completely uncovered return snow_coverage.clip(lower=0) diff --git a/pvlib/tests/test_snow.py b/pvlib/tests/test_snow.py index 65687f3f0..6d8954011 100644 --- a/pvlib/tests/test_snow.py +++ b/pvlib/tests/test_snow.py @@ -55,20 +55,21 @@ def test_coverage_nrel_hourly_with_snow_depth(): surface_tilt = 45 slide_amount_coefficient = 0.197 threshold_depth = 0.5 - dt = pd.date_range(start="2019-1-1 10:00:00", end="2019-1-1 17:00:00", + dt = pd.date_range(start="2019-1-1 10:00:00", end="2019-1-1 18:00:00", freq='1h') - poa_irradiance = pd.Series([400, 200, 100, 1234, 134, 982, 100, 100], + poa_irradiance = pd.Series([400, 200, 100, 1234, 134, 982, 100, 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) + temp_air = pd.Series([10, 2, 10, 1234, 34, 982, 10, 10, 10], index=dt) + # restarts with new snow on 5th time step + snowfall_data = pd.Series([1, .5, .6, .4, .23, 5., .1, .1, 0.], index=dt) + snow_depth = pd.Series([1, 1, 1, 1, 0, 1, 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, threshold_depth=threshold_depth) slide_amt = slide_amount_coefficient * sind(surface_tilt) - covered = 1.0 - slide_amt * np.array([0, 1, 2, 3, 4, 5, 6, 7]) + covered = 1.0 - slide_amt * np.array([0, 1, 2, 3, 0, 0, 1, 0, 0]) expected = pd.Series(covered, index=dt) expected[snow_depth < threshold_depth] = 0 assert_series_equal(expected, snow_coverage)