コード例 #1
0
def main(cfg):
    """Execute validation analysis and plotting."""
    logger.setLevel(cfg['log_level'].upper())
    input_data, grouped_input_data = do_preamble(cfg)

    # select variables and their corresponding obs files
    for short_name in grouped_input_data:
        logger.info("Processing variable %s", short_name)

        cmip_era = cfg["cmip_era"]
        # get the control, experiment and obs dicts
        ctrl, exper, obs = get_control_exper_obs(short_name, input_data, cfg,
                                                 cmip_era)
        # set a plot key holding info on var and data set names
        plot_key = "{}_{}_vs_{}".format(short_name, ctrl['dataset'],
                                        exper['dataset'])
        control_dataset_name = ctrl['dataset']

        # get seasons if needed then apply analysis
        if cfg['seasonal_analysis']:
            ctrl_seasons = apply_seasons(ctrl)
            exper_seasons = apply_seasons(exper)
            ctrl_seasons = [
                coordinate_collapse(cts, cfg) for cts in ctrl_seasons
            ]
            exper_seasons = [
                coordinate_collapse(exps, cfg) for exps in exper_seasons
            ]
            plot_ctrl_exper_seasons(ctrl_seasons, exper_seasons, cfg, plot_key)
            if obs:
                for iobs in obs:
                    obs_seasons = apply_seasons(iobs)
                    obs_seasons = [
                        coordinate_collapse(obss, cfg) for obss in obs_seasons
                    ]
                    plot_key_obs = "{}_{}_vs_{}".format(
                        short_name, ctrl['dataset'], iobs['dataset'])
                    plot_ctrl_exper_seasons(ctrl_seasons, obs_seasons, cfg,
                                            plot_key_obs)

        # apply the supermeans (MEAN on time), collapse a coord and plot
        ctrl, exper, obs_list = apply_supermeans(ctrl, exper, obs)
        ctrl = coordinate_collapse(ctrl, cfg)
        exper = coordinate_collapse(exper, cfg)
        plot_ctrl_exper(ctrl, exper, cfg, plot_key)

        # apply desired analysis on obs's
        if obs_list:
            for obs_i, obsfile in zip(obs_list, obs):
                obs_analyzed = coordinate_collapse(obs_i, cfg)
                obs_name = obsfile['dataset']
                plot_key = "{}_{}_vs_{}".format(short_name,
                                                control_dataset_name, obs_name)
                if cfg['analysis_type'] == 'lat_lon':
                    plot_latlon_cubes(ctrl,
                                      obs_analyzed,
                                      cfg,
                                      plot_key,
                                      obs_name=obs_name)
コード例 #2
0
def main(cfg):
    """Execute the radiation rms diag."""
    logger.setLevel(cfg['log_level'].upper())
    input_data, grouped_input_data = do_preamble(cfg)

    # select variables and their corresponding
    # obs files
    for short_name in grouped_input_data:
        logger.info("Processing variable %s", short_name)

        # control, experiment and obs's
        ctrl, exper, obslist = get_control_exper_obs(short_name, input_data,
                                                     cfg, _CMIP_TYPE)

        # apply the supermeans
        ctrl_sm, exper_sm, obs_sm_list = apply_supermeans(ctrl, exper, obslist)

        # assemble a dict that contains various params depending
        # on the data combinations for RMS computations
        # control-experiment
        data_component_dict = {'ct-ex': {'ctrl': ctrl, 'exper': exper}}
        logger.info("Computing CONTROL-EXPERIMENT RMS...")
        apply_rms(ctrl_sm, exper_sm, cfg, data_component_dict['ct-ex'],
                  short_name)
        if obs_sm_list:
            for obs, obsfile in zip(obs_sm_list, obslist):
                data_component_dict = {
                    'ct-obs': {
                        'ctrl': ctrl,
                        'obs': obsfile
                    },
                    'ex-obs': {
                        'exper': exper,
                        'obs': obsfile
                    }
                }

                # ctrl-obs
                logger.info("Computing CONTROL-OBS RMS...")
                apply_rms(ctrl_sm, obs, cfg, data_component_dict['ct-obs'],
                          short_name)
                # exper-obs
                logger.info("Computing EXPERIMENT-OBS RMS...")
                apply_rms(exper_sm, obs, cfg, data_component_dict['ex-obs'],
                          short_name)
        else:
            # only ctrl-exper
            data_component_dict = {'ct-ex': {'ctrl': ctrl, 'exper': exper}}
            logger.info("Computing CONTROL-EXPERIMENT RMS...")
            apply_rms(ctrl_sm, exper_sm, cfg, data_component_dict['ct-ex'],
                      short_name)