Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Removing HistogramDisplay and updating functions to remove graph… #741

Merged
merged 5 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ omit =
act/*version*py
versioneer.py
setup.py
act/plotting/histogramdisplay.py
3 changes: 0 additions & 3 deletions act/plotting/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -31,7 +30,6 @@
'common',
'contourdisplay',
'geodisplay',
'histogramdisplay',
'plot',
'skewtdisplay',
'timeseriesdisplay',
Expand All @@ -42,7 +40,6 @@
submod_attrs={
'contourdisplay': ['ContourDisplay'],
'geodisplay': ['GeographicPlotDisplay'],
'histogramdisplay': ['HistogramDisplay'],
'plot': ['Display', 'GroupByDisplay'],
'skewtdisplay': ['SkewTDisplay'],
'timeseriesdisplay': ['TimeSeriesDisplay'],
Expand Down
4 changes: 2 additions & 2 deletions act/plotting/distributiondisplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -334,7 +334,7 @@ def plot_size_distribution(

return self.axes[subplot_index]

def plot_stairstep_graph(
def plot_stairstep(
self,
field,
dsname=None,
Expand Down
22 changes: 11 additions & 11 deletions act/tests/test_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,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
Expand All @@ -166,7 +166,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

Expand Down Expand Up @@ -487,7 +487,7 @@ def test_stair_graph():
sonde_ds = act.io.arm.read_arm_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:
Expand All @@ -501,7 +501,7 @@ def test_stair_graph_sorted():
sonde_ds = act.io.arm.read_arm_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',
Expand All @@ -520,7 +520,7 @@ def test_stacked_bar_graph():
sonde_ds = act.io.arm.read_arm_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:
Expand All @@ -534,7 +534,7 @@ def test_stacked_bar_graph2():
sonde_ds = act.io.arm.read_arm_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()
Expand All @@ -550,7 +550,7 @@ def test_stacked_bar_graph_sorted():
sonde_ds = act.io.arm.read_arm_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',
Expand Down Expand Up @@ -1264,27 +1264,27 @@ def test_histogram_kwargs():
ds = act.io.arm.read_arm_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),
hist_kwargs=hist_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),
hist_kwargs=hist_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)

Expand Down
1 change: 0 additions & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ comment: false

ignore:
- 'act/tests/*.py'
- 'act/plotting/histogramdisplay.py'
- 'act/*version*py'
- 'setup.py'
- 'versioneer.py'
Expand Down
4 changes: 2 additions & 2 deletions examples/plotting/plot_hist_kwargs.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
# Plot data
hist_kwargs = {'range': (-10, 10)}
histdisplay = act.plotting.DistributionDisplay(met_ds)
histdisplay.plot_stacked_bar_graph('temp_mean', bins=np.arange(-40, 40, 5),
hist_kwargs=hist_kwargs)
histdisplay.plot_stacked_bar('temp_mean', bins=np.arange(-40, 40, 5),
hist_kwargs=hist_kwargs)
plt.show()
6 changes: 3 additions & 3 deletions guides/act_cheatsheet.tex
Original file line number Diff line number Diff line change
Expand Up @@ -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)\\
\\
Expand Down Expand Up @@ -710,4 +710,4 @@
}

\end{poster}
\end{document}
\end{document}
2 changes: 1 addition & 1 deletion scripts/ads.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Loading