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

_delta_kt_prime_dirint() Method Returns Values That Are Half of What they Should be #637

Closed
chriswmackey opened this issue Jan 3, 2019 · 5 comments
Labels

Comments

@chriswmackey
Copy link

Hello,

I believe that I have found a bug or at least a misalignment between a formula that was written in a publication and the result of a pvlib method.

The bug appears specifically on these lines of the _delta_kt_prime_dirint() method in irradiance.py:
https://github.com/pvlib/pvlib-python/blob/master/pvlib/irradiance.py#L1566-L1568

... and I realize that this formula references Perez's equation 2 as follows:
image

Here is the full publication where the image above came from from:
https://www.researchgate.net/publication/279868352_Dynamic_global-to-direct_irradiance_conversion_models

The bug seems to be the result of how pandas deals with the add() method and the fill_value.

To re-create the bug, I recommend running the following code:

kt_prime = pd.Series([0.79, 0.77])
times = pd.DatetimeIndex(['2014-06-24T12-0700', '2014-06-24T18-0700'])
delta_kt_prime = pvlib.irradiance._delta_kt_prime_dirint(kt_prime, True, times)

At the moment, this returns a delta_kt_prime value that is equal to 0.01. However, this should clearly be equal to 0.02 according to Perez's equation 2.

Versions:

  • pvlib.__version__: 0.6.0
  • pandas.__version__: 0.23.4
  • python: 3.7
@cwhanse
Copy link
Member

cwhanse commented Jan 3, 2019

@chriswmackey verified. Calculating Kt' is handled differently in PVLib Matlab

@cwhanse cwhanse added the bug label Jan 3, 2019
@cwhanse
Copy link
Member

cwhanse commented Jan 3, 2019

@chriswmackey thanks very much for bringing this to our attention!

@cwhanse
Copy link
Member

cwhanse commented Jan 3, 2019

This bug affects the first and last values in a time series of DNI calculated by irradiance.dirint. The error is not "small", e.g., with GHI = 1038 W/m2 and zenith = 10.6 degrees, the incorrect value of DNI was 888, after correction DHI is 868.

@wholmgren
Copy link
Member

thanks @chriswmackey for the report and @cwhanse for the fix.

@chriswmackey
Copy link
Author

Thank you @cwhanse for the fix! It's a great library that you have built here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants