From 0ae17ef8cb409b397f61547bf975ba48ed838c82 Mon Sep 17 00:00:00 2001 From: AdamTheisen Date: Fri, 13 Oct 2023 15:29:20 -0500 Subject: [PATCH 1/4] ENH: Removing HistogramDisplay and updating functions to remove graph from the name --- .coveragerc | 1 - act/plotting/__init__.py | 3 - act/plotting/distributiondisplay.py | 4 +- act/plotting/histogramdisplay.py | 606 -------------------------- act/tests/test_plotting.py | 22 +- codecov.yml | 1 - examples/plotting/plot_hist_kwargs.py | 6 +- guides/act_cheatsheet.tex | 6 +- scripts/ads.py | 2 +- 9 files changed, 20 insertions(+), 631 deletions(-) delete mode 100644 act/plotting/histogramdisplay.py diff --git a/.coveragerc b/.coveragerc index fb5ff5e650..c37e75b8c5 100644 --- a/.coveragerc +++ b/.coveragerc @@ -4,7 +4,6 @@ omit = act/*version*py versioneer.py setup.py - act/plotting/histogramdisplay.py act/discovery/get_arm.py act/discovery/arm.py act/discovery/airnow.py diff --git a/act/plotting/__init__.py b/act/plotting/__init__.py index 4830bd667a..68547a9a3c 100644 --- a/act/plotting/__init__.py +++ b/act/plotting/__init__.py @@ -7,7 +7,6 @@ | :func:`act.plotting.ContourDisplay` handles the plotting of contour plots. | :func:`act.plotting.DistributionDisplay` handles the plotting of distribution-related plots. | :func:`act.plotting.GeographicPlotDisplay` handles the plotting of lat-lon plots. -| :func:`act.plotting.HistogramDisplay` handles the plotting of histogram plots. | :func:`act.plotting.SkewTDisplay` handles the plotting of Skew-T diagrams. | :func:`act.plotting.TimeSeriesDisplay` handles the plotting of timeseries. | :func:`act.plotting.WindRoseDisplay` handles the plotting of wind rose plots. @@ -31,7 +30,6 @@ 'common', 'contourdisplay', 'geodisplay', - 'histogramdisplay', 'plot', 'skewtdisplay', 'timeseriesdisplay', @@ -42,7 +40,6 @@ submod_attrs={ 'contourdisplay': ['ContourDisplay'], 'geodisplay': ['GeographicPlotDisplay'], - 'histogramdisplay': ['HistogramDisplay'], 'plot': ['Display', 'GroupByDisplay'], 'skewtdisplay': ['SkewTDisplay'], 'timeseriesdisplay': ['TimeSeriesDisplay'], diff --git a/act/plotting/distributiondisplay.py b/act/plotting/distributiondisplay.py index 92baa94ff4..64e3598e85 100644 --- a/act/plotting/distributiondisplay.py +++ b/act/plotting/distributiondisplay.py @@ -89,7 +89,7 @@ def _get_data(self, dsname, fields): fields = [fields] return self._ds[dsname][fields].dropna('time') - def plot_stacked_bar_graph( + def plot_stacked_bar( self, field, dsname=None, @@ -334,7 +334,7 @@ def plot_size_distribution( return self.axes[subplot_index] - def plot_stairstep_graph( + def plot_stairstep( self, field, dsname=None, diff --git a/act/plotting/histogramdisplay.py b/act/plotting/histogramdisplay.py deleted file mode 100644 index 0e87083a0b..0000000000 --- a/act/plotting/histogramdisplay.py +++ /dev/null @@ -1,606 +0,0 @@ -""" Module for Histogram Plotting. """ - -import matplotlib.pyplot as plt -import numpy as np -import xarray as xr -import warnings - -from ..utils import datetime_utils as dt_utils -from .plot import Display - - -class HistogramDisplay(Display): - """ - This class is used to make histogram plots. It is inherited from Display - and therefore contains all of Display's attributes and methods. - - Examples - -------- - To create a TimeSeriesDisplay with 3 rows, simply do: - - .. code-block:: python - - ds = act.read_netcdf(the_file) - disp = act.plotting.HistogramDisplay(ds, subplot_shape=(3,), figsize=(15, 5)) - - The HistogramDisplay constructor takes in the same keyword arguments as - plt.subplots. For more information on the plt.subplots keyword arguments, - see the `matplotlib documentation - `_. - If no subplot_shape is provided, then no figure or axis will be created - until add_subplots or plots is called. - - """ - - def __init__(self, ds, subplot_shape=(1,), ds_name=None, **kwargs): - super().__init__(ds, subplot_shape, ds_name, **kwargs) - - message = 'HistogramDisplay will be retired in version 2.0.0. Please use DistributionDisplay instead.' - warnings.warn(message, DeprecationWarning, 2) - - def set_xrng(self, xrng, subplot_index=(0,)): - """ - Sets the x range of the plot. - - Parameters - ---------- - xrng : 2 number array - The x limits of the plot. - subplot_index : 1 or 2D tuple, list, or array - The index of the subplot to set the x range of. - - """ - if self.axes is None: - raise RuntimeError('set_xrng requires the plot to be displayed.') - - if not hasattr(self, 'xrng') and len(self.axes.shape) == 2: - self.xrng = np.zeros((self.axes.shape[0], self.axes.shape[1], 2), dtype='datetime64[D]') - elif not hasattr(self, 'xrng') and len(self.axes.shape) == 1: - self.xrng = np.zeros((self.axes.shape[0], 2), dtype='datetime64[D]') - - self.axes[subplot_index].set_xlim(xrng) - self.xrng[subplot_index, :] = np.array(xrng) - - def set_yrng(self, yrng, subplot_index=(0,)): - """ - Sets the y range of the plot. - - Parameters - ---------- - yrng : 2 number array - The y limits of the plot. - subplot_index : 1 or 2D tuple, list, or array - The index of the subplot to set the x range of. - - """ - if self.axes is None: - raise RuntimeError('set_yrng requires the plot to be displayed.') - - if not hasattr(self, 'yrng') and len(self.axes.shape) == 2: - self.yrng = np.zeros((self.axes.shape[0], self.axes.shape[1], 2)) - elif not hasattr(self, 'yrng') and len(self.axes.shape) == 1: - self.yrng = np.zeros((self.axes.shape[0], 2)) - - if yrng[0] == yrng[1]: - yrng[1] = yrng[1] + 1 - - self.axes[subplot_index].set_ylim(yrng) - self.yrng[subplot_index, :] = yrng - - def _get_data(self, dsname, fields): - if isinstance(fields, str): - fields = [fields] - return self._ds[dsname][fields].dropna('time') - - def plot_stacked_bar_graph( - self, - field, - dsname=None, - bins=10, - sortby_field=None, - sortby_bins=None, - subplot_index=(0,), - set_title=None, - density=False, - hist_kwargs=dict(), - **kwargs, - ): - """ - This procedure will plot a stacked bar graph of a histogram. - - Parameters - ---------- - field : str - The name of the field to take the histogram of. - dsname : str or None - The name of the datastream the field is contained in. Set - to None to let ACT automatically determine this. - bins : array-like or int - The histogram bin boundaries to use. If not specified, numpy's - default 10 is used. - sortby_field : str or None - Set this option to a field name in order to sort the histograms - by a given field parameter. For example, one can sort histograms of CO2 - concentration by temperature. - sortby_bins : array-like or None - The bins to sort the histograms by. - subplot_index : tuple - The subplot index to place the plot in - set_title : str - The title of the plot. - density : bool - Set to True to plot a p.d.f. instead of a frequency histogram. - hist_kwargs : dict - Additional keyword arguments to pass to numpy histogram. - - Other keyword arguments will be passed into :func:`matplotlib.pyplot.bar`. - - Returns - ------- - return_dict : dict - A dictionary containing the plot axis handle, bin boundaries, and - generated histogram. - - """ - if dsname is None and len(self._ds.keys()) > 1: - raise ValueError( - 'You must choose a datastream when there are 2 ' - + 'or more datasets in the TimeSeriesDisplay ' - + 'object.' - ) - elif dsname is None: - dsname = list(self._ds.keys())[0] - - if sortby_field is not None: - ds = self._get_data(dsname, [field, sortby_field]) - xdata, ydata = ds[field], ds[sortby_field] - else: - xdata = self._get_data(dsname, field)[field] - - if 'units' in xdata.attrs: - xtitle = ''.join(['(', xdata.attrs['units'], ')']) - else: - xtitle = field - - if sortby_bins is None and sortby_field is not None: - # We will defaut the y direction to have the same # of bins as x - sortby_bins = np.linspace(ydata.values.min(), ydata.values.max(), len(bins)) - - # Get the current plotting axis, add day/night background and plot data - if self.fig is None: - self.fig = plt.figure() - - if self.axes is None: - self.axes = np.array([plt.axes()]) - self.fig.add_axes(self.axes[0]) - - if sortby_field is not None: - if 'units' in ydata.attrs: - ytitle = ''.join(['(', ydata.attrs['units'], ')']) - else: - ytitle = field - if sortby_bins is None: - my_hist, x_bins, y_bins = np.histogram2d( - xdata.values.flatten(), ydata.values.flatten(), density=density, - bins=bins, - **hist_kwargs) - else: - my_hist, x_bins, y_bins = np.histogram2d( - xdata.values.flatten(), - ydata.values.flatten(), - density=density, - bins=[bins, sortby_bins], - **hist_kwargs) - x_inds = (x_bins[:-1] + x_bins[1:]) / 2.0 - self.axes[subplot_index].bar( - x_inds, - my_hist[:, 0].flatten(), - label=(str(y_bins[0]) + ' to ' + str(y_bins[1])), - **kwargs, - ) - for i in range(1, len(y_bins) - 1): - self.axes[subplot_index].bar( - x_inds, - my_hist[:, i].flatten(), - bottom=my_hist[:, i - 1], - label=(str(y_bins[i]) + ' to ' + str(y_bins[i + 1])), - **kwargs, - ) - self.axes[subplot_index].legend() - else: - my_hist, bins = np.histogram(xdata.values.flatten(), bins=bins, - density=density, **hist_kwargs) - x_inds = (bins[:-1] + bins[1:]) / 2.0 - self.axes[subplot_index].bar(x_inds, my_hist) - - # Set Title - if set_title is None: - set_title = ' '.join( - [ - dsname, - field, - 'on', - dt_utils.numpy_to_arm_date(self._ds[dsname].time.values[0]), - ] - ) - self.axes[subplot_index].set_title(set_title) - self.axes[subplot_index].set_ylabel('count') - self.axes[subplot_index].set_xlabel(xtitle) - - return_dict = {} - return_dict['plot_handle'] = self.axes[subplot_index] - if 'x_bins' in locals(): - return_dict['x_bins'] = x_bins - return_dict['y_bins'] = y_bins - else: - return_dict['bins'] = bins - return_dict['histogram'] = my_hist - - return return_dict - - def plot_size_distribution( - self, field, bins, time=None, dsname=None, subplot_index=(0,), set_title=None, **kwargs - ): - """ - This procedure plots a stairstep plot of a size distribution. This is - useful for plotting size distributions and waveforms. - - Parameters - ---------- - field : str - The name of the field to plot the spectrum from. - bins : str or array-like - The name of the field that stores the bins for the spectra. - time : none or datetime - If None, spectra to plot will be automatically determined. - Otherwise, specify this field for the time period to plot. - dsname : str - The name of the Dataset to plot. Set to None to have - ACT automatically determine this. - subplot_index : tuple - The subplot index to place the plot in. - set_title : str or None - Use this to set the title. - - Additional keyword arguments will be passed into :func:`matplotlib.pyplot.step` - - Returns - ------- - ax : matplotlib axis handle - The matplotlib axis handle referring to the plot. - - """ - if dsname is None and len(self._ds.keys()) > 1: - raise ValueError( - 'You must choose a datastream when there are 2 ' - + 'or more datasets in the TimeSeriesDisplay ' - + 'object.' - ) - elif dsname is None: - dsname = list(self._ds.keys())[0] - - xdata = self._get_data(dsname, field)[field] - - if isinstance(bins, str): - bins = self._ds[dsname][bins] - else: - bins = xr.DataArray(bins) - - if 'units' in bins.attrs: - xtitle = ''.join(['(', bins.attrs['units'], ')']) - else: - xtitle = 'Bin #' - - if 'units' in xdata.attrs: - ytitle = ''.join(['(', xdata.attrs['units'], ')']) - else: - ytitle = field - - if len(xdata.dims) > 1 and time is None: - raise ValueError( - 'Input data has more than one dimension, ' + 'you must specify a time to plot!' - ) - elif len(xdata.dims) > 1: - xdata = xdata.sel(time=time, method='nearest') - - if len(bins.dims) > 1 or len(bins.values) != len(xdata.values): - raise ValueError( - 'Bins must be a one dimensional field whose ' - + 'length is equal to the field length!' - ) - - # Get the current plotting axis, add day/night background and plot data - if self.fig is None: - self.fig = plt.figure() - - if self.axes is None: - self.axes = np.array([plt.axes()]) - self.fig.add_axes(self.axes[0]) - - # Set Title - if set_title is None: - set_title = ' '.join( - [ - dsname, - field, - 'on', - dt_utils.numpy_to_arm_date(self._ds[dsname].time.values[0]), - ] - ) - - self.axes[subplot_index].set_title(set_title) - self.axes[subplot_index].step(bins.values, xdata.values, **kwargs) - self.axes[subplot_index].set_xlabel(xtitle) - self.axes[subplot_index].set_ylabel(ytitle) - - return self.axes[subplot_index] - - def plot_stairstep_graph( - self, - field, - dsname=None, - bins=10, - sortby_field=None, - sortby_bins=None, - subplot_index=(0,), - set_title=None, - density=False, - hist_kwargs=dict(), - **kwargs, - ): - """ - This procedure will plot a stairstep plot of a histogram. - - Parameters - ---------- - field : str - The name of the field to take the histogram of. - dsname : str or None - The name of the datastream the field is contained in. Set - to None to let ACT automatically determine this. - bins : array-like or int - The histogram bin boundaries to use. If not specified, numpy's - default 10 is used. - sortby_field : str or None - Set this option to a field name in order to sort the histograms - by a given field parameter. For example, one can sort histograms of CO2 - concentration by temperature. - sortby_bins : array-like or None - The bins to sort the histograms by. - subplot_index : tuple - The subplot index to place the plot in. - set_title : str - The title of the plot. - density : bool - Set to True to plot a p.d.f. instead of a frequency histogram. - hist_kwargs : dict - Additional keyword arguments to pass to numpy histogram. - - Other keyword arguments will be passed into :func:`matplotlib.pyplot.step`. - - Returns - ------- - return_dict : dict - A dictionary containing the plot axis handle, bin boundaries, and - generated histogram. - - """ - if dsname is None and len(self._ds.keys()) > 1: - raise ValueError( - 'You must choose a datastream when there are 2 ' - + 'or more datasets in the TimeSeriesDisplay ' - + 'object.' - ) - elif dsname is None: - dsname = list(self._ds.keys())[0] - - xdata = self._get_data(dsname, field)[field] - - if 'units' in xdata.attrs: - xtitle = ''.join(['(', xdata.attrs['units'], ')']) - else: - xtitle = field - - if sortby_field is not None: - ydata = self._ds[dsname][sortby_field] - - if sortby_bins is None and sortby_field is not None: - # We will defaut the y direction to have the same # of bins as x - sortby_bins = np.linspace(ydata.values.min(), ydata.values.max(), len(bins)) - - # Get the current plotting axis, add day/night background and plot data - if self.fig is None: - self.fig = plt.figure() - - if self.axes is None: - self.axes = np.array([plt.axes()]) - self.fig.add_axes(self.axes[0]) - - if sortby_field is not None: - if 'units' in ydata.attrs: - ytitle = ''.join(['(', ydata.attrs['units'], ')']) - else: - ytitle = field - if sortby_bins is None: - my_hist, x_bins, y_bins = np.histogram2d( - xdata.values.flatten(), ydata.values.flatten(), bins=bins, - density=density, **hist_kwargs) - else: - my_hist, x_bins, y_bins = np.histogram2d( - xdata.values.flatten(), - ydata.values.flatten(), - density=density, - bins=[bins, sortby_bins], - **hist_kwargs - ) - x_inds = (x_bins[:-1] + x_bins[1:]) / 2.0 - self.axes[subplot_index].step( - x_inds, - my_hist[:, 0].flatten(), - label=(str(y_bins[0]) + ' to ' + str(y_bins[1])), - **kwargs, - ) - for i in range(1, len(y_bins) - 1): - self.axes[subplot_index].step( - x_inds, - my_hist[:, i].flatten(), - label=(str(y_bins[i]) + ' to ' + str(y_bins[i + 1])), - **kwargs, - ) - self.axes[subplot_index].legend() - else: - my_hist, bins = np.histogram(xdata.values.flatten(), bins=bins, - density=density, **hist_kwargs) - - x_inds = (bins[:-1] + bins[1:]) / 2.0 - self.axes[subplot_index].step(x_inds, my_hist, **kwargs) - - # Set Title - if set_title is None: - set_title = ' '.join( - [ - dsname, - field, - 'on', - dt_utils.numpy_to_arm_date(self._ds[dsname].time.values[0]), - ] - ) - self.axes[subplot_index].set_title(set_title) - self.axes[subplot_index].set_ylabel('count') - self.axes[subplot_index].set_xlabel(xtitle) - - return_dict = {} - return_dict['plot_handle'] = self.axes[subplot_index] - if 'x_bins' in locals(): - return_dict['x_bins'] = x_bins - return_dict['y_bins'] = y_bins - else: - return_dict['bins'] = bins - return_dict['histogram'] = my_hist - - return return_dict - - def plot_heatmap( - self, - x_field, - y_field, - dsname=None, - x_bins=None, - y_bins=None, - subplot_index=(0,), - set_title=None, - density=False, - set_shading='auto', - hist_kwargs=dict(), - **kwargs, - ): - """ - This procedure will plot a heatmap of a histogram from 2 variables. - - Parameters - ---------- - x_field : str - The name of the field to take the histogram of on the X axis. - y_field : str - The name of the field to take the histogram of on the Y axis. - dsname : str or None - The name of the datastream the field is contained in. Set - to None to let ACT automatically determine this. - x_bins : array-like or None - The histogram bin boundaries to use for the variable on the X axis. - Set to None to use numpy's default boundaries. - y_bins : array-like or None - The histogram bin boundaries to use for the variable on the Y axis. - Set to None to use numpy's default boundaries. - subplot_index : tuple - The subplot index to place the plot in - set_title : str - The title of the plot. - density : bool - Set to True to plot a p.d.f. instead of a frequency histogram. - set_shading : string - Option to to set the matplotlib.pcolormesh shading parameter. - Default to 'auto' - hist_kwargs : Additional keyword arguments to pass to numpy histogram. - - Other keyword arguments will be passed into :func:`matplotlib.pyplot.pcolormesh`. - - Returns - ------- - return_dict : dict - A dictionary containing the plot axis handle, bin boundaries, and - generated histogram. - - """ - if dsname is None and len(self._ds.keys()) > 1: - raise ValueError( - 'You must choose a datastream when there are 2 ' - 'or more datasets in the TimeSeriesDisplay ' - 'object.' - ) - elif dsname is None: - dsname = list(self._ds.keys())[0] - - ds = self._get_data(dsname, [x_field, y_field]) - xdata, ydata = ds[x_field], ds[y_field] - - if 'units' in xdata.attrs: - xtitle = ''.join(['(', xdata.attrs['units'], ')']) - else: - xtitle = x_field - - if x_bins is not None and y_bins is None: - # We will defaut the y direction to have the same # of bins as x - y_bins = np.linspace(ydata.values.min(), ydata.values.max(), len(x_bins)) - - # Get the current plotting axis, add day/night background and plot data - if self.fig is None: - self.fig = plt.figure() - - if self.axes is None: - self.axes = np.array([plt.axes()]) - self.fig.add_axes(self.axes[0]) - - if 'units' in ydata.attrs: - ytitle = ''.join(['(', ydata.attrs['units'], ')']) - else: - ytitle = y_field - - if x_bins is None: - my_hist, x_bins, y_bins = np.histogram2d( - xdata.values.flatten(), ydata.values.flatten(), density=density, - **hist_kwargs) - else: - my_hist, x_bins, y_bins = np.histogram2d( - xdata.values.flatten(), - ydata.values.flatten(), - density=density, - bins=[x_bins, y_bins], - **hist_kwargs - ) - x_inds = (x_bins[:-1] + x_bins[1:]) / 2.0 - y_inds = (y_bins[:-1] + y_bins[1:]) / 2.0 - xi, yi = np.meshgrid(x_inds, y_inds, indexing='ij') - mesh = self.axes[subplot_index].pcolormesh(xi, yi, my_hist, shading=set_shading, **kwargs) - - # Set Title - if set_title is None: - set_title = ' '.join( - [ - dsname, - 'on', - dt_utils.numpy_to_arm_date(self._ds[dsname].time.values[0]), - ] - ) - self.axes[subplot_index].set_title(set_title) - self.axes[subplot_index].set_ylabel(ytitle) - self.axes[subplot_index].set_xlabel(xtitle) - self.add_colorbar(mesh, title='count', subplot_index=subplot_index) - - return_dict = {} - return_dict['plot_handle'] = self.axes[subplot_index] - return_dict['x_bins'] = x_bins - return_dict['y_bins'] = y_bins - return_dict['histogram'] = my_hist - - return return_dict diff --git a/act/tests/test_plotting.py b/act/tests/test_plotting.py index b549594137..c23da627fe 100644 --- a/act/tests/test_plotting.py +++ b/act/tests/test_plotting.py @@ -156,7 +156,7 @@ def test_histogram_errors(): 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.plot_stacked_bar('temp_mean', bins=np.arange(-40, 40, 5)) histdisplay.set_yrng([0, 0]) assert histdisplay.yrng[0][1] == 1.0 assert histdisplay.fig is not None @@ -167,7 +167,7 @@ def test_histogram_errors(): histdisplay.axes = None histdisplay.fig = None - histdisplay.plot_stairstep_graph('temp_mean', bins=np.arange(-40, 40, 5)) + histdisplay.plot_stairstep('temp_mean', bins=np.arange(-40, 40, 5)) assert histdisplay.fig is not None assert histdisplay.axes is not None @@ -476,7 +476,7 @@ def test_stair_graph(): sonde_ds = arm.read_netcdf(sample_files.EXAMPLE_SONDE1) histdisplay = DistributionDisplay({'sgpsondewnpnC1.b1': sonde_ds}) - histdisplay.plot_stairstep_graph('tdry', bins=np.arange(-60, 10, 1)) + histdisplay.plot_stairstep('tdry', bins=np.arange(-60, 10, 1)) sonde_ds.close() try: @@ -490,7 +490,7 @@ def test_stair_graph_sorted(): sonde_ds = arm.read_netcdf(sample_files.EXAMPLE_SONDE1) histdisplay = DistributionDisplay({'sgpsondewnpnC1.b1': sonde_ds}) - histdisplay.plot_stairstep_graph( + histdisplay.plot_stairstep( 'tdry', bins=np.arange(-60, 10, 1), sortby_field='alt', @@ -509,7 +509,7 @@ def test_stacked_bar_graph(): sonde_ds = arm.read_netcdf(sample_files.EXAMPLE_SONDE1) histdisplay = DistributionDisplay({'sgpsondewnpnC1.b1': sonde_ds}) - histdisplay.plot_stacked_bar_graph('tdry', bins=np.arange(-60, 10, 1)) + histdisplay.plot_stacked_bar('tdry', bins=np.arange(-60, 10, 1)) sonde_ds.close() try: @@ -523,7 +523,7 @@ def test_stacked_bar_graph2(): sonde_ds = arm.read_netcdf(sample_files.EXAMPLE_SONDE1) histdisplay = DistributionDisplay({'sgpsondewnpnC1.b1': sonde_ds}) - histdisplay.plot_stacked_bar_graph('tdry') + histdisplay.plot_stacked_bar('tdry') histdisplay.set_yrng([0, 400]) histdisplay.set_xrng([-70, 0]) sonde_ds.close() @@ -539,7 +539,7 @@ def test_stacked_bar_graph_sorted(): sonde_ds = arm.read_netcdf(sample_files.EXAMPLE_SONDE1) histdisplay = DistributionDisplay({'sgpsondewnpnC1.b1': sonde_ds}) - histdisplay.plot_stacked_bar_graph( + histdisplay.plot_stacked_bar( 'tdry', bins=np.arange(-60, 10, 1), sortby_field='alt', @@ -1253,7 +1253,7 @@ def test_histogram_kwargs(): ds = arm.read_netcdf(files) hist_kwargs = {'range': (-10, 10)} histdisplay = DistributionDisplay(ds) - hist_dict = histdisplay.plot_stacked_bar_graph( + hist_dict = histdisplay.plot_stacked_bar( 'temp_mean', bins=np.arange(-40, 40, 5), sortby_bins=np.arange(-40, 40, 5), @@ -1261,11 +1261,11 @@ def test_histogram_kwargs(): ) hist_array = np.array([0, 0, 0, 0, 0, 0, 493, 883, 64, 0, 0, 0, 0, 0, 0]) assert_allclose(hist_dict['histogram'], hist_array) - hist_dict = histdisplay.plot_stacked_bar_graph('temp_mean', hist_kwargs=hist_kwargs) + hist_dict = histdisplay.plot_stacked_bar('temp_mean', hist_kwargs=hist_kwargs) hist_array = np.array([0, 0, 950, 177, 249, 64, 0, 0, 0, 0]) assert_allclose(hist_dict['histogram'], hist_array) - hist_dict_stair = histdisplay.plot_stairstep_graph( + hist_dict_stair = histdisplay.plot_stairstep( 'temp_mean', bins=np.arange(-40, 40, 5), sortby_bins=np.arange(-40, 40, 5), @@ -1273,7 +1273,7 @@ def test_histogram_kwargs(): ) hist_array = np.array([0, 0, 0, 0, 0, 0, 493, 883, 64, 0, 0, 0, 0, 0, 0]) assert_allclose(hist_dict_stair['histogram'], hist_array) - hist_dict_stair = histdisplay.plot_stairstep_graph('temp_mean', hist_kwargs=hist_kwargs) + hist_dict_stair = histdisplay.plot_stairstep('temp_mean', hist_kwargs=hist_kwargs) hist_array = np.array([0, 0, 950, 177, 249, 64, 0, 0, 0, 0]) assert_allclose(hist_dict_stair['histogram'], hist_array) diff --git a/codecov.yml b/codecov.yml index edde4fd145..67479cb40b 100644 --- a/codecov.yml +++ b/codecov.yml @@ -6,7 +6,6 @@ comment: false ignore: - 'act/tests/*.py' - - 'act/plotting/histogramdisplay.py' - 'act/discovery/get_arm.py' - 'act/discovery/arm.py' - 'act/discovery/airnow.py' diff --git a/examples/plotting/plot_hist_kwargs.py b/examples/plotting/plot_hist_kwargs.py index 481198076a..33e5fb4e13 100644 --- a/examples/plotting/plot_hist_kwargs.py +++ b/examples/plotting/plot_hist_kwargs.py @@ -18,7 +18,7 @@ # Plot data hist_kwargs = {'range': (-10, 10)} -histdisplay = act.plotting.HistogramDisplay(met_ds) -histdisplay.plot_stacked_bar_graph('temp_mean', bins=np.arange(-40, 40, 5), - hist_kwargs=hist_kwargs) +histdisplay = act.plotting.DistributionDisplay(met_ds) +histdisplay.plot_stacked_bar('temp_mean', bins=np.arange(-40, 40, 5), + hist_kwargs=hist_kwargs) plt.show() diff --git a/guides/act_cheatsheet.tex b/guides/act_cheatsheet.tex index 0e8dd77328..819bc7a6bd 100644 --- a/guides/act_cheatsheet.tex +++ b/guides/act_cheatsheet.tex @@ -559,11 +559,11 @@ \begin{tabular}{@{}ll@{}} \\ -\multicolumn{2}{l}{\cellcolor[HTML]{DDFFFF}\bf HistogramDisplay} \\ +\multicolumn{2}{l}{\cellcolor[HTML]{DDFFFF}\bf DistributionDisplay} \\ \\ Class used to make histogram plots.\\ \\ -$>$$>$$>$ display = act.plotting.HistogramDisplay(\\ +$>$$>$$>$ display = act.plotting.DistributionDisplay(\\ \-\hspace{1.2cm} obj, subplot\_shape=(1, ), ds\_name=None,\\ \-\hspace{1.2cm} **kwargs)\\ \\ @@ -710,4 +710,4 @@ } \end{poster} -\end{document} \ No newline at end of file +\end{document} diff --git a/scripts/ads.py b/scripts/ads.py index af7ec02ffb..d5a5327dda 100644 --- a/scripts/ads.py +++ b/scripts/ads.py @@ -432,7 +432,7 @@ def histogram(args): except KeyError: pass - display = act.plotting.HistogramDisplay( + display = act.plotting.DistributionDisplay( {dsname: ds}, figsize=args.figsize, subplot_shape=subplot_shape) From 928ce2d780c77bbcec784099743d78e894dbb9c8 Mon Sep 17 00:00:00 2001 From: zssherman Date: Wed, 29 Nov 2023 21:02:51 -0600 Subject: [PATCH 2/4] FIX: Conflict fixes. --- .coveragerc | 9 +-------- codecov.yml | 9 +-------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/.coveragerc b/.coveragerc index c37e75b8c5..c716e80acc 100644 --- a/.coveragerc +++ b/.coveragerc @@ -4,11 +4,4 @@ omit = act/*version*py versioneer.py setup.py - act/discovery/get_arm.py - act/discovery/arm.py - act/discovery/airnow.py - act/discovery/asos.py - act/discovery/cropscape.py - act/discovery/neon.py - act/discovery/noaapsl.py - act/discovery/surfrad.py + diff --git a/codecov.yml b/codecov.yml index 67479cb40b..f3faf7ae96 100644 --- a/codecov.yml +++ b/codecov.yml @@ -6,14 +6,6 @@ comment: false ignore: - 'act/tests/*.py' - - 'act/discovery/get_arm.py' - - 'act/discovery/arm.py' - - 'act/discovery/airnow.py' - - 'act/discovery/asos.py' - - 'act/discovery/cropscape.py' - - 'act/discovery/neon.py' - - 'act/discovery/noaapsl.py' - - 'act/discovery/surfrad.py' - 'act/*version*py' - 'setup.py' - 'versioneer.py' @@ -29,3 +21,4 @@ coverage: informational: true patch: off changes: off + From e55ccced06d2d0e5e6eaf456328fc284bcd91681 Mon Sep 17 00:00:00 2001 From: zssherman Date: Wed, 29 Nov 2023 21:06:20 -0600 Subject: [PATCH 3/4] STY: Remove blank line. --- .coveragerc | 2 +- codecov.yml | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.coveragerc b/.coveragerc index 32bf3b31db..dcea0b50ea 100644 --- a/.coveragerc +++ b/.coveragerc @@ -3,4 +3,4 @@ omit = act/tests/* act/*version*py versioneer.py - setup.py + setup.py \ No newline at end of file diff --git a/codecov.yml b/codecov.yml index f3faf7ae96..bcb8280c4e 100644 --- a/codecov.yml +++ b/codecov.yml @@ -21,4 +21,3 @@ coverage: informational: true patch: off changes: off - From 51dd18bfec73bea866a858670f655807d63cbeae Mon Sep 17 00:00:00 2001 From: zssherman Date: Wed, 29 Nov 2023 21:07:14 -0600 Subject: [PATCH 4/4] STY: Remove nonewline. --- .coveragerc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.coveragerc b/.coveragerc index dcea0b50ea..32bf3b31db 100644 --- a/.coveragerc +++ b/.coveragerc @@ -3,4 +3,4 @@ omit = act/tests/* act/*version*py versioneer.py - setup.py \ No newline at end of file + setup.py