Skip to content

Commit 393399a

Browse files
committed
Address review comments
Set front_side_fraction default to 1.0, simplify the scaling logic, clean up tests, and add a whatsnew entry.
1 parent 88246d0 commit 393399a

3 files changed

Lines changed: 16 additions & 17 deletions

File tree

docs/sphinx/source/whatsnew/v0.15.2.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ Bug fixes
2121

2222
Enhancements
2323
~~~~~~~~~~~~
24-
24+
* Added the ``front_side_fraction`` parameter to
25+
:py:func:`pvlib.snow.loss_townsend` to support bifacial Townsend snow-loss
26+
workflows where the calculated loss is scaled by the front-side energy
27+
fraction. (:pull:`2756`) (:ghuser:`shethkajal7`)
2528

2629
Documentation
2730
~~~~~~~~~~~~~
@@ -53,3 +56,4 @@ Contributors
5356
~~~~~~~~~~~~
5457
* :ghuser:`Omesh37`
5558
* Cliff Hansen (:ghuser:`cwhanse`)
59+
* :ghuser:`shethkajal7`

pvlib/snow.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ def _townsend_effective_snow(snow_total, snow_events):
249249
def loss_townsend(snow_total, snow_events, surface_tilt, relative_humidity,
250250
temp_air, poa_global, slant_height, lower_edge_height,
251251
string_factor=1.0, angle_of_repose=40,
252-
front_side_fraction=None):
252+
front_side_fraction=1.0):
253253
'''
254254
Calculates monthly snow loss based on the Townsend monthly snow loss
255255
model.
@@ -294,13 +294,12 @@ def loss_townsend(snow_total, snow_events, surface_tilt, relative_humidity,
294294
Piled snow angle, assumed to stabilize at 40°, the midpoint of
295295
25°-55° avalanching slope angles. [deg]
296296
297-
front_side_fraction : numeric or array-like, default None
298-
Optional multiplier applied to the calculated loss fraction. For
299-
bifacial systems, this can be used to scale the snow loss by the
300-
front-side energy fraction from a no-soiling simulation. For example,
301-
use 0.9 when 90% of monthly energy is from the front side and 10% is
302-
from the rear side. If None, no bifacial adjustment is applied. [-]
303-
297+
front_side_fraction : numeric or array-like, default 1.0
298+
Fraction of monthly energy from front-side insolation (unitless).
299+
Multiplies the calculated loss fraction. For example,
300+
use 0.9 when 90% of monthly energy is from the front side
301+
of a bifacial system and 10% is from the rear side.
302+
304303
Returns
305304
-------
306305
loss : array-like
@@ -319,8 +318,8 @@ def loss_townsend(snow_total, snow_events, surface_tilt, relative_humidity,
319318
The definition for snow events documented above is based on [3]_.
320319
321320
For bifacial systems, [2]_ recommends including both front-side and
322-
rear-side insolation in ``poa_global``. The resulting loss may then be
323-
scaled by the front-side energy fraction using ``front_side_fraction``.
321+
rear-side insolation in ``poa_global``. The resulting loss is
322+
scaled by the front-side energy fraction ``front_side_fraction``.
324323
325324
References
326325
----------
@@ -396,8 +395,6 @@ def loss_townsend(snow_total, snow_events, surface_tilt, relative_humidity,
396395
* string_factor
397396
)
398397

399-
if front_side_fraction is not None:
400-
front_side_fraction = np.asarray(front_side_fraction)
401-
loss_fraction = loss_fraction * front_side_fraction
398+
loss_fraction = loss_fraction * front_side_fraction
402399

403400
return np.clip(loss_fraction, 0, 1)

tests/test_snow.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,6 @@ def test_loss_townsend_cases(poa_global, surface_tilt, slant_height,
247247
poa_global, slant_height, lower_edge_height, string_factor)
248248
actual = np.around(actual * 100)
249249
assert np.allclose(expected, actual)
250-
251-
252250
def test_loss_townsend_front_side_fraction():
253251
snow_total = np.array([25.4, 25.4, 12.7, 2.54, 0, 0, 0, 0, 0, 0, 12.7,
254252
25.4])
@@ -270,4 +268,4 @@ def test_loss_townsend_front_side_fraction():
270268
poa_global, slant_height, lower_edge_height,
271269
front_side_fraction=front_side_fraction)
272270

273-
np.testing.assert_allclose(adjusted, unadjusted * front_side_fraction)
271+
np.testing.assert_allclose(adjusted, unadjusted * front_side_fraction)

0 commit comments

Comments
 (0)