Skip to content

Commit

Permalink
Merge pull request #2787 from CliMA/zs/surface_albedo
Browse files Browse the repository at this point in the history
refactor surface albedo calculation
  • Loading branch information
szy21 authored Mar 14, 2024
2 parents ee2f72a + ff07b43 commit 9b203a7
Showing 1 changed file with 16 additions and 21 deletions.
37 changes: 16 additions & 21 deletions src/cache/surface_albedo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,29 +80,24 @@ function set_surface_albedo!(
λ = FT(0) # spectral wavelength (not used for now)
μ = cos_zenith

ArrayType = ClimaComms.array_type(Y)

# set the direct and diffuse surface albedos
direct_sw_surface_albedo .=
ArrayType(ones(axes(direct_sw_surface_albedo))) .* ArrayType(
reshape(
surface_albedo_direct(
α_model,
).(λ, μ, RRTMGPI.field2array(norm.(Fields.level(Y.c.uₕ, 1)))),
1,
:,
),
surface_albedo = p.scratch.temp_field_level
f_direct = surface_albedo_direct(α_model)
surface_albedo .=
f_direct.(
λ,
RRTMGPI.array2field(μ, axes(surface_albedo)),
norm.(Fields.level(Y.c.uₕ, 1)),
)
diffuse_sw_surface_albedo .=
ArrayType(ones(axes(direct_sw_surface_albedo))) .* ArrayType(
reshape(
surface_albedo_diffuse(
α_model,
).(λ, μ, RRTMGPI.field2array(norm.(Fields.level(Y.c.uₕ, 1)))),
1,
:,
),
direct_sw_surface_albedo .= RRTMGPI.field2array(surface_albedo)'

f_diffuse = surface_albedo_diffuse(α_model)
surface_albedo .=
f_diffuse.(
λ,
RRTMGPI.array2field(μ, axes(surface_albedo)),
norm.(Fields.level(Y.c.uₕ, 1)),
)
diffuse_sw_surface_albedo .= RRTMGPI.field2array(surface_albedo)'
end

"""
Expand Down

0 comments on commit 9b203a7

Please sign in to comment.