From d3e63f2770ef4430e965bf0b85d5bc302aa6b390 Mon Sep 17 00:00:00 2001 From: sriharshakandala Date: Tue, 7 Nov 2023 17:46:44 -0800 Subject: [PATCH] Update instantaneous zenith angle computation --- Project.toml | 3 ++- examples/Manifest.toml | 42 +++++++++----------------------------- examples/Project.toml | 1 + src/callbacks/callbacks.jl | 25 +++++++++++------------ 4 files changed, 25 insertions(+), 46 deletions(-) diff --git a/Project.toml b/Project.toml index 3405a6317a..0150bc133c 100644 --- a/Project.toml +++ b/Project.toml @@ -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" @@ -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" diff --git a/examples/Manifest.toml b/examples/Manifest.toml index 22162d47e0..324c5daf68 100644 --- a/examples/Manifest.toml +++ b/examples/Manifest.toml @@ -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" @@ -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"] @@ -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" @@ -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" @@ -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"] @@ -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" @@ -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" @@ -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" diff --git a/examples/Project.toml b/examples/Project.toml index 859263e27d..f55cab3f9f 100644 --- a/examples/Project.toml +++ b/examples/Project.toml @@ -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" diff --git a/src/callbacks/callbacks.jl b/src/callbacks/callbacks.jl index f0af2081d0..ff2f10c168 100644 --- a/src/callbacks/callbacks.jl +++ b/src/callbacks/callbacks.jl @@ -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 @@ -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( @@ -114,13 +120,12 @@ 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) @@ -128,13 +133,7 @@ NVTX.@annotate function rrtmgp_model_callback!(integrator) 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 .=