From 19dc5a25bc5c9af9e1fd3475f6642009348b0211 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Fri, 6 Oct 2023 13:38:13 -0400 Subject: [PATCH] ignore invalid values in arccos calculation --- xclim/indices/helpers.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/xclim/indices/helpers.py b/xclim/indices/helpers.py index e830decec..89673b00f 100644 --- a/xclim/indices/helpers.py +++ b/xclim/indices/helpers.py @@ -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