@@ -291,8 +291,8 @@ def load_obs_data():
291291
292292
293293def plot_data (
294- model_dataset ,
295294 model_data ,
295+ model_label ,
296296 model_period ,
297297 obs_names ,
298298 obs_unit ,
@@ -307,11 +307,11 @@ def plot_data(
307307
308308 Parameters
309309 ----------
310- model_dataset : string
311- The name of the model.
312310 model_data : list
313311 Data values from the model for which this comparison plot is being
314312 generated.
313+ model_label : string
314+ An identifier for the model dataset to be used in the plot legend.
315315 model_period : string
316316 The start and end years of the model dataset.
317317 obs_names : list
@@ -341,7 +341,7 @@ def plot_data(
341341 model_minus_ceres = np .array (model_data ) - np .array (ceres_data )
342342
343343 figure , axes = plt .subplots (figsize = (12 , 8 ))
344- title = f"Radiation budget for { model_dataset } "
344+ title = f"Radiation budget for { model_label } "
345345 y_label = f"Difference between model output and observations [{ obs_unit } ]"
346346 y_lim = (- 20 , 20 )
347347 axes .set (title = title , ylabel = y_label , ylim = y_lim )
@@ -357,7 +357,7 @@ def plot_data(
357357 bar_width ,
358358 alpha = opacity ,
359359 color = "cornflowerblue" ,
360- label = f"{ model_dataset } ({ model_period } ) - Stephens et al. (2012)" ,
360+ label = f"{ model_label } ({ model_period } ) - Stephens et al. (2012)" ,
361361 yerr = stephens_error ,
362362 )
363363 axes .bar (
@@ -367,7 +367,7 @@ def plot_data(
367367 alpha = opacity ,
368368 color = "orange" ,
369369 label = (
370- f"{ model_dataset } ({ model_period } ) - { ceres_dataset } "
370+ f"{ model_label } ({ model_period } ) - { ceres_dataset } "
371371 f"({ ceres_period } )"
372372 ),
373373 )
@@ -377,7 +377,7 @@ def plot_data(
377377 bar_width ,
378378 alpha = opacity ,
379379 color = "darkgrey" ,
380- label = f"{ model_dataset } ({ model_period } ) - Demory et al. (2014)" ,
380+ label = f"{ model_label } ({ model_period } ) - Demory et al. (2014)" ,
381381 )
382382 axes .spines ["bottom" ].set_position (("data" , 0 ))
383383 axes .spines ["top" ].set_position (("data" , 0 ))
@@ -442,16 +442,20 @@ def main(config):
442442
443443 for model_dataset , group in datasets .items ():
444444 # 'model_dataset' is the name of the model dataset.
445- # 'group' is a list of dictionaries containing metadata.
445+ # 'group' is a list of dictionaries containing metadata for each variable .
446446 logger .info ("Processing data for %s" , model_dataset )
447447 filenames = [item ["filename" ] for item in group ]
448448 unordered_model_data = iris .load (filenames )
449449 all_model_data = derive_additional_variables (unordered_model_data )
450450 model_data = order_data (all_model_data , obs_names , obs_unit )
451+ # An assumption has been made that the start_year, end_year and alias
452+ # from the first variable in the list (for a given dataset)
453+ # is the same as all the others.
451454 model_period = f"{ group [0 ]['start_year' ]} - { group [0 ]['end_year' ]} "
455+ model_label = group [0 ]["alias" ]
452456 figure = plot_data (
453- model_dataset ,
454457 model_data ,
458+ model_label ,
455459 model_period ,
456460 obs_names ,
457461 obs_unit ,
0 commit comments