def test_qc_flag_block_plot(): obj = arm.read_netcdf(sample_files.EXAMPLE_SURFSPECALB1MLAWER) display = TimeSeriesDisplay(obj, subplot_shape=(2, ), figsize=(8, 2 * 4)) display.plot('surface_albedo_mfr_narrowband_10m', force_line_plot=True, labels=True) display.qc_flag_block_plot('surface_albedo_mfr_narrowband_10m', subplot_index=(1, )) obj.close() del obj return display.fig
def test_qc_bar_plot(): ds_object = arm.read_netcdf(sample_files.EXAMPLE_MET1) ds_object.clean.cleanup() var_name = 'temp_mean' ds_object.qcfilter.set_test(var_name, index=range(100, 600), test_number=2) display = TimeSeriesDisplay({'sgpmetE13.b1': ds_object}, subplot_shape=(2, ), figsize=(7, 4)) display.plot(var_name, subplot_index=(0, ), assessment_overplot=True) display.day_night_background('sgpmetE13.b1', subplot_index=(0, )) display.qc_flag_block_plot(var_name, subplot_index=(1, )) ds_object.close() del ds_object return display.fig
def test_qc_bar_plot(): ds_object = arm.read_netcdf(sample_files.EXAMPLE_MET1) ds_object.clean.cleanup() var_name = 'temp_mean' ds_object.qcfilter.set_test(var_name, index=range(100, 600), test_number=2) # Testing out when the assessment is not listed ds_object.qcfilter.set_test(var_name, index=range(500, 800), test_number=4) ds_object['qc_' + var_name].attrs['flag_assessments'][3] = 'Wonky' display = TimeSeriesDisplay({'sgpmetE13.b1': ds_object}, subplot_shape=(2, ), figsize=(7, 4)) display.plot(var_name, subplot_index=(0, ), assessment_overplot=True) display.day_night_background('sgpmetE13.b1', subplot_index=(0, )) display.qc_flag_block_plot(var_name, subplot_index=(1, )) ds_object.close() return display.fig
def test_qc_bar_plot(): ds_object = arm.read_netcdf(sample_files.EXAMPLE_MET1) ds_object.clean.cleanup() var_name = 'temp_mean' ds_object.qcfilter.set_test(var_name, index=range(100, 600), test_number=2) # Testing out when the assessment is not listed ds_object.qcfilter.set_test(var_name, index=range(500, 800), test_number=4) ds_object['qc_' + var_name].attrs['flag_assessments'][3] = 'Wonky' display = TimeSeriesDisplay({'sgpmetE13.b1': ds_object}, subplot_shape=(2, ), figsize=(7, 4)) display.plot(var_name, subplot_index=(0, ), assessment_overplot=True) display.day_night_background('sgpmetE13.b1', subplot_index=(0, )) color_lookup = {'Bad': 'red', 'Incorrect': 'red', 'Indeterminate': 'orange', 'Suspect': 'orange', 'Missing': 'darkgray', 'Not Failing': 'green', 'Acceptable': 'green'} display.qc_flag_block_plot(var_name, subplot_index=(1, ), assessment_color=color_lookup) ds_object.close() return display.fig
def test_errors(): files = sample_files.EXAMPLE_MET_WILDCARD obj = arm.read_netcdf(files) display = TimeSeriesDisplay(obj) display.axes = None with np.testing.assert_raises(RuntimeError): display.day_night_background() display = TimeSeriesDisplay({'met': obj, 'met2': obj}) with np.testing.assert_raises(ValueError): display.plot('temp_mean') with np.testing.assert_raises(ValueError): display.qc_flag_block_plot('qc_temp_mean') with np.testing.assert_raises(ValueError): display.plot_barbs_from_spd_dir('wdir_vec_mean', 'wspd_vec_mean') with np.testing.assert_raises(ValueError): display.plot_barbs_from_u_v('wdir_vec_mean', 'wspd_vec_mean') del obj.attrs['_file_dates'] data = np.empty(len(obj['time'])) * np.nan lat = obj['lat'].values lon = obj['lon'].values obj['lat'].values = data obj['lon'].values = data display = TimeSeriesDisplay(obj) display.plot('temp_mean') display.set_yrng([0, 0]) with np.testing.assert_warns(RuntimeWarning): display.day_night_background() obj['lat'].values = lat with np.testing.assert_warns(RuntimeWarning): display.day_night_background() obj['lon'].values = lon * 100. with np.testing.assert_warns(RuntimeWarning): display.day_night_background() obj['lat'].values = lat * 100. with np.testing.assert_warns(RuntimeWarning): display.day_night_background() obj.close() # Test some of the other errors obj = arm.read_netcdf(files) del obj['temp_mean'].attrs['units'] display = TimeSeriesDisplay(obj) display.axes = None with np.testing.assert_raises(RuntimeError): display.set_yrng([0, 10]) with np.testing.assert_raises(RuntimeError): display.set_xrng([0, 10]) display.fig = None display.plot('temp_mean', add_nan=True) assert display.fig is not None assert display.axes is not None with np.testing.assert_raises(AttributeError): display = TimeSeriesDisplay([]) fig, ax = matplotlib.pyplot.subplots() display = TimeSeriesDisplay(obj) display.add_subplots((2, 2), figsize=(15, 10)) display.assign_to_figure_axis(fig, ax) assert display.fig is not None assert display.axes is not None obj = arm.read_netcdf(files) display = TimeSeriesDisplay(obj) obj.clean.cleanup() display.axes = None display.fig = None display.qc_flag_block_plot('atmos_pressure') assert display.fig is not None assert display.axes is not None matplotlib.pyplot.close(fig=display.fig)
from act.io.armfiles import read_netcdf from act.plotting import TimeSeriesDisplay from act.tests import EXAMPLE_SURFSPECALB1MLAWER # Read a data file that has a 2D DataArray of multiple 1D data. # The corresponding quality control DataArray is also read in and # will be used to make a summary plot of quality control infomation # of each assessment category. obj = read_netcdf(EXAMPLE_SURFSPECALB1MLAWER) # The name of the data variable we wish to plot var_name = 'surface_albedo_mfr_narrowband_10m' # Create the ACT display object used for plotting. This will have two # vertical plots of 800 by 400 pixels. display = TimeSeriesDisplay(obj, subplot_shape=(2, ), figsize=(8, 2 * 4)) # Create the top plot of data using the force_line_plot option. # This will force the plotting to not assume the data are 2D data that # would normally be plotted as a 2D plot. Rather for each index into the # filter dimention plot a 1D time series plot. Setting labels=True # will create a legend using the filter dimention DataArray. display.plot(var_name, force_line_plot=True, labels=True) # Create the bottom plot of summarized quality control by assessment # cateory. display.qc_flag_block_plot(var_name, subplot_index=(1, )) # Show the plot in a new window. plt.show()