Skip to content
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

Migrate spectral modifier functions to pvlib.spectrum #1628

Merged
merged 14 commits into from Jun 9, 2023

Conversation

kandersolar
Copy link
Member

@kandersolar kandersolar commented Dec 29, 2022

  • [ ] Closes #xxxx
  • 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.

As suggested in #1062 (comment) and maybe elsewhere, this PR moves the functions for First Solar and SAPM spectral modifiers to the pvlib.spectrum.mismatch module.

I also thought as long as we are moving things, it would be good to rename sapm_spectral_loss to sapm_spectral_correction. Currently, the two functions are renamed to just spectrum.sapm and spectrum.first_solar. Now renamed to spectrum.spectral_factor_firstsolar and spectrum.spectral_factor_sapm Do others agree with this change? Should pvlib.pvsystem.PVSystem.sapm_spectral_loss be renamed as well?

@kandersolar kandersolar added this to the 0.9.5 milestone Dec 29, 2022
@adriesse
Copy link
Member

Good move!

Still thinking about the names and wondering what naming patterns they conform to and which patterns are currently gaining or losing popularity. Subspecies (?) is often at the end.

in coordination with pvlib#1658, drop "spectral_correction" from the new function names
@adriesse
Copy link
Member

I'm not in favor of shortening the function names to just the author names. I though we had some other discussion recently where that was discouraged actually.

echedey-ls added a commit to echedey-ls/pvlib-python that referenced this pull request Feb 20, 2023
@mikofski
Copy link
Member

I had a similar thought recently, thanks for pulling this together!

@kandersolar
Copy link
Member Author

kandersolar commented Feb 22, 2023

I'm not in favor of shortening the function names to just the author names. I though we had some other discussion recently where that was discouraged actually.

My thought was that function names in other modules don't include the type of the model, e.g. it's not iam.sapm_reflectance or somesuch, so it makes sense to remove spectral_correction from these names. But that's a separate consideration from whether it's desirable to choose sapm and first_solar as the model names here. Suggestions for alternatives are welcome :)

@cwhanse
Copy link
Member

cwhanse commented Feb 22, 2023

I don't know if this scales, but maybe we can reach out to authors and ask them what they'd like the function name to be.

I agree with shortening the function names when the module conveys the function purpose, but, that creates a pit for new users to fall into:

from pvlib.iam import sapm
from pvlib.spectrum import sapm

etc.

Another thought to toss out: we could add a publication year to the function name to create space for e.g. another model from First Solar.

@adriesse
Copy link
Member

I think the year may be added on occasion, but I don't think this is a global solution.

There are few modules/namespaces as focused and conveniently short as iam; because of these two characteristics it is not onerous to import iam and use iam.author(). We could try to create more of those, but again it would not be a global solution.

Spectrum does not contain only one type of function, so I think the functions need a suitable prefix. The latest addition to this module got a nice long name: calc_spectral_mismatch_field so if we take that as a starting point the new ones could be:

calc_spectral_factor_sapm
calc_spectral_factor_firstsolar

I somewhat hesitate to use spectral_mismatch in the names of the empirical models or approximations.

I'm also not sure about the calc_ prefix because it doesn't seem to add much information, but I would go with the flow on that one. Maybe we could introduce a prefix est_ for functions that merely estimate things. :)

@cwhanse
Copy link
Member

cwhanse commented Feb 22, 2023

spectral_factor_sapm
spectral_factor_firstsolar

These work for me.

I somewhat hesitate to use spectral_mismatch in the names

Ditto.

@kandersolar
Copy link
Member Author

kandersolar commented Feb 22, 2023

I have updated to spectral_factor_sapm and spectral_factor_firstsolar, but still grumble to myself on the basis of there being no irradiance.transposition_perez or irradiance.decomposition_erbs ;)

@adriesse
Copy link
Member

I'll be anticipating some PR's with renames then!

@kandersolar kandersolar mentioned this pull request Mar 2, 2023
12 tasks
@kandersolar kandersolar modified the milestones: 0.9.5, 0.9.6 Mar 18, 2023
@kandersolar kandersolar removed this from the 0.9.6 milestone May 16, 2023
@kandersolar kandersolar added this to the 0.10.0 milestone May 16, 2023
pvlib/atmosphere.py Outdated Show resolved Hide resolved
kandersolar and others added 2 commits June 9, 2023 16:09
Co-Authored-By: Cliff Hansen <5393711+cwhanse@users.noreply.github.com>
@kandersolar
Copy link
Member Author

Looking back through the discussion, it seems like the current state of the PR is acceptable to those who expressed opinions on the matter. I'll go ahead and merge to prevent it from languishing again.

Codecov failure can be ignored.

@kandersolar kandersolar merged commit ebf29a4 into pvlib:main Jun 9, 2023
28 of 29 checks passed
@kandersolar kandersolar deleted the spectrum-migrate branch June 9, 2023 20:40
kandersolar added a commit to Jacc0027/pvlib-python that referenced this pull request Jun 12, 2023
following the conventions set out in pvlib#1628
kandersolar added a commit that referenced this pull request Jun 23, 2023
* Update atmosphere.py

* Update atmosphere.py

* Update atmosphere.py

* Update atmosphere.py

* Merge branch 'Spectral-corrections' of https://github.com/Jacc0027/pvlib-python into Spectral-corrections

* Update atmosphere.py

* Update atmosphere.py

* Update atmosphere.py

* Update atmosphere.py

* Update atmosphere.py

* Update atmosphere.py

* Update atmosphere.py

* Update atmosphere.py

* Update atmosphere.py

* Update atmosphere.py

* Update atmosphere.py

* Update atmosphere.py

* Update atmosphere.py

* Update atmosphere.py

* Update atmosphere.py

* Update atmosphere.py

* Update atmosphere.py

* Update atmosphere.py

* Update atmosphere.py

* Update atmosphere.py

* Update atmosphere.py

* Update atmosphere.py

* Update pvlib/atmosphere.py

Co-authored-by: Kevin Anderson <57452607+kanderso-nrel@users.noreply.github.com>

* relocation of parameter descriptions according to the order of input parameters

* Update api.rst

Adding atmosphere.AM_AOD_PW_spectral correction as requested in #1296

* remove input screening

* move reference values to be optional parameters

* fix implementation issues

* first cut at tests using file from Jacc0027

* CI correction. Line #215

* Update test_atmosphere.py

* Update test_atmosphere.py

* Update test_atmosphere.py

* Update atmosphere.py

* Update atmosphere.py

* Update atmosphere.py

* Update atmosphere.py

* Testing tests

* Update test_atmosphere.py

* Update test_atmosphere.py

* Update test_atmosphere.py

* Update test_atmosphere.py

* Update test_atmosphere.py

* Update atmosphere.py

* Test Review

* Update atmosphere.py

* Update test_atmosphere.py

* Update test_atmosphere.py

* Update test_atmosphere.py

* Update test_atmosphere.py

* Update atmosphere.py

* Update atmosphere.py

* Update atmosphere.py

* Update atmosphere.py

* Update test_atmosphere.py

* Update atmosphere.py

* Update test_atmosphere.py

* Update test_atmosphere.py

* Update test_atmosphere.py

* Update test_atmosphere.py

* Update test_atmosphere.py

* Update pvlib/atmosphere.py

Co-authored-by: Cliff Hansen <cwhanse@sandia.gov>

* Update atmosphere.py

Added the requested changes

* Update atmosphere.py

Fixed 2 blank line errors.

* Update test_atmosphere.py

Updated test function name to: caballero_spectral_correction

* Update api.rst

Updated the atmosphere function name from AM_AOD_PW_spectral_correction to caballero_spectral_correction

* Update test_atmosphere.py

Updated some functions calls from AM_AOD_PW_spectral_correction to caballero_spectral_correction

* Update atmosphere.py

Updated the logic to show errors.

* Update pvlib/atmosphere.py

Co-authored-by: Cliff Hansen <cwhanse@sandia.gov>

* Update pvlib/atmosphere.py

Co-authored-by: Cliff Hansen <cwhanse@sandia.gov>

* Update pvlib/atmosphere.py

Co-authored-by: Cliff Hansen <cwhanse@sandia.gov>

* Update pvlib/atmosphere.py

Co-authored-by: Cliff Hansen <cwhanse@sandia.gov>

* Update pvlib/atmosphere.py

Co-authored-by: Cliff Hansen <cwhanse@sandia.gov>

* Update pvlib/atmosphere.py

Co-authored-by: Cliff Hansen <cwhanse@sandia.gov>

* Update atmosphere.py

* Update atmosphere.py

* Update atmosphere.py

Trying to solve #814 and #817 issues.

* Update atmosphere.py

* Update api.rst

* Delete api.rst

* Update test_atmosphere.py

* Update atmosphere.py

* Update test_atmosphere.py

* Update atmosphere.py

* Update test_atmosphere.py

* Update test_atmosphere.py

* Update test_atmosphere.py

* Update test_atmosphere.py

* Update test_atmosphere.py

* Update test_atmosphere.py

* update function logic and get tests working

* Update atmosphere.py

Updated both "TODO" issues.

* Update atmosphere.py

* Update v0.9.6.rst

Added caballero spectral correction as a new function.

* Update airmass_atmospheric.rst

Added a new function: atmosphere.caballero_spectral_correction

* Update pvlib/atmosphere.py

Co-authored-by: Anton Driesse <anton.driesse@pvperformancelabs.com>

* rename function and move to pvlib.spectrum

following the conventions set out in #1628

* misc cleanup

- reorder and rename parameters to match #1768
- remove reference parameters
- shorten/simplify docstring
- restructure calculation to be more readable

---------

Co-authored-by: Kevin Anderson <57452607+kanderso-nrel@users.noreply.github.com>
Co-authored-by: Kevin Anderson <kevin.anderson@nrel.gov>
Co-authored-by: Cliff Hansen <cwhanse@sandia.gov>
Co-authored-by: Anton Driesse <anton.driesse@pvperformancelabs.com>
Co-authored-by: Kevin Anderson <kevin.anderso@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants