def hofm_plot_params(cfg, hofm_var, var_number, observations): """Prepeare configuration for Hovmoeller plot.""" model_filenames = get_clim_model_filenames(cfg, hofm_var) model_filenames = OrderedDict( sorted(model_filenames.items(), key=lambda t: t[0])) # remove "model" that contain observations, # since there will be no monthly data model_filenames = model_filenames.copy() if observations: del model_filenames[observations] # set the color map if not default if cfg['hofm_cmap']: cmap = get_cmap(cfg['hofm_cmap'][var_number]) else: cmap = get_cmap('Spectral_r') # set the number of columns in the output figure # if defined if cfg['hofm_ncol']: ncols = cfg['hofm_ncol'] else: ncols = 3 # get the levels for plots of this variable vmin, vmax, sstep, roundlimit = cfg['hofm_limits'][var_number] plot_params = {} plot_params['variable'] = hofm_var plot_params['model_filenames'] = model_filenames plot_params['cmap'] = cmap plot_params['ncols'] = ncols plot_params['levels'] = np.round(np.linspace(vmin, vmax, sstep), roundlimit) plot_params['observations'] = observations return plot_params
def plot2d_bias_params(cfg, plot2d_bias_var, var_number, observations): """Prepeare configuration for plot2d bias.""" model_filenames = get_clim_model_filenames(cfg, plot2d_bias_var) model_filenames = OrderedDict( sorted(model_filenames.items(), key=lambda t: t[0])) # setup the color map if cfg['plot2d_bias_cmap']: cmap = get_cmap(cfg['plot2d_bias_cmap'][var_number]) else: cmap = get_cmap('Spectral_r') # setup the number of columns if cfg['plot2d_bias_ncol']: ncols = cfg['plot2d_bias_ncol'] else: ncols = 3 # setup color limits vmin, vmax, sstep, roundlimit = cfg['plot2d_bias_limits'][var_number] plot_params = {} plot_params['variable'] = plot2d_bias_var plot_params['model_filenames'] = model_filenames plot_params['cmap'] = cmap plot_params['ncols'] = ncols plot_params['levels'] = np.round(np.linspace(vmin, vmax, sstep), roundlimit) plot_params['dpi'] = 100 plot_params['observations'] = observations plot_params['projection'] = ccrs.NorthPolarStereo() plot_params['bbox'] = (-180, 180, 60, 90) return plot_params
def run_hofm_data(cfg): """Extract data for Hovmoeller diagrams. Parameters ---------- cfg: dict configuration dictionary ESMValTool format. areacello_fx : dict configuration dictionary with names of the areacello_fx files associated to dataset names. diagworkdir: str path to the diagnostic work directory. """ logger.info("The `hofm_data` is True, going \ to extract monthly values for `hofm_regions`") logger.info("`hofm_vars` are: %s", cfg['hofm_vars']) # doing the loop for every variable for hofm_var in cfg['hofm_vars']: logger.info("Processing %s", hofm_var) # get dictionary with model names as key and path to the # preprocessed file as a value model_filenames = get_clim_model_filenames(cfg, hofm_var) model_filenames = OrderedDict( sorted(model_filenames.items(), key=lambda t: t[0])) # loop over regions and models for mmodel, region in itertools.product(model_filenames, cfg['hofm_regions']): # actual extraction of the data for specific model and region hofm_data(cfg, model_filenames, mmodel, hofm_var, region)
def run_aw_core_2d(cfg, aw_core_parameters): """Plot temperature spatial distribution at AW core depth. Parameters ---------- cfg: dict configuration dictionary ESMValTool format. aw_core_parameters: dict dictionary that contain AW core parameters generated by run_aw_core function. """ model_filenames = get_clim_model_filenames(cfg, 'thetao') model_filenames = OrderedDict( sorted(model_filenames.items(), key=lambda t: t[0])) aw_core_parameters = aw_core(model_filenames, cfg['work_dir'], 'EB', 'thetao') # this is now just using plot2d_original_grid with # additional `explicit_depths` parameter plot_params = {} plot_params['variable'] = 'thetao' plot_params['model_filenames'] = model_filenames plot_params['depth'] = 0 plot_params['cmap'] = cm.Spectral_r plot_params['ncols'] = 4 plot_params['levels'] = np.round(np.linspace(-2, 2.3, 41), 1) plot_params['dpi'] = 100 plot_params['explicit_depths'] = aw_core_parameters plot_params['projection'] = ccrs.NorthPolarStereo() plot_params['bbox'] = (-180, 180, 60, 90) plot2d_original_grid(cfg, plot_params)
def plot2d_params(cfg, plot2d_var, var_number): """Prepeare configuration for plot2d.""" model_filenames = get_clim_model_filenames(cfg, plot2d_var) model_filenames = OrderedDict( sorted(model_filenames.items(), key=lambda t: t[0])) # set the color map if cfg['plot2d_cmap']: cmap = get_cmap(cfg['plot2d_cmap'][var_number]) else: cmap = get_cmap('Spectral_r') # set the number of columns in the plot if cfg['plot2d_ncol']: ncols = cfg['plot2d_ncol'] else: ncols = 4 # create color limits for the plot vmin, vmax, sstep, roundlimit = cfg['plot2d_limits'][var_number] # loop over depths plot_params = {} plot_params['variable'] = plot2d_var plot_params['model_filenames'] = model_filenames plot_params['cmap'] = cmap plot_params['ncols'] = ncols plot_params['levels'] = np.round(np.linspace(vmin, vmax, sstep), roundlimit) plot_params['dpi'] = 100 plot_params['explicit_depths'] = None plot_params['projection'] = ccrs.NorthPolarStereo() plot_params['bbox'] = (-180, 180, 60, 90) return plot_params
def run_mean(cfg, observations): """Create time mean. Parameters ---------- cfg: dict configuration dictionary ESMValTool format. observations: str name of the observation data set """ # loop over variables for hofm_var in cfg['hofm_vars']: model_filenames = get_clim_model_filenames( cfg, hofm_var, ) model_filenames = OrderedDict( sorted(model_filenames.items(), key=lambda t: t[0])) # loop over models for model in model_filenames: timmean(cfg, model_filenames, model, hofm_var, observations=observations)
def run_aw_core(cfg): """Calculate depth and temperature of the Atlantic Water core. Parameters ---------- cfg: dict configuration dictionary ESMValTool format. """ model_filenames = get_clim_model_filenames(cfg, 'thetao') model_filenames = OrderedDict( sorted(model_filenames.items(), key=lambda t: t[0])) aw_core_parameters = aw_core(model_filenames, cfg['work_dir'], 'EB', 'thetao') plot_aw_core_stat(aw_core_parameters, cfg['plot_dir']) return aw_core_parameters
def plot_profile_params(cfg, hofm_var, observations): """Prepeare configuration for profile plot.""" model_filenames = get_clim_model_filenames(cfg, hofm_var) model_filenames = OrderedDict( sorted(model_filenames.items(), key=lambda t: t[0])) plot_params = {} plot_params['variable'] = hofm_var plot_params['model_filenames'] = model_filenames plot_params['cmap'] = cm.Set2 plot_params['dpi'] = 100 plot_params['observations'] = observations return plot_params
def tsdiag_plot_parameters(cfg): """Prepeare configuration for TS plots.""" # get the dictionary with model file names model_filenames = get_clim_model_filenames(cfg, 'thetao') model_filenames = OrderedDict( sorted(model_filenames.items(), key=lambda t: t[0])) # setting the number of columns for the plot if cfg['tsdiag_ncol']: ncols = cfg['tsdiag_ncol'] else: ncols = 3 plot_params = {} plot_params['model_filenames'] = model_filenames plot_params['ncols'] = ncols plot_params['cmap'] = cm.Set1 return plot_params
def transect_plot_params(cfg, trans_var, var_number): """Prepeare configuration for transect plot.""" model_filenames = get_clim_model_filenames(cfg, trans_var) model_filenames = OrderedDict( sorted(model_filenames.items(), key=lambda t: t[0])) # loop over regions for mmodel, region in itertools.product(model_filenames, cfg['transects_regions']): # ploting a transect transect_data(cfg, mmodel, trans_var, region) # setup a color map if cfg['transects_cmap']: cmap = get_cmap(cfg['transects_cmap'][var_number]) else: cmap = get_cmap('Spectral_r') # setup number of columns if cfg['transects_ncol']: ncols = cfg['transects_ncol'] else: ncols = 3 # setup color limits vmin, vmax, sstep, roundlimit = cfg['transects_limits'][var_number] plot_params = {} plot_params['variable'] = trans_var plot_params['model_filenames'] = model_filenames plot_params['cmap'] = cmap plot_params['ncols'] = ncols plot_params['levels'] = np.round(np.linspace(vmin, vmax, sstep), roundlimit) plot_params['dpi'] = 100 plot_params['projection'] = ccrs.NorthPolarStereo() plot_params['bbox'] = (-180, 180, 60, 90) return plot_params