Skip to content

Commit

Permalink
ignore invalid values in arccos calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeitsperre committed Oct 6, 2023
1 parent 2665a6f commit 19dc5a2
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions xclim/indices/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,10 @@ def day_lengths(
lat = convert_units_to(lat, "rad")
# arccos gives the hour-angle at sunset, multiply by 24 / 2π to get hours.
# The day length is twice that.
day_length_hours = (
(24 / np.pi) * np.arccos(-np.tan(lat) * np.tan(declination))
).assign_attrs(units="h")
with np.errstate(invalid="ignore"):
day_length_hours = (
(24 / np.pi) * np.arccos(-np.tan(lat) * np.tan(declination))
).assign_attrs(units="h")

return day_length_hours

Expand Down

0 comments on commit 19dc5a2

Please sign in to comment.