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

Create function to calculate average photon energy #2140

Merged
merged 37 commits into from
Aug 14, 2024

Conversation

RDaxini
Copy link
Contributor

@RDaxini RDaxini commented Jul 20, 2024

  • Closes Create calculate_avg_photon_energy function #2135
  • 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.

docs: https://pvlib-python--2140.org.readthedocs.build/en/2140/reference/generated/pvlib.spectrum.average_photon_energy.html

update docstring
fix docs typesetting
add checks in function for negative irradiance and invalid data type
add tests for these checks
update docs maths typesetting
@RDaxini RDaxini marked this pull request as ready for review August 2, 2024 09:55
@RDaxini RDaxini changed the title Create function to calculate average photon energy (draft) Create function to calculate average photon energy Aug 2, 2024
still trying to typeset the units without using / / between multiple length units
trying unicode superscript
@kandersolar kandersolar added this to the v0.11.1 milestone Aug 5, 2024
pvlib/spectrum/__init__.py Outdated Show resolved Hide resolved
pvlib/spectrum/mismatch.py Outdated Show resolved Hide resolved
pvlib/spectrum/mismatch.py Outdated Show resolved Hide resolved
pvlib/spectrum/mismatch.py Outdated Show resolved Hide resolved
pvlib/tests/test_spectrum.py Outdated Show resolved Hide resolved
pvlib/spectrum/mismatch.py Outdated Show resolved Hide resolved
RDaxini and others added 2 commits August 5, 2024 14:10
Co-authored-by: Kevin Anderson <kevin.anderso@gmail.com>
@echedey-ls
Copy link
Contributor

echedey-ls commented Aug 6, 2024

In general terms of the API, is it reasonable to add an optional parameter for the wavelength (pandas object index)? For example, polars users are understandably afraid of indexes https://docs.pola.rs/user-guide/migration/pandas/#polars-does-not-have-a-multi-indexindex .

Other pandas alternatives that state performance improvements may also have indexes, so it may be worth to check against the index attribute in the input object instead of the exact datatype of pandas. I'm not really sure since I would expect these alternative to patch the datatype.

My idea is to apply a pattern like this (edit: forget about the normalize parameter):

def qe_to_sr(qe, wavelength=None, normalize=False):

Nevertheless, I would understand opinions against this suggestion. The code may be a little more messy doing so.

Otherwise, I think this PR is well packed.

@kandersolar
Copy link
Member

My 2 cents: the idea of making design decisions around non-pandas dataframes deserves more thorough discussion than what it will get in this PR. In this particular case, I think it should be easy to add that functionality later in a backwards-compatible way, so I think we should keep it simple and stick with the pandas use case for now.

RDaxini and others added 4 commits August 8, 2024 15:52
update returns statement, change symbols, suppress runtimewarning for division by zero

Co-Authored-By: Kevin Anderson <57452607+kandersolar@users.noreply.github.com>
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.

Maybe include one more test verifying "returns np.nan in the case of 0 Wm⁻²nm⁻¹ spectral irradiance input."

pvlib/spectrum/irradiance.py Outdated Show resolved Hide resolved
pvlib/spectrum/irradiance.py Outdated Show resolved Hide resolved
pvlib/spectrum/irradiance.py Outdated Show resolved Hide resolved
pvlib/spectrum/irradiance.py Outdated Show resolved Hide resolved
RDaxini and others added 3 commits August 12, 2024 20:07
add test for return np.nan in case of zero si input
Co-authored-by: Cliff Hansen <cwhanse@sandia.gov>
Copy link
Member

@AdamRJensen AdamRJensen left a comment

Choose a reason for hiding this comment

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

This is awesome, thanks @RDaxini

pvlib/spectrum/irradiance.py Outdated Show resolved Hide resolved
pvlib/spectrum/irradiance.py Outdated Show resolved Hide resolved
pvlib/spectrum/irradiance.py Outdated Show resolved Hide resolved
pvlib/tests/spectrum/test_irradiance.py Outdated Show resolved Hide resolved
RDaxini and others added 3 commits August 14, 2024 11:56
apple suggestions from code review

Co-Authored-By: Adam R. Jensen <39184289+adamrjensen@users.noreply.github.com>
"spectrum" variable --> "spectra" (see pvlib#2150)
"spectrum" variable --> "spectra" (see pvlib#2150)
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.

A few more comments :)

docs/sphinx/source/whatsnew/v0.11.1.rst Outdated Show resolved Hide resolved
pvlib/spectrum/irradiance.py Outdated Show resolved Hide resolved
pvlib/tests/spectrum/test_mismatch.py Outdated Show resolved Hide resolved
pvlib/spectrum/irradiance.py Show resolved Hide resolved
pvlib/tests/spectrum/test_irradiance.py Outdated Show resolved Hide resolved
RDaxini and others added 5 commits August 14, 2024 17:58
remove unintentional change
apply suggestion from code review

Co-Authored-By: Kevin Anderson <57452607+kandersolar@users.noreply.github.com>
sentence correction

Co-Authored-By: Kevin Anderson <57452607+kandersolar@users.noreply.github.com>
return series in case of dataframe input, add test to verify. Remove unnecessary spaces from tests
update test for datatype according to suggestion from code review
docs/sphinx/source/whatsnew/v0.11.1.rst Outdated Show resolved Hide resolved
Co-authored-by: Kevin Anderson <kevin.anderso@gmail.com>
@kandersolar kandersolar merged commit cd9cb9a into pvlib:main Aug 14, 2024
30 checks passed
@kandersolar
Copy link
Member

Thanks @RDaxini and reviewers!

@RDaxini RDaxini deleted the calc_ape branch August 14, 2024 18:40
@RDaxini RDaxini restored the calc_ape branch August 14, 2024 18:40
@RDaxini RDaxini deleted the calc_ape branch August 14, 2024 18:40
@RDaxini
Copy link
Contributor Author

RDaxini commented Aug 14, 2024

Thanks all:)

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.

Create calculate_avg_photon_energy function
6 participants