Skip to content

Commit

Permalink
Add raise_on_empty option
Browse files Browse the repository at this point in the history
  • Loading branch information
tukiains committed Oct 22, 2024
1 parent fef1198 commit 20e07f7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cloudnetpy/plotting/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class PlotParameters:
instruments and model).
footer_text: The text to display in the footer of the plot.
plot_meta: Additional metadata for the plot.
raise_on_empty: Whether to raise an error if no data is found for a
plotted variable.
"""

dpi: float = 120
Expand All @@ -55,6 +57,7 @@ class PlotParameters:
show_sources: bool = False
footer_text: str | None = None
plot_meta: PlotMeta | None = None
raise_on_empty: bool = False


class Dimensions:
Expand Down Expand Up @@ -492,7 +495,7 @@ def _plot_mesh_data(self, figure_data: FigureData) -> None:
smoothed_data = uniform_filter(self._data[valid_time_ind, :], sigma_units)
self._data[valid_time_ind, :] = smoothed_data

if self._data.mask.all():
if self._data.mask.all() and figure_data.options.raise_on_empty:
msg = "All data is masked"
raise PlottingError(msg)

Expand Down Expand Up @@ -603,7 +606,7 @@ def plot_tb(self, figure_data: FigureData, freq_ind: int) -> None:
raise PlottingError(msg)
self._data = self._data[:, freq_ind]
self._data[np.isnan(self._data)] = ma.masked
if self._data.mask.all():
if self._data.mask.all() and figure_data.options.raise_on_empty:
msg = "All data is masked"
raise PlottingError(msg)
self._data_orig = self._data_orig[:, freq_ind]
Expand Down

0 comments on commit 20e07f7

Please sign in to comment.