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

Implement Lorenz et al. POA and GHI QC methods #167

Open
wants to merge 43 commits into
base: main
Choose a base branch
from

Conversation

abhisheksparikh
Copy link

@abhisheksparikh abhisheksparikh commented Nov 13, 2022

  • Closes QA methods for plane-of-array irradiance #123
  • Added tests to cover all new or modified code.
  • Clearly documented all new API functions with PEP257 and numpydoc compliant docstrings.
  • Added new API functions to docs/api.rst.
  • Non-API functions clearly documented with docstrings or comments as necessary.
  • Adds description and name entries in the appropriate "what's new" file
    in docs/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`).
  • 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.

This is a draft PR. I need help editing the .rst files.

@abhisheksparikh abhisheksparikh marked this pull request as ready for review November 16, 2022 07:48
@kperrynrel kperrynrel added the enhancement New feature or request label Nov 17, 2022
@kperrynrel kperrynrel added this to the v0.1.3 milestone Nov 17, 2022
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.

Thanks @abhisheksparikh, this is looking pretty good. This PR has some merge conflicts, largely due to editing the same files as #163 did. If you need help resolving those let us know.

Also, the reference says:

Additionally, we limit the maximal step between two consecutive irradiance measurements to 1000 W/m2 for both GHI and GTI as proposed for also in Espinar et al. (2011).

Do we need to do that as well in order to claim we have fully implemented the method as published?

pvanalytics/quality/irradiance.py Outdated Show resolved Hide resolved
pvanalytics/quality/irradiance.py Outdated Show resolved Hide resolved
pvanalytics/quality/irradiance.py Outdated Show resolved Hide resolved
pvanalytics/quality/irradiance.py Outdated Show resolved Hide resolved
pvanalytics/quality/irradiance.py Outdated Show resolved Hide resolved
pvanalytics/quality/irradiance.py Outdated Show resolved Hide resolved
pvanalytics/quality/irradiance.py Outdated Show resolved Hide resolved
pvanalytics/quality/irradiance.py Outdated Show resolved Hide resolved
pvanalytics/quality/irradiance.py Outdated Show resolved Hide resolved
pvanalytics/tests/quality/test_irradiance.py Outdated Show resolved Hide resolved
abhisheksparikh and others added 2 commits November 28, 2022 12:00
Co-authored-by: Kevin Anderson <kevin.anderson@nrel.gov>
Co-authored-by: Kevin Anderson <kevin.anderson@nrel.gov>
@kperrynrel kperrynrel self-requested a review November 28, 2022 20:05
abhisheksparikh and others added 2 commits November 28, 2022 12:05
Co-authored-by: Kevin Anderson <kevin.anderson@nrel.gov>
@kandersolar kandersolar mentioned this pull request Dec 9, 2022
docs/whatsnew/0.1.3.rst Outdated Show resolved Hide resolved
pvanalytics/quality/irradiance.py Outdated Show resolved Hide resolved
pvanalytics/quality/irradiance.py Outdated Show resolved Hide resolved
pvanalytics/quality/irradiance.py Outdated Show resolved Hide resolved
pvanalytics/quality/irradiance.py Outdated Show resolved Hide resolved
pvanalytics/tests/quality/test_irradiance.py Outdated Show resolved Hide resolved
pvanalytics/tests/quality/test_irradiance.py Outdated Show resolved Hide resolved
pvanalytics/tests/quality/test_irradiance.py Outdated Show resolved Hide resolved
pvanalytics/tests/quality/test_irradiance.py Outdated Show resolved Hide resolved
pvanalytics/tests/quality/test_irradiance.py Show resolved Hide resolved
abhisheksparikh and others added 13 commits December 12, 2022 09:00
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>
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>
Co-authored-by: Cliff Hansen <cwhanse@sandia.gov>
@cwhanse
Copy link
Member

cwhanse commented Jan 9, 2023

I think that flagging low irradiance at nighttime is OK in the context of pvanalytics. The package provides other functions which label day/night periods, and each quality function returns a time series of Boolean for the critieria it checks. The temptation is to regard 'True' here as equivalent to a valid measurement - and that is not always the case, as the discussion brings out.

irradiance measurements at nighttime typically have a slightly negative value

That is certainly true for thermopile instruments, but not for all instruments. I think a reference cell would report a small positive value.

@AdamRJensen
Copy link
Member

AdamRJensen commented Mar 20, 2023

Elke Lorenz has written the following to me:

For the naming: Do you think it would be o.k. to name the functions “pvlive” instead of “Lorenz”? I think that using the name of the main author of a paper is what you typically do, but this was really team work and so I think “pvlive” would be more appropriate.

Thus, I suggest that we change the name as requested. If anyone have any objection, please comment!

@abhisheksparikh
Copy link
Author

abhisheksparikh commented Mar 20, 2023 via email

@kandersolar
Copy link
Member

Friendly ping @abhisheksparikh about this PR :)

docs/api.rst Outdated Show resolved Hide resolved
pvanalytics/quality/irradiance.py Outdated Show resolved Hide resolved
pvanalytics/quality/irradiance.py Outdated Show resolved Hide resolved
abhisheksparikh and others added 3 commits May 26, 2023 10:56
Co-authored-by: Adam R. Jensen <39184289+AdamRJensen@users.noreply.github.com>
Co-authored-by: Adam R. Jensen <39184289+AdamRJensen@users.noreply.github.com>
Co-authored-by: Adam R. Jensen <39184289+AdamRJensen@users.noreply.github.com>
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.

The code seems good, so well done!

My main concern is that it seems like an awful lot of code to implement the integer flags. I would prefer to just have the individual functions, but it's not a strong preference.

pvanalytics/quality/irradiance.py Outdated Show resolved Hide resolved
pvanalytics/quality/irradiance.py Outdated Show resolved Hide resolved
pvanalytics/quality/irradiance.py Outdated Show resolved Hide resolved
Comment on lines +668 to +669
The upper limit for `poa_global` is set to 0 when `solar_zenith` is greater
than 90 degrees. Missing values of `poa_global`, `solar_zenith`
Copy link
Member

Choose a reason for hiding this comment

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

I'm still in strong favor of not flagging values at nighttime. I recently had a chat with the main author of the paper who did not have a recommendation for night time. Lorenz pointed me toward one of the co-authors who has yet to respond to my request.

Copy link
Author

Choose a reason for hiding this comment

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

Not having thought about the significance of nighttime data, I don't have a strong opinion on this. But if I were to think of irradiance as a part of operational analysis of a PV plant, I would like to have some distinction between daytime and nighttime data.

Comment on lines +696 to +701
# Changing the poa_global_flag to 3 when the step change in poa values is
# more than 1000 W/m2
poa_global_limit_int_flag = poa_global_limit_int_flag.mask(
poa_global.diff().abs() > 1000,
3
)
Copy link
Member

Choose a reason for hiding this comment

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

I think this deserves it's own function.

The step change limit is fairly common:

For 1-min data Shafer et al. (2000) recommended a step change limit of 800 W/m2, although Espinar (2011) suggested 1000 W/m2 for GHI. Lorenz et al. (2022) also suggested using the 1000 W/m2 threshold for tilted irradiance measurements.

Copy link
Member

Choose a reason for hiding this comment

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

It could be done in a separate pull request.

Copy link
Author

Choose a reason for hiding this comment

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

Good point. I think one good reason to have the step change limit in here is to stay true to the list of checks the paper suggests.

Copy link
Member

Choose a reason for hiding this comment

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

we could have a helper function that returns the step threshold, and pass it a kwarg 'pvlive' to return 1000.

Copy link
Member

Choose a reason for hiding this comment

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

However, I am completely fine with separating out the filter as a separate function ☺️.

As am I, let's do this and have a step_limit kwarg or something.

Copy link
Author

Choose a reason for hiding this comment

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

we could have a helper function that returns the step threshold, and pass it a kwarg 'pvlive' to return 1000.

Can somebody help me with this? After some reading, I think I understand kwargs, but have never written a function with them. Some more guidance on how the functions' design would be helpful.

Copy link
Member

Choose a reason for hiding this comment

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

@abhisheksparikh let's do that in a follow-on pull request. I feel like we are good enough here and we can improve later. Agree @AdamRJensen ?

abhisheksparikh and others added 3 commits May 30, 2023 06:06
Co-authored-by: Adam R. Jensen <39184289+AdamRJensen@users.noreply.github.com>
Co-authored-by: Adam R. Jensen <39184289+AdamRJensen@users.noreply.github.com>
Co-authored-by: Adam R. Jensen <39184289+AdamRJensen@users.noreply.github.com>
@abhisheksparikh
Copy link
Author

The code seems good, so well done!

My main concern is that it seems like an awful lot of code to implement the integer flags. I would prefer to just have the individual functions, but it's not a strong preference.

Do you have any recommendations? For e.g. would you combine the upper and lower limit functions? Individual functions provide clarity, but I am okay with combining them.

@abhisheksparikh
Copy link
Author

The code seems good, so well done!

My main concern is that it seems like an awful lot of code to implement the integer flags. I would prefer to just have the individual functions, but it's not a strong preference.

Yeah, I agree, the code is definitely longer for what it's doing.

pvanalytics/quality/irradiance.py Outdated Show resolved Hide resolved
pvanalytics/quality/irradiance.py Outdated Show resolved Hide resolved
pvanalytics/quality/irradiance.py Outdated Show resolved Hide resolved
pvanalytics/quality/irradiance.py Outdated Show resolved Hide resolved
@cwhanse
Copy link
Member

cwhanse commented May 30, 2023

@abhisheksparikh I think we should explain the integer flag values. I don't know if my suggestions will render properly as a web page.

@cwhanse cwhanse mentioned this pull request May 30, 2023
4 tasks
abhisheksparikh and others added 4 commits June 3, 2023 22:15
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>
@AdamRJensen
Copy link
Member

AdamRJensen commented Jun 8, 2023

The authors have responded to our question concerning what to do for nighttime values:

Regarding the night values: in our implementation we set all night values to zero and set a Flag with value 1 for all values changed. But actually, the method is not made for night values. So as you wrote, not checking is also an option which is maybe better for general applications. For some applications night values might be of interest, we actually do not use them anywhere.

So for the integer output, I think we should set nighttime values to 1 True. But for the bool series returned, I suggest not setting any nighttime limits but rather setting a flag of True or False depending on the outcome of #191.

Additionally, the authors also wrote:

One other thing I have to point out. While checking your implementation we found a mistake in the publication, which is very unfortunate. We write I0 as solar constant with a fixed value. But actually I0 should be the Normal extraterrestrial irradiance corrected from Sun-Earth distance, which has a yearly cycle. We use the formula proposed by Spencer 1971 with a simplification suggested in “Energy Meteorology, Lecture Notes from Detlev Heinemann, 2002 Formula 2.16”

@abhisheksparikh This should be relatively straightforward to correct. You can look at the existing tests which do something very similar.

@abhisheksparikh
Copy link
Author

abhisheksparikh commented Jun 14, 2023

So for the integer output, I think we should set nighttime values to True. But for the bool series returned, I suggest not setting any nighttime limits but rather setting a flag of True or False depending on the outcome of #191.

@AdamRJensen - I am confused by this: 'So for the integer output, I think we should set nighttime values to True'.

I will change the Normal extraterrestrial irradiance based on the formula.

@AdamRJensen
Copy link
Member

@AdamRJensen - I am confused by this: 'So for the integer output, I think we should set nighttime values to True'.

A typo on my behalf - the flag for the integer should of course be 1 as stated by the authors 😄

@kandersolar kandersolar modified the milestones: v0.2.0, v0.2.1 Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

QA methods for plane-of-array irradiance
6 participants