Skip to content

Overflow warning from pvlib.clearsky.haurwitz #363

Closed

Description

@cwhanse

The Haurwitz model takes apparent_zenith as its argument. pvlib ephemeris calculations can return zenith>90 for times after sunset. The Haurwitz model includes this term:
np.exp(-0.059/cos_zenith)
which causes a numerical overflow when cos_zenith is small and negative, i.e., apparent_zenith is greater than but close to 90.
The current Haurwitz model code obscures the warning by
clearsky_ghi[clearsky_ghi < 0] = 0
clearsky_ghi < 0 occurs whenever cos_zenith<0
I propose that we apply the Haurwitz formula only for cos_zenith>0 and set clearsky_ghi=0 otherwise.
The function output would remain unchanged but the overflow condition would be handled.

Activity

  1. wholmgren commented on Aug 11, 2017

    @wholmgren
    Member

    Sounds like a good approach.

  2. added this to the 0.5.1 milestone on Aug 11, 2017
  3. cwhanse commented on Aug 12, 2017

    @cwhanse
    MemberAuthor

    What would you like to do with the tests? All the clearsky model test follow the same pattern: compute GHI at 3hr intervals for 2014/6/24 in a location in US/Arizona, compare with known result. To catch this edge case we'd need to insert a time point just prior to sunrise or just after sunset. I'm OK with this, but do you want to propagate the edge case to all the other clearsky models?

  4. wholmgren commented on Aug 12, 2017

    @wholmgren
    Member
  5. cwhanse commented on Aug 12, 2017

    @cwhanse
    MemberAuthor

    I'll rewrite the Haurwitz test to operate on a range of zenith angles. Right now, the test could fail due to unrelated changes in the solar position algorithm. To keep it clean I'll not touch the other clearsky model tests where this could also happen: ineichen and simplified solis. We might want to consider more focused test cases for these other clear sky models.

  6. wholmgren commented on Aug 15, 2017

    @wholmgren
    Member

    closed by #364

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions