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

Update instantaneous zenith angle function #2358

Merged
merged 2 commits into from
Nov 21, 2023
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
Expand Up @@ -64,7 +64,7 @@ DocStringExtensions = "0.8, 0.9"
FastGaussQuadrature = "0.4, 0.5, 1"
HDF5_jll = "~1.12"
ImageFiltering = "0.7"
Insolation = "0.6"
Insolation = "0.8"
Interpolations = "0.14"
IntervalSets = "0.5, 0.6, 0.7"
Krylov = "0.9"
Expand Down
8 changes: 4 additions & 4 deletions docs/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -777,9 +777,9 @@ version = "1.4.0"

[[deps.Insolation]]
deps = ["Artifacts", "Dates", "DelimitedFiles", "Interpolations"]
git-tree-sha1 = "36fe16ea725ed8c8eb5fd066fd8d0ef14adc80dd"
git-tree-sha1 = "937658520f9d5786ea11b70713163fe277925492"
uuid = "e98cc03f-d57e-4e3c-b70c-8d51efe9e0d8"
version = "0.6.0"
version = "0.8.0"

[[deps.IntegerMathUtils]]
git-tree-sha1 = "b8ffb903da9f7b8cf695a8bead8e01814aa24b30"
Expand Down Expand Up @@ -1270,9 +1270,9 @@ version = "2.2.8"

[[deps.Primes]]
deps = ["IntegerMathUtils"]
git-tree-sha1 = "4c9f306e5d6603ae203c2000dd460d81a5251489"
git-tree-sha1 = "1d05623b5952aed1307bf8b43bec8b8d1ef94b6e"
uuid = "27ebfcd6-29c5-5fa9-bf4b-fb8fc14df3ae"
version = "0.5.4"
version = "0.5.5"

[[deps.Printf]]
deps = ["Unicode"]
Expand Down
16 changes: 8 additions & 8 deletions examples/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ weakdeps = ["SparseArrays"]
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

[[deps.BitFlags]]
git-tree-sha1 = "43b1a4a8f797c1cddadf60499a8a077d4af2cd2d"
git-tree-sha1 = "2dc09997850d68179b69dafb58ae806167a32b1b"
uuid = "d1d4a3ce-64b1-5f1a-9ba4-7e7e69966f35"
version = "0.1.7"
version = "0.1.8"

[[deps.BitTwiddlingConvenienceFunctions]]
deps = ["Static"]
Expand Down Expand Up @@ -1086,9 +1086,9 @@ version = "1.4.0"

[[deps.Insolation]]
deps = ["Artifacts", "Dates", "DelimitedFiles", "Interpolations"]
git-tree-sha1 = "36fe16ea725ed8c8eb5fd066fd8d0ef14adc80dd"
git-tree-sha1 = "937658520f9d5786ea11b70713163fe277925492"
uuid = "e98cc03f-d57e-4e3c-b70c-8d51efe9e0d8"
version = "0.6.0"
version = "0.8.0"

[[deps.IntegerMathUtils]]
git-tree-sha1 = "b8ffb903da9f7b8cf695a8bead8e01814aa24b30"
Expand Down Expand Up @@ -1929,9 +1929,9 @@ version = "2.2.8"

[[deps.Primes]]
deps = ["IntegerMathUtils"]
git-tree-sha1 = "4c9f306e5d6603ae203c2000dd460d81a5251489"
git-tree-sha1 = "1d05623b5952aed1307bf8b43bec8b8d1ef94b6e"
uuid = "27ebfcd6-29c5-5fa9-bf4b-fb8fc14df3ae"
version = "0.5.4"
version = "0.5.5"

[[deps.Printf]]
deps = ["Unicode"]
Expand Down Expand Up @@ -2520,9 +2520,9 @@ version = "0.4.1"

[[deps.Unitful]]
deps = ["Dates", "LinearAlgebra", "Random"]
git-tree-sha1 = "a72d22c7e13fe2de562feda8645aa134712a87ee"
git-tree-sha1 = "242982d62ff0d1671e9029b52743062739255c7e"
uuid = "1986cc42-f94f-5a68-af5c-568840ba703d"
version = "1.17.0"
version = "1.18.0"
weakdeps = ["ConstructionBase", "InverseFunctions"]

[deps.Unitful.extensions]
Expand Down
20 changes: 10 additions & 10 deletions perf/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,9 @@ uuid = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
version = "1.3.2"

[[deps.BitFlags]]
git-tree-sha1 = "43b1a4a8f797c1cddadf60499a8a077d4af2cd2d"
git-tree-sha1 = "2dc09997850d68179b69dafb58ae806167a32b1b"
uuid = "d1d4a3ce-64b1-5f1a-9ba4-7e7e69966f35"
version = "0.1.7"
version = "0.1.8"

[[deps.BitTwiddlingConvenienceFunctions]]
deps = ["Static"]
Expand Down Expand Up @@ -1133,9 +1133,9 @@ version = "1.4.0"

[[deps.Insolation]]
deps = ["Artifacts", "Dates", "DelimitedFiles", "Interpolations"]
git-tree-sha1 = "36fe16ea725ed8c8eb5fd066fd8d0ef14adc80dd"
git-tree-sha1 = "937658520f9d5786ea11b70713163fe277925492"
uuid = "e98cc03f-d57e-4e3c-b70c-8d51efe9e0d8"
version = "0.6.0"
version = "0.8.0"

[[deps.IntegerMathUtils]]
git-tree-sha1 = "b8ffb903da9f7b8cf695a8bead8e01814aa24b30"
Expand Down Expand Up @@ -1261,9 +1261,9 @@ uuid = "9c1d0b0a-7046-5b2e-a33f-ea22f176ac7e"
version = "0.2.1+0"

[[deps.JuliaSyntax]]
git-tree-sha1 = "d080fa670adde72509d03d91bf6ce6da2addb4be"
git-tree-sha1 = "1a4857ab55396b2da745f07f76ce4e696207b740"
uuid = "70703baa-626e-46a2-a12c-08ffd08c73b4"
version = "0.4.6"
version = "0.4.7"

[[deps.KernelAbstractions]]
deps = ["Adapt", "Atomix", "InteractiveUtils", "LinearAlgebra", "MacroTools", "PrecompileTools", "Requires", "SparseArrays", "StaticArrays", "UUIDs", "UnsafeAtomics", "UnsafeAtomicsLLVM"]
Expand Down Expand Up @@ -1987,9 +1987,9 @@ version = "2.2.8"

[[deps.Primes]]
deps = ["IntegerMathUtils"]
git-tree-sha1 = "4c9f306e5d6603ae203c2000dd460d81a5251489"
git-tree-sha1 = "1d05623b5952aed1307bf8b43bec8b8d1ef94b6e"
uuid = "27ebfcd6-29c5-5fa9-bf4b-fb8fc14df3ae"
version = "0.5.4"
version = "0.5.5"

[[deps.Printf]]
deps = ["Unicode"]
Expand Down Expand Up @@ -2614,9 +2614,9 @@ version = "0.4.1"

[[deps.Unitful]]
deps = ["Dates", "LinearAlgebra", "Random"]
git-tree-sha1 = "a72d22c7e13fe2de562feda8645aa134712a87ee"
git-tree-sha1 = "242982d62ff0d1671e9029b52743062739255c7e"
uuid = "1986cc42-f94f-5a68-af5c-568840ba703d"
version = "1.17.0"
version = "1.18.0"
weakdeps = ["ConstructionBase", "InverseFunctions"]

[deps.Unitful.extensions]
Expand Down
2 changes: 1 addition & 1 deletion regression_tests/ref_counter.jl
Original file line number Diff line number Diff line change
@@ -1 +1 @@
137
138
31 changes: 16 additions & 15 deletions src/callbacks/callbacks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import SciMLBase
import .Parameters as CAP
import DiffEqCallbacks as DECB
import ClimaCore: InputOutput
import Dates
using Dates
using Insolation: instantaneous_zenith_angle
import ClimaCore.Fields: ColumnField

Expand Down Expand Up @@ -47,7 +47,7 @@ NVTX.@annotate function rrtmgp_model_callback!(integrator)
(; idealized_insolation, idealized_h2o, idealized_clouds) = p.radiation
(; insolation_tuple, ᶠradiation_flux, radiation_model) = p.radiation

FT = eltype(params)
FT = Spaces.undertype(axes(Y.c))
thermo_params = CAP.thermodynamics_params(params)
insolation_params = CAP.insolation_params(params)

Expand Down Expand Up @@ -102,8 +102,15 @@ NVTX.@annotate function rrtmgp_model_callback!(integrator)
max_zenith_angle = FT(π) / 2 - eps(FT)
irradiance = FT(CAP.tot_solar_irrad(params))
au = FT(CAP.astro_unit(params))
(; orbital_data) = p.radiation

date0 = DateTime("2000-01-01T11:58:56.816")
sriharshakandala marked this conversation as resolved.
Show resolved Hide resolved
d, δ, η_UTC =
FT.(
Insolation.helper_instantaneous_zenith_angle(
current_datetime,
date0,
insolation_params,
)
)
bottom_coords = Fields.coordinate_field(Spaces.level(Y.c, 1))
if eltype(bottom_coords) <: Geometry.LatLongZPoint
solar_zenith_angle = RRTMGPI.array2field(
Expand All @@ -114,27 +121,21 @@ NVTX.@annotate function rrtmgp_model_callback!(integrator)
radiation_model.weighted_irradiance,
axes(bottom_coords),
)
ref_insolation_params = tuple(insolation_params)
@. insolation_tuple = instantaneous_zenith_angle(
current_datetime,
orbital_data,
d,
δ,
η_UTC,
bottom_coords.long,
bottom_coords.lat,
ref_insolation_params,
) # the tuple is (zenith angle, azimuthal angle, earth-sun distance)
@. solar_zenith_angle =
min(first(insolation_tuple), max_zenith_angle)
@. weighted_irradiance =
irradiance * (au / last(insolation_tuple))^2
else
# assume that the latitude and longitude are both 0 for flat space
insolation_tuple = instantaneous_zenith_angle(
current_datetime,
orbital_data,
0.0,
0.0,
insolation_params,
)
insolation_tuple =
instantaneous_zenith_angle(d, δ, η_UTC, FT(0), FT(0))
radiation_model.solar_zenith_angle .=
min(first(insolation_tuple), max_zenith_angle)
radiation_model.weighted_irradiance .=
Expand Down
Loading