esmvaltool/diag_scripts/examples/diagnostic_multiplot.py
def main(cfg):
    """Compute the time average for each input dataset."""

    for index, metadata_filename in enumerate(cfg['input_files']):
        logger.info(
            'metadata filename:\t%s',
            metadata_filename,
        )
        input_files = diagtools.get_input_files(cfg, index=index)
        multi_model_maps(
            cfg,
            input_files,
        )

    logger.info('Success')


    # Get a description of the preprocessed data that we will use as input.
    input_data = cfg['input_data'].values()

    # Demonstrate use of metadata access convenience functions.
    selection = select_metadata(input_data, short_name='pr', project='CMIP5')
    logger.info("Example of how to select only CMIP5 precipitation data:\n%s",
                pformat(selection))

    selection = sorted_metadata(selection, sort='dataset')
    logger.info("Example of how to sort this selection by dataset:\n%s",
                pformat(selection))

    grouped_input_data = group_metadata(
        input_data, 'standard_name', sort='dataset')
    logger.info(
        "Example of how to group and sort input data by standard_name:"
        "\n%s", pformat(grouped_input_data))

    # Example of how to loop over variables/datasets in alphabetical order
    for standard_name in grouped_input_data:
        logger.info("Processing variable %s", standard_name)
        for attributes in grouped_input_data[standard_name]:
            logger.info("Processing dataset %s", attributes['dataset'])

            filename = attributes['filename']
            logger.debug("Loading %s", filename)
            cube = iris.load_cube(filename)

            logger.debug("Running example computation")
            cube = cube.collapsed('time', iris.analysis.MEAN)

            name = os.path.splitext(os.path.basename(filename))[0] + '_mean'
            plot_results(cube, name, cfg)
Compute the time average for each input dataset.
Compute the time average for each input dataset.
Compute the time average for each input dataset .
def main(cfg):
    for index, metadata_filename in enumerate(cfg['input_files']):
        logger.info(
            'metadata filename:\t%s',
            metadata_filename,
        )
        input_files = diagtools.get_input_files(cfg, index=index)
        multi_model_maps(
            cfg,
            input_files,
        )
    logger.info('Success')
    input_data = cfg['input_data'].values()
    selection = select_metadata(input_data, short_name='pr', project='CMIP5')
    logger.info("Example of how to select only CMIP5 precipitation data:\n%s",
                pformat(selection))
    selection = sorted_metadata(selection, sort='dataset')
    logger.info("Example of how to sort this selection by dataset:\n%s",
                pformat(selection))
    grouped_input_data = group_metadata(
        input_data, 'standard_name', sort='dataset')
    logger.info(
        "Example of how to group and sort input data by standard_name:"
        "\n%s", pformat(grouped_input_data))
    for standard_name in grouped_input_data:
        logger.info("Processing variable %s", standard_name)
        for attributes in grouped_input_data[standard_name]:
            logger.info("Processing dataset %s", attributes['dataset'])
            filename = attributes['filename']
            logger.debug("Loading %s", filename)
            cube = iris.load_cube(filename)
            logger.debug("Running example computation")
            cube = cube.collapsed('time', iris.analysis.MEAN)
            name = os.path.splitext(os.path.basename(filename))[0] + '_mean'
            plot_results(cube, name, cfg)
def main ( cfg ) : for index , metadata_filename in enumerate ( cfg [ 'input_files' ] ) : logger . info ( 'metadata filename:\t%s' , metadata_filename , ) input_files = diagtools . get_input_files ( cfg , index = index ) multi_model_maps ( cfg , input_files , ) logger . info ( 'Success' ) input_data = cfg [ 'input_data' ] . values ( ) selection = select_metadata ( input_data , short_name = 'pr' , project = 'CMIP5' ) logger . info ( "Example of how to select only CMIP5 precipitation data:\n%s" , pformat ( selection ) ) selection = sorted_metadata ( selection , sort = 'dataset' ) logger . info ( "Example of how to sort this selection by dataset:\n%s" , pformat ( selection ) ) grouped_input_data = group_metadata ( input_data , 'standard_name' , sort = 'dataset' ) logger . info ( "Example of how to group and sort input data by standard_name:" "\n%s" , pformat ( grouped_input_data ) ) for standard_name in grouped_input_data : logger . info ( "Processing variable %s" , standard_name ) for attributes in grouped_input_data [ standard_name ] : logger . info ( "Processing dataset %s" , attributes [ 'dataset' ] ) filename = attributes [ 'filename' ] logger . debug ( "Loading %s" , filename ) cube = iris . load_cube ( filename ) logger . debug ( "Running example computation" ) cube = cube . collapsed ( 'time' , iris . analysis . MEAN ) name = os . path . splitext ( os . path . basename ( filename ) ) [ 0 ] + '_mean' plot_results ( cube , name , cfg )
Compute the time average for each input dataset.
Compute the time average for each input dataset .
"""Compute the time average for each input dataset.""" # Get a description of the preprocessed data that we will use as input. # Demonstrate use of metadata access convenience functions. # Example of how to loop over variables/datasets in alphabetical order
cfg