Skip to content

Commit 57f5eef

Browse files
committed
move check for snow depth
1 parent 0ef3d7a commit 57f5eef

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

pvlib/snow.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,14 @@ def coverage_nrel(snowfall, poa_irradiance, temp_air, surface_tilt,
155155
# don't slide in the interval preceding the snowfall data
156156
slide_amt.iloc[0] = 0
157157

158+
if snow_depth is not None:
159+
# all slides off if there is no snow on the ground
160+
# described in [2] to avoid non-sliding snow for low-tilt systems.
161+
# default threshold_depth of 1cm is from SAM's implementation and
162+
# is different than the value of 0cm implied in [2].
163+
# https://github.com.mcas-gov.ms/NREL/ssc/issues/1265
164+
slide_amt[snow_depth < threshold_depth] = 1.
165+
158166
# build time series of cumulative slide amounts
159167
sliding_period_ID = new_snowfall.cumsum()
160168
cumulative_sliding = slide_amt.groupby(sliding_period_ID).cumsum()
@@ -166,13 +174,13 @@ def coverage_nrel(snowfall, poa_irradiance, temp_air, surface_tilt,
166174
snow_coverage.ffill(inplace=True)
167175
snow_coverage -= cumulative_sliding
168176

169-
if snow_depth is not None:
170-
# no coverage when there's no snow on the ground
171-
# described in [2] to avoid non-sliding snow for low-tilt systems.
172-
# default threshold_depth of 1cm is from SAM's implementation and
173-
# is different than the value of 0cm implied in [2].
174-
# https://github.com.mcas-gov.ms/NREL/ssc/issues/1265
175-
snow_coverage[snow_depth < threshold_depth] = 0.
177+
# if snow_depth is not None:
178+
# # no coverage when there's no snow on the ground
179+
# # described in [2] to avoid non-sliding snow for low-tilt systems.
180+
# # default threshold_depth of 1cm is from SAM's implementation and
181+
# # is different than the value of 0cm implied in [2].
182+
# # https://github.com.mcas-gov.ms/NREL/ssc/issues/1265
183+
# snow_coverage[snow_depth < threshold_depth] = 0.
176184
# clean up periods where row is completely uncovered
177185
return snow_coverage.clip(lower=0)
178186

pvlib/tests/test_snow.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,21 @@ def test_coverage_nrel_hourly_with_snow_depth():
5555
surface_tilt = 45
5656
slide_amount_coefficient = 0.197
5757
threshold_depth = 0.5
58-
dt = pd.date_range(start="2019-1-1 10:00:00", end="2019-1-1 17:00:00",
58+
dt = pd.date_range(start="2019-1-1 10:00:00", end="2019-1-1 18:00:00",
5959
freq='1h')
60-
poa_irradiance = pd.Series([400, 200, 100, 1234, 134, 982, 100, 100],
60+
poa_irradiance = pd.Series([400, 200, 100, 1234, 134, 982, 100, 100, 100],
6161
index=dt)
62-
temp_air = pd.Series([10, 2, 10, 1234, 34, 982, 10, 10], index=dt)
63-
snowfall_data = pd.Series([1, .5, .6, .4, .23, -5, .1, .1], index=dt)
64-
snow_depth = pd.Series([1, 1, 1, 1, 0, 1, 0, .1], index=dt)
62+
temp_air = pd.Series([10, 2, 10, 1234, 34, 982, 10, 10, 10], index=dt)
63+
# restarts with new snow on 5th time step
64+
snowfall_data = pd.Series([1, .5, .6, .4, .23, 5., .1, .1, 0.], index=dt)
65+
snow_depth = pd.Series([1, 1, 1, 1, 0, 1, 1, 0, .1], index=dt)
6566
snow_coverage = snow.coverage_nrel(
6667
snowfall_data, poa_irradiance, temp_air, surface_tilt,
6768
snow_depth=snow_depth, threshold_snowfall=0.6,
6869
threshold_depth=threshold_depth)
6970

7071
slide_amt = slide_amount_coefficient * sind(surface_tilt)
71-
covered = 1.0 - slide_amt * np.array([0, 1, 2, 3, 4, 5, 6, 7])
72+
covered = 1.0 - slide_amt * np.array([0, 1, 2, 3, 0, 0, 1, 0, 0])
7273
expected = pd.Series(covered, index=dt)
7374
expected[snow_depth < threshold_depth] = 0
7475
assert_series_equal(expected, snow_coverage)

0 commit comments

Comments
 (0)