Skip to content
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
7 changes: 6 additions & 1 deletion doc/sphinx/source/recipes/recipe_clouds.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ User settings in recipe
"CylindricalEquidistant")
* showdiff: calculate and plot differences model - reference
(default = false)
* showyears: add start and end years to the plot titles
(default = false)
* rel_diff: if showdiff = true, then plot relative differences (%)
(default = False)
* ref_diff_min: lower cutoff value in case of calculating relative
Expand Down Expand Up @@ -233,6 +235,7 @@ User settings in recipe
*Optional settings (scripts)*

* explicit_cn_levels: contour levels
* highlight_dataset: name of dataset to highlight (default = "MultiModelMean")
* mask_ts_sea_ice: true = mask T < 272 K as sea ice (only for variable "ts");
false = no additional grid cells masked for variable "ts"
* projection: map projection, e.g., Mollweide, Mercator
Expand Down Expand Up @@ -297,7 +300,7 @@ User settings in recipe

none

8. Script clouds_lifrac_pdf.ncl
8. Script clouds_pdf.ncl

*Required settings (scripts)*

Expand Down Expand Up @@ -333,6 +336,8 @@ User settings in recipe
* explicit_cn_levels: use these contour levels for plotting
* filename_add: optionally add this string to plot filesnames
* projection: map projection, e.g., Mollweide, Mercator
* showyears: add start and end years to the plot titles
(default = false)
* var: short_name of variable to process (default = "" i.e. use
first variable in variable list)

Expand Down
41 changes: 28 additions & 13 deletions esmvaltool/diag_scripts/clouds/clouds.ncl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
; plot(s)
; projection: map projection for plotting (default =
; "CylindricalEquidistant")
; showdiff calculate and plot differences (default = False)
; showdiff: calculate and plot differences (default = False)
; showyears: add start and end years to the plot titles (default =
; false)
; rel_diff: if showdiff = True, then plot relative differences (%)
; (default = False)
; rel_diff_min: lower cutoff value in case of calculating relative
Expand Down Expand Up @@ -58,6 +60,7 @@
; none
;
; Modification history
; 20230117-lauer_axel: added support for ICON (code from Manuel)
; 20211021-lauer_axel: added output of basic statistics as ascii files
; 20211006-lauer_axel: removed write_plots
; 20210325-lauer_axel: added option to estimate observational uncertainty
Expand Down Expand Up @@ -98,6 +101,7 @@ begin
set_default_att(diag_script_info, "rel_diff", False)
set_default_att(diag_script_info, "rel_diff_min", -1.0e19)
set_default_att(diag_script_info, "showdiff", False)
set_default_att(diag_script_info, "showyears", False)
set_default_att(diag_script_info, "timemean", "annualclim")
set_default_att(diag_script_info, "treat_var_as_error", False)
set_default_att(diag_script_info, "var", "")
Expand All @@ -109,17 +113,18 @@ begin
end if

variables = metadata_att_as_array(variable_info, "short_name")
varidx = ind(variables .eq. var0)
if (ismissing(varidx)) then
errstr = "diagnostic " + diag + " requires the following variable: var0"
if (.not. any(variables .eq. var0)) then
errstr = "diagnostic " + diag + " requires the following variable: " + var0
error_msg("f", DIAG_SCRIPT, "", errstr)
end if

var0_info = select_metadata_by_name(variable_info, var0)
var0_info := var0_info[0]
info0 = select_metadata_by_name(input_file_info, var0)
dim_MOD = ListCount(info0)

if (isatt(variable_info[varidx], "reference_dataset")) then
refname = variable_info[varidx]@reference_dataset
if (isatt(var0_info, "reference_dataset")) then
refname = var0_info@reference_dataset
end if
names = metadata_att_as_array(info0, "dataset")
projects = metadata_att_as_array(info0, "project")
Expand Down Expand Up @@ -453,8 +458,18 @@ begin

; annotation

; if desired, add years to plot title
years_str = ""
if (diag_script_info@showyears) then
years_str = " (" + var0_info@start_year
if (var0_info@start_year .ne. var0_info@end_year) then
years_str = years_str + "-" + var0_info@end_year
end if
years_str = years_str + ")"
end if

; res@tiMainOn = False
res@tiMainString = names(imod)
res@tiMainString = names(imod) + years_str
res@tiMainFontHeightF = 0.025

res@cnLevelSelectionMode = "ExplicitLevels"
Expand All @@ -465,8 +480,8 @@ begin

; variable specific plotting settings

if (isatt(variable_info[varidx], "units")) then
data1@units = variable_info[varidx]@units
if (isatt(var0_info, "units")) then
data1@units = var0_info@units
else
data1@units = ""
end if
Expand Down Expand Up @@ -576,8 +591,8 @@ begin
data1@diag_script = (/DIAG_SCRIPT/)
end if

if (isatt(variable_info[varidx], "long_name")) then
data1@long_name = variable_info[varidx]@long_name
if (isatt(var0_info, "long_name")) then
data1@long_name = var0_info@long_name
end if

data1@var = var0
Expand Down Expand Up @@ -784,7 +799,7 @@ begin
dres@mpPerimOn = perim ; draw line around map
dres@gsnStringFontHeightF = 0.02

dres@tiMainString = names(imod) + " - " + refname
dres@tiMainString = names(imod) + " - " + refname + years_str
dres@tiMainFontHeightF = 0.025

rmsd(imod, :) = rmsd@_FillValue
Expand Down Expand Up @@ -818,7 +833,7 @@ begin
dres@gsnLeftString = ""
dres@gsnRightString = ""
dres@gsnCenterString = ""
dres@tiMainString = refname + " uncertainty"
dres@tiMainString = refname + " uncertainty" + years_str
rmsd(imod, :) = rmsd@_FillValue
bias(imod, :) = bias@_FillValue
else
Expand Down
33 changes: 21 additions & 12 deletions esmvaltool/diag_scripts/clouds/clouds_bias.ncl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
; PROJECT-NAME EMBRACE
; ############################################################################
; Description
; Calculates the multi-model mean bias, absolute difference and relative
; Calculates the (multi-model mean) bias, absolute difference and relative
; difference of annual mean 2-d cloud variables compared with a
; reference dataset (observations).
;
Expand All @@ -28,6 +28,7 @@
; none
;
; Modification history
; 20230118-lauer_axel: added support to plot just 1 model
; 20211006-lauer_axel: removed write_plots
; 20190222-lauer_axel: added output of provenance (v2.0)
; 20181119-lauer_axel: adapted code to multi-variable capable framework
Expand Down Expand Up @@ -126,7 +127,15 @@ begin
mm_ind = ind(names .eq. "MultiModelMean")

if (ismissing(mm_ind)) then
error_msg("f", DIAG_SCRIPT, "", "multi-model mean is missing (required)")
mod_ind = ind(names .ne. ref_ind)
if (all(ismissing(mod_ind))) then
error_msg("f", DIAG_SCRIPT, "", "no dataset besides reference " \
+ "dataset found. Cannot continue.")
end if
mm_ind = mod_ind(0)
log_info("multi-model mean is missing, using first dataset (" \
+ names(mm_ind) + ") instead")
delete(mod_ind)
end if

; basename of diag_script
Expand Down Expand Up @@ -233,7 +242,7 @@ begin

diff@res_tiMainFontHeightF = 0.016

diff@res_tiMainString = "Multi Model Mean Bias"
diff@res_tiMainString = names(mm_ind) + " Bias"

copy_VarMeta(diff, mmdata)
delete(mmdata@res_cnLevels)
Expand Down Expand Up @@ -272,7 +281,7 @@ begin
end if
end if

mmdata@res_tiMainString = "Multi Model Mean"
mmdata@res_tiMainString = names(mm_ind)

plotsperline = (/2, 0/)
plotind = (/0, 1/) ; mmm and mean bias are always plotted
Expand All @@ -298,7 +307,7 @@ begin
absdiff@res_cnLevels = tmp(1:dimsizes(tmp)-1)
delete(tmp)

absdiff@res_tiMainString = "Multi Model Mean of Absolute Error"
absdiff@res_tiMainString = names(mm_ind) + " Absolute Error"

iadd = 2
itmp = array_append_record(plotind, iadd, 0)
Expand All @@ -319,7 +328,7 @@ begin
copy_VarMeta(diff, reldiff)
delete(reldiff@res_cnLevels)
reldiff@res_cnLevels = fspan(-90.0, 90.0, 13)
reldiff@res_tiMainString = "Multi Model Mean of Relative Error"
reldiff@res_tiMainString = names(mm_ind) + " Relative Error"
reldiff@units = "%"
reldiff@res_lbTitleString = "(" + reldiff@units + ")"
if (isvar("pal4")) then
Expand Down Expand Up @@ -384,8 +393,8 @@ begin

; add meta data to plot (for reporting)

caption = "Multi model values, from top left to bottom right: " \
+ "mean, bias"
caption = names(mm_ind) + " values, from top left to bottom right: " \
+ "mean, bias"
if (plot_abs_diff) then
caption = caption + ", absolute error"
end if
Expand All @@ -403,22 +412,22 @@ begin
nc_filename@existing = "append"

mmdata@var = var0 + "_mean"
mmdata@long_name = var0 + " (multi-model mean)"
mmdata@long_name = var0 + " " + names(mm_ind) + " (mean)"
nc_outfile = ncdf_write(mmdata, nc_filename)

diff@var = var0 + "_bias"
diff@long_name = var0 + " (multi-model bias)"
diff@long_name = var0 + " " + names(mm_ind) + " (bias)"
nc_outfile = ncdf_write(diff, nc_filename)

if (isvar("absdiff")) then
absdiff@var = var0 + "_abs_bias"
absdiff@long_name = var0 + " (multi-model absolute bias)"
absdiff@long_name = var0 + " " + names(mm_ind) + " (absolute bias)"
nc_outfile = ncdf_write(absdiff, nc_filename)
end if

if (isvar("reldiff")) then
reldiff@var = var0 + "_rel_bias"
reldiff@long_name = var0 + " (multi-model relative bias)"
reldiff@long_name = var0 + " " + names(mm_ind) + " (relative bias)"
reldiff@units = reldiff@units
nc_outfile = ncdf_write(reldiff, nc_filename)
end if
Expand Down
31 changes: 22 additions & 9 deletions esmvaltool/diag_scripts/clouds/clouds_dyn_matrix.ncl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
; none
;
; Modification history
; 20230117-lauer_axel: added support for ICON (code from Manuel)
; 20220126-lauer_axel: added optional variable labels for x- and y-axes
; 20211118-lauer_axel: added output of frequency distributions
; 20210607-lauer_axel: added multi-model-average (= average over all models)
Expand All @@ -57,7 +58,8 @@ begin
enter_msg(DIAG_SCRIPT, "")

diag = "clouds_dyn_matrix.ncl"
variables = metadata_att_as_array(variable_info, "short_name")
variables = get_unique_values(metadata_att_as_array(variable_info, \
"short_name"))

; Check required diag_script_info attributes
exit_if_missing_atts(diag_script_info, (/"var_x", "var_y", "var_z", \
Expand Down Expand Up @@ -162,21 +164,26 @@ begin
; is equal for each variable

do i = 0, nVAR - 1
if (isatt(variable_info[idx(i)], "reference_dataset")) then
refname(i) = variable_info[idx(i)]@reference_dataset
var = variables(idx(i))
var_info = select_metadata_by_name(variable_info, var)
var_info := var_info[0]
if (isatt(var_info, "reference_dataset")) then
refname(i) = var_info@reference_dataset
end if
info = select_metadata_by_name(input_file_info, variables(idx(i)))
info = select_metadata_by_name(input_file_info, var)
if (i .eq. 0) then
dim_MOD = ListCount(info)
else
dim_test = ListCount(info)
if (dim_test .ne. dim_MOD) then
error_msg("f", DIAG_SCRIPT, "", "number of datasets for variable " \
+ variables(i) + " does not match number of datasets for " \
+ variables(0))
+ var + " does not match number of datasets for " \
+ variables(idx(0)))
end if
end if
delete(info)
delete(var)
delete(var_info)
end do

; Set default values for non-required diag_script_info attributes
Expand Down Expand Up @@ -251,9 +258,11 @@ begin

idxmod = get_mod(names_x, projects_x)

if (idxmod(0) .eq. -1) then
if (idxmod(0) .eq. -1) then ; no model found
flag_multimod = False
else
elseif (dimsizes(idxmod) .eq. 1) then ; one model found
flag_multimod = False
else ; more than one model found
flag_multimod = True
end if

Expand Down Expand Up @@ -814,7 +823,11 @@ begin

ref = where(count(ref_ind, :, :) .gt. 1.0e-3, count(ref_ind, :, :), \
count@_FillValue)
modavg = dim_avg_n_Wrap(count(idxmod, :, :), 0)
if (dimsizes(idxmod) .gt. 1) then
modavg = dim_avg_n_Wrap(count(idxmod, :, :), 0)
else
modavg = count(idxmod, :, :)
end if
modavg = where(modavg .gt. 1.0e-3, modavg, modavg@_FillValue)

diff = modavg
Expand Down
22 changes: 13 additions & 9 deletions esmvaltool/diag_scripts/clouds/clouds_interannual.ncl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
; none
;
; Modification history
; 20230117-lauer_axel: added support for ICON (code from Manuel)
; 20211006-lauer_axel: removed write_plots
; 20210413-lauer_axel: added multi-obs mean and average over all models
; as individual plots
Expand Down Expand Up @@ -79,17 +80,18 @@ begin
end if

variables = metadata_att_as_array(variable_info, "short_name")
varidx = ind(variables .eq. var0)
if (ismissing(varidx)) then
errstr = "diagnostic " + diag + " requires the following variable: var0"
if (.not. any(variables .eq. var0)) then
errstr = "diagnostic " + diag + " requires the following variable: " + var0
error_msg("f", DIAG_SCRIPT, "", errstr)
end if

var0_info = select_metadata_by_name(variable_info, var0)
var0_info := var0_info[0]
info0 = select_metadata_by_name(input_file_info, var0)
dim_MOD = ListCount(info0)

if (isatt(variable_info[varidx], "reference_dataset")) then
refname = variable_info[varidx]@reference_dataset
if (isatt(var0_info, "reference_dataset")) then
refname = var0_info@reference_dataset
end if

names = metadata_att_as_array(info0, "dataset")
Expand Down Expand Up @@ -141,9 +143,11 @@ begin

idxmod = get_mod(names, projects)

if (idxmod(0) .eq. -1) then
if (idxmod(0) .eq. -1) then ; no model found
flag_multimod = False
else
elseif (dimsizes(idxmod) .eq. 1) then ; one model found
flag_multimod = False
else ; more than one model found
flag_multimod = True
end if

Expand Down Expand Up @@ -416,8 +420,8 @@ begin
data1@diag_script = (/DIAG_SCRIPT/)
end if
data1@var = var0 ; Overwrite existing entry
if (isatt(variable_info[varidx], "long_name")) then
data1@long_name = variable_info[varidx]@long_name
if (isatt(var0_info, "long_name")) then
data1@long_name = var0_info@long_name
else
data1@long_name = var0
end if
Expand Down
Loading