Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

limit cos of zenith angle between -1 and 1 in ZenithAngleCalc.jl #76

Merged
merged 1 commit into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
5 changes: 4 additions & 1 deletion src/ZenithAngleCalc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading