Skip to content
Snippets Groups Projects
Commit da7b268b authored by Alan De Smet's avatar Alan De Smet
Browse files

"Data shape" shows single value arrays directly

In glance gui, if a variable has only a single value, it will be displayed directly in the "Data shape" field.
parent 6c22b6b6
No related branches found
No related tags found
No related merge requests found
......@@ -236,6 +236,22 @@ class DataObject (object) :
self.self_analysis()
return delta.max_with_mask(self.data, self.masks.valid_mask) if len(self.data.shape) > 0 else np.nan
def describe_shape(self):
"""
describe my data's shape
Typically just the shape (ex "(50,50)"), but may have
additional information. For example, single value shapes
will also show the value.
Intended strictly for human viewing, not parsing!
"""
if self.data.size == 1:
return str(self.data.shape) + " = " + str(self.data.item())
return str(self.data.shape)
class DiffInfoObject (object) :
"""
This class represents the full difference between two data sets.
......
......@@ -224,7 +224,7 @@ class GlanceGUIModel (object) :
for dataListener in self.dataListeners :
LOG.debug("Sending update for file " + filePrefix + " with loaded data.")
dataListener.fileDataUpdate(filePrefix, newFile.path, tempVariable, tempDataObj.override_fill_value,
self._select_fill_value(filePrefix), str(tempDataObj.data.shape),
self._select_fill_value(filePrefix), tempDataObj.describe_shape(),
variable_list=variableList, attribute_list=tempAttrs)
dataListener.updateSelectedLatLon(filePrefix,
self.fileData[filePrefix].latitude,
......@@ -363,7 +363,7 @@ class GlanceGUIModel (object) :
for listener in self.dataListeners :
listener.fileDataUpdate(file_prefix, self.fileData[file_prefix].file.path, tempVariableName,
tempDataObject.override_fill_value, self._select_fill_value(file_prefix),
str(tempDataObject.data.shape), attribute_list=tempAttrsList)
tempDataObject.describe_shape(), attribute_list=tempAttrsList)
def _select_fill_value (self, file_prefix) :
"""
......
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