Skip to content

Improvements and correction to snow.loss_townsend #1653

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Feb 6, 2023

Conversation

cwhanse
Copy link
Member

@cwhanse cwhanse commented Jan 28, 2023

  • Closes Corrections to Townsend snow model #1636
  • I am familiar with the contributing guidelines
  • Tests added
  • Updates entries in docs/sphinx/source/reference for API changes.
  • Adds description and name entries in the appropriate "what's new" file in docs/sphinx/source/whatsnew for 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:`user`).
  • New code is fully documented. Includes numpydoc compliant docstrings, examples, and comments where necessary.
  • Pull request is nearly complete and ready for detailed review.
  • Maintainer: Appropriate GitHub Labels (including remote-data) and Milestone are assigned to the Pull Request and linked Issue.

Adds a lower bound to a term in the calculation of the ground interference term that prevents a negative squared distance from driving loss fractions to 1.0. Although the reference doesn't describe this limit, I consider its omission a bug in that results from the uncorrected function should be regarded as wrong.

Adds a new parameter, string_factor, that avoids loss fractions of 1.0 for systems with multiple strings across the slant height. This new parameter was added to the model by its author after publication of the reference.

@cwhanse
Copy link
Member Author

cwhanse commented Jan 28, 2023

@kanderso-nrel curious what you think should be done with the current test. If it is checking against output from the original function, that output is wrong. The new tests have limited precision so may not serve as suitable regression checks.

@kandersolar
Copy link
Member

If it is checking against output from the original function, that output is wrong.

Isn't the original function's output correct except for the case when lower_edge_height_inches**2 - effective_snow_weighted**2 < 0? That case wasn't explored in the original test, so although the original test wasn't comprehensive, I think it's still valid. The original test is failing here not because of incorrect expected values but because it is incorrectly passing by position an angle_of_repose value to the new string_factor parameter.

snow_total, snow_events, surface_tilt, relative_humidity, temp_air,
poa_global, slant_height, lower_edge_height, string_factor)
actual = np.around(actual * 100)
assert np.allclose(expected, actual)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

np.testing.assert_allclose is generally preferable over assert np.allclose because the former reports more detailed information about the differences

@kandersolar kandersolar added this to the 0.9.5 milestone Jan 30, 2023
Copy link
Member

@kandersolar kandersolar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks @cwhanse both for the PR and the behind-the-scenes work on this one.

@cwhanse cwhanse merged commit 7e88d21 into pvlib:main Feb 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Corrections to Townsend snow model
2 participants