diff --git a/netCDFVisualizer.ui b/netCDFVisualizer.ui index 7d046f3ffdb827a3826e02567852b4dffdb5a5c8..d0b36e5ea00eb3f3f88fb5e72c2d56655d671d8f 100644 --- a/netCDFVisualizer.ui +++ b/netCDFVisualizer.ui @@ -6,8 +6,8 @@ <rect> <x>0</x> <y>0</y> - <width>771</width> - <height>835</height> + <width>389</width> + <height>518</height> </rect> </property> <property name="windowTitle"> diff --git a/netCDF_visualizer.py b/netCDF_visualizer.py index 4faa3ddd827c802baee7aa1098c8401d335af65f..573f0603278156910333c93b9cac00885d9d1504 100644 --- a/netCDF_visualizer.py +++ b/netCDF_visualizer.py @@ -50,7 +50,7 @@ class netCDFVisualizer: #decalre instance attributes self.actions = [] self.menu = self.tr(u'&netCDFVisualizer') - + def tr(self, message): """Get the translation for a string using Qt translation API. @@ -135,22 +135,24 @@ class netCDFVisualizer: #when we click the plugin in QGIS the plugin will be loaded def initGui(self): """Create the menu entries and toolbar icons inside the QGIS GUI.""" - icon_path = ':/plugins/netCDFVisualizer/icon.png' + icon_path = ':/plugins/netCDFVisualizer/adventure.png' self.add_action( icon_path, text=self.tr(u'netCDFVisualizer'), callback=self.callMask, parent=self.iface.mainWindow()) - - - #when we close the plugin in QGIS the plugin will be unloaded def unload(self): - #we remove the menu item - self.iface.removePluginMenu('netCDFVisualizer', self.pluginButton) - #we remove the menu item - self.iface.removeToolBarIcon(self.pluginButton) + """Removes the plugin menu item and icon from QGIS GUI.""" + for action in self.actions: + self.iface.removePluginMenu( + self.tr(u'&netCDFVisualizer'), + action) + self.iface.removeToolBarIcon(action) + else : + self.toolbar.removeAction(action) + #we create a function to call the mask def callMask(self): diff --git a/netCDF_visualizer_funtionality.py b/netCDF_visualizer_funtionality.py index 6bc87dc84fa9fe61f4046a6ead1e90b8603e718a..f55b69bc64887645c5df9ee003d072ad7b11a8e5 100644 --- a/netCDF_visualizer_funtionality.py +++ b/netCDF_visualizer_funtionality.py @@ -34,7 +34,8 @@ import os #to import general tools from QGIS we need the qgis.core module from qgis.core import * #for loading the netCDF files we need the netCDF4 module - +import netCDF4 as nc +from netCDF4 import Dataset #we create the path to the ui file #Path to the Ordner where the ui file is ncvPath = os.path.dirname(__file__) #the comand dirname gives the path to the directory where the file is @@ -58,6 +59,8 @@ class maskAndFuntionality (BASE, WIDGET): """ Here is the place for the Clicked Signal""" self.btn_closePlugin.clicked.connect(self.closePlugin) self.btn_inputFile.clicked.connect(self.importData) + self.btn_remove.clicked.connect(self.removePath) + self.btn_load.clicked.connect(self.loadNetCDF) def closePlugin(self): @@ -76,7 +79,21 @@ class maskAndFuntionality (BASE, WIDGET): """This function removes the path from the text space""" #we remove the path from the text space self.text_set.clear() - + + def loadNetCDF(self): + """This function loads the netCDF file""" + #we get the path from the text space + path = self.text_set.text() + #we load the netCDF file + self.nc = Dataset(path, 'r', format='NETCDF4') + #we get the name of the variables + self.variables = self.nc.variables.keys() + #we set the name of the variables in the combo box + self.txt_tab_dataSet.addItems(self.variables) + #we get the name of the dimensions + self.dimensions = self.nc.dimensions.keys() + #we set the name of the dimensions in the combo box + self.txt_tab_dataSet.addItems(self.dimensions)