Skip to content

Snow coverage model from SAM#764

Merged
CameronTStark merged 163 commits into
pvlib:masterfrom
JPalakapillyKWH:snow_coverage_model
Mar 28, 2020
Merged

Snow coverage model from SAM#764
CameronTStark merged 163 commits into
pvlib:masterfrom
JPalakapillyKWH:snow_coverage_model

Conversation

@JPalakapillyKWH

@JPalakapillyKWH JPalakapillyKWH commented Aug 13, 2019

Copy link
Copy Markdown
Contributor
  • Closes Implement another snow loss model like Bill Marion as an alt to pvwatts #577
  • I am familiar with the contributing guidelines.
  • Fully tested. Added and/or modified tests to ensure correct behavior for all reasonable inputs. Tests (usually) must pass on the TravisCI and Appveyor testing services.
  • Updates entries to docs/sphinx/source/api.rst for API changes.
  • Adds description and name entries in the appropriate docs/sphinx/source/whatsnew file for all changes.
  • Code quality and style is sufficient. Passes LGTM and SticklerCI checks.
  • New code is fully documented. Includes sphinx/numpydoc compliant docstrings and comments in the code where necessary.
  • Pull request is nearly complete and ready for detailed review.

Brief description of the problem and proposed solution (if not already fully described in the issue linked to above):

I implemented the snow coverage model first proposed by Marion et al. in [1] and later validated and implemented in SAM [2]. Thought it might be useful to include in pvlib.

[1] Marion, B.; Schaefer, R.; Caine, H.; Sanchez, G. (2013). “Measured and modeled photovoltaic
system energy losses from snow for Colorado and Wisconsin locations.” Solar Energy 97; pp.
112-121.
[2] https://www.nrel.gov/docs/fy17osti/68705.pdf

@mikofski

mikofski commented Aug 14, 2019

Copy link
Copy Markdown
Member

Yes! Thank you! Can you please search the issues for "snow" or "Marion" to find the ticket number and then add a comment that says, "closes #XYZ" thanks!

@JPalakapillyKWH

Copy link
Copy Markdown
Contributor Author

Yes! Thank you! Can you please search the issues for "snow" or "Martin" to find the ticket number and then add a comment that says, "closes #XYZ" thanks!

Edited above comment.

@cwhanse

cwhanse commented Aug 14, 2019

Copy link
Copy Markdown
Member

I'm not opposed to a python native implementation of this model, but I'll ask a due diligence question: is it feasible, and desirable, to wrap the appropriate function in SAM SSC using nrel-pysam? I haven't located the snow model function in the SAM SSC so I don't know if 1) it does what we want, or 2) it is exposed by nrel-pysam. @janinefreeman

@janinefreeman

Copy link
Copy Markdown

@cwhanse The snow model implementation in SAM is exposed in nrel-pysam via cmod_snowmodel (https://github.com/NREL/ssc/blob/develop/ssc/cmod_snowmodel.cpp) which calls a shared library (https://github.com/NREL/ssc/blob/develop/shared/lib_snowmodel.cpp) that allows it to be integrated on the DC side in the detailed PV model.

@wholmgren

wholmgren commented Aug 14, 2019

Copy link
Copy Markdown
Member

I think there's value in a python implementation (particularly for people that want to play with the source code), I think there's value in pysam exposing the c implementation to python users (consistency with SAM, maybe speed), but what's the point of pvlib wrapping the pysam wrapper?

@JPalakapillyKWH

JPalakapillyKWH commented Aug 14, 2019

Copy link
Copy Markdown
Contributor Author

I think there's value in a python implementation (particularly for people that want to play with the source code), I think there's value in pysam exposing the c implementation to python users (consistency with SAM, maybe speed), but what's the point of pvlib wrapping the pysam implementation?

Agree with this. I was able to fit data better by tuning some of the empirically determined coefficients in Marion's model.

@cwhanse

cwhanse commented Aug 15, 2019

Copy link
Copy Markdown
Member

I think there's value in a python implementation (particularly for people that want to play with the source code), I think there's value in pysam exposing the c implementation to python users (consistency with SAM, maybe speed), but what's the point of pvlib wrapping the pysam wrapper?

It is not easy (at least for me it isn't) to figure out how to use pysam to access specific SAM functions, so in cases where we are leveraging SAM functions, I think it is worth wrapping the wrapper for pvlib users' convenience.
In this case I think we should implement the snow model native in python for pvlib. It does not appear to me that pysam exposes the model parameters.

@janinefreeman

Copy link
Copy Markdown

That is true, the SAM implementation doesn't expose the model parameters because most of our users do not have the data necessary to tweak those. On a related note, @JPalakapillyKWH if any of your analysis tuning the parameters to the model is publish-able, the industry would definitely appreciate that :)

@cwhanse

cwhanse commented Aug 15, 2019

Copy link
Copy Markdown
Member

@wholmgren do we want this PR as it's own module, or bundled with other code into a more general "irradiance_loss" module? I'm inclined to the former, anticipating a "soiling" module, whatever we call the "iam" module, "shading" module, etc.

@wholmgren

Copy link
Copy Markdown
Member

I also favor putting this in its own module. Maybe snow instead snowcoverage? Not sure coverage adds anything and Anton recently reminded us that module names should be brief.

We should probably think harder about if/when/how to interface with pysam elsewhere.

@cwhanse cwhanse left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@JPalakapillyKWH thanks for this contribution! A partial review focused on consistency with the references, terms and interface with the rest of pvlib.

Comment thread pvlib/snowcoverage.py Outdated
Comment thread pvlib/snowcoverage.py Outdated
Comment thread pvlib/snowcoverage.py Outdated
Comment thread pvlib/snowcoverage.py Outdated
Comment thread pvlib/snowcoverage.py Outdated
Comment thread pvlib/snowcoverage.py Outdated
Comment thread pvlib/snowcoverage.py Outdated
Comment thread pvlib/snowcoverage.py Outdated
Comment thread pvlib/snowcoverage.py Outdated
Comment thread pvlib/snowcoverage.py Outdated
@CameronTStark CameronTStark added this to the 0.7.2 milestone Feb 12, 2020

@kandersolar kandersolar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@cwhanse I like this rewrite and how it declutters the namespace. Is it worth mentioning in the docstring that this implementation differs from the original in that the original works in "tenths of row slant height"?

Comment thread pvlib/snowcoverage.py Outdated
Comment thread pvlib/snowcoverage.py Outdated
Comment thread pvlib/snowcoverage.py Outdated
Comment thread pvlib/snowcoverage.py Outdated
Comment thread pvlib/snowcoverage.py Outdated
Comment thread pvlib/snowcoverage.py Outdated
Comment thread pvlib/snowcoverage.py Outdated
Comment thread pvlib/tests/test_snowcoverage.py Outdated
Comment thread pvlib/snowcoverage.py Outdated
Comment thread pvlib/snowcoverage.py Outdated
@cwhanse

cwhanse commented Mar 18, 2020

Copy link
Copy Markdown
Member

Test failures are for pvlib.bifacial.pvfactors. I believe this PR is ready.

@kandersolar kandersolar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Some small doc suggestions. Also, consider adding @JPalakapillyKWH to the contributors list for getting the ball rolling.

Comment thread docs/sphinx/source/api.rst Outdated
Comment thread docs/sphinx/source/whatsnew/v0.7.2.rst Outdated
Comment thread pvlib/snow.py Outdated
Comment thread pvlib/snow.py Outdated
Comment thread pvlib/snow.py
@kandersolar

Copy link
Copy Markdown
Member

I included a comment in that review but I think it got buried back in the thread history, so I'll repost it -- I think this suggestion didn't make it into the PR: #764 (comment)

cwhanse and others added 9 commits March 19, 2020 08:49
Co-Authored-By: Kevin Anderson <57452607+kanderso-nrel@users.noreply.github.com>
Co-Authored-By: Kevin Anderson <57452607+kanderso-nrel@users.noreply.github.com>
Co-Authored-By: Kevin Anderson <57452607+kanderso-nrel@users.noreply.github.com>
@CameronTStark

Copy link
Copy Markdown
Contributor

Looks great! I appreciate your commitment on this @cwhanse.

I'll leave it open for a little while longer for others to review, if desired, then I'll merge.

Thank you!

@CameronTStark CameronTStark merged commit a28d819 into pvlib:master Mar 28, 2020
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.

Implement another snow loss model like Bill Marion as an alt to pvwatts