汇总数据: gatherdata.py

desktop
esea_info 3 years ago
parent d0bf3e328b
commit 893cd1f11d
  1. 109
      gatherdata.py
  2. 12
      yiwinframe.py

@ -0,0 +1,109 @@
import numpy as np
from myconfig import OUTPUT_DIR
from tools.mylogger import log
from pathlib import Path
from handheld import HandHeldPath
class GatherData(object):
"""对数据进行汇总后分析 csv"""
def __init__(self, ):
super(GatherData, self).__init__()
self.dir = OUTPUT_DIR
self.extname = ".csv"
def setDir(self, fpath):
self.dir = fpath
pass
def setExtname(self, extname):
self.extname = extname
pass
def getChildDirs(self, ):
'''
按时间排放每个目录下有五个文件 Esky....Rs
文件直接保存到 output下的五个文件 Esky ..... Rs
'''
childdirs = []
for path in Path(self.dir).iterdir():
# if path.is_dir():
# print(path)
if not path.is_dir():
continue
childdirs.append(path)
return childdirs
pass
def gather_handheld(self, ):
log.info(f" ",__name__,'gather_handheld')
childDirs = self.getChildDirs()
for cdir in childDirs:
tmp_path:Path = cdir.joinpath("Lw"+self.extname)
self.transfer_data(tmp_path)
tmp_path:Path = cdir.joinpath("Rs"+self.extname)
self.transfer_data(tmp_path)
pass
def transfer_data(self, fpath:Path):
log.info(f" ",__name__,'transfer_data')
log.info(fpath)
old_path:Path = fpath
new_path:Path = self.dir.joinpath( old_path.stem + self.extname)
if not new_path.exists():
new_path.touch()
if old_path.exists():
count = 0
with open( new_path, "a" ) as fnew:
with open( old_path, "r" ) as f:
while True:
line = f.readline()
if not line :
break
if count != 0:
fnew.write(line)
count+=1
def gather_awrams(self, ):
'''
一个文件包含 Esky .....Rs 五组数据
获得csv文件,转移不同的行到不同文件
第一列要转为时间
'''
# ret = []
fs = None
self.filelist = []
fs = self.dir.glob( "*/*/*/*.csv" )
for f in fs:
print(f)
tmp = np.loadtxt( fs, dtype=str, delimiter=';',skiprows=1 )
self.addNdarray2File(tmp[0])
def addNdarray2File( self, data:np.ndarray ):
pass
# def transfer_line_without_firstline(self, oldpath:Path, newPath:Path):
# count = 0
# with open( newPath, "a" ) as fnew:
# with open( oldpath, "r" ) as f:
# line = f.readline()
# if count != 0:
# fnew.write(line)
# pass
# pass
def getFileList_awrams(self, ):
'''
一个文件包含 Esky .....Rs 五组数据
获得csv文件,转移不同的行到不同文件
'''
# ret = []
fs = None
self.filelist = []
fs = self.dir.glob( "*/*.csv" )
pass
if __name__ == "__main__":
gd = GatherData()
gd.gather_handheld()

@ -21,6 +21,7 @@ from myconfig import MyConfig,RamsesFunc
from mythread import Mythead from mythread import Mythead
from configuration import Configuration from configuration import Configuration
from handheld import HandHeld,HandHeldBuf from handheld import HandHeld,HandHeldBuf
from gatherdata import GatherData
from tools.myexception import MyException from tools.myexception import MyException
from tools.mylogger import log from tools.mylogger import log
@ -37,6 +38,7 @@ ID_PLOT_LAST = 15
ID_PLOT_LAST_7 = 16 ID_PLOT_LAST_7 = 16
ID_PLOT_7 = 17 ID_PLOT_7 = 17
ID_PLOT_SETTING = 18 ID_PLOT_SETTING = 18
ID_GATHER_DATA = 19
ID_HELP = 21 ID_HELP = 21
ID_ABOUT = 22 ID_ABOUT = 22
@ -124,6 +126,8 @@ class YiwinFrame(wx.Frame):
plotMenu.Append(ID_PLOT_7, u'&指定七条', ' ') plotMenu.Append(ID_PLOT_7, u'&指定七条', ' ')
plotMenu.AppendSeparator() plotMenu.AppendSeparator()
plotMenu.Append(ID_PLOT_SETTING, u'&指定设置', ' ') plotMenu.Append(ID_PLOT_SETTING, u'&指定设置', ' ')
plotMenu.AppendSeparator()
plotMenu.Append(ID_GATHER_DATA, u'&汇总数据', ' ')
self.menubar.Append(plotMenu, u'&绘图 ') self.menubar.Append(plotMenu, u'&绘图 ')
aboutMenu = wx.Menu() aboutMenu = wx.Menu()
@ -154,6 +158,7 @@ class YiwinFrame(wx.Frame):
self.Bind(wx.EVT_MENU, self.OnPlotLast7, id=ID_PLOT_LAST_7 ) self.Bind(wx.EVT_MENU, self.OnPlotLast7, id=ID_PLOT_LAST_7 )
self.Bind(wx.EVT_MENU, self.OnPlot7, id=ID_PLOT_7) self.Bind(wx.EVT_MENU, self.OnPlot7, id=ID_PLOT_7)
self.Bind(wx.EVT_MENU, self.OnPlotSetting, id=ID_PLOT_SETTING) self.Bind(wx.EVT_MENU, self.OnPlotSetting, id=ID_PLOT_SETTING)
self.Bind(wx.EVT_MENU, self.OnGatherData, id=ID_GATHER_DATA)
self.Bind(wx.EVT_MENU, self.OnHelpConfig, id=ID_HELP) self.Bind(wx.EVT_MENU, self.OnHelpConfig, id=ID_HELP)
self.Bind(wx.EVT_MENU, self.OnAboutConfig, id=ID_ABOUT) self.Bind(wx.EVT_MENU, self.OnAboutConfig, id=ID_ABOUT)
@ -317,7 +322,12 @@ class YiwinFrame(wx.Frame):
self.popDialog(" 功能开发中...") self.popDialog(" 功能开发中...")
pass pass
def OnGatherData(self,e):
gd = GatherData()
gd.gather_handheld()
self.alterStatus_0(" 数据汇总完成")
pass
def OnPlotSetting(self,e): def OnPlotSetting(self,e):
with UI_Plot_Setting( with UI_Plot_Setting(
self, self,

Loading…
Cancel
Save