diff --git a/Project.toml b/Project.toml index 6b34534..e900cac 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Insolation" uuid = "e98cc03f-d57e-4e3c-b70c-8d51efe9e0d8" authors = ["Climate Modeling Alliance"] -version = "0.9.2" +version = "0.9.3" [deps] Artifacts = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" diff --git a/src/ZenithAngleCalc.jl b/src/ZenithAngleCalc.jl index 850a604..cd82adf 100644 --- a/src/ZenithAngleCalc.jl +++ b/src/ZenithAngleCalc.jl @@ -122,7 +122,10 @@ function instantaneous_zenith_angle( η = mod(η_UTC + λ, FT(2π)) # zenith angle, radians - θ = mod(acos(cos(ϕ) * cos(δ) * cos(η) + sin(ϕ) * sin(δ)), FT(2π)) + θ = mod( + acos(max(FT(-1), min(FT(1), cos(ϕ) * cos(δ) * cos(η) + sin(ϕ) * sin(δ)))), + FT(2π), + ) # solar azimuth angle, ζ = 0 when due E and increasing CCW # ζ = 3π/2 (due S) when η=0 at local solar noon