Skip to content

Commit

Permalink
Update instantaneous zenith angle computation
Browse files Browse the repository at this point in the history
  • Loading branch information
sriharshakandala committed Nov 8, 2023
1 parent f03f850 commit d3e63f2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 46 deletions.
3 changes: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
NCDatasets = "85f8d34a-cbdd-5861-8df4-14fed0d494ab"
NVTX = "5da4648a-3479-48b8-97b9-01cb529c0a1f"
OpenMPI_jll = "fe0851c0-eecd-5654-98d4-656369965a5c"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
RRTMGP = "a01a1ee8-cea4-48fc-987c-fc7878d79da1"
Expand Down Expand Up @@ -61,7 +62,7 @@ DiffEqCallbacks = "2"
DocStringExtensions = "0.8, 0.9"
FastGaussQuadrature = "0.4, 0.5, 1"
ImageFiltering = "0.7"
Insolation = "0.6"
Insolation = "0.7"
Interpolations = "0.14"
IntervalSets = "0.5, 0.6, 0.7"
Krylov = "0.9"
Expand Down
42 changes: 10 additions & 32 deletions examples/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

julia_version = "1.9.3"
manifest_format = "2.0"
project_hash = "97503acc47d6551f0f811a36b2d6bc5c5bc7e710"
project_hash = "363fad744a5399e56122f45ad4451b23306c0e3a"

[[deps.ADTypes]]
git-tree-sha1 = "5d2e21d7b0d8c22f67483ef95ebdc39c0e6b6003"
Expand Down Expand Up @@ -282,10 +282,10 @@ weakdeps = ["SparseArrays"]
ChainRulesCoreSparseArraysExt = "SparseArrays"

[[deps.ClimaAtmos]]
deps = ["ArgParse", "ArtifactWrappers", "Artifacts", "AtmosphericProfilesLibrary", "CLIMAParameters", "ClimaComms", "ClimaCore", "ClimaTimeSteppers", "CloudMicrophysics", "Colors", "Dates", "Dierckx", "DiffEqBase", "DiffEqCallbacks", "DocStringExtensions", "FastGaussQuadrature", "ImageFiltering", "Insolation", "Interpolations", "IntervalSets", "Krylov", "LinearAlgebra", "Logging", "NCDatasets", "NVTX", "Pkg", "Printf", "RRTMGP", "Random", "RootSolvers", "SciMLBase", "StaticArrays", "Statistics", "StatsBase", "SurfaceFluxes", "Test", "Thermodynamics", "YAML"]
deps = ["ArgParse", "ArtifactWrappers", "Artifacts", "AtmosphericProfilesLibrary", "CLIMAParameters", "ClimaComms", "ClimaCore", "ClimaTimeSteppers", "CloudMicrophysics", "Colors", "Dates", "Dierckx", "DiffEqBase", "DiffEqCallbacks", "DocStringExtensions", "FastGaussQuadrature", "ImageFiltering", "Insolation", "Interpolations", "IntervalSets", "Krylov", "LinearAlgebra", "Logging", "NCDatasets", "NVTX", "OpenMPI_jll", "Pkg", "Printf", "RRTMGP", "Random", "RootSolvers", "SciMLBase", "StaticArrays", "Statistics", "StatsBase", "SurfaceFluxes", "Test", "Thermodynamics", "YAML"]
path = ".."
uuid = "b2c96348-7fb7-4fe0-8da9-78d88439e717"
version = "0.16.2"
version = "0.16.3"

[[deps.ClimaComms]]
deps = ["CUDA", "MPI"]
Expand Down Expand Up @@ -967,12 +967,6 @@ git-tree-sha1 = "129acf094d168394e80ee1dc4bc06ec835e510a3"
uuid = "2e76f6c2-a576-52d4-95c1-20adfe4de566"
version = "2.8.1+1"

[[deps.Hwloc_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl"]
git-tree-sha1 = "8ecb0b34472a3c98f945e3c75fc7d5428d165511"
uuid = "e33a78d0-f292-5ffc-b300-72abe9b543c8"
version = "2.9.3+0"

[[deps.HypergeometricFunctions]]
deps = ["DualNumbers", "LinearAlgebra", "OpenLibm_jll", "SpecialFunctions"]
git-tree-sha1 = "f218fe3736ddf977e0e772bc9a586b2383da2685"
Expand Down Expand Up @@ -1044,9 +1038,11 @@ version = "1.4.0"

[[deps.Insolation]]
deps = ["Artifacts", "Dates", "DelimitedFiles", "Interpolations"]
git-tree-sha1 = "36fe16ea725ed8c8eb5fd066fd8d0ef14adc80dd"
git-tree-sha1 = "be1929a43fd09854401d4ca9496f05f253cb63b4"
repo-rev = "sk/pass_date0"
repo-url = "https://github.com/CliMA/Insolation.jl.git"
uuid = "e98cc03f-d57e-4e3c-b70c-8d51efe9e0d8"
version = "0.6.0"
version = "0.7.0"

[[deps.IntegerMathUtils]]
git-tree-sha1 = "b8ffb903da9f7b8cf695a8bead8e01814aa24b30"
Expand Down Expand Up @@ -1630,10 +1626,10 @@ uuid = "05823500-19ac-5b8b-9628-191a04bc5112"
version = "0.8.1+0"

[[deps.OpenMPI_jll]]
deps = ["Artifacts", "CompilerSupportLibraries_jll", "Hwloc_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "MPIPreferences", "PMIx_jll", "TOML", "Zlib_jll", "libevent_jll", "prrte_jll"]
git-tree-sha1 = "694458ae803b684f09c07f90459cb79655fb377d"
deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "MPIPreferences", "TOML"]
git-tree-sha1 = "e25c1778a98e34219a00455d6e4384e017ea9762"
uuid = "fe0851c0-eecd-5654-98d4-656369965a5c"
version = "5.0.0+0"
version = "4.1.6+0"

[[deps.OpenSSL]]
deps = ["BitFlags", "Dates", "MozillaCACerts_jll", "OpenSSL_jll", "Sockets"]
Expand Down Expand Up @@ -1681,12 +1677,6 @@ git-tree-sha1 = "66b2fcd977db5329aa35cac121e5b94dd6472198"
uuid = "90014a1f-27ba-587c-ab20-58faa44d9150"
version = "0.11.28"

[[deps.PMIx_jll]]
deps = ["Artifacts", "Hwloc_jll", "JLLWrappers", "Libdl", "Zlib_jll", "libevent_jll"]
git-tree-sha1 = "8b3b19351fa24791f94d7ae85faf845ca1362541"
uuid = "32165bc3-0280-59bc-8c0b-c33b6203efab"
version = "4.2.7+0"

[[deps.PNGFiles]]
deps = ["Base64", "CEnum", "ImageCore", "IndirectArrays", "OffsetArrays", "libpng_jll"]
git-tree-sha1 = "5ded86ccaf0647349231ed6c0822c10886d4a1ee"
Expand Down Expand Up @@ -2748,12 +2738,6 @@ git-tree-sha1 = "141fe65dc3efabb0b1d5ba74e91f6ad26f84cc22"
uuid = "2db6ffa8-e38f-5e21-84af-90c45d0032cc"
version = "1.11.0+0"

[[deps.libevent_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "OpenSSL_jll", "Pkg"]
git-tree-sha1 = "31bceb8a838f2e1e6d7e0311f2bea22e3a3fdae3"
uuid = "1080aeaf-3a6a-583e-a51c-c537b09f60ec"
version = "2.1.12+0"

[[deps.libfdk_aac_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "daacc84a041563f965be61859a36e17c4e4fcd55"
Expand Down Expand Up @@ -2800,12 +2784,6 @@ deps = ["Artifacts", "Libdl"]
uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0"
version = "17.4.0+0"

[[deps.prrte_jll]]
deps = ["Artifacts", "Hwloc_jll", "JLLWrappers", "Libdl", "PMIx_jll", "libevent_jll"]
git-tree-sha1 = "5adb2d7a18a30280feb66cad6f1a1dfdca2dc7b0"
uuid = "eb928a42-fffd-568d-ab9c-3f5d54fc65b9"
version = "3.0.2+0"

[[deps.x264_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "4fea590b89e6ec504593146bf8b988b2c00922b2"
Expand Down
1 change: 1 addition & 0 deletions examples/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
NCDatasets = "85f8d34a-cbdd-5861-8df4-14fed0d494ab"
NCRegressionTests = "1789bc09-29e6-4c93-9c75-fe2179693664"
NVTX = "5da4648a-3479-48b8-97b9-01cb529c0a1f"
OpenMPI_jll = "fe0851c0-eecd-5654-98d4-656369965a5c"
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
Expand Down
25 changes: 12 additions & 13 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 @@ -103,7 +103,13 @@ NVTX.@annotate function rrtmgp_model_callback!(integrator)
irradiance = FT(CAP.tot_solar_irrad(params))
au = FT(CAP.astro_unit(params))
(; orbital_data) = p.radiation

epoch_string = "2000-01-01T11:58:56.816"
date0 = DateTime(epoch_string, dateformat"y-m-dTHH:MM:SS.s")
d, δ, η_UTC = 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 +120,20 @@ 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, 0.0, 0.0)
radiation_model.solar_zenith_angle .=
min(first(insolation_tuple), max_zenith_angle)
radiation_model.weighted_irradiance .=
Expand Down

0 comments on commit d3e63f2

Please sign in to comment.