Skip to content

Commit 08f5f19

Browse files
committed
docstring edits, move some functions to private
1 parent 13500d2 commit 08f5f19

File tree

1 file changed

+65
-75
lines changed

1 file changed

+65
-75
lines changed

pvlib/snowcoverage.py

Lines changed: 65 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
"""
2-
The ``snowcoverage`` module contains functions that model snow coverage on
3-
solar modules. The model was first proposed in Marion et al. 2013 and was
4-
later validated and implemented into NREL's SAM.
2+
The ``snow`` module contains functions that model the effect of snow on
3+
solar modules.
54
"""
65

76
import numpy as np
87
import pandas as pd
8+
from pvlib.tools import sind
99

1010

11-
def snow_slide_amount(surface_tilt, sliding_coefficient=1.97,
12-
time_step_hours=1):
11+
def _snow_slide_amount(surface_tilt, sliding_coefficient=1.97,
12+
time_step=1):
1313
'''
14-
Calculates the amount of snow that slides off of the surface of a module
15-
following the model first described in [1] and later implemented with minor
16-
improvements in SAM [2] in tenths of panel height.
14+
Calculates the amount of snow that slides off in each time step.
1715
1816
Parameters
1917
----------
@@ -24,102 +22,84 @@ def snow_slide_amount(surface_tilt, sliding_coefficient=1.97,
2422
2523
2624
sliding_coefficient : numeric
27-
Another empirically determined coefficient used in [1]. It determines
28-
how much snow slides off of the panel if a sliding event occurs.
25+
An empirically determined coefficient used in [1] to determine
26+
how much snow slides off if a sliding event occurs.
2927
30-
time_step_hours: float
31-
Period of the data in hours. (hours between data points)
28+
time_step: float
29+
Period of the data. [hour]
3230
3331
Returns
3432
----------
3533
slide_amount : numeric
36-
The amount of snow that slides off of the panel
37-
in tenths of the panel area at each time step.
38-
39-
References
40-
----------
41-
[1] Marion, B.; Schaefer, R.; Caine, H.; Sanchez, G. (2013).
42-
“Measured and modeled photovoltaic system energy losses from snow for
43-
Colorado and Wisconsin locations.” Solar Energy 97; pp.112-121.
44-
[2] Ryberg, D; Freeman, J. "Integration, Validation, and Application
45-
of a PV Snow Coverage Model in SAM" (2017) NREL Technical Report
34+
The fraction of panel slant height from which snow slides off
35+
at each time step, in tenths of the panel's slant height.
4636
'''
4737

48-
tilt = np.radians(surface_tilt)
49-
slide_amount = sliding_coefficient / 10 * np.sin(tilt) * time_step_hours
50-
return slide_amount
38+
return sliding_coefficient / 10 * sind(surface_tilt) * time_step
5139

5240

53-
def snow_slide_event(poa_irradiance, temperature,
54-
m=-80):
41+
def _snow_slide_event(poa_irradiance, temperature,
42+
m=-80):
5543
'''
56-
Calculates when snow sliding events will occur following the model first
57-
described in [1] and later implemented in SAM [2].
44+
Calculates when snow sliding events will occur.
5845
5946
Parameters
6047
----------
6148
poa_irradiance : numeric
62-
Total in-plane irradiance (W/m^2)
49+
Total in-plane irradiance [W/m^2]
6350
6451
temperature : numeric
65-
Ambient air temperature at the surface (C)
52+
Ambient air temperature at the surface [C]
6653
6754
m : numeric
68-
A coefficient used in the model described in [1]. It is an
69-
empirically determined value given in W/m^2.
55+
A coefficient used in the model described in [1]. [W/m^2 C]
7056
7157
Returns
7258
----------
7359
slide_event : boolean array
7460
True if the condiditions are suitable for a snow slide event.
7561
False elsewhere.
76-
77-
References
78-
----------
79-
[1] Marion, B.; Schaefer, R.; Caine, H.; Sanchez, G. (2013).
80-
“Measured and modeled photovoltaic system energy losses from snow for
81-
Colorado and Wisconsin locations.” Solar Energy 97; pp.112-121.
82-
[2] Ryberg, D; Freeman, J. "Integration, Validation, and Application
83-
of a PV Snow Coverage Model in SAM" (2017) NREL Technical Report
8462
'''
8563

86-
slide_event = temperature > poa_irradiance / m
87-
return slide_event
64+
return temperature > poa_irradiance / m
8865

8966

90-
def fully_covered_panel(snow_data, time_step_hours=1,
67+
def fully_covered_panel(snow_data, time_step=1,
9168
snow_data_type="snowfall"):
9269
'''
93-
Calculates the timesteps where the panel is presumed to be fully covered
94-
by snow. Follows the same model first described in [1] and later
95-
implemented in SAM [2].
70+
Calculates the timesteps when the panel is presumed to be fully covered
71+
by snow.
9672
9773
Parameters
9874
----------
9975
snow_data : numeric
100-
Time series data on either snowfall or ground snow depth. The type of
101-
data should be specified in snow_data_type. The original model was
102-
designed for ground snowdepth only. (cm/hr or cm)
76+
Time series data on either snowfall (cm/hr) or ground snow depth (cm).
77+
The type of data should be specified in snow_data_type.
10378
104-
time_step_hours: float
105-
Period of the data in hours. (hours between data points)
79+
time_step: float
80+
Period of the data. [hour]
10681
10782
snow_data_type : string
10883
Defines what type of data is being passed as snow_data. Acceptable
109-
values are "snowfall" and "snow_depth". "snowfall" will be in units of
110-
cm/hr. "snow_depth" is in units of cm.
84+
values are "snowfall" and "snow_depth".
11185
11286
Returns
11387
----------
11488
fully_covered_mask : boolean array
11589
True where the snowfall exceeds the defined threshold to fully cover
11690
the panel. False elsewhere.
11791
92+
Notes
93+
-----
94+
Implements the model described in [1] with minor improvements in [2].
95+
11896
References
11997
----------
120-
[1] Marion, B.; Schaefer, R.; Caine, H.; Sanchez, G. (2013).
121-
“Measured and modeled photovoltaic system energy losses from snow for
122-
Colorado and Wisconsin locations.” Solar Energy 97; pp.112-121.
98+
.. [1] Marion, B.; Schaefer, R.; Caine, H.; Sanchez, G. (2013).
99+
“Measured and modeled photovoltaic system energy losses from snow for
100+
Colorado and Wisconsin locations.” Solar Energy 97; pp.112-121.
101+
.. [2] Ryberg, D; Freeman, J. "Integration, Validation, and Application
102+
of a PV Snow Coverage Model in SAM" (2017) NREL Technical Report
123103
'''
124104
if snow_data_type == "snow_depth":
125105
prev_data = snow_data.shift(1)
@@ -131,19 +111,17 @@ def fully_covered_panel(snow_data, time_step_hours=1,
131111
raise ValueError('snow_data_type was not specified or was not set to a'
132112
'valid option (snowfall, snow_depth).')
133113

134-
time_adjusted = snowfall / time_step_hours
114+
time_adjusted = snowfall / time_step
135115
fully_covered_mask = time_adjusted >= 1
136116
return fully_covered_mask
137117

138118

139119
def snow_coverage_model(snow_data, snow_data_type,
140120
poa_irradiance, temperature, surface_tilt,
141-
time_step_hours=1, m=-80, sliding_coefficient=1.97):
121+
time_step=1, m=-80, sliding_coefficient=1.97):
142122
'''
143123
Calculates the fraction of the slant height of a row of modules covered by
144-
snow at every time step following the same model first described in [1]
145-
and later implemented in SAM [2]. Currently only validated for fixed tilt
146-
systems.
124+
snow at every time step.
147125
148126
Parameters
149127
----------
@@ -168,32 +146,45 @@ def snow_coverage_model(snow_data, snow_data_type,
168146
<=180. The tilt angle is defined as degrees from horizontal
169147
(e.g. surface facing up = 0, surface facing horizon = 90).
170148
171-
time_step_hours: float
172-
Period of the data in hours. (hours between data points)
149+
time_step: float
150+
Period of the data. [hour]
173151
174152
sliding coefficient : numeric
175-
Another empirically determined coefficient used in [1]. It determines
176-
how much snow slides off of the panel if a sliding event occurs.
153+
Empirically determined coefficient used in [1] to determine how much
154+
snow slides off if a sliding event occurs.
177155
178156
m : numeric
179-
A coefficient used in the model described in [1]. It is an
180-
empirically determined value given in W/(m^2 C).
157+
A coefficient used in the model described in [1]. [W/(m^2 C)]
181158
182159
Returns
183160
-------
184161
snow_coverage : numeric
185-
The fraction of a module covered by snow at each time step.
162+
The fraction of a the slant height of a row of modules that is covered
163+
by snow at each time step.
164+
165+
Notes
166+
-----
167+
Implements the model described in [1] with minor improvements in [2].
168+
Currently only validated for fixed tilt systems.
169+
170+
References
171+
----------
172+
.. [1] Marion, B.; Schaefer, R.; Caine, H.; Sanchez, G. (2013).
173+
“Measured and modeled photovoltaic system energy losses from snow for
174+
Colorado and Wisconsin locations.” Solar Energy 97; pp.112-121.
175+
.. [2] Ryberg, D; Freeman, J. "Integration, Validation, and Application
176+
of a PV Snow Coverage Model in SAM" (2017) NREL Technical Report
186177
'''
187178

188179
full_coverage_events = fully_covered_panel(snow_data,
189-
time_step_hours=time_step_hours,
180+
time_step=time_step,
190181
snow_data_type=snow_data_type)
191182
snow_coverage = pd.Series(np.full(len(snow_data), np.nan))
192183
snow_coverage = snow_coverage.reindex(snow_data.index)
193184
snow_coverage[full_coverage_events] = 1
194-
slide_events = snow_slide_event(poa_irradiance, temperature)
195-
slide_amount = snow_slide_amount(surface_tilt, sliding_coefficient,
196-
time_step_hours)
185+
slide_events = _snow_slide_event(poa_irradiance, temperature)
186+
slide_amount = _snow_slide_amount(surface_tilt, sliding_coefficient,
187+
time_step)
197188
slidable_snow = ~np.isnan(snow_coverage)
198189
while(np.any(slidable_snow)):
199190
new_slides = np.logical_and(slide_events, slidable_snow)
@@ -231,5 +222,4 @@ def DC_loss_factor(snow_coverage, num_strings):
231222
loss : numeric
232223
DC loss due to snow coverage at each time step.
233224
'''
234-
loss = np.ceil(snow_coverage * num_strings) / num_strings
235-
return loss
225+
return np.ceil(snow_coverage * num_strings) / num_strings

0 commit comments

Comments
 (0)