def test_histogram_errors(): files = sample_files.EXAMPLE_MET1 obj = arm.read_netcdf(files) histdisplay = HistogramDisplay(obj) histdisplay.axes = None with np.testing.assert_raises(RuntimeError): histdisplay.set_yrng([0, 10]) with np.testing.assert_raises(RuntimeError): histdisplay.set_xrng([-40, 40]) histdisplay.fig = None histdisplay.plot_stacked_bar_graph('temp_mean', bins=np.arange(-40, 40, 5)) histdisplay.set_yrng([0, 0]) assert histdisplay.yrng[0][1] == 1. assert histdisplay.fig is not None assert histdisplay.axes is not None with np.testing.assert_raises(AttributeError): HistogramDisplay([]) histdisplay.axes = None histdisplay.fig = None histdisplay.plot_stairstep_graph('temp_mean', bins=np.arange(-40, 40, 5)) assert histdisplay.fig is not None assert histdisplay.axes is not None sigma = 10 mu = 50 bins = np.linspace(0, 100, 50) ydata = 1 / (sigma * np.sqrt(2 * np.pi)) * np.exp(-(bins - mu)**2 / (2 * sigma**2)) y_array = xr.DataArray(ydata, dims={'bins': bins}) bins = xr.DataArray(bins, dims={'bins': bins}) my_fake_ds = xr.Dataset({'bins': bins, 'ydata': y_array}) histdisplay = HistogramDisplay(my_fake_ds) histdisplay.axes = None histdisplay.fig = None histdisplay.plot_size_distribution('ydata', 'bins', set_title='Fake distribution.') assert histdisplay.fig is not None assert histdisplay.axes is not None sonde_ds = arm.read_netcdf(sample_files.EXAMPLE_SONDE1) histdisplay = HistogramDisplay({'sgpsondewnpnC1.b1': sonde_ds}) histdisplay.axes = None histdisplay.fig = None histdisplay.plot_heatmap('tdry', 'alt', x_bins=np.arange(-60, 10, 1), y_bins=np.linspace(0, 10000., 50), cmap='coolwarm') assert histdisplay.fig is not None assert histdisplay.axes is not None matplotlib.pyplot.close(fig=histdisplay.fig)
def test_stacked_bar_graph2(): sonde_ds = arm.read_netcdf( sample_files.EXAMPLE_SONDE1) histdisplay = HistogramDisplay({'sgpsondewnpnC1.b1': sonde_ds}) histdisplay.plot_stacked_bar_graph('tdry') histdisplay.set_yrng([0, 400]) histdisplay.set_xrng([-70, 0]) sonde_ds.close() return histdisplay.fig