From df97a3f0a5b762d626604764cea6e3bdeb6d1d04 Mon Sep 17 00:00:00 2001 From: Emmanuel Heriberto Oceguera Conchas <e.oceguera@gmx.de> Date: Wed, 12 Oct 2022 13:39:34 +0200 Subject: [PATCH] updated --- netCDF_visualizer.py | 5 ++--- netCDF_visualizer_funtionality.py | 22 ++++++++++++++++++++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/netCDF_visualizer.py b/netCDF_visualizer.py index 573f060..d000004 100644 --- a/netCDF_visualizer.py +++ b/netCDF_visualizer.py @@ -26,13 +26,13 @@ from PyQt5.QtCore import * from PyQt5.QtGui import * from PyQt5.QtWidgets import * - #import everthing from the netCDF_visualization_funtionality.py file from .netCDF_visualizer_funtionality import * - #we write a class, Plugins is a class import os + + class netCDFVisualizer: """This is a class for the netCDFVisualizer Plugin""" #we set that we need the iface to build something with the class @@ -153,7 +153,6 @@ class netCDFVisualizer: else : self.toolbar.removeAction(action) - #we create a function to call the mask def callMask(self): #we create the mask or GUI diff --git a/netCDF_visualizer_funtionality.py b/netCDF_visualizer_funtionality.py index f55b69b..8c61ec0 100644 --- a/netCDF_visualizer_funtionality.py +++ b/netCDF_visualizer_funtionality.py @@ -34,8 +34,26 @@ 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 +try: + from pip import main as pipmain +except ImportError: + from pip._internal import main as pipmain + +try: + import netCDF4 as nc +except ImportError: + pipmain(['install', 'netCDF4']) + import netCDF4 as nc + from netCDF4 import Dataset + +#we need the matplotlib module to plot the data +#try: +# import matplotlib +#except ImportError: +# pipmain(['install', 'matplotlib']) +# import matplotlib + + #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 -- GitLab