esmvaltool/diag_scripts/validation.py
def plot_zonal_cubes(cube_1, cube_2, cfg, plot_data):
    """Plot cubes data vs latitude or longitude when zonal meaning"""
    # xcoordinate: latotude or longitude (str)
    data_names, xcoordinate, period = plot_data
    var = data_names.split('_')[0]
    cube_names = [data_names.split('_')[1], data_names.split('_')[3]]
    lat_points = cube_1.coord(xcoordinate).points
    plt.plot(lat_points, cube_1.data, label=cube_names[0])
    plt.plot(lat_points, cube_2.data, label=cube_names[1])
    if xcoordinate == 'latitude':
        plt.title(period + ' Zonal Mean for ' + var + ' ' + data_names)
    elif xcoordinate == 'longitude':
        plt.title(period + ' Meridional Mean for ' + var + ' ' + data_names)
    plt.xlabel(xcoordinate + ' (deg)')
    plt.ylabel(var)
    plt.tight_layout()
    plt.grid()
    plt.legend()
    if xcoordinate == 'latitude':
        png_name = 'Zonal_Mean_' + xcoordinate + '_' + data_names + '.png'
    elif xcoordinate == 'longitude':
        png_name = 'Merid_Mean_' + xcoordinate + '_' + data_names + '.png'
    plt.savefig(os.path.join(cfg['plot_dir'], period, png_name))
    plt.close()
Plot cubes data vs latitude or longitude when zonal meaning
Plot cubes data vs latitude or longitude when zonal meaning
Plot cubes data vs latitude or longitude when zonal meaning
def plot_zonal_cubes(cube_1, cube_2, cfg, plot_data):
    data_names, xcoordinate, period = plot_data
    var = data_names.split('_')[0]
    cube_names = [data_names.split('_')[1], data_names.split('_')[3]]
    lat_points = cube_1.coord(xcoordinate).points
    plt.plot(lat_points, cube_1.data, label=cube_names[0])
    plt.plot(lat_points, cube_2.data, label=cube_names[1])
    if xcoordinate == 'latitude':
        plt.title(period + ' Zonal Mean for ' + var + ' ' + data_names)
    elif xcoordinate == 'longitude':
        plt.title(period + ' Meridional Mean for ' + var + ' ' + data_names)
    plt.xlabel(xcoordinate + ' (deg)')
    plt.ylabel(var)
    plt.tight_layout()
    plt.grid()
    plt.legend()
    if xcoordinate == 'latitude':
        png_name = 'Zonal_Mean_' + xcoordinate + '_' + data_names + '.png'
    elif xcoordinate == 'longitude':
        png_name = 'Merid_Mean_' + xcoordinate + '_' + data_names + '.png'
    plt.savefig(os.path.join(cfg['plot_dir'], period, png_name))
    plt.close()
def plot_zonal_cubes ( cube_1 , cube_2 , cfg , plot_data ) : data_names , xcoordinate , period = plot_data var = data_names . split ( '_' ) [ 0 ] cube_names = [ data_names . split ( '_' ) [ 1 ] , data_names . split ( '_' ) [ 3 ] ] lat_points = cube_1 . coord ( xcoordinate ) . points plt . plot ( lat_points , cube_1 . data , label = cube_names [ 0 ] ) plt . plot ( lat_points , cube_2 . data , label = cube_names [ 1 ] ) if xcoordinate == 'latitude' : plt . title ( period + ' Zonal Mean for ' + var + ' ' + data_names ) elif xcoordinate == 'longitude' : plt . title ( period + ' Meridional Mean for ' + var + ' ' + data_names ) plt . xlabel ( xcoordinate + ' (deg)' ) plt . ylabel ( var ) plt . tight_layout ( ) plt . grid ( ) plt . legend ( ) if xcoordinate == 'latitude' : png_name = 'Zonal_Mean_' + xcoordinate + '_' + data_names + '.png' elif xcoordinate == 'longitude' : png_name = 'Merid_Mean_' + xcoordinate + '_' + data_names + '.png' plt . savefig ( os . path . join ( cfg [ 'plot_dir' ] , period , png_name ) ) plt . close ( )
Plot cubes data vs latitude or longitude when zonal meaning
Plot cubes data vs latitude or longitude when zonal meaning
"""Plot cubes data vs latitude or longitude when zonal meaning""" # xcoordinate: latotude or longitude (str)
cube_1
cube_2
cfg
plot_data