Skip to content

Added irradiance_loss_pvsyst function to pvsystem #1000

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 33 commits into from
Sep 2, 2020

Conversation

btaute
Copy link
Contributor

@btaute btaute commented Jul 8, 2020

Added irradiance_loss_pvsyst function to pvsystem module and method to PVSystem class.

Partially addresses Issue #988.

I still need to incorporate tests and update the "what's new" file. I'm hoping for some feedback on implementation before starting those.

Thank you for your review.

  • Closes Adding Loss Model Categories #988
  • I am familiar with the contributing guidelines
  • Tests added
  • Updates entries to docs/sphinx/source/api.rst 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 and Milestone are assigned to the Pull Request and linked Issue.

@cwhanse
Copy link
Member

cwhanse commented Jul 9, 2020

The direction this PR goes is fine. The review will be easier if we can clean up the formatting issues first, LMK if you would like some help with that.

I'm fine with the calculations. I'll probably suggest some renaming of the parameters (drop irradiance_ from each name), and some editing of the docstring.

@btaute
Copy link
Contributor Author

btaute commented Jul 9, 2020

I updated the formatting, but I'm still running into some issues there that I'm not sure how to resolve. Some insight on what's required for passing formatting would be greatly appreciated.

With respect to the "irradiance_" included in many variable names, I agree that's cumbersome and am happy to pull that. The reason I included it was to differentiate from the electrical loss models that can also be associated with shading, soiling, and snow coverage. If you believe that differentiation is obvious given the context of the function, then it's overly specific.

@btaute
Copy link
Contributor Author

btaute commented Jul 10, 2020

I attempted to add tests. I'm a little unfamiliar with this system, but I don't think all of the test failures happening are from my addition. If they are, there is clearly something I'm missing and will require assistance.

I think it's at a place for detailed review when a @pvlib/maintainer has the time.

@cwhanse
Copy link
Member

cwhanse commented Jul 10, 2020

The test warnings and failures are unrelated to this PR. I'll review the PR soon.

Copy link
Member

@cwhanse cwhanse left a comment

Choose a reason for hiding this comment

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

Thanks @btaute I got caught up in other work. This is looking very good.

btaute and others added 8 commits July 21, 2020 15:02
Co-authored-by: Cliff Hansen <cwhanse@sandia.gov>
Co-authored-by: Cliff Hansen <cwhanse@sandia.gov>
Co-authored-by: Cliff Hansen <cwhanse@sandia.gov>
Co-authored-by: Cliff Hansen <cwhanse@sandia.gov>
Co-authored-by: Cliff Hansen <cwhanse@sandia.gov>
Co-authored-by: Cliff Hansen <cwhanse@sandia.gov>
@btaute
Copy link
Contributor Author

btaute commented Jul 22, 2020

I believe I've incorporated all of your comments @cwhanse. The only one outstanding is the What's New addition. This should be ready for another (maybe final) review.

Copy link
Member

@wholmgren wholmgren left a comment

Choose a reason for hiding this comment

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

Thanks @btaute for the contribution. Some questions for you and Cliff below...

Also needs an entry in https://github.com/pvlib/pvlib-python/blob/master/docs/sphinx/source/api.rst

Comment on lines 2556 to 2557
def irradiance_loss_pvsyst(effective_irradiance, irradiance_shading_loss,
irradiance_snow_loss, irradiance_soiling_loss):
Copy link
Member

Choose a reason for hiding this comment

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

The function would return the same thing if the user permuted the loss arguments. We could consider *losses for a more general and extensible approach.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like this idea. I believe calling out the losses explicitly helps guide new users, but I think an in-depth tutorial can serve that purpose better while allowing for more flexibility here.

If we make this update, I don't think the function name "irradiance_loss_pvsyst" is apt anymore. The point of the function is that it allows a convenient way to compound any irradiance losses that should be applied to the total POA (not specific to beam, diffuse, or ground POA). Maybe that means it should be called "compound_effective_irradiance_losses?" Maybe "combine_effective_irradiance_losses?"

A future implementation more inline with PVSyst should be a "pvsyst_effective_irradiance" function.

Copy link
Member

Choose a reason for hiding this comment

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

+1 to combine_loss_factors or similar for a general purpose function, since the PVWatts model does the same calculation on a different set of inputs.

I think it's helpful to also have a function named irradiance_loss_pvsyst or similar, with arguments that are easily recognized by someone used to using the PVsyst loss model. If we keep a _pvsyst function, it should return effective_irradiance with losses applied, instead of the loss factor.

effective_irradiance_pvsyst implies that the function also calculates and applies reflection and spectral mismatch modifiers, which is a larger scope that this PR.

@btaute
Copy link
Contributor Author

btaute commented Aug 4, 2020

I'm not sure how to address the Read the Docs build failure. Any advice there would be greatly appreciated.

I changed the direction of the Pull Request based on the conversation. It's now a general function for combining losses, which will end up getting called by almost all of the specific system loss functions (i.e. PVSyst loss functions). The math is simple but it also takes into account resampling, which will be beneficial for extrapolating monthly values to hourly values, etc.

@cwhanse
Copy link
Member

cwhanse commented Aug 4, 2020

@btaute the numerical test failures are unrelated to your PR, @kanderso-nrel reported the cause in #1018

Copy link
Member

@cwhanse cwhanse left a comment

Choose a reason for hiding this comment

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

some suggestions for the docstring

@wholmgren wholmgren added this to the 0.8.0 milestone Aug 28, 2020
@wholmgren
Copy link
Member

@btaute it looks to me like this could be merged once the conflicts are resolved.

@btaute
Copy link
Contributor Author

btaute commented Sep 2, 2020

@wholmgren I believe those conflicts have been resolved.

@wholmgren
Copy link
Member

@btaute looks like the merge brought some older unwanted code back into the modules.

@btaute
Copy link
Contributor Author

btaute commented Sep 2, 2020

Sorry, I misunderstood the conflicts. Is this better?

Comment on lines 78 to 94
* Add :py:func:`pvlib.shading.sky_diffuse_passias`,
:py:func:`pvlib.shading.masking_angle_passias`, and
:py:func:`pvlib.shading.masking_angle` to model diffuse shading loss.
(:pull:`1017`)
* Add :py:func:`pvlib.inverter.fit_sandia` that fits the Sandia inverter model
to a set of inverter efficiency curves. (:pull:`1011`)
* Add :py:func:`pvlib.ivtools.sdm.fit_pvsyst_sandia` and :py:func:`pvlib.ivtools.sdm.fit_desoto_sandia`
for fitting the Pvsyst and De Soto models to IV curve data (:issue:`227`)(:pull:`708`)
* Add factory methods :py:meth:`~pvlib.modelchain.ModelChain.with_pvwatts`
:py:meth:`~pvlib.modelchain.ModelChain.with_sapm` to create ``ModelChain``
objects configured for the respective modeling paradigms. The
configurations are defined in ``modelchain.PVWATTS_CONFIG``, and
``modelchain.SAPM_CONFIG``. (:issue:`1013`, :pull:`1022`)
* Added *racking_model*, *module_type*, and *temperature_model_parameters* to
PVSystem, LocalizedPVSystem, SingleAxisTracker, and
LocalizedSingleAxisTracker repr methods. (:issue:`1027`)
* Added ability for :py:func:`pvlib.soiling.hsu` to accept arbitrary time intervals. (:pull:`980`)
Copy link
Member

Choose a reason for hiding this comment

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

@btaute one more merge issue here and then we'll be done. sorry for the hassle

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay. I took one more stab at it.

@wholmgren wholmgren merged commit b2a17e4 into pvlib:master Sep 2, 2020
@wholmgren
Copy link
Member

Thanks @btaute!

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.

Adding Loss Model Categories
4 participants