コード例 #1
0
def _uv_plotting(df, lats, lons, data_type, analysis_use, bias_correction,
                 metadata, plot_type, outdir):

    bias = 'adjusted' if bias_correction else 'unadjusted'
    # Creates column name fo u and v data
    u = f'u_{data_type}' if data_type in ['observation'] \
        else f'u_{data_type}_{bias}'
    v = f'v_{data_type}' if data_type in ['observation'] \
        else f'v_{data_type}_{bias}'

    if analysis_use:
        data = {
            'u': {
                'assimilated': df['assimilated'][u].to_numpy(),
                'rejected': df['rejected'][u].to_numpy(),
                'monitored': df['monitored'][u].to_numpy()
            },
            'v': {
                'assimilated': df['assimilated'][v].to_numpy(),
                'rejected': df['rejected'][v].to_numpy(),
                'monitored': df['monitored'][v].to_numpy()
            }
        }
    else:
        data = {
            'u': df[u].to_numpy(),
            'v': df[v].to_numpy(),
        }

    for key in data.keys():
        metadata['Variable'] = key
        if np.isin('histogram', plot_type):
            plot_histogram(data[key], metadata, outdir)
        if np.isin('spatial', plot_type):
            plot_map(lats, lons, data[key], metadata, outdir)
コード例 #2
0
def plotting(sat_config, diag_file, data_type, plot_type, outdir):

    channel = sat_config['channel']
    qcflag = sat_config['qc flag']
    analysis_use = sat_config['analysis use'][0]
    bias_correction = sat_config['bias correction'][0]

    diag = Radiance(diag_file)

    df = diag.get_data(channel=channel,
                       qcflag=qcflag,
                       analysis_use=analysis_use)
    metadata = diag.metadata
    metadata['Diag Type'] = data_type

    bias = 'adjusted' if bias_correction else 'unadjusted'
    column = f'{data_type}' if data_type in ['observation'] \
        else f'{data_type}_{bias}'

    if analysis_use:
        lats = {
            'assimilated': df['assimilated']['latitude'].to_numpy(),
            'rejected': df['rejected']['latitude'].to_numpy(),
            'monitored': df['monitored']['latitude'].to_numpy()
        }
        lons = {
            'assimilated': df['assimilated']['longitude'].to_numpy(),
            'rejected': df['rejected']['longitude'].to_numpy(),
            'monitored': df['monitored']['longitude'].to_numpy()
        }

        data = {
            'assimilated': df['assimilated'][column].to_numpy(),
            'rejected': df['rejected'][column].to_numpy(),
            'monitored': df['monitored'][column].to_numpy()
        }

        for key in data.keys():
            data[key][data[key] > 1e5] = np.nan

    else:
        lats = df['latitude'].to_numpy()
        lons = df['longitude'].to_numpy()

        data = df[column].to_numpy()

        data[data > 1e5] = np.nan

    if np.isin('histogram', plot_type):
        plot_histogram(data, metadata, outdir)
    if np.isin('spatial', plot_type):
        plot_map(lats, lons, data, metadata, outdir)
コード例 #3
0
ファイル: mp_plot_ozone_diags.py プロジェクト: NOAA-EMC/PyGSI
def plotting(sat_config, diag_file, data_type, plot_type, outdir):

    analysis_use = ozone_config['analysis use'][0]
    layer = ozone_config['layer'][0]
    bias_correction = ozone_config['bias correction'][0]

    diag = Ozone(diag_file)

    df = diag.get_data(analysis_use=analysis_use)
    metadata = diag.metadata
    metadata['Diag Type'] = data_type

    bias = 'adjusted' if bias_correction else 'unadjusted'
    column = f'{data_type}' if data_type in ['observation'] \
        else f'{data_type}_{bias}'

    if layer == 0:
        dict_key = 'column total'
    else:
        dict_key = list(df)[layer]
    metadata['Layer'] = dict_key

    if analysis_use:
        lats = {
            'assimilated': df[dict_key]['assimilated']['latitude'].to_numpy(),
            'monitored': df[dict_key]['monitored']['latitude'].to_numpy()
        }
        lons = {
            'assimilated': df[dict_key]['assimilated']['longitude'].to_numpy(),
            'monitored': df[dict_key]['monitored']['longitude'].to_numpy()
        }

        data = {
            'assimilated': df[dict_key]['assimilated'][column].to_numpy(),
            'monitored': df[dict_key]['monitored'][column].to_numpy()
        }

    else:
        lats = df[dict_key]['latitude'].to_numpy()
        lons = df[dict_key]['longitude'].to_numpy()

        data = df[dict_key][column].to_numpy()

    if np.isin('histogram', plot_type):
        plot_histogram(data, metadata, outdir)
    if np.isin('spatial', plot_type):
        plot_map(lats, lons, data, metadata, outdir)
コード例 #4
0
def plotting_radiance(sat_config):

    diagfile = sat_config['radiance input']['path'][0]
    diag_type = sat_config['radiance input']['data type'][0].lower()
    channel = sat_config['radiance input']['channel']
    qcflag = sat_config['radiance input']['qc flag']
    plot_type = sat_config['radiance input']['plot type']
    outdir = sat_config['outdir']

    diag = Radiance(diagfile)

    data = diag.get_data(diag_type, channel=channel, qcflag=qcflag)
    lats, lons = diag.get_lat_lon(channel=channel, qcflag=qcflag)

    metadata = diag.metadata

    if np.isin('histogram', plot_type):
        plot_histogram(data, metadata, outdir)
    if np.isin('spatial', plot_type):
        plot_spatial(data, metadata, lats, lons, outdir)

    return
コード例 #5
0
def plotting(conv_config, diag_file, data_type, plot_type, outdir):

    obsid = conv_config['observation id']
    obsubtype = conv_config['observation subtype']
    analysis_use = conv_config['analysis use'][0]
    bias_correction = conv_config['bias correction'][0]

    diag = Conventional(diag_file)

    df = diag.get_data(obsid=obsid,
                       subtype=obsubtype,
                       analysis_use=analysis_use)
    metadata = diag.metadata
    metadata['Diag Type'] = data_type

    bias = 'adjusted' if bias_correction else 'unadjusted'
    column = f'{data_type}' if data_type in ['observation'] \
        else f'{data_type}_{bias}'

    if analysis_use:
        lats = {
            'assimilated': df['assimilated']['latitude'].to_numpy(),
            'rejected': df['rejected']['latitude'].to_numpy(),
            'monitored': df['monitored']['latitude'].to_numpy()
        }
        lons = {
            'assimilated': df['assimilated']['longitude'].to_numpy(),
            'rejected': df['rejected']['longitude'].to_numpy(),
            'monitored': df['monitored']['longitude'].to_numpy()
        }

        if metadata['Obs Type'] == 'conv' and metadata['Variable'] == 'uv':
            _uv_plotting(df, lats, lons, data_type, analysis_use, metadata,
                         plot_type, outdir)

        else:
            data = {
                'assimilated': df['assimilated'][column].to_numpy(),
                'rejected': df['rejected'][column].to_numpy(),
                'monitored': df['monitored'][column].to_numpy()
            }

            if np.isin('histogram', plot_type):
                plot_histogram(data, metadata, outdir)
            if np.isin('spatial', plot_type):
                plot_map(lats, lons, data, metadata, outdir)

    else:
        lats = df['latitude'].to_numpy()
        lons = df['longitude'].to_numpy()

        if metadata['Obs Type'] == 'conv' and metadata['Variable'] == 'uv':
            _uv_plotting(df, lats, lons, data_type, analysis_use,
                         bias_correction, metadata, plot_type, outdir)

        else:
            data = df[column].to_numpy()

            if np.isin('histogram', plot_type):
                plot_histogram(data, metadata, outdir)
            if np.isin('spatial', plot_type):
                plot_map(lats, lons, data, metadata, outdir)
コード例 #6
0
def plotting_conventional(conv_config):

    diagfile = conv_config['conventional input']['path'][0]
    diag_type = conv_config['conventional input']['data type'][0].lower()
    obsid = conv_config['conventional input']['observation id']
    analysis_use = conv_config['conventional input']['analysis use'][0]
    plot_type = conv_config['conventional input']['plot type']
    outdir = conv_config['outdir']

    diag = Conventional(diagfile)

    if analysis_use:
        diag_components = diagfile.split('/')[-1].split('.')[0].split('_')
        if diag_components[1] == 'conv' and diag_components[2] == 'uv':
            u, v = diag.get_data(diag_type,
                                 obsid=obsid,
                                 analysis_use=analysis_use)

            data = {
                'assimilated': {
                    'u':
                    u['assimilated'],
                    'v':
                    v['assimilated'],
                    'windspeed':
                    np.sqrt(
                        np.square(u['assimilated']) +
                        np.square(v['assimilated']))
                },
                'monitored': {
                    'u':
                    u['monitored'],
                    'v':
                    v['monitored'],
                    'windspeed':
                    np.sqrt(
                        np.square(u['monitored']) + np.square(v['monitored']))
                }
            }

        else:
            data = diag.get_data(diag_type,
                                 obsid=obsid,
                                 analysis_use=analysis_use)

            data = {
                'assimilated': data['assimilated'],
                'monitored': data['monitored']
            }

        lats, lons = diag.get_lat_lon(obsid=obsid, analysis_use=analysis_use)

        metadata = diag.metadata

        if np.isin('histogram', plot_type):
            plot_histogram(data, metadata, outdir)
        if np.isin('spatial', plot_type):
            plot_spatial(data, metadata, lats, lons, outdir)

    else:

        diag_components = diagfile.split('/')[-1].split('.')[0].split('_')
        if diag_components[1] == 'conv' and diag_components[2] == 'uv':
            u, v = diag.get_data(diag_type,
                                 obsid=obsid,
                                 analysis_use=analysis_use)
            data = {
                'u': u,
                'v': v,
                'windspeed': np.sqrt(np.square(u) + np.square(v))
            }
        else:
            data = diag.get_data(diag_type, obsid=obsid)

        lats, lons = diag.get_lat_lon(obsid=obsid)

        metadata = diag.metadata

        if np.isin('histogram', plot_type):
            plot_histogram(data, metadata, outdir)
        if np.isin('spatial', plot_type):
            plot_spatial(data, metadata, lats, lons, outdir)

        return