def infer_hfds(cube_dict, inargs):
    """Infer the downward heat flux into ocean."""

    hfls_data = grids.regrid_1D(cube_dict['hfls'],
                                cube_dict['rns'],
                                'latitude',
                                clear_units=False)
    hfss_data = grids.regrid_1D(cube_dict['hfss'],
                                cube_dict['rns'],
                                'latitude',
                                clear_units=False)
    data_list = [hfls_data, hfss_data, cube_dict['rns']]
    if inargs.hfsithermds_files:
        hfsithermds_data = grids.regrid_1D(cube_dict['hfsithermds'],
                                           cube_dict['rns'],
                                           'latitude',
                                           clear_units=False)
        data_list.append(hfsithermds_data)
    else:
        hfsithermds_data = 0.0

    iris.util.unify_time_units(data_list)

    cube_dict['hfds-inferred'] = cube_dict[
        'rns'] + hfls_data + hfss_data + hfsithermds_data

    return cube_dict
Beispiel #2
0
def plot_ensmean(data_dict, experiment, nexperiments,
                 single_run=False, linestyle='-', linewidth=2.0):
    """Plot the ensemble mean.

    If single_run is true, the ensemble is calculated using
      only the first run from each model/physics family.

    """

    target_grid = make_zonal_grid()
    regridded_cube_list = iris.cube.CubeList([])
    count = 0
    for key, cube in data_dict.items():
        model, physics, realization = key
        if not single_run or ((realization == 'r1') or (model == 'FGOALS-g2')):
            regridded_cube = grids.regrid_1D(cube, target_grid, 'latitude')
            new_aux_coord = iris.coords.AuxCoord(count, long_name='ensemble_member', units='no_unit')
            regridded_cube.add_aux_coord(new_aux_coord)
            regridded_cube.cell_methods = None
            regridded_cube.data = regridded_cube.data.astype(numpy.float64)
            regridded_cube_list.append(regridded_cube)
            count = count + 1

    if len(regridded_cube_list) > 1:
        equalise_attributes(regridded_cube_list)
        ensemble_cube = regridded_cube_list.merge_cube()
        ensemble_mean = ensemble_cube.collapsed('ensemble_member', iris.analysis.MEAN)
    else:
        ensemble_mean = regridded_cube_list[0]
   
    label, color = get_ensemble_label_color(experiment, nexperiments, count, single_run)
    iplt.plot(ensemble_mean, label=label, color=color, linestyle=linestyle, linewidth=linewidth)

    return ensemble_mean
Beispiel #3
0
def plot_inferred_data(primary_data, secondary_data, y_axis_name, y_var_name,
                       y_standard_name, y_long_name, quantity):
    """Plot the inferred data.

    inferred = primary + secondary (for quantity = OHC)
    OR
    inferred = primary - secondary (for HTC and SFL)

    """

    primary_data.coord(y_axis_name).var_name = y_var_name
    primary_data.coord(y_axis_name).standard_name = y_standard_name
    primary_data.coord(y_axis_name).long_name = y_long_name
    primary_data.units = ''
    regridded_secondary_data = grids.regrid_1D(secondary_data,
                                               primary_data,
                                               y_axis_name,
                                               clear_units=True)

    if 'OHC' in quantity:
        label = 'inferred ' + quantity + ' (= HTC + SFL)'
        iplt.plot(primary_data + regridded_secondary_data,
                  label=label,
                  color='black',
                  linestyle='--')
    elif 'HTC' in quantity:
        label = 'inferred ' + quantity + ' (= OHC - SFL)'
        iplt.plot(primary_data - regridded_secondary_data,
                  label=label,
                  color='green',
                  linestyle='--')
    elif 'SFL' in quantity:
        label = 'inferred ' + quantity + ' (= OHC - HTC)'
        iplt.plot(primary_data - regridded_secondary_data,
                  label=label,
                  color='orange',
                  linestyle='--')