From 8708c0341f524d22cd0f2bcfd8593a94776ead67 Mon Sep 17 00:00:00 2001 From: Julia Sloan Date: Thu, 17 Aug 2023 11:56:59 -0700 Subject: [PATCH 1/2] use space instead of surface --- src/standalone/Bucket/Bucket.jl | 8 ++++---- test/standalone/Bucket/albedo_types.jl | 17 ++++++++--------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/standalone/Bucket/Bucket.jl b/src/standalone/Bucket/Bucket.jl index 77a72467be..1fc7b9b54b 100644 --- a/src/standalone/Bucket/Bucket.jl +++ b/src/standalone/Bucket/Bucket.jl @@ -142,7 +142,7 @@ end regrid_dirpath::String, date_ref::Union{DateTime, DateTimeNoLeap}, t_start::FT, - surface; + Space::ClimaCore.Spaces.AbstractSpace; input_file = Bucket.cesm2_albedo_dataset_path(), varname = "sw_alb" ) where {FT} @@ -157,12 +157,12 @@ function BulkAlbedoTemporal{FT}( regrid_dirpath::String, date_ref::Union{DateTime, DateTimeNoLeap}, t_start::FT, - surface; + space::ClimaCore.Spaces.AbstractSpace; input_file = Bucket.cesm2_albedo_dataset_path(), varname = "sw_alb", ) where {FT} # Verify inputs - if typeof(surface) <: ClimaLSM.Domains.Point + if typeof(space) <: ClimaCore.Spaces.PointSpace error("Using an albedo map requires a global run.") end NCDataset(input_file, "r") do ds @@ -180,7 +180,7 @@ function BulkAlbedoTemporal{FT}( varname, date_ref, t_start, - surface.space, + space, ) return BulkAlbedoTemporal{FT}(data_info) end diff --git a/test/standalone/Bucket/albedo_types.jl b/test/standalone/Bucket/albedo_types.jl index a87cb8239b..ab2dbb5006 100644 --- a/test/standalone/Bucket/albedo_types.jl +++ b/test/standalone/Bucket/albedo_types.jl @@ -105,8 +105,7 @@ end regrid_dir_temporal = joinpath(pkgdir(ClimaLSM), "test", "temporal") t_start = FT(0) domain = create_domain_2d(FT) - surface = domain.surface - space = surface.space + space = domain.surface.space input_file = cesm2_albedo_dataset_path() date_ref = to_datetime(NCDataset(input_file, "r") do ds @@ -114,7 +113,7 @@ end end) albedo = - BulkAlbedoTemporal{FT}(regrid_dir_temporal, date_ref, t_start, surface) + BulkAlbedoTemporal{FT}(regrid_dir_temporal, date_ref, t_start, space) p = (; bucket = (; α_sfc = Fields.zeros(space))) surface_coords = Fields.coordinate_field(space) @@ -218,7 +217,7 @@ end regrid_dir_temporal, date_ref, t_start, - domain.surface, + space, ) Y = (; bucket = (; W = Fields.zeros(space))) @@ -374,7 +373,7 @@ end input_file = bareground_albedo_dataset_path() date_ref = Dates.DateTime(1900, 1, 1) t_start = FT(0) - surface = nothing + space = nothing err = nothing try @@ -382,7 +381,7 @@ end regrid_dirpath, date_ref, t_start, - surface, + space, input_file = input_file, ) catch err @@ -429,13 +428,13 @@ end orbital_data = Insolation.OrbitalData() for bucket_domain in bucket_domains - surface = bucket_domain.surface + space = bucket_domain.surface.space if bucket_domain isa LSMSphericalShellDomain albedo_model = BulkAlbedoTemporal{FT}( regrid_dirpath, date_ref, t_start, - surface, + space, ) # Radiation SW_d = (t) -> eltype(t)(0.0) @@ -532,7 +531,7 @@ end regrid_dirpath, date_ref, t_start, - surface, + space, ) catch err end From cc9c318c6713dff3b679fc614e7f77697383868f Mon Sep 17 00:00:00 2001 From: Julia Sloan Date: Thu, 17 Aug 2023 12:09:47 -0700 Subject: [PATCH 2/2] use CC space for albedo --- test/standalone/Bucket/albedo_types.jl | 50 ++++++++++++-------------- 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/test/standalone/Bucket/albedo_types.jl b/test/standalone/Bucket/albedo_types.jl index ab2dbb5006..7c418e961b 100644 --- a/test/standalone/Bucket/albedo_types.jl +++ b/test/standalone/Bucket/albedo_types.jl @@ -213,12 +213,8 @@ end end) t_start = FT(0) - albedo = BulkAlbedoTemporal{FT}( - regrid_dir_temporal, - date_ref, - t_start, - space, - ) + albedo = + BulkAlbedoTemporal{FT}(regrid_dir_temporal, date_ref, t_start, space) Y = (; bucket = (; W = Fields.zeros(space))) p = (; bucket = (; α_sfc = Fields.zeros(space))) @@ -373,23 +369,25 @@ end input_file = bareground_albedo_dataset_path() date_ref = Dates.DateTime(1900, 1, 1) t_start = FT(0) - space = nothing - err = nothing - - try - BulkAlbedoTemporal{FT}( - regrid_dirpath, - date_ref, - t_start, - space, - input_file = input_file, - ) - catch err - end + domain = create_domain_2d(FT) + space = domain.surface.space - @test err isa Exception - @test sprint(showerror, err) == - "Using a temporal albedo map requires data with time dimension." + let err = nothing + try + BulkAlbedoTemporal{FT}( + regrid_dirpath, + date_ref, + t_start, + space, + input_file = input_file, + ) + catch err + end + + @test err isa Exception + @test sprint(showerror, err) == + "Using a temporal albedo map requires data with time dimension." + end end @@ -430,12 +428,8 @@ end for bucket_domain in bucket_domains space = bucket_domain.surface.space if bucket_domain isa LSMSphericalShellDomain - albedo_model = BulkAlbedoTemporal{FT}( - regrid_dirpath, - date_ref, - t_start, - space, - ) + albedo_model = + BulkAlbedoTemporal{FT}(regrid_dirpath, date_ref, t_start, space) # Radiation SW_d = (t) -> eltype(t)(0.0) LW_d = (t) -> eltype(t)(5.67e-8 * 280.0^4.0)