Skip to content

Discontinuous Diffuse Sky Irradiance from Perez Model #2043

Closed

Description

@jmobrecht

Describe the bug
Using PVLib functions, I calculate a clear sky irradiance and find small ~1% discontinuities originating from the Perez model. I have isolated the issue in the source code and can correct the issue with only a few additional lines and without any cost in computational time.

To Reproduce
Steps to reproduce the behavior:

  1. Calculate solar position using pvlib.solar_position.get_solarposition
  2. Calculate air pressure pvlib.atmosphere.alt2pres
  3. Calculate airmass pvlib.atmosphere.get_relative_airmass
  4. Calculate Linke Turbidity pvlib.clearsky.lookup_linke_turbidity
  5. Calculate DNI_extra pvlib.irradiance.get_extra_radiation
  6. Calculate GHI, DNI, DHI from pvlib.clearsky.ineichen

From the above inputs, I calculate the diffuse sky irradiance using the pvlib.irradiance.perez model. The output results show a sharp discontinuity, which arises from calculation of the F1 & F2 coefficients in the 'perez' function. When an interpolation is used, the discontinuity is eliminated.

Expected behavior
Attached is an image showing the discontinuity of the diffuse sky irradiance from PVLib (blue) and the irradiance from my solution (JMO - red).
pvlib_error

Solution
image

Note
Just spoke with PVLib maintainer Adam who told me that this solution is already solved (Perez-Driesse model)... regardless I'm posting my solution for anyone who wants to use it (see comparison below)

Comparison
The edited code runs just as fast as (and sometimes faster than) the original 'perez' code, while the 'perez-driesse' code runs 50% slower than 'perez' (on my laptop).

Activity

  1. AdamRJensen commented on May 13, 2024

    @AdamRJensen
    Member

    Thanks for bringing this up @jmobrecht.

    Would it be an idea to add a warning admonition on the Perez documentation page, stating that there are small discontinuities and point to the Perez-Driesse model?

  2. kandersolar commented on Jun 14, 2024

    @kandersolar
    Member

    These minor discontinuities in the output of the Perez model are a frequent source of surprise. I think a brief explanatory note in the docstring is a good idea.

  3. added this to the 0.11.0 milestone on Jun 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions