Пример #1
0
def test_plot():
    # Process MET data to get simple LCL
    files = sample_files.EXAMPLE_MET_WILDCARD
    met = arm.read_netcdf(files)
    met_temp = met.temp_mean
    met_rh = met.rh_mean
    met_lcl = (20. + met_temp / 5.) * (100. - met_rh) / 1000.
    met['met_lcl'] = met_lcl * 1000.
    met['met_lcl'].attrs['units'] = 'm'
    met['met_lcl'].attrs['long_name'] = 'LCL Calculated from SGP MET E13'

    # Plot data
    display = TimeSeriesDisplay(met)
    display.add_subplots((2, 2), figsize=(15, 10))
    display.plot('wspd_vec_mean', subplot_index=(0, 0))
    display.plot('temp_mean', subplot_index=(1, 0))
    display.plot('rh_mean', subplot_index=(0, 1))

    windrose = WindRoseDisplay(met)
    display.put_display_in_subplot(windrose, subplot_index=(1, 1))
    windrose.plot('wdir_vec_mean',
                  'wspd_vec_mean',
                  spd_bins=np.linspace(0, 10, 4))
    windrose.axes[0].legend(loc='best')
    met.close()
    return display.fig
Пример #2
0
def test_wind_rose():
    sonde_ds = arm.read_netcdf(
        sample_files.EXAMPLE_TWP_SONDE_WILDCARD)

    WindDisplay = WindRoseDisplay(sonde_ds, figsize=(10, 10))
    WindDisplay.plot('deg', 'wspd',
                     spd_bins=np.linspace(0, 20, 10), num_dirs=30,
                     tick_interval=2)
    sonde_ds.close()
    return WindDisplay.fig
Пример #3
0
def test_wind_rose():
    sonde_ds = arm.read_netcdf(
        sample_files.EXAMPLE_TWP_SONDE_WILDCARD)

    WindDisplay = WindRoseDisplay(sonde_ds, figsize=(10, 10))
    WindDisplay.plot('deg', 'wspd',
                     spd_bins=np.linspace(0, 20, 10), num_dirs=30,
                     tick_interval=2, cmap='viridis')
    WindDisplay.set_thetarng(trng=(0., 360.))
    WindDisplay.set_rrng((0., 14))

    sonde_ds.close()
    return WindDisplay.fig
#! /usr/bin/env python3

from pathlib import Path
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from act.io.noaagml import read_gml
from act.plotting import WindRoseDisplay

# Read in data. This will read in one or more files and do a bit of work
# updating the variable attributes with units, long_name and quality
# control variables.
ds_obj = read_gml(Path('data', 'brw21120.dat'))

# Create a date string for plot title
timestring = pd.to_datetime(ds_obj['time'].values[0]).strftime('%Y-%m-%d')

WindDisplay = WindRoseDisplay({'noaa_gml_brw': ds_obj}, figsize=(8, 8))
WindDisplay.plot(
    'wind_direction',
    'wind_speed',
    set_title=(
        f"NOAA GML {ds_obj.attrs['location']} Wind Rose for {timestring}"),
    spd_bins=np.linspace(0, 25, 5),
    num_dirs=20,
    tick_interval=4)

plt.show()