esmvaltool/diag_scripts/ocean/diagnostic_maps.py
def make_map_plots(
        cfg,
        metadata,
        filename,
):
    """
    Make a simple map plot for an individual model.

    The cfg is the opened global config,
    metadata is the metadata dictionairy
    filename is the preprocessing model file.
    """
    # Load cube and set up units
    cube = iris.load_cube(filename)
    cube = diagtools.bgc_units(cube, metadata['short_name'])

    # Is this data is a multi-model dataset?
    multi_model = metadata['dataset'].find('MultiModel') > -1

    # Make a dict of cubes for each layer.
    cubes = diagtools.make_cube_layer_dict(cube)

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

    # Making plots for each layer
    for layer_index, (layer, cube_layer) in enumerate(cubes.items()):
        layer = str(layer)

        qplt.contourf(cube_layer, 25, linewidth=0, rasterized=True)

        try:
            plt.gca().coastlines()
        except AttributeError:
            logger.warning('Not able to add coastlines')

        # Add title to plot
        title = ' '.join([metadata['dataset'], metadata['long_name']])
        if layer:
            title = ' '.join(
                [title, '(', layer,
                 str(cube_layer.coords('depth')[0].units), ')'])
        plt.title(title)

        # Determine image filename:
        if multi_model:
            path = diagtools.folder(
                cfg['plot_dir']) + os.path.basename(filename).replace(
                    '.nc', '_map_' + str(layer_index) + image_extention)
        else:
            path = diagtools.get_image_path(
                cfg,
                metadata,
                suffix='map_' + str(layer_index) + 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,
    metadata is the metadata dictionairy
    filename is the preprocessing model file.
    
Make a simple map plot for an individual model.
The cfg is the opened global config,
metadata is the metadata dictionairy
filename is the preprocessing model file.
Make a simple map plot for an individual model . The cfg is the opened global config metadata is the metadata dictionairy filename is the preprocessing model file .
def make_map_plots(
        cfg,
        metadata,
        filename,
):
    cube = iris.load_cube(filename)
    cube = diagtools.bgc_units(cube, metadata['short_name'])
    multi_model = metadata['dataset'].find('MultiModel') > -1
    cubes = diagtools.make_cube_layer_dict(cube)
    image_extention = diagtools.get_image_format(cfg)
    for layer_index, (layer, cube_layer) in enumerate(cubes.items()):
        layer = str(layer)
        qplt.contourf(cube_layer, 25, linewidth=0, rasterized=True)
        try:
            plt.gca().coastlines()
        except AttributeError:
            logger.warning('Not able to add coastlines')
        title = ' '.join([metadata['dataset'], metadata['long_name']])
        if layer:
            title = ' '.join(
                [title, '(', layer,
                 str(cube_layer.coords('depth')[0].units), ')'])
        plt.title(title)
        if multi_model:
            path = diagtools.folder(
                cfg['plot_dir']) + os.path.basename(filename).replace(
                    '.nc', '_map_' + str(layer_index) + image_extention)
        else:
            path = diagtools.get_image_path(
                cfg,
                metadata,
                suffix='map_' + str(layer_index) + image_extention,
            )
        if cfg['write_plots']:
            logger.info('Saving plots to %s', path)
            plt.savefig(path)
        plt.close()
def make_map_plots ( cfg , metadata , filename , ) : cube = iris . load_cube ( filename ) cube = diagtools . bgc_units ( cube , metadata [ 'short_name' ] ) multi_model = metadata [ 'dataset' ] . find ( 'MultiModel' ) > - 1 cubes = diagtools . make_cube_layer_dict ( cube ) image_extention = diagtools . get_image_format ( cfg ) for layer_index , ( layer , cube_layer ) in enumerate ( cubes . items ( ) ) : layer = str ( layer ) qplt . contourf ( cube_layer , 25 , linewidth = 0 , rasterized = True ) try : plt . gca ( ) . coastlines ( ) except AttributeError : logger . warning ( 'Not able to add coastlines' ) title = ' ' . join ( [ metadata [ 'dataset' ] , metadata [ 'long_name' ] ] ) if layer : title = ' ' . join ( [ title , '(' , layer , str ( cube_layer . coords ( 'depth' ) [ 0 ] . units ) , ')' ] ) plt . title ( title ) if multi_model : path = diagtools . folder ( cfg [ 'plot_dir' ] ) + os . path . basename ( filename ) . replace ( '.nc' , '_map_' + str ( layer_index ) + image_extention ) else : path = diagtools . get_image_path ( cfg , metadata , suffix = 'map_' + str ( layer_index ) + 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,
    metadata is the metadata dictionairy
    filename is the preprocessing model file.
    """ # Load cube and set up units # Is this data is a multi-model dataset? # Make a dict of cubes for each layer. # Load image format extention # Making plots for each layer # Add title to plot # Determine image filename: # Saving files:
cfg
metadata
filename