esmvaltool/diag_scripts/ocean/diagnostic_maps_quad.py
def multi_model_maps(
        cfg,
        input_files,
):
    """
    Make a simple map plot for an individual model.

    The cfg is the opened global config,
    input_files is the input files dictionairy
    filename is the preprocessing model file.
    """
    filenames = {}
    ctl_key = 'control_model'
    exp_key = 'exper_model'
    obs_key = 'observational_dataset'
    model_types = [ctl_key, exp_key, obs_key]
    for model_type in model_types:
        logger.debug(model_type, cfg[model_type])
        filenames[model_type] = match_model_to_key(model_type,
                                                   cfg[model_type],
                                                   input_files)

    # ####
    # Load the data for each layer as a separate cube
    layers = {}
    cubes = {}
    for model_type, input_file in filenames.items():
        cube = iris.load_cube(input_file)
        cube = diagtools.bgc_units(cube, input_files[input_file]['short_name'])

        cubes[model_type] = diagtools.make_cube_layer_dict(cube)
        for layer in cubes[model_type]:
            layers[layer] = True

    logger.debug('layers: %s', ', '.join(layers))
    logger.debug('cubes: %s', ', '.join(cubes.keys()))

    # ####
    # load names:
    exper = input_files[filenames[exp_key]]['dataset']
    control = input_files[filenames[ctl_key]]['dataset']
    obs = input_files[filenames[obs_key]]['dataset']
    long_name = cubes[exp_key][list(layers.keys())[0]].long_name

    # Load image format extention
    image_extention = diagtools.get_image_format(cfg)

    # Make a plot for each layer
    for layer in layers:
        fig = plt.figure()
        fig.set_size_inches(9, 6)

        # Create the cubes
        cube221 = cubes[exp_key][layer]
        cube222 = cubes[exp_key][layer] - cubes[ctl_key][layer]
        cube223 = cubes[ctl_key][layer] - cubes[obs_key][layer]
        cube224 = cubes[exp_key][layer] - cubes[obs_key][layer]

        # create the z axis for plots 2, 3, 4.
        zrange = get_cube_range_diff([cube222, cube223, cube224])
        n_points = 15
        linspace = np.linspace(zrange[0], zrange[1], n_points, endpoint=True)

        # Add the sub plots to the figure.
        add_map_subplot(221, cube221, n_points=n_points, cmap='viridis',
                        title=exper)
        add_map_subplot(222, cube222, n_points=linspace, cmap='bwr',
                        title=' '.join([exper, 'minus', control]))
        add_map_subplot(223, cube223, n_points=linspace, cmap='bwr',
                        title=' '.join([control, 'minus', obs]))
        add_map_subplot(224, cube224, n_points=linspace, cmap='bwr',
                        title=' '.join([exper, 'minus', obs]))

        # Add overall title
        fig.suptitle(long_name, fontsize=14)

        # Determine image filename:
        fn_list = [long_name, exper, control, obs, str(layer)]
        path = diagtools.folder(cfg['plot_dir']) + '_'.join(fn_list)
        path = path.replace(' ', '') + image_extention

        # Saving files:
        if cfg['write_plots']:
            logger.info('Saving plots to %s', path)
            plt.savefig(path)

        plt.close()

    Make a simple map plot for an individual model.

    The cfg is the opened global config,
    input_files is the input files dictionairy
    filename is the preprocessing model file.
    
Make a simple map plot for an individual model.
The cfg is the opened global config,
input_files is the input files dictionairy
filename is the preprocessing model file.
Make a simple map plot for an individual model . The cfg is the opened global config input_files is the input files dictionairy filename is the preprocessing model file .
def multi_model_maps(
        cfg,
        input_files,
):
    filenames = {}
    ctl_key = 'control_model'
    exp_key = 'exper_model'
    obs_key = 'observational_dataset'
    model_types = [ctl_key, exp_key, obs_key]
    for model_type in model_types:
        logger.debug(model_type, cfg[model_type])
        filenames[model_type] = match_model_to_key(model_type,
                                                   cfg[model_type],
                                                   input_files)
    layers = {}
    cubes = {}
    for model_type, input_file in filenames.items():
        cube = iris.load_cube(input_file)
        cube = diagtools.bgc_units(cube, input_files[input_file]['short_name'])
        cubes[model_type] = diagtools.make_cube_layer_dict(cube)
        for layer in cubes[model_type]:
            layers[layer] = True
    logger.debug('layers: %s', ', '.join(layers))
    logger.debug('cubes: %s', ', '.join(cubes.keys()))
    exper = input_files[filenames[exp_key]]['dataset']
    control = input_files[filenames[ctl_key]]['dataset']
    obs = input_files[filenames[obs_key]]['dataset']
    long_name = cubes[exp_key][list(layers.keys())[0]].long_name
    image_extention = diagtools.get_image_format(cfg)
    for layer in layers:
        fig = plt.figure()
        fig.set_size_inches(9, 6)
        cube221 = cubes[exp_key][layer]
        cube222 = cubes[exp_key][layer] - cubes[ctl_key][layer]
        cube223 = cubes[ctl_key][layer] - cubes[obs_key][layer]
        cube224 = cubes[exp_key][layer] - cubes[obs_key][layer]
        zrange = get_cube_range_diff([cube222, cube223, cube224])
        n_points = 15
        linspace = np.linspace(zrange[0], zrange[1], n_points, endpoint=True)
        add_map_subplot(221, cube221, n_points=n_points, cmap='viridis',
                        title=exper)
        add_map_subplot(222, cube222, n_points=linspace, cmap='bwr',
                        title=' '.join([exper, 'minus', control]))
        add_map_subplot(223, cube223, n_points=linspace, cmap='bwr',
                        title=' '.join([control, 'minus', obs]))
        add_map_subplot(224, cube224, n_points=linspace, cmap='bwr',
                        title=' '.join([exper, 'minus', obs]))
        fig.suptitle(long_name, fontsize=14)
        fn_list = [long_name, exper, control, obs, str(layer)]
        path = diagtools.folder(cfg['plot_dir']) + '_'.join(fn_list)
        path = path.replace(' ', '') + image_extention
        if cfg['write_plots']:
            logger.info('Saving plots to %s', path)
            plt.savefig(path)
        plt.close()
def multi_model_maps ( cfg , input_files , ) : filenames = { } ctl_key = 'control_model' exp_key = 'exper_model' obs_key = 'observational_dataset' model_types = [ ctl_key , exp_key , obs_key ] for model_type in model_types : logger . debug ( model_type , cfg [ model_type ] ) filenames [ model_type ] = match_model_to_key ( model_type , cfg [ model_type ] , input_files ) layers = { } cubes = { } for model_type , input_file in filenames . items ( ) : cube = iris . load_cube ( input_file ) cube = diagtools . bgc_units ( cube , input_files [ input_file ] [ 'short_name' ] ) cubes [ model_type ] = diagtools . make_cube_layer_dict ( cube ) for layer in cubes [ model_type ] : layers [ layer ] = True logger . debug ( 'layers: %s' , ', ' . join ( layers ) ) logger . debug ( 'cubes: %s' , ', ' . join ( cubes . keys ( ) ) ) exper = input_files [ filenames [ exp_key ] ] [ 'dataset' ] control = input_files [ filenames [ ctl_key ] ] [ 'dataset' ] obs = input_files [ filenames [ obs_key ] ] [ 'dataset' ] long_name = cubes [ exp_key ] [ list ( layers . keys ( ) ) [ 0 ] ] . long_name image_extention = diagtools . get_image_format ( cfg ) for layer in layers : fig = plt . figure ( ) fig . set_size_inches ( 9 , 6 ) cube221 = cubes [ exp_key ] [ layer ] cube222 = cubes [ exp_key ] [ layer ] - cubes [ ctl_key ] [ layer ] cube223 = cubes [ ctl_key ] [ layer ] - cubes [ obs_key ] [ layer ] cube224 = cubes [ exp_key ] [ layer ] - cubes [ obs_key ] [ layer ] zrange = get_cube_range_diff ( [ cube222 , cube223 , cube224 ] ) n_points = 15 linspace = np . linspace ( zrange [ 0 ] , zrange [ 1 ] , n_points , endpoint = True ) add_map_subplot ( 221 , cube221 , n_points = n_points , cmap = 'viridis' , title = exper ) add_map_subplot ( 222 , cube222 , n_points = linspace , cmap = 'bwr' , title = ' ' . join ( [ exper , 'minus' , control ] ) ) add_map_subplot ( 223 , cube223 , n_points = linspace , cmap = 'bwr' , title = ' ' . join ( [ control , 'minus' , obs ] ) ) add_map_subplot ( 224 , cube224 , n_points = linspace , cmap = 'bwr' , title = ' ' . join ( [ exper , 'minus' , obs ] ) ) fig . suptitle ( long_name , fontsize = 14 ) fn_list = [ long_name , exper , control , obs , str ( layer ) ] path = diagtools . folder ( cfg [ 'plot_dir' ] ) + '_' . join ( fn_list ) path = path . replace ( ' ' , '' ) + image_extention if cfg [ 'write_plots' ] : logger . info ( 'Saving plots to %s' , path ) plt . savefig ( path ) plt . close ( )
Make a simple map plot for an individual model.
Make a simple map plot for an individual model .
"""
    Make a simple map plot for an individual model.

    The cfg is the opened global config,
    input_files is the input files dictionairy
    filename is the preprocessing model file.
    """ # #### # Load the data for each layer as a separate cube # #### # load names: # Load image format extention # Make a plot for each layer # Create the cubes # create the z axis for plots 2, 3, 4. # Add the sub plots to the figure. # Add overall title # Determine image filename: # Saving files:
cfg
input_files