From 395155f0ac7717101d31d5795a704a158596fa76 Mon Sep 17 00:00:00 2001 From: davidh-ssec <david.hoese@ssec.wisc.edu> Date: Fri, 14 Jul 2017 09:14:05 -0500 Subject: [PATCH] Add checks for empty frame to quicklooks --- aosstower/tower_quicklooks/create_quicklook.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/aosstower/tower_quicklooks/create_quicklook.py b/aosstower/tower_quicklooks/create_quicklook.py index 4215631..2d9ce7f 100644 --- a/aosstower/tower_quicklooks/create_quicklook.py +++ b/aosstower/tower_quicklooks/create_quicklook.py @@ -217,19 +217,19 @@ class PlotMaker(object): :param shared_x: :return: """ + specific_frame = frame[[x for x in frame.columns if x in self.deps]] + if frame.empty or specific_frame.empty or specific_frame.isnull().all().any(): + raise ValueError("No valid data found or missing necessary data to make {}".format(self.name)) if start_time is None: start_time = frame.index[0].to_pydatetime() if end_time is None: end_time = frame.index[-1].to_pydatetime() - # TODO: If frame is empty, make an empty plot ax = self._get_axes(fig, is_subplot, shared_x) self._set_title(frame, fig, ax, start_time=start_time, end_time=end_time, title=title, is_subplot=is_subplot) - # get the min for each column then combine them assuming we can - specific_frame = frame[[x for x in frame.columns if x in self.deps]] # make ticks show up on top and bottom inside and out of the axis line ax.xaxis.set_tick_params(left=True, right=True, direction='inout') lines = self._call_plot(specific_frame, ax) @@ -427,7 +427,11 @@ def create_plot(plot_names, frame, output, plot_frame = plot_frame[~plot_frame.isnull().any(axis=1)] fig = plt.figure() - ax = plot_maker.create_plot(plot_frame, fig, start_time=start_time, end_time=end_time) + try: + ax = plot_maker.create_plot(plot_frame, fig, start_time=start_time, end_time=end_time) + except ValueError: + LOG.error("Could not make '{}'".format(name), exc_info=True) + continue out_fn = output.format(plot_name=name, start_time=start_time, end_time=end_time) LOG.info("Saving plot '{}' to filename '{}'".format(name, out_fn)) -- GitLab