Add bifacial scaling to Townsend snow loss model#2756
Conversation
Add optional front_side_fraction argument to loss_townsend for bifacial snow loss adjustment. Includes test coverage for the scaling behavior.
| rear-side insolation in ``poa_global``. The resulting loss may then be | ||
| scaled by the front-side energy fraction using ``front_side_fraction``. |
There was a problem hiding this comment.
| rear-side insolation in ``poa_global``. The resulting loss may then be | |
| scaled by the front-side energy fraction using ``front_side_fraction``. | |
| rear-side insolation in ``poa_global``. The resulting loss is | |
| scaled by the front-side energy fraction ``front_side_fraction``. |
| front_side_fraction : numeric or array-like, default None | ||
| Optional multiplier applied to the calculated loss fraction. For | ||
| bifacial systems, this can be used to scale the snow loss by the | ||
| front-side energy fraction from a no-soiling simulation. For example, | ||
| use 0.9 when 90% of monthly energy is from the front side and 10% is | ||
| from the rear side. If None, no bifacial adjustment is applied. [-] |
There was a problem hiding this comment.
| front_side_fraction : numeric or array-like, default None | |
| Optional multiplier applied to the calculated loss fraction. For | |
| bifacial systems, this can be used to scale the snow loss by the | |
| front-side energy fraction from a no-soiling simulation. For example, | |
| use 0.9 when 90% of monthly energy is from the front side and 10% is | |
| from the rear side. If None, no bifacial adjustment is applied. [-] | |
| front_side_fraction : numeric or array-like, default 1.0 | |
| Fraction of monthly energy from front-side insolation (unitless). | |
| Multiplies the calculated loss fraction. For example, | |
| use 0.9 when 90% of monthly energy is from the front side | |
| of a bifacial system and 10% is from the rear side. |
Here I think 1.0 is a suitable default.
| if front_side_fraction is not None: | ||
| front_side_fraction = np.asarray(front_side_fraction) |
There was a problem hiding this comment.
I think this if and np.asarray are unnecessary if the default is set to 1.0
RDaxini
left a comment
There was a problem hiding this comment.
Thanks for submitting this PR @shethkajal7.
I have added a few suggestions: use np.full to avoid repetition in the array creation, and a few minor flake8 fixes.
Don't forget to add an entry to the docs/sphinx/source/whatsnew file and list yourself there as a contributor for the next release.
|
|
||
|
|
There was a problem hiding this comment.
Deleting this blank space will resolve the flake8 error
| front-side energy fraction from a no-soiling simulation. For example, | ||
| use 0.9 when 90% of monthly energy is from the front side and 10% is | ||
| from the rear side. If None, no bifacial adjustment is applied. [-] | ||
|
|
There was a problem hiding this comment.
Deleting this blank space will resolve the flake8 error (same below)
| poa_global, slant_height, lower_edge_height, | ||
| front_side_fraction=front_side_fraction) | ||
|
|
||
| np.testing.assert_allclose(adjusted, unadjusted * front_side_fraction) No newline at end of file |
There was a problem hiding this comment.
Adding a new line at the end of the file will resolve this flake8 error
| np.testing.assert_allclose(adjusted, unadjusted * front_side_fraction) | |
| np.testing.assert_allclose(adjusted, unadjusted * front_side_fraction) | |
rewrite the test function to avoid repetition in numpy array. Co-authored-by: Rajiv Daxini <143435106+RDaxini@users.noreply.github.com>
Add optional
front_side_fractionargument toloss_townsendfor bifacial snow loss adjustment. Includes test coverage for the scaling behavior.Description
This PR adds an optional
front_side_fractionargument topvlib.snow.loss_townsend.The new argument allows users to scale the calculated Townsend snow loss by the front-side energy fraction for bifacial systems. This follows the bifacial guidance in Townsend and Previtali (2023), where bifacial snow modeling uses total front + rear POA in the Townsend calculation and then scales the resulting loss by the front-side energy contribution.
The default value is
None, so existing behavior is unchanged.Changes
front_side_fractionkeyword argument toloss_townsendfront_side_fractionscales the existing Townsend result correctlyBackward compatibility
This change is backward compatible. When
front_side_fraction=None, the function follows the existing behavior.Tests
Ran locally:
Both passed.
Checklist
docs/sphinx/source/referencefor API changes.docs/sphinx/source/whatsnewfor all changes. Includes link to the GitHub Issue with:issue:`num`or this Pull Request with:pull:`num`. Includes contributor name and/or GitHub username (link with:ghuser:`shethkajal7`).remote-data) and Milestone are assigned to the Pull Request and linked Issue.