Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BulkAlbedoTemporal - use ClimaCore space #300

Merged
merged 2 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading