Skip to content
Snippets Groups Projects
Commit 58f92edf authored by Emmanuel Heriberto Oceguera Conchas's avatar Emmanuel Heriberto Oceguera Conchas
Browse files

updated

parent 9036217b
No related branches found
No related tags found
No related merge requests found
...@@ -168,11 +168,9 @@ class maskAndFuntionality (BASE, WIDGET): ...@@ -168,11 +168,9 @@ class maskAndFuntionality (BASE, WIDGET):
child3 = QTreeWidgetItem([ncFileVariablesName2[k], longNameVariables2]) child3 = QTreeWidgetItem([ncFileVariablesName2[k], longNameVariables2])
child2.addChild(child3) child2.addChild(child3)
#we get the variables of the groups #we get the variables of the groups
ncFileGroupsVariablesName = list(ncFile.groups[ncFileGroupsName[i]].variables.keys()) ncFileGroupsVariablesName = list(ncFile.groups[ncFileGroupsName[i]].variables.keys())
#we show the variables of the groups in the QTreeWidgetite and set the long name of the variables #we show the variables of the groups in the QTreeWidgetite and set the long name of the variables
for j in range(len(ncFileGroupsVariablesName)): for j in range(len(ncFileGroupsVariablesName)):
longNameVariables = ncFile.groups[ncFileGroupsName[i]].variables[ncFileGroupsVariablesName[j]].long_name longNameVariables = ncFile.groups[ncFileGroupsName[i]].variables[ncFileGroupsVariablesName[j]].long_name
...@@ -187,41 +185,35 @@ class maskAndFuntionality (BASE, WIDGET): ...@@ -187,41 +185,35 @@ class maskAndFuntionality (BASE, WIDGET):
ncFile.close() ncFile.close()
def showInfo(self): def showInfo(self):
"""this function is to show the attributes of the groups if the group is clicked and the groups of the groups if the group of the group is clicked and the attributes of the variables if the variable is clicked""" """this function shows first the name of the file and the global attributes and then if a varible is clicked delete the info and add the attributes of the selected variable"""
#we get the item that is clicked #we get the path from the text space
item = self.tree_data.currentItem() path = self.text_set.text()
#we get the name of the item that is clicked #we load the netCDF file
itemName = item.text(0) ncFile = nc.Dataset(path, 'r', format='NETCDF4')
#we get the name of the file #we get the name of the netCDF file to show it in the GUI
fileName = self.text_file.text() ncFileName = os.path.basename(path)
#we open the netCDF file #We get the title of the netCDF file
ncFile = Dataset(fileName, "r", format="NETCDF4") ncFileTitle = ncFile.title
#we get the name of the file without the extension #we get the global attributes of the netCDF file
ncFileName = os.path.splitext(fileName)[0] ncFileGlobalAttributes = list(ncFile.ncattrs())
#we set first the name of the file in the QTextBrowser
self.text_info.append('File name: '+ ncFileName)
#we get the attributes of the groups if the group is clicked #we show the name of the file and the global attributes in the QtextBrowser
if item.parent() != None and item.parent().parent() == None: self.text_info.append("File name: " + ncFileName)
ncFileGroupsAttributes = list(ncFile.groups[itemName].ncattrs()) self.text_info.append("File title: " + ncFileTitle)
for i in range(len(ncFileGroupsAttributes)): for i in range(len(ncFileGlobalAttributes)):
ncFileGroupsAttributesValue = ncFile.groups[itemName].getncattr(ncFileGroupsAttributes[i]) self.text_info.append(ncFileGlobalAttributes[i] + ": " + str(ncFile.getncattr(ncFileGlobalAttributes[i])))
self.text_info.append("- "+ ncFileGroupsAttributes[i] + ": " + str(ncFileGroupsAttributesValue))
#if a variable is clicked delete the info and add the attributes of the selected item
#we get the attributes of the groups of the groups if the group of the group is clicked if self.tree_data.currentItem().parent() != None:
if item.parent() != None and item.parent().parent() != None and item.parent().parent().parent() == None: self.text_info.clear()
ncFileGroupsAttributes2 = list(ncFile.groups[item.parent().text(0)].groups[itemName].ncattrs()) self.text_info.append("File name: " + ncFileName)
for i in range(len(ncFileGroupsAttributes2)): self.text_info.append("File title: " + ncFileTitle)
ncFileGroupsAttributesValue2 = ncFile.groups[item.parent().text(0)].groups[itemName].getncattr(ncFileGroupsAttributes2[i]) ncFileVariableAttributes = list(ncFile.variables[self.tree_data.currentItem().text(0)].ncattrs())
self.text_info.append(ncFileGroupsAttributes2[i] + ": " + str(ncFileGroupsAttributesValue2)) for i in range(len(ncFileVariableAttributes)):
self.text_info.append(ncFileVariableAttributes[i] + ": " + str(ncFile.variables[self.tree_data.currentItem().text(0)].getncattr(ncFileVariableAttributes[i])))
#we get the attributes of the variables if the variable is clicked
if item.parent() != None and item.parent().parent() != None and item.parent().parent().parent() != None: #we close the netCDF file
ncFileVariablesAttributes = list(ncFile.groups[item.parent().parent().text(0)].groups[item.parent().text(0)].variables[itemName].ncattrs()) ncFile.close()
for i in range(len(ncFileVariablesAttributes)):
ncFileVariablesAttributesValue = ncFile.groups[item.parent().parent().text(0)].groups[item.parent().text(0)].variables[itemName].getncattr(ncFileVariablesAttributes[i])
self.text_info.append(ncFileVariablesAttributes[i] + ": " + str(ncFileVariablesAttributesValue))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment