Skip to content

Commit

Permalink
Merge #317
Browse files Browse the repository at this point in the history
317: Address edge cases in cloud sampling r=szy21 a=szy21

When comparing random number with 1 - cloud fraction, we change the condition > to >= to address the edge case that cloud fraction is 1 but random number is 0.

Co-authored-by: Zhaoyi Shen <[email protected]>
  • Loading branch information
bors[bot] and szy21 authored Sep 20, 2022
2 parents 6d5bacd + 90855a3 commit 27ebc3c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/optics/CloudOptics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,9 @@ function build_cloud_mask!(cld_mask, cld_frac, random_arr, gcol, ::MaxRandomOver
end
# set cloud mask for cloudy layers
# last layer
# RRTMG uses local_rand[igpt, finish] > (FT(1) - local_cld_frac[finish]), we change > to >= to address edge cases
for igpt in 1:ngpt
local_cld_mask[igpt, finish] = local_rand[igpt, finish] > (FT(1) - local_cld_frac[finish])
local_cld_mask[igpt, finish] = local_rand[igpt, finish] >= (FT(1) - local_cld_frac[finish])
end
for ilay in (finish - 1):-1:start
if local_cld_frac[ilay] > FT(0)
Expand All @@ -254,7 +255,8 @@ function build_cloud_mask!(cld_mask, cld_frac, random_arr, gcol, ::MaxRandomOver
else
local_rand[igpt, ilay] *= (FT(1) - local_cld_frac[ilay + 1]) # update random numbers if layer above is not cloudy
end
local_cld_mask[igpt, ilay] = local_rand[igpt, ilay] > (FT(1) - local_cld_frac[ilay])
# RRTMG uses local_rand[igpt, ilay] > (FT(1) - local_cld_frac[ilay]), we change > to >= to address edge cases
local_cld_mask[igpt, ilay] = local_rand[igpt, ilay] >= (FT(1) - local_cld_frac[ilay])
end
else
for igpt in 1:ngpt
Expand Down

0 comments on commit 27ebc3c

Please sign in to comment.