Skip to content

solarposition.solar_azimuth_analytical returns nan #420

Closed
@adriesse

Description

@adriesse

The value passed to arccos() can end up being greater than 1 due to numerical imprecision. When this happens, nan is returned.

return np.sign(hour_angle) * np.abs(np.arccos((np.cos(zenith) * np.sin(
        latitude) - np.sin(declination)) / (np.sin(zenith) * np.cos(
        latitude)))) + np.pi

My solution would be to put in a clip(-1,1) (and also do some reformatting).

A search for arccos and arcsin turns up a few other code locations that could be susceptible to this.

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