Skip to content

Commit

Permalink
Merge pull request #562 from CliMA/zs/update_cloud_optics
Browse files Browse the repository at this point in the history
update cloud optics
  • Loading branch information
szy21 authored Jan 30, 2025
2 parents dd81c18 + e475a43 commit 692cb88
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 54 deletions.
12 changes: 10 additions & 2 deletions Artifacts.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
# Artifacts file for RRTMGP.jl

[rrtmgp-data]
git-tree-sha1 = "5080a733a316b74accf4d5897f5bf6641141c41d"
git-tree-sha1 = "d601aa60f46f03d12db9841833c7b25bd4dcd785"

[[rrtmgp-data.download]]
url = "https://github.com/earth-system-radiation/rrtmgp-data/archive/refs/tags/v1.8.1.tar.gz"
sha256 = "e0f868c32efbbe6c0a5bd9b764718f74d9f53b476f65a0d806988bbc83dd13c1"
url = "https://github.com/earth-system-radiation/rrtmgp-data/archive/refs/tags/v1.9.tar.gz"

[rrtmgp-data-v181]
git-tree-sha1 = "5080a733a316b74accf4d5897f5bf6641141c41d"

[[rrtmgp-data-v181.download]]
sha256 = "8dcf7ba2442c7093e707a5d3c0c3c76b249eb8905d3478cb3fe87535b51455bb"
url = "https://github.com/earth-system-radiation/rrtmgp-data/archive/refs/tags/v1.8.1.tar.gz"
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ RRTMGP.jl Release Notes

main
------
- Remove pade approximation. PR [#563](https://github.com/CliMA/RRTMGP.jl/pull/563)
Update cloud optics to the latest version of rrtmgp-data.
PR [#562](https://github.com/CliMA/RRTMGP.jl/pull/562)

v0.19.1
-----
Expand Down
Binary file not shown.
7 changes: 3 additions & 4 deletions src/ArtifactPaths.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@ function get_lookup_filename(optics_type::Symbol, λ::Symbol)
config == (:gas, :lw) && return joinpath(basedir, "rrtmgp-gas-lw-g256.nc")
config == (:gas, :sw) && return joinpath(basedir, "rrtmgp-gas-sw-g224.nc")

config == (:cloud, :lw) && return joinpath(basedir, "rrtmgp-clouds-lw.nc")
config == (:cloud, :sw) && return joinpath(basedir, "rrtmgp-clouds-sw.nc")
config == (:cloud, :lw) && return joinpath(basedir, "rrtmgp-clouds-lw-bnd.nc")
config == (:cloud, :sw) && return joinpath(basedir, "rrtmgp-clouds-sw-bnd.nc")

config == (:aerosol, :lw) && return joinpath(basedir, "rrtmgp-aerosols-merra-lw.nc")
#config == (:aerosol, :sw)
return joinpath(currdir, "../lookup_tables/aerosol/rrtmgp-sw-inputs-aerosol-optics.nc")
config == (:aerosol, :sw) && return joinpath(basedir, "rrtmgp-aerosols-merra-sw.nc")
end

"""
Expand Down
2 changes: 1 addition & 1 deletion src/RRTMGP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ using Artifacts
# https://stackoverflow.com/questions/14687665/very-slow-stdpow-for-bases-very-close-to-1
pow_fast(x, y) = exp(y * log(x))

get_artifact_path() = joinpath(artifact"rrtmgp-data", "rrtmgp-data-1.8.1")
get_artifact_path() = joinpath(artifact"rrtmgp-data", "rrtmgp-data-1.9")

import ClimaComms
include("Parameters.jl")
Expand Down
12 changes: 4 additions & 8 deletions src/optics/LookUpTables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -772,17 +772,13 @@ function LookUpCld(ds, ::Type{FT}, ::Type{DA}) where {FT <: AbstractFloat, DA}
FT(ds["radliq_lwr"][]),
# liquid particle size upper bound for LUT interpolation
FT(ds["radliq_upr"][]),
# factor for calculating LUT interpolation for liquid particle
FT(ds["radliq_fac"][]),
# ice particle size lower bound for LUT interpolation
FT(ds["radice_lwr"][]),
FT(ds["diamice_lwr"][]) / 2,
# ice particle size upper bound for LUT interpolation
FT(ds["radice_upr"][]),
# factor for calculating LUT interpolation for ice particle
FT(ds["radice_fac"][]),
FT(ds["diamice_upr"][]) / 2,
])
liqdata = DA(vcat(Array(ds["lut_extliq"]), Array(ds["lut_ssaliq"]), Array(ds["lut_asyliq"])))
icedata = DA(vcat(Array(ds["lut_extice"]), Array(ds["lut_ssaice"]), Array(ds["lut_asyice"])))
liqdata = DA(vcat(Array(ds["extliq"]), Array(ds["ssaliq"]), Array(ds["asyliq"])))
icedata = DA(vcat(Array(ds["extice"]), Array(ds["ssaice"]), Array(ds["asyice"])))
bnd_lims_wn = DA(Array(ds["bnd_limits_wavenumber"]))
return LookUpCld(dims, bounds, liqdata, icedata, bnd_lims_wn)
end
Expand Down
72 changes: 36 additions & 36 deletions src/optics/cloud_optics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
)
@inbounds begin
nlay = length(τ)
lut_extliq, lut_ssaliq, lut_asyliq = LookUpTables.getview_liqdata(lkp_cld, ibnd)
lut_extice, lut_ssaice, lut_asyice = LookUpTables.getview_icedata(lkp_cld, ibnd, ice_rgh)
extliq, ssaliq, asyliq = LookUpTables.getview_liqdata(lkp_cld, ibnd)
extice, ssaice, asyice = LookUpTables.getview_icedata(lkp_cld, ibnd, ice_rgh)
_, _, nsize_liq, nsize_ice, _ = lkp_cld.dims
radliq_lwr, radliq_upr, _, radice_lwr, radice_upr, _ = lkp_cld.bounds
radliq_lwr, radliq_upr, radice_lwr, radice_upr = lkp_cld.bounds

for glay in 1:nlay
if cld_mask[glay]
Expand All @@ -23,9 +23,9 @@
nsize_liq,
radliq_lwr,
radliq_upr,
lut_extliq,
lut_ssaliq,
lut_asyliq,
extliq,
ssaliq,
asyliq,
cld_r_eff_liq[glay],
cld_path_liq[glay],
)
Expand All @@ -34,9 +34,9 @@
nsize_ice,
radice_lwr,
radice_upr,
lut_extice,
lut_ssaice,
lut_asyice,
extice,
ssaice,
asyice,
cld_r_eff_ice[glay],
cld_path_ice[glay],
)
Expand Down Expand Up @@ -82,10 +82,10 @@ to the TwoStream gas optics properties.
)
nlay = length(τ)
FT = eltype(τ)
lut_extliq, lut_ssaliq, lut_asyliq = LookUpTables.getview_liqdata(lkp_cld, ibnd)
lut_extice, lut_ssaice, lut_asyice = LookUpTables.getview_icedata(lkp_cld, ibnd, ice_rgh)
extliq, ssaliq, asyliq = LookUpTables.getview_liqdata(lkp_cld, ibnd)
extice, ssaice, asyice = LookUpTables.getview_icedata(lkp_cld, ibnd, ice_rgh)
_, _, nsize_liq, nsize_ice, _ = lkp_cld.dims
radliq_lwr, radliq_upr, _, radice_lwr, radice_upr, _ = lkp_cld.bounds
radliq_lwr, radliq_upr, radice_lwr, radice_upr = lkp_cld.bounds
@inbounds begin
for glay in 1:nlay
if cld_mask[glay]
Expand All @@ -94,9 +94,9 @@ to the TwoStream gas optics properties.
nsize_liq,
radliq_lwr,
radliq_upr,
lut_extliq,
lut_ssaliq,
lut_asyliq,
extliq,
ssaliq,
asyliq,
cld_r_eff_liq[glay],
cld_path_liq[glay],
)
Expand All @@ -105,9 +105,9 @@ to the TwoStream gas optics properties.
nsize_ice,
radice_lwr,
radice_upr,
lut_extice,
lut_ssaice,
lut_asyice,
extice,
ssaice,
asyice,
cld_r_eff_ice[glay],
cld_path_ice[glay],
)
Expand All @@ -133,9 +133,9 @@ end
nsize_liq,
radliq_lwr,
radliq_upr,
lut_extliq,
lut_ssaliq,
lut_asyliq,
extliq,
ssaliq,
asyliq,
re_liq,
cld_path_liq,
)
Expand All @@ -146,9 +146,9 @@ This function computes the `TwoStream` cloud liquid properties using the `LookUp
nsize_liq,
radliq_lwr,
radliq_upr,
lut_extliq,
lut_ssaliq,
lut_asyliq,
extliq,
ssaliq,
asyliq,
re_liq,
cld_path_liq,
)
Expand All @@ -161,9 +161,9 @@ This function computes the `TwoStream` cloud liquid properties using the `LookUp
fac = (re_liq - radliq_lwr - (loc - 1) * Δr_liq) / Δr_liq
fc1 = FT(1) - fac
@inbounds begin
τl = max((fc1 * lut_extliq[loc] + fac * lut_extliq[loc + 1]) * cld_path_liq, FT(0))
τl_ssa = (fc1 * lut_ssaliq[loc] + fac * lut_ssaliq[loc + 1]) * τl
τl_ssag = (fc1 * lut_asyliq[loc] + fac * lut_asyliq[loc + 1]) * τl_ssa
τl = max((fc1 * extliq[loc] + fac * extliq[loc + 1]) * cld_path_liq, FT(0))
τl_ssa = (fc1 * ssaliq[loc] + fac * ssaliq[loc + 1]) * τl
τl_ssag = (fc1 * asyliq[loc] + fac * asyliq[loc + 1]) * τl_ssa
end
end
return (τl, τl_ssa, τl_ssag)
Expand All @@ -174,9 +174,9 @@ end
nsize_ice,
radice_lwr,
radice_upr,
lut_extice,
lut_ssaice,
lut_asyice,
extice,
ssaice,
asyice,
re_ice,
cld_path_ice,
)
Expand All @@ -187,9 +187,9 @@ This function computes the `TwoStream` cloud ice properties using the `LookUpTab
nsize_ice,
radice_lwr,
radice_upr,
lut_extice,
lut_ssaice,
lut_asyice,
extice,
ssaice,
asyice,
re_ice,
cld_path_ice,
)
Expand All @@ -202,9 +202,9 @@ This function computes the `TwoStream` cloud ice properties using the `LookUpTab
fac = (re_ice - radice_lwr - (loc - 1) * Δr_ice) / Δr_ice
fc1 = FT(1) - fac
@inbounds begin
τi = max((fc1 * lut_extice[loc] + fac * lut_extice[loc + 1]) * cld_path_ice, FT(0))
τi_ssa = (fc1 * lut_ssaice[loc] + fac * lut_ssaice[loc + 1]) * τi
τi_ssag = (fc1 * lut_asyice[loc] + fac * lut_asyice[loc + 1]) * τi_ssa
τi = max((fc1 * extice[loc] + fac * extice[loc + 1]) * cld_path_ice, FT(0))
τi_ssa = (fc1 * ssaice[loc] + fac * ssaice[loc + 1]) * τi
τi_ssag = (fc1 * asyice[loc] + fac * asyice[loc + 1]) * τi_ssa
end
end
return (τi, τi_ssa, τi_ssag)
Expand Down
2 changes: 1 addition & 1 deletion test/read_all_sky_with_aerosols.jl
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ function setup_allsky_with_aerosols_as(
cld_path_liq = zeros(FT, nlay, ncol)
cld_path_ice = zeros(FT, nlay, ncol)

radliq_lwr, radliq_upr, _, radice_lwr, radice_upr, _ = Array(lkp_lw_cld.bounds)
radliq_lwr, radliq_upr, radice_lwr, radice_upr = Array(lkp_lw_cld.bounds)
r_eff_liq = (radliq_lwr + radliq_upr) / FT(2)
r_eff_ice = (radice_lwr + radice_upr) / FT(2)

Expand Down
2 changes: 1 addition & 1 deletion test/read_cloudy_sky.jl
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function setup_cloudy_sky_as(
cld_path_liq = zeros(FT, nlay, ncol)
cld_path_ice = zeros(FT, nlay, ncol)

radliq_lwr, radliq_upr, _, radice_lwr, radice_upr, _ = Array(lkp_lw_cld.bounds)
radliq_lwr, radliq_upr, radice_lwr, radice_upr = Array(lkp_lw_cld.bounds)
r_eff_liq = (radliq_lwr + radliq_upr) / FT(2)
r_eff_ice = (radice_lwr + radice_upr) / FT(2)

Expand Down

0 comments on commit 692cb88

Please sign in to comment.