diff --git a/pyglance/glance/data.py b/pyglance/glance/data.py index 4e213de9d916dbe8af0737c5e69afcda3ebed079..233a55c43b6054710bb5402c2d809dcc7702d9c7 100644 --- a/pyglance/glance/data.py +++ b/pyglance/glance/data.py @@ -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. diff --git a/pyglance/glance/gui_model.py b/pyglance/glance/gui_model.py index 422c18864132a82a3ffeba6d3d9e6fbd52f86432..af84b1b99b59d5f755f0f9b7fcd6fa1ac531819b 100644 --- a/pyglance/glance/gui_model.py +++ b/pyglance/glance/gui_model.py @@ -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) : """