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

added a new definition to plot and save the data

parent df97a3f0
No related branches found
No related tags found
No related merge requests found
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#we import the impotant libraries and modules #we import the impotant libraries and modules
#always import the libraries and modules at the top of the code #always import the libraries and modules at the top of the code
from json import load
from PyQt5.QtCore import * from PyQt5.QtCore import *
from PyQt5.QtGui import * from PyQt5.QtGui import *
from PyQt5.QtWidgets import * from PyQt5.QtWidgets import *
...@@ -101,19 +102,36 @@ class maskAndFuntionality (BASE, WIDGET): ...@@ -101,19 +102,36 @@ class maskAndFuntionality (BASE, WIDGET):
def loadNetCDF(self): def loadNetCDF(self):
"""This function loads the netCDF file""" """This function loads the netCDF file"""
#we get the path from the text space #we get the path from the text space
path = self.text_set.text() if self.text_set.text()=="": #if the text space is empty
#we load the netCDF file QmessageBox.warning(None, "Warning", "Please select a netCDF file") #we show a warning
self.nc = Dataset(path, 'r', format='NETCDF4') else: #if the text space is not empty
#we get the name of the variables path = self.text_set.text() #we get the path from the text space
self.variables = self.nc.variables.keys() #we load the netCDF file
#we set the name of the variables in the combo box ncFile = nc.dataset(path, 'r', format='NETCDF4')
self.txt_tab_dataSet.addItems(self.variables) #we get the variables from the netCDF file
#we get the name of the dimensions ncVar = ncFile.variables
self.dimensions = self.nc.dimensions.keys() #we get the names of the variables
#we set the name of the dimensions in the combo box ncVarNames = ncVar.keys()
self.txt_tab_dataSet.addItems(self.dimensions) #we get the dimensions of the variables
ncVarDimensions = ncVar.values()
#we get the attributes of the variables
ncVarAttributes = ncVar.values()
#we get the values of the variables
ncVarValues = ncVar.values()
#we get the units of the variables
ncVarUnits = ncVar.values()
#we show the variables in the list
self.list_variables.addItems(ncVarNames)
#we show the dimensions in the list
self.list_dimensions.addItems(ncVarDimensions)
#we show the attributes in the list
self.list_attributes.addItems(ncVarAttributes)
#we show the values in the list
self.list_values.addItems(ncVarValues)
#we show the units in the list
self.list_units.addItems(ncVarUnits)
#we close the netCDF file
ncFile.close()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment