From a50e3cb5dbaaf9135270b7fe04e40add16f214bb Mon Sep 17 00:00:00 2001 From: sriharshakandala Date: Tue, 14 Nov 2023 09:10:02 -0800 Subject: [PATCH] Update instantaneous zenith angle function --- Project.toml | 2 +- docs/Manifest.toml | 8 ++++---- examples/Manifest.toml | 16 ++++++++-------- perf/Manifest.toml | 20 ++++++++++---------- src/callbacks/callbacks.jl | 30 +++++++++++++++--------------- 5 files changed, 38 insertions(+), 38 deletions(-) diff --git a/Project.toml b/Project.toml index dde7d1ac566..0bafc1179bc 100644 --- a/Project.toml +++ b/Project.toml @@ -63,7 +63,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" diff --git a/docs/Manifest.toml b/docs/Manifest.toml index 32a57907b04..24fe35727b4 100644 --- a/docs/Manifest.toml +++ b/docs/Manifest.toml @@ -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" @@ -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"] diff --git a/examples/Manifest.toml b/examples/Manifest.toml index 00ea63173e0..2b75d4d6050 100644 --- a/examples/Manifest.toml +++ b/examples/Manifest.toml @@ -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"] @@ -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" @@ -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"] @@ -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] diff --git a/perf/Manifest.toml b/perf/Manifest.toml index af0f302a8ff..6a54f0c83a5 100644 --- a/perf/Manifest.toml +++ b/perf/Manifest.toml @@ -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"] @@ -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" @@ -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"] @@ -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"] @@ -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] diff --git a/src/callbacks/callbacks.jl b/src/callbacks/callbacks.jl index ac8eb185391..bde9e03d9f6 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 @@ -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 = eltype(parent(Y.c)) thermo_params = CAP.thermodynamics_params(params) insolation_params = CAP.insolation_params(params) @@ -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") + d, δ, η_UTC = + Float64.( + Insolation.helper_instantaneous_zenith_angle( + current_datetime, + date0, + insolation_params, + ) + ) # TODO: This needs to be changed to FT bottom_coords = Fields.coordinate_field(Spaces.level(Y.c, 1)) if eltype(bottom_coords) <: Geometry.LatLongZPoint solar_zenith_angle = RRTMGPI.array2field( @@ -114,13 +121,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 +134,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 .=