Skip to content
Snippets Groups Projects
Commit fd7d8ceb authored by Eva Schiffer's avatar Eva Schiffer
Browse files

warn the user if they ask for a scatter or hex plot and have too much data for that to be practical

parent 310e43ea
No related branches found
No related tags found
No related merge requests found
......@@ -224,6 +224,15 @@ def _plot_tag_data_mapped(plotting_axes, input_c_projection, tagData, x, y, addE
return numMismatchPoints
def check_data_amount_for_scatter_plot (num_data_points,) :
"""
Is the given amount too much data for a scatter plot?
return True if this is an ok amount and False if we won't make a scatter plot with this much data
"""
return True if num_data_points < MAX_SCATTER_PLOT_DATA else False
# build a scatter plot of the x,y points
def create_scatter_plot(dataX, dataY, title_str, xLabel, yLabel, badMask=None, epsilon=None, units_x=None, units_y=None) :
"""
......@@ -247,6 +256,7 @@ def create_scatter_plot(dataX, dataY, title_str, xLabel, yLabel, badMask=None, e
units_x=units_x, units_y=units_y)
else :
LOG.warn("Too much data present to allow creation of scatter plot for \"" + title_str + "\". Plot will not be created.")
fff
return to_return
......@@ -411,6 +421,16 @@ def create_density_scatter_plot(dataX, dataY,
return figure_obj
def check_data_amount_for_hex_plot (num_data_points, ):
"""
Is the given amount too much data for a hex plot?
return True if this is an ok amount and False if we won't make a hex plot with this much data
"""
return True if num_data_points < MAX_HEX_PLOT_DATA else False
# build a hexbin plot of the x,y points and show the density of the point distribution
def create_hexbin_plot(dataX, dataY, title_str, xLabel, yLabel, epsilon=None, units_x=None, units_y=None) :
......
......@@ -7,7 +7,7 @@ Created by evas Oct 2011.
Copyright (c) 2011 University of Wisconsin SSEC. All rights reserved.
"""
import sys, logging, traceback
import sys, logging
from PyQt5.QtWidgets import QApplication
......@@ -19,6 +19,7 @@ import glance.gui_figuremanager as gui_figs
from glance.gui_constants import A_CONST, B_CONST
from glance.data import IncompatableDataObjects
from glance.io import IONonnumericalTypeError
from glance.gui_figuremanager import TooMuchDataForPlot
LOG = logging.getLogger(__name__)
......@@ -258,9 +259,8 @@ class GlanceGUIController (object) :
try :
self.figs.spawnPlot()
except (IncompatableDataObjects, ValueError) as idove :
self.handleWarning(str(idove))
#raise
except (IncompatableDataObjects, ValueError, TooMuchDataForPlot,) as error :
self.handleWarning(str(error))
################# end of methods to handle user input reporting #################
......
......@@ -80,6 +80,23 @@ NEEDED_DATA_PER_PLOT = \
HEX_PLOT : {A_CONST, B_CONST,},
}
class TooMuchDataForPlot(Exception):
"""
An exception to be used when there's too much data to practically provide a plot when requested
"""
def __init__(self, dataSize):
"""
create this exception, giving a message based on the file path
"""
self.message = str("Unable to create requested plot. The data size of " + str(dataSize)
+ " was too large for the requested plot type.")
def __str__(self):
return self.message
class GlanceGUIFigures (object) :
"""
This class handles creating figures for the glance gui.
......@@ -583,13 +600,17 @@ class GlanceGUIFigures (object) :
if imageType == SCATTER :
cleanMismatchMask = diffData.diff_data_object.masks.mismatch_mask[tempCleanMask]
tempFigure = figures.create_scatter_plot(aDataClean, bDataClean,
"Value in File A vs Value in File B",
"File A Value for " + aVarName,
"File B Value for " + bVarName,
badMask=cleanMismatchMask,
epsilon=self.dataModel.getEpsilon(),
units_x=aUnitsText, units_y=bUnitsText)
if figures.check_data_amount_for_scatter_plot(aDataClean.size) :
tempFigure = figures.create_scatter_plot(aDataClean, bDataClean,
"Value in File A vs Value in File B",
"File A Value for " + aVarName,
"File B Value for " + bVarName,
badMask=cleanMismatchMask,
epsilon=self.dataModel.getEpsilon(),
units_x=aUnitsText, units_y=bUnitsText)
else :
# this is too much data to make a scatter plot, warn the user
raise TooMuchDataForPlot(aDataClean.size)
elif imageType == D_SCATTER :
......@@ -601,13 +622,17 @@ class GlanceGUIFigures (object) :
units_x=aUnitsText, units_y=bUnitsText)
else:
tempFigure = figures.create_hexbin_plot(aDataClean, bDataClean,
"Value in File A vs Value in File B",
"File A Value for " + aVarName,
"File B Value for " + bVarName,
epsilon=self.dataModel.getEpsilon(),
units_x=aUnitsText, units_y=bUnitsText)
if figures.check_data_amount_for_hex_plot(aDataClean.size) :
tempFigure = figures.create_hexbin_plot(aDataClean, bDataClean,
"Value in File A vs Value in File B",
"File A Value for " + aVarName,
"File B Value for " + bVarName,
epsilon=self.dataModel.getEpsilon(),
units_x=aUnitsText, units_y=bUnitsText)
else :
# this is too much data to make a hex plot, warn the user
raise TooMuchDataForPlot(aDataClean.size)
plt.draw()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment