def create_algorithm(file): ''' 根据文件类型判断数据类型,输出解码类 :param file: :return: ''' data_type = None modelDataType = None try: modelDataType = jt.judge_model_data_type(file) if modelDataType == ModelDataType.NETCDF: # nc类型 data_type = Nc(file) elif modelDataType == ModelDataType.HDF: data_type = HDF(file) elif modelDataType == ModelDataType.MICAPS4: data_type = M4(file) elif modelDataType == ModelDataType.GRIB: # 增加判断是GRIB1还是2 xxf 20191210 if (g2.judgeGribType(file) == "GRIB1"): data_type = GRIB1Info(file) else: data_type = GRIB2Info( file, GloalConfig.LibNetPath() + '/grib2Parameters.xml') pass except: return data_type, modelDataType # logger.error("AlgorithmFactory error : ", exc_info=1) finally: return data_type, modelDataType
def main(): app = QtWidgets.QApplication(sys.argv) gui = MainUi() gui.setWindowTitle('模式产品读数器') icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(GloalConfig.ImagePath() + "/globe.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off) gui.setWindowIcon(icon) gui.showMaximized() sys.exit(app.exec_())
def GetObject(id, **kwargs): try: config_path = os.path.join(GloalConfig().config, 'config.xml') context = ApplicationContext(XMLConfig(config_path)) obj = context.get_object(id) logger.info(obj) return obj except: logger.error("", exc_info=1) return None
def create_algorithm(file): import lib.judgetype as jt from lib.judgetype import ModelDataType from module.algorithm.netcdf.netcdf import Nc from module.algorithm.netcdf.hdf import HDF from module.algorithm.micaps.pymicaps import M4 import module.algorithm.grib.grib2_info as g2 from module.algorithm.grib.grib2_info import GRIB2Info from module.algorithm.grib.grib1_info import GRIB1Info from module.mrc_core.gloalConfig import GloalConfig ''' 根据文件类型判断数据类型,输出解码类 :param file: :return: ''' data_type = None modelDataType = None try: modelDataType = jt.judge_model_data_type(file) if modelDataType == ModelDataType.NETCDF: # nc类型 data_type = Nc(file) elif modelDataType == ModelDataType.HDF: data_type = HDF(file) elif modelDataType == ModelDataType.MICAPS4: data_type = M4(file) elif modelDataType == ModelDataType.GRIB: # 增加判断是GRIB1还是2 xxf 20191210 if (g2.judgeGribType(file) == "GRIB1"): data_type = GRIB1Info(file) else: data_type = GRIB2Info( file, GloalConfig.LibNetPath() + '/grib2Parameters.xml') pass except: return data_type, modelDataType # logger.error("AlgorithmFactory error : ", exc_info=1) finally: return data_type, modelDataType
@author: @site: @software: PyCharm @file: @time: """ from module.algorithm.grib.grib2_info import GRIB2Info from module.mrc_core.gloalConfig import GloalConfig file = r'D:\PanoplyWin\gef.gra.grb2' # file=r'E:\Work\Hitec\MSZC\MSS2\05source\MRC\data\NAFP_ECMF_1_FTM-98-GLB-TEM-125X125-1-0-999998-999998-999998-2017092812-0.GRB' # ds=xr.open_dataset(file,engine='cfgrib') # print(ds) grib_info = GRIB2Info(file, GloalConfig.LibNetPath() + '/grib2Parameters.xml') s = grib_info.print_property_info() print(s) #print(s) #print(grib_info.print_variable_property(None,38165271)) data = grib_info.get_data_by_name(1071) array = grib_info.system_double_2_array(data) print(array) # meteo = MeteoDataInfo() # o=meteo.OpenGRIBData(file) # for var_name in meteo.DataInfo.VariableNames: # grid_data=meteo.GetGridData(var_name)
def judgeGribType(file): meteo = MeteoDataInfo() # 实例化Hitec.DataParse.MeteoDataInfo类 meteo.OpenGRIBData(file,GloalConfig.LibNetPath()+'/grib2Parameters.xml') if(int(meteo.GRIBType)==1): return "GRIB1" else:return "GRIB2"
@version: v0.1 @author: xxf @site: @software: PyCharm @file: GRIB数据解码类 @time: 2019-8-2 """ import lib.array as ay from module.algorithm.algorithmbase import PyMeteoDataInfo import clr import sys from module.mrc_core.gloalConfig import GloalConfig net_path=GloalConfig.LibNetPath() #net_path=r'D:\workspace09\MMS2_MRC\lib\net' sys.path.append(net_path)#导入.net动态库路径 clr.AddReference('System.Collections') clr.AddReference('System.IO') clr.AddReference('MeteoInfoC')#导入MeteoInfoC.dll clr.AddReference('Hitec.DataParse')#导入解析dll #clr.AddReference('nwfd-grib2-win32') from MeteoInfoC.Data.MeteoData import * from Hitec.DataParse import * from module.algorithm.algorithmbase import PyMeteoDataInfo from module.mrc_core.gloalConfig import GloalConfig def judgeGribType(file):
class ToolBarLoader(CommandActive): # 菜单配置路径 config_path = os.path.join(GloalConfig().config, 'toolbar.xml') image_dir = GloalConfig().image def __init__(self, mainWindow, treeWidget, tabWidget): self.mainWindow = mainWindow #self.textBrowser = textBrowser self.treeWidget = treeWidget self.tabWidget = tabWidget def CreateQToolBar(self): _translate = QCoreApplication.translate screen = QGuiApplication.primaryScreen() # 主屏幕信息 dom_tree = dom.parse(self.config_path) dom_coll = dom_tree.documentElement if dom_coll.hasAttribute("toolbars"): logger.info("Root element : %s" % dom_coll.getAttribute("toolbars")) toolbar_name = dom_coll.getAttribute("name") self.toolbar = QToolBar(self.mainWindow) self.toolbar.setObjectName(toolbar_name) self.toolbar.setIconSize(QtCore.QSize(60, 60)) self.toolbar.setToolButtonStyle(Qt.ToolButtonStyle(0)) self.toolbar.setStyleSheet(''' QToolBar{background:#F0F0F0;border-radius:50px;} QToolBar:hover{background:#F0F0F0;} QToolButton{border:none;border-radius:50px;} QToolButton:hover{border-bottom:2px solid #F0F0F0;} ''') tools = dom_coll.getElementsByTagName("toolbar") for tool in tools: tool_caption = tool.getAttribute("caption") tool_name = tool.getAttribute("name") buttons = tool.getElementsByTagName("button") for btn in buttons: btn_caption = btn.getAttribute("caption") btn_name = btn.getAttribute("name") # 图片路径 btn_icon = btn.getAttribute("iconPath") # 图片路径 btn_toolTip = btn.getAttribute("toolTip") btn_shortcut = btn.getAttribute("shortcut") # 快捷键 btn_visible = btn.getAttribute("visible") # 是否可见 btn_enable = btn.getAttribute("enable") # 是否可用 btn_command = btn.getAttribute("command") # 命令 # 创建QAction action = ActionQ(self.mainWindow) # 创建ActionQ信号,继承Action action.setObjectName(btn_name) action.setText(_translate("MainWindow", btn_caption)) icon = QIcon() icon.addPixmap(QtGui.QPixmap(self.image_dir + '/' + btn_icon), QtGui.QIcon.Normal, QtGui.QIcon.Off) action.setIcon(icon) # 设置图片 action.setToolTip(_translate("MainWindow", btn_toolTip)) action.setVisible(True if btn_visible.lower() == "true" else False) action.setEnabled(True if btn_enable.lower() == "true" else False) action.setShortcut(_translate("MainWindow", btn_shortcut)) action.setShortcutContext(QtCore.Qt.WindowShortcut) action.setPriority(QtWidgets.QAction.NormalPriority) # QActionGroup() # action.setActionGroup() action.tag = btn_command command = AppContext.GetObject( btn_command) # springpython 实现Ioc控制翻转 if isinstance(command, ICommand): command.mainWindow = self.mainWindow #command.textBrowser = self.textBrowser # 设置文本显示控件 command.treeWidget = self.treeWidget # 设置树形结构控件 command.tabWidget = self.tabWidget command.InitCmd(action) # 注册action self.toolbar.addAction(action) logger.info("Root element : %s" % dom_coll.getAttribute("toolbars") + " OK") return self.toolbar
class MenuLoader(CommandActive): # 菜单配置路径 config_path = os.path.join(GloalConfig().config, 'menu.xml') def __init__(self, mainWindow, treeWidget, tabWidget): super(MenuLoader, self).__init__() #self.config_path="" # 菜单配置路径 #self.config_path = os.path.join(GloalConfig().config, 'menu.xml') self.mainWindow = mainWindow #self.textBrowser = textBrowser self.treeWidget = treeWidget self.tabWidget = tabWidget def CreateQMenu(self): _translate = QCoreApplication.translate screen = QGuiApplication.primaryScreen() #主屏幕信息 dom_tree = dom.parse(self.config_path) dom_coll = dom_tree.documentElement if dom_coll.hasAttribute("menuItems"): logger.info("Root element : %s" % dom_coll.getAttribute("menuItems")) menubar_name = dom_coll.getAttribute("name") # 创建QMenuBar self.menubar = QMenuBar(self.mainWindow) self.menubar.setObjectName(menubar_name) self.menubar.setGeometry(QRect(0, 0, screen.size().width(), 30)) menus = dom_coll.getElementsByTagName("menuItem") for menu in menus: menu_id = menu.getAttribute("id") menu_name = menu.getAttribute("name") menu_caption = menu.getAttribute("caption") # 创建QMenu menu_c = QMenu(self.menubar) menu_c.setObjectName(menu_name) menu_c.setTitle(_translate("MainWindow", menu_caption)) #创建QAction,将QAction绑定到QMenu buttons = menu.getElementsByTagName('button') for btn in buttons: btn_caption = btn.getAttribute("caption") btn_name = btn.getAttribute("name") # 图片路径 #btn_icon = btn.getAttribute("iconPath") # 图片路径 btn_toolTip = btn.getAttribute("toolTip") btn_shortcut = btn.getAttribute("shortcut") # 快捷键 btn_visible = btn.getAttribute("visible") # 是否可见 btn_enable = btn.getAttribute("enable") # 是否可用 btn_command = btn.getAttribute("command") # 命令 # 创建QAction action = ActionQ(self.mainWindow) # 创建ActionQ信号,继承Action action.setObjectName(btn_name) action.setText(_translate("MainWindow", btn_caption)) action.setToolTip(_translate("MainWindow", btn_toolTip)) action.setVisible(True if btn_visible.lower() == "true" else False) action.setEnabled(True if btn_enable.lower() == "true" else False) action.setShortcut(_translate("MainWindow", btn_shortcut)) action.setShortcutContext(QtCore.Qt.WindowShortcut) action.setPriority(QtWidgets.QAction.NormalPriority) action.tag = btn_command command = AppContext.GetObject( btn_command) #springpython 实现Ioc控制翻转 if isinstance(command, ICommand): command.mainWindow = self.mainWindow #command.textBrowser = self.textBrowser#设置文本显示控件 command.treeWidget = self.treeWidget #设置树形结构控件 command.tabWidget = self.tabWidget command.InitCmd(action) #注册action menu_c.addAction(action) self.menubar.addAction(menu_c.menuAction()) logger.info("Root element : %s" % dom_coll.getAttribute("menuItems") + " OK") return self.menubar def closelog(self): logger