Skip to content

Commit

Permalink
Merge #300
Browse files Browse the repository at this point in the history
300: BulkAlbedoTemporal - use ClimaCore space r=juliasloan25 a=juliasloan25



Co-authored-by: Julia Sloan <jsloan@caltech.edu>
  • Loading branch information
bors[bot] and juliasloan25 committed Aug 22, 2023
2 parents 076d040 + cc9c318 commit bcc8d22
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 37 deletions.
8 changes: 4 additions & 4 deletions src/standalone/Bucket/Bucket.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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
Expand All @@ -180,7 +180,7 @@ function BulkAlbedoTemporal{FT}(
varname,
date_ref,
t_start,
surface.space,
space,
)
return BulkAlbedoTemporal{FT}(data_info)
end
Expand Down
59 changes: 26 additions & 33 deletions test/standalone/Bucket/albedo_types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,15 @@ 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
ds["time"][1]
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)

Expand Down Expand Up @@ -214,12 +213,8 @@ end
end)
t_start = FT(0)

albedo = BulkAlbedoTemporal{FT}(
regrid_dir_temporal,
date_ref,
t_start,
domain.surface,
)
albedo =
BulkAlbedoTemporal{FT}(regrid_dir_temporal, date_ref, t_start, space)

Y = (; bucket = (; W = Fields.zeros(space)))
p = (; bucket = (; α_sfc = Fields.zeros(space)))
Expand Down Expand Up @@ -374,23 +369,25 @@ end
input_file = bareground_albedo_dataset_path()
date_ref = Dates.DateTime(1900, 1, 1)
t_start = FT(0)
surface = nothing
err = nothing

try
BulkAlbedoTemporal{FT}(
regrid_dirpath,
date_ref,
t_start,
surface,
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

Expand Down Expand Up @@ -429,14 +426,10 @@ 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,
)
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)
Expand Down Expand Up @@ -532,7 +525,7 @@ end
regrid_dirpath,
date_ref,
t_start,
surface,
space,
)
catch err
end
Expand Down

0 comments on commit bcc8d22

Please sign in to comment.