From 8fb650c1d560fbb96b89b78162d5df4779548e03 Mon Sep 17 00:00:00 2001 From: Julia Sloan Date: Wed, 22 Nov 2023 16:04:55 -0800 Subject: [PATCH] use Insolation v0.8 --- docs/Manifest.toml | 6 +-- docs/Project.toml | 2 +- .../integrated/soil_canopy_tutorial.jl | 2 +- .../standalone/Bucket/bucket_tutorial.jl | 10 +---- .../standalone/Canopy/canopy_tutorial.jl | 2 +- experiments/Manifest.toml | 6 +-- experiments/Project.toml | 2 +- .../ozark/conservation/ozark_conservation.jl | 2 +- experiments/integrated/ozark/ozark.jl | 2 +- .../ozark/ozark_met_drivers_FLUXNET.jl | 28 ++++++++----- experiments/integrated/vaira_ranch/vaira.jl | 2 +- .../vaira_ranch/vaira_met_drivers_FLUXNET.jl | 27 ++++++++----- experiments/standalone/Soil/evaporation.jl | 10 +---- src/shared_utilities/drivers.jl | 18 ++------- src/standalone/Vegetation/Canopy.jl | 2 +- test/Project.toml | 2 +- test/standalone/Bucket/albedo_types.jl | 15 ++----- test/standalone/Bucket/snow_bucket_tests.jl | 22 ++-------- test/standalone/Bucket/soil_bucket_tests.jl | 19 ++------- test/standalone/Soil/climate_drivers.jl | 10 +---- test/standalone/Vegetation/canopy_model.jl | 40 +++++++++++++------ .../Vegetation/plant_hydraulics_test.jl | 40 +++++++++++++------ 22 files changed, 125 insertions(+), 144 deletions(-) diff --git a/docs/Manifest.toml b/docs/Manifest.toml index 943d2173b7..afac3ace90 100644 --- a/docs/Manifest.toml +++ b/docs/Manifest.toml @@ -2,7 +2,7 @@ julia_version = "1.9.4" manifest_format = "2.0" -project_hash = "6cc9e2b156a4b59ebb284e1be687ef18f212cffe" +project_hash = "6e09c6e4bb3544522827eac8007d75cd7aedbc96" [[deps.ADTypes]] git-tree-sha1 = "332e5d7baeff8497b923b730b994fa480601efc7" @@ -746,9 +746,9 @@ version = "0.1.1" [[deps.Insolation]] deps = ["Artifacts", "Dates", "DelimitedFiles", "Interpolations"] -git-tree-sha1 = "eb83622d1d24e764d799ebeb92e9ffa5926870fc" +git-tree-sha1 = "937658520f9d5786ea11b70713163fe277925492" uuid = "e98cc03f-d57e-4e3c-b70c-8d51efe9e0d8" -version = "0.7.0" +version = "0.8.0" [[deps.IntelOpenMP_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] diff --git a/docs/Project.toml b/docs/Project.toml index 96752f4320..cfd20363b8 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -20,5 +20,5 @@ Thermodynamics = "b60c26fb-14c3-4610-9d3e-2d17fe7ff00c" [compat] CLIMAParameters = "0.7" ClimaTimeSteppers = "=0.7.7" -Insolation = "0.7" +Insolation = "0.8" InteractiveUtils = "1" diff --git a/docs/tutorials/integrated/soil_canopy_tutorial.jl b/docs/tutorials/integrated/soil_canopy_tutorial.jl index b3f4a573cf..cd69c7def0 100644 --- a/docs/tutorials/integrated/soil_canopy_tutorial.jl +++ b/docs/tutorials/integrated/soil_canopy_tutorial.jl @@ -36,7 +36,7 @@ import SciMLBase using Plots using Statistics using Dates -using Insolation + # Load CliMA Packages and ClimaLSM Modules: diff --git a/docs/tutorials/standalone/Bucket/bucket_tutorial.jl b/docs/tutorials/standalone/Bucket/bucket_tutorial.jl index 841d4318ff..2300b16ae5 100644 --- a/docs/tutorials/standalone/Bucket/bucket_tutorial.jl +++ b/docs/tutorials/standalone/Bucket/bucket_tutorial.jl @@ -131,7 +131,7 @@ using ClimaCore import CLIMAParameters as CP # We also use Insolation to calculate solar zenith angle and solar insolation. -using Insolation + # Lastly, let's bring in the bucket model types (from ClimaLSM) that we # will need access to. @@ -230,13 +230,7 @@ ref_time = DateTime(2005); # Here we define the model drivers, starting with downward radiation. SW_d = (t) -> 300; LW_d = (t) -> 300; -bucket_rad = PrescribedRadiativeFluxes( - FT, - SW_d, - LW_d, - ref_time; - orbital_data = Insolation.OrbitalData(), -); +bucket_rad = PrescribedRadiativeFluxes(FT, SW_d, LW_d, ref_time); # Prescribed atmospheric variables diff --git a/docs/tutorials/standalone/Canopy/canopy_tutorial.jl b/docs/tutorials/standalone/Canopy/canopy_tutorial.jl index 199d59b751..c663571a87 100644 --- a/docs/tutorials/standalone/Canopy/canopy_tutorial.jl +++ b/docs/tutorials/standalone/Canopy/canopy_tutorial.jl @@ -38,7 +38,7 @@ import SciMLBase using Plots using Statistics using Dates -using Insolation + # Load CliMA Packages and ClimaLSM Modules: diff --git a/experiments/Manifest.toml b/experiments/Manifest.toml index 2cf2f94250..9eed3ccbca 100644 --- a/experiments/Manifest.toml +++ b/experiments/Manifest.toml @@ -2,7 +2,7 @@ julia_version = "1.9.4" manifest_format = "2.0" -project_hash = "b3e3a6d4123251d3704cd4a385039b761f093c21" +project_hash = "2067c786604e9e079cf0e3e81be0d40fac5319be" [[deps.ADTypes]] git-tree-sha1 = "332e5d7baeff8497b923b730b994fa480601efc7" @@ -724,9 +724,9 @@ version = "0.1.1" [[deps.Insolation]] deps = ["Artifacts", "Dates", "DelimitedFiles", "Interpolations"] -git-tree-sha1 = "eb83622d1d24e764d799ebeb92e9ffa5926870fc" +git-tree-sha1 = "937658520f9d5786ea11b70713163fe277925492" uuid = "e98cc03f-d57e-4e3c-b70c-8d51efe9e0d8" -version = "0.7.0" +version = "0.8.0" [[deps.IntelOpenMP_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] diff --git a/experiments/Project.toml b/experiments/Project.toml index 4ad9d3a182..634cc92942 100644 --- a/experiments/Project.toml +++ b/experiments/Project.toml @@ -20,5 +20,5 @@ Thermodynamics = "b60c26fb-14c3-4610-9d3e-2d17fe7ff00c" [compat] CLIMAParameters = "0.7" ClimaTimeSteppers = "=0.7.7" -Insolation = "0.7" +Insolation = "0.8" Statistics = "1" diff --git a/experiments/integrated/ozark/conservation/ozark_conservation.jl b/experiments/integrated/ozark/conservation/ozark_conservation.jl index 7e7d021ecc..caa3308658 100644 --- a/experiments/integrated/ozark/conservation/ozark_conservation.jl +++ b/experiments/integrated/ozark/conservation/ozark_conservation.jl @@ -5,7 +5,7 @@ import CLIMAParameters as CP using Plots using Statistics using Dates -using Insolation + using ClimaLSM using ClimaLSM.Domains: Column diff --git a/experiments/integrated/ozark/ozark.jl b/experiments/integrated/ozark/ozark.jl index dd1e08425a..56881e7db2 100644 --- a/experiments/integrated/ozark/ozark.jl +++ b/experiments/integrated/ozark/ozark.jl @@ -5,7 +5,7 @@ import CLIMAParameters as CP using Plots using Statistics using Dates -using Insolation + using StatsBase using ClimaLSM diff --git a/experiments/integrated/ozark/ozark_met_drivers_FLUXNET.jl b/experiments/integrated/ozark/ozark_met_drivers_FLUXNET.jl index 2aa96b9a11..e73be535b5 100644 --- a/experiments/integrated/ozark/ozark_met_drivers_FLUXNET.jl +++ b/experiments/integrated/ozark/ozark_met_drivers_FLUXNET.jl @@ -3,12 +3,13 @@ ## Citation: Jeffrey Wood, Lianhong Gu (2021), ## AmeriFlux FLUXNET-1F US-MOz Missouri Ozark Site, Ver. 3-5, AmeriFlux AMP, (Dataset). https://doi.org/10.17190/AMF/1854370 - using ArtifactWrappers using DelimitedFiles using Dierckx using Thermodynamics using Dates +import Insolation + function replace_missing_with_mean!(field, flag) good_indices = (flag .== 0) .|| (flag .== 1) fill_value = mean(field[good_indices]) @@ -133,23 +134,31 @@ long = FT(-92.2000) # degree function zenith_angle( t, - orbital_data, ref_time; latitude = lat, longitude = long, insol_params::Insolation.Parameters.InsolationParameters{FT} = earth_param_set.insol_params, ) where {FT} # This should be time in UTC - dt = ref_time + Dates.Second(round(t)) - # Orbital Data uses Float64, so we need to convert to our sim - # FT. + current_datetime = ref_time + Dates.Second(round(t)) + + # Orbital Data uses Float64, so we need to convert to our sim FT + d, δ, η_UTC = + FT.( + Insolation.helper_instantaneous_zenith_angle( + current_datetime, + ref_time, + insol_params, + ) + ) + FT( - instantaneous_zenith_angle( - dt, - orbital_data, + Insolation.instantaneous_zenith_angle( + d, + δ, + η_UTC, longitude, latitude, - insol_params, )[1], ) end @@ -161,7 +170,6 @@ radiation = ClimaLSM.PrescribedRadiativeFluxes( LW_IN_spline, UTC_DATETIME[1]; θs = zenith_angle, - orbital_data = Insolation.OrbitalData(), ) diff --git a/experiments/integrated/vaira_ranch/vaira.jl b/experiments/integrated/vaira_ranch/vaira.jl index d1eac6a10c..f73e5a2522 100644 --- a/experiments/integrated/vaira_ranch/vaira.jl +++ b/experiments/integrated/vaira_ranch/vaira.jl @@ -5,7 +5,7 @@ import CLIMAParameters as CP using Plots using Statistics using Dates -using Insolation + using StatsBase using ClimaLSM diff --git a/experiments/integrated/vaira_ranch/vaira_met_drivers_FLUXNET.jl b/experiments/integrated/vaira_ranch/vaira_met_drivers_FLUXNET.jl index 1ada11fe02..8d1c1f72f7 100644 --- a/experiments/integrated/vaira_ranch/vaira_met_drivers_FLUXNET.jl +++ b/experiments/integrated/vaira_ranch/vaira_met_drivers_FLUXNET.jl @@ -10,6 +10,8 @@ using Dierckx using Thermodynamics using Dates using ArtifactWrappers +import Insolation + function replace_missing_with_mean!(field, flag) good_indices = (flag .== 0) .|| (flag .== 1) fill_value = mean(field[good_indices]) @@ -152,23 +154,31 @@ long = FT(-120.9508) # degree function zenith_angle( t, - orbital_data, ref_time; latitude = lat, longitude = long, insol_params::Insolation.Parameters.InsolationParameters{FT} = earth_param_set.insol_params, ) where {FT} # This should be time in UTC - dt = ref_time + Dates.Second(round(t)) - # Orbital Data uses Float64, so we need to convert to our sim - # FT. + current_datetime = ref_time + Dates.Second(round(t)) + + # Orbital Data uses Float64, so we need to convert to our sim FT. + d, δ, η_UTC = + FT.( + Insolation.helper_instantaneous_zenith_angle( + current_datetime, + ref_time, + insol_params, + ) + ) + FT( - instantaneous_zenith_angle( - dt, - orbital_data, + Insolation.instantaneous_zenith_angle( + d, + δ, + η_UTC, longitude, latitude, - insol_params, )[1], ) end @@ -180,7 +190,6 @@ radiation = ClimaLSM.PrescribedRadiativeFluxes( LW_IN_spline, UTC_DATETIME[1]; θs = zenith_angle, - orbital_data = Insolation.OrbitalData(), ) # LAI data diff --git a/experiments/standalone/Soil/evaporation.jl b/experiments/standalone/Soil/evaporation.jl index 509d4df781..24e7477df3 100644 --- a/experiments/standalone/Soil/evaporation.jl +++ b/experiments/standalone/Soil/evaporation.jl @@ -2,7 +2,7 @@ using Plots import SciMLBase import ClimaTimeSteppers as CTS using Thermodynamics -using Insolation + using ClimaCore import CLIMAParameters as CP using RootSolvers @@ -67,13 +67,7 @@ for (FT, tf) in ((Float32, 2 * dt), (Float64, tf)) ref_time = DateTime(2005) SW_d = (t) -> 0 LW_d = (t) -> 301.15^4 * 5.67e-8 - radiation = PrescribedRadiativeFluxes( - FT, - SW_d, - LW_d, - ref_time; - orbital_data = Insolation.OrbitalData(), - ) + radiation = PrescribedRadiativeFluxes(FT, SW_d, LW_d, ref_time) # Atmos T_air = 301.15 rh = 0.38 diff --git a/src/shared_utilities/drivers.jl b/src/shared_utilities/drivers.jl index 99024ff73d..15add7c6db 100644 --- a/src/shared_utilities/drivers.jl +++ b/src/shared_utilities/drivers.jl @@ -273,7 +273,7 @@ function surface_fluxes_at_a_point( end """ - PrescribedRadiativeFluxes{FT, DT, T, OD} <: AbstractRadiativeDrivers{FT} + PrescribedRadiativeFluxes{FT, SW, LW, DT, T} <: AbstractRadiativeDrivers{FT} Container for the prescribed radiation functions needed to drive land models in standalone mode. $(DocStringExtensions.FIELDS) @@ -281,7 +281,7 @@ $(DocStringExtensions.FIELDS) The arguments labeled with "function of time" are typically either of type `Function` or type `Spline1D` from the `Dierckx.jl` package. """ -struct PrescribedRadiativeFluxes{FT, SW, LW, DT, T, OD} <: +struct PrescribedRadiativeFluxes{FT, SW, LW, DT, T} <: AbstractRadiativeDrivers{FT} "Downward shortwave radiation function of time (W/m^2): positive indicates towards surface" SW_d::SW @@ -291,18 +291,8 @@ struct PrescribedRadiativeFluxes{FT, SW, LW, DT, T, OD} <: ref_time::DT "Sun zenith angle, in radians" θs::T - "Orbital Data for Insolation.jl" - orbital_data::OD - function PrescribedRadiativeFluxes( - FT, - SW_d, - LW_d, - ref_time; - θs = nothing, - orbital_data, - ) - args = (SW_d, LW_d, ref_time, θs, orbital_data) - @assert !isnothing(orbital_data) + function PrescribedRadiativeFluxes(FT, SW_d, LW_d, ref_time; θs = nothing) + args = (SW_d, LW_d, ref_time, θs) return new{FT, typeof.(args)...}(args...) end end diff --git a/src/standalone/Vegetation/Canopy.jl b/src/standalone/Vegetation/Canopy.jl index 894fbf7b71..7f95bec9d4 100644 --- a/src/standalone/Vegetation/Canopy.jl +++ b/src/standalone/Vegetation/Canopy.jl @@ -427,7 +427,7 @@ function ClimaLSM.make_update_aux( # Current atmospheric conditions ref_time = canopy.atmos.ref_time - θs::FT = canopy.radiation.θs(t, canopy.radiation.orbital_data, ref_time) + θs::FT = canopy.radiation.θs(t, ref_time) c_co2_air::FT = canopy.atmos.c_co2(t) P_air::FT = canopy.atmos.P(t) T_air::FT = canopy.atmos.T(t) diff --git a/test/Project.toml b/test/Project.toml index cac6311dec..e2777a72a4 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -23,7 +23,7 @@ Thermodynamics = "b60c26fb-14c3-4610-9d3e-2d17fe7ff00c" Aqua = "0.8" CLIMAParameters = "0.7" DelimitedFiles = "1" -Insolation = "0.7" +Insolation = "0.8" NLsolve = "4.5" SafeTestsets = "0.1" Test = "1" diff --git a/test/standalone/Bucket/albedo_types.jl b/test/standalone/Bucket/albedo_types.jl index 500426fd13..76ac88ae04 100644 --- a/test/standalone/Bucket/albedo_types.jl +++ b/test/standalone/Bucket/albedo_types.jl @@ -4,7 +4,7 @@ using ClimaCore using ClimaCore: Geometry, Meshes, Domains, Topologies, Spaces, Fields using ClimaComms import CLIMAParameters as CP -using Insolation + using Dates using NCDatasets using JLD2 @@ -302,15 +302,13 @@ end npolynomial = 2, ), ] - orbital_data = Insolation.OrbitalData() for bucket_domain in bucket_domains # Radiation ref_time = DateTime(2005) SW_d = (t) -> 0.0 LW_d = (t) -> 5.67e-8 * 280.0^4.0 - bucket_rad = - PrescribedRadiativeFluxes(FT, SW_d, LW_d, ref_time; orbital_data) + bucket_rad = PrescribedRadiativeFluxes(FT, SW_d, LW_d, ref_time) # Atmos precip = (t) -> 0 # no precipitation T_atmos = (t) -> 280.0 @@ -416,7 +414,6 @@ end npolynomial = 2, ), ] - orbital_data = Insolation.OrbitalData() for bucket_domain in bucket_domains space = bucket_domain.space.surface @@ -427,13 +424,7 @@ end ref_time = DateTime(2005) SW_d = (t) -> 0 LW_d = (t) -> 5.67e-8 * 280.0^4.0 - bucket_rad = PrescribedRadiativeFluxes( - FT, - SW_d, - LW_d, - ref_time; - orbital_data, - ) + bucket_rad = PrescribedRadiativeFluxes(FT, SW_d, LW_d, ref_time) # Atmos precip = (t) -> 0 # no precipitation T_atmos = (t) -> 280.0 diff --git a/test/standalone/Bucket/snow_bucket_tests.jl b/test/standalone/Bucket/snow_bucket_tests.jl index e9df71ac1e..d0d601273f 100644 --- a/test/standalone/Bucket/snow_bucket_tests.jl +++ b/test/standalone/Bucket/snow_bucket_tests.jl @@ -1,7 +1,7 @@ using Test using Statistics -using Insolation + using Dates using ClimaCore using ClimaLSM.Bucket: @@ -54,20 +54,13 @@ for FT in (Float32, Float64) ), ] init_temp(z::FT, value::FT) where {FT} = FT(value) - orbital_data = Insolation.OrbitalData() for i in 1:3 @testset "Conservation of water and energy I (snow present), FT = $FT" begin "Radiation" ref_time = DateTime(2005) SW_d = (t) -> 20 LW_d = (t) -> 20 - bucket_rad = PrescribedRadiativeFluxes( - FT, - SW_d, - LW_d, - ref_time; - orbital_data, - ) + bucket_rad = PrescribedRadiativeFluxes(FT, SW_d, LW_d, ref_time) "Atmos" liquid_precip = (t) -> 1e-8 # precipitation snow_precip = (t) -> 1e-7 # precipitation @@ -174,13 +167,7 @@ for FT in (Float32, Float64) ref_time = DateTime(2005) SW_d = (t) -> 20 LW_d = (t) -> 20 - bucket_rad = PrescribedRadiativeFluxes( - FT, - SW_d, - LW_d, - ref_time; - orbital_data, - ) + bucket_rad = PrescribedRadiativeFluxes(FT, SW_d, LW_d, ref_time) "Atmos" liquid_precip = (t) -> 1e-8 # precipitation snow_precip = (t) -> 1e-7 # precipitation @@ -286,8 +273,7 @@ for FT in (Float32, Float64) ref_time = DateTime(2005) SW_d = (t) -> 20 LW_d = (t) -> 20 - bucket_rad = - PrescribedRadiativeFluxes(FT, SW_d, LW_d, ref_time; orbital_data) + bucket_rad = PrescribedRadiativeFluxes(FT, SW_d, LW_d, ref_time) "Atmos" liquid_precip = (t) -> 1e-8 # precipitation snow_precip = (t) -> 1e-7 # precipitation diff --git a/test/standalone/Bucket/soil_bucket_tests.jl b/test/standalone/Bucket/soil_bucket_tests.jl index bdd50ce1e4..2368c700f7 100644 --- a/test/standalone/Bucket/soil_bucket_tests.jl +++ b/test/standalone/Bucket/soil_bucket_tests.jl @@ -2,7 +2,7 @@ using Test using Dates using Statistics -using Insolation + using ClimaCore import CLIMAParameters as CP using ClimaLSM.Bucket: BucketModel, BucketModelParameters, BulkAlbedoFunction @@ -49,7 +49,6 @@ for FT in (Float32, Float64) npolynomial = 1, ), ] - orbital_data = Insolation.OrbitalData() init_temp(z::FT, value::FT) where {FT} = FT(value) for bucket_domain in bucket_domains @testset "Zero flux tendency, FT = $FT" begin @@ -57,13 +56,7 @@ for FT in (Float32, Float64) ref_time = DateTime(2005) SW_d = (t) -> 0 LW_d = (t) -> 5.67e-8 * 280.0^4.0 - bucket_rad = PrescribedRadiativeFluxes( - FT, - SW_d, - LW_d, - ref_time; - orbital_data, - ) + bucket_rad = PrescribedRadiativeFluxes(FT, SW_d, LW_d, ref_time) # Atmos precip = (t) -> 0 # no precipitation T_atmos = (t) -> 280.0 @@ -153,13 +146,7 @@ for FT in (Float32, Float64) ref_time = DateTime(2005) SW_d = (t) -> 10 LW_d = (t) -> 300 - bucket_rad = PrescribedRadiativeFluxes( - FT, - SW_d, - LW_d, - ref_time; - orbital_data, - ) + bucket_rad = PrescribedRadiativeFluxes(FT, SW_d, LW_d, ref_time) "Atmos" precip = (t) -> 1e-6 precip_snow = (t) -> 0 diff --git a/test/standalone/Soil/climate_drivers.jl b/test/standalone/Soil/climate_drivers.jl index c7b50010e8..cbcc691b9e 100644 --- a/test/standalone/Soil/climate_drivers.jl +++ b/test/standalone/Soil/climate_drivers.jl @@ -6,7 +6,7 @@ using ClimaLSM using ClimaLSM.Soil import ClimaLSM import ClimaLSM.Parameters as LSMP -using Insolation + using Dates include(joinpath(pkgdir(ClimaLSM), "parameters", "create_parameters.jl")) @@ -65,13 +65,7 @@ for FT in (Float32, Float64) ref_time = DateTime(2005) SW_d = (t) -> 500 LW_d = (t) -> 5.67e-8 * 280.0^4.0 - radiation = PrescribedRadiativeFluxes( - FT, - SW_d, - LW_d, - ref_time; - orbital_data = Insolation.OrbitalData(), - ) + radiation = PrescribedRadiativeFluxes(FT, SW_d, LW_d, ref_time) # Atmos precip = (t) -> 1e-8 precip_snow = (t) -> 0 diff --git a/test/standalone/Vegetation/canopy_model.jl b/test/standalone/Vegetation/canopy_model.jl index 4899b5f02e..dcb2e6182e 100644 --- a/test/standalone/Vegetation/canopy_model.jl +++ b/test/standalone/Vegetation/canopy_model.jl @@ -2,13 +2,13 @@ using Test import CLIMAParameters as CP using ClimaCore using Thermodynamics -using Insolation using Dates using ClimaLSM using ClimaLSM: PrescribedAtmosphere, PrescribedRadiativeFluxes using ClimaLSM.Canopy using ClimaLSM.Canopy.PlantHydraulics using ClimaLSM.Domains: Point +import Insolation import ClimaLSM import ClimaLSM.Parameters as LSMP @@ -43,18 +43,26 @@ for FT in (Float32, Float64) function zenith_angle( t, - orbital_data, ref_time; latitude = lat, longitude = long, insol_params = earth_param_set.insol_params, ) - return instantaneous_zenith_angle( - ref_time + Dates.Second(round(t)), - orbital_data, + current_datetime = ref_time + Dates.Second(round(t)) + d, δ, η_UTC = + FT.( + Insolation.helper_instantaneous_zenith_angle( + current_datetime, + ref_time, + insol_params, + ) + ) + return Insolation.instantaneous_zenith_angle( + d, + δ, + η_UTC, longitude, latitude, - insol_params, )[1] end @@ -98,7 +106,6 @@ for FT in (Float32, Float64) longwave_radiation, ref_time; θs = zenith_angle, - orbital_data = Insolation.OrbitalData(), ) # Plant Hydraulics @@ -477,18 +484,26 @@ for FT in (Float32, Float64) function zenith_angle( t, - orbital_data, ref_time; latitude = lat, longitude = long, insol_params = earth_param_set.insol_params, ) - return instantaneous_zenith_angle( - ref_time + Dates.Second(round(t)), - orbital_data, + current_datetime = ref_time + Dates.Second(round(t)) + d, δ, η_UTC = + FT.( + Insolation.helper_instantaneous_zenith_angle( + current_datetime, + ref_time, + insol_params, + ) + ) + return Insolation.instantaneous_zenith_angle( + d, + δ, + η_UTC, longitude, latitude, - insol_params, )[1] end @@ -532,7 +547,6 @@ for FT in (Float32, Float64) longwave_radiation, ref_time; θs = zenith_angle, - orbital_data = Insolation.OrbitalData(), ) # Plant Hydraulics diff --git a/test/standalone/Vegetation/plant_hydraulics_test.jl b/test/standalone/Vegetation/plant_hydraulics_test.jl index 1fab4fca3d..b2c31bf5b1 100644 --- a/test/standalone/Vegetation/plant_hydraulics_test.jl +++ b/test/standalone/Vegetation/plant_hydraulics_test.jl @@ -9,7 +9,7 @@ using ClimaLSM.Domains: Point, Plane using ClimaLSM.Canopy using ClimaLSM.Canopy.PlantHydraulics import ClimaLSM -using Insolation +import Insolation using Dates include(joinpath(pkgdir(ClimaLSM), "parameters", "create_parameters.jl")) @@ -139,18 +139,26 @@ for FT in (Float32, Float64) function zenith_angle( t, - orbital_data, ref_time; latitude = lat, longitude = long, insol_params = earth_param_set.insol_params, ) - return instantaneous_zenith_angle( - ref_time + Dates.Second(round(t)), - orbital_data, + current_datetime = ref_time + Dates.Second(round(t)) + d, δ, η_UTC = + FT.( + Insolation.helper_instantaneous_zenith_angle( + current_datetime, + ref_time, + insol_params, + ) + ) + return Insolation.instantaneous_zenith_angle( + d, + δ, + η_UTC, longitude, latitude, - insol_params, )[1] end @@ -194,7 +202,6 @@ for FT in (Float32, Float64) longwave_radiation, ref_time; θs = zenith_angle, - orbital_data = Insolation.OrbitalData(), ) Δz = FT(1.0) # height of compartments n_stem = Int64(5) # number of stem elements @@ -426,18 +433,26 @@ for FT in (Float32, Float64) function zenith_angle( t, - orbital_data, ref_time; latitude = lat, longitude = long, insol_params = earth_param_set.insol_params, ) - return instantaneous_zenith_angle( - ref_time + Dates.Second(round(t)), - orbital_data, + current_datetime = ref_time + Dates.Second(round(t)) + d, δ, η_UTC = + FT.( + Insolation.helper_instantaneous_zenith_angle( + current_datetime, + ref_time, + insol_params, + ) + ) + return Insolation.instantaneous_zenith_angle( + d, + δ, + η_UTC, longitude, latitude, - insol_params, )[1] end @@ -481,7 +496,6 @@ for FT in (Float32, Float64) longwave_radiation, ref_time; θs = zenith_angle, - orbital_data = Insolation.OrbitalData(), ) n_stem = Int64(0) # number of stem elements