Surface NMR processing and inversion GUI
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

akvoGUI.py 79KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798
  1. #/usr/bin/env python
  2. import sys
  3. import matplotlib
  4. matplotlib.use("QT5Agg")
  5. from PyQt5 import QtCore, QtGui, QtWidgets #, uic
  6. import numpy as np
  7. import time
  8. import os
  9. from copy import deepcopy
  10. from matplotlib.backends.backend_qt4 import NavigationToolbar2QT #as NavigationToolbar
  11. import datetime, time
  12. import pkg_resources # part of setuptools
  13. from collections import OrderedDict
  14. from ruamel import yaml
  15. from akvo.gui.main_ui import Ui_MainWindow
  16. from akvo.gui.addCircularLoop_ui import Ui_circularLoopAdd
  17. from akvo.gui.addFigure8Loop_ui import Ui_figure8LoopAdd
  18. from akvo.gui.addPolygonalLoop_ui import Ui_polygonalLoopAdd
  19. from akvo.gui.redirect_ui import Ui_callScript
  20. from akvo.gui.callScript import callScript
  21. from akvo.tressel import mrsurvey
  22. from pyLemma import LemmaCore
  23. from pyLemma import FDEM1D
  24. from pyLemma import Merlin
  25. VERSION = pkg_resources.require("Akvo")[0].version
  26. # Writes out numpy arrays into Eigen vectors as serialized by Lemma
  27. class MatrixXr(yaml.YAMLObject):
  28. yaml_tag = u'MatrixXr'
  29. def __init__(self, rows, cols, data):
  30. self.rows = rows
  31. self.cols = cols
  32. self.data = np.zeros((rows,cols))
  33. def __repr__(self):
  34. return "%s(rows=%r, cols=%r, data=%r)" % (self.__class__.__name__, self.rows, self.cols, self.data)
  35. class VectorXr(yaml.YAMLObject):
  36. yaml_tag = r'VectorXr'
  37. def __init__(self, array):
  38. self.size = np.shape(array)[0]
  39. self.data = array.tolist()
  40. def __repr__(self):
  41. # Converts to numpy array on import
  42. return "np.array(%r)" % (self.data)
  43. def setup_yaml():
  44. """ https://stackoverflow.com/a/8661021 """
  45. represent_dict_order = lambda self, data: self.represent_mapping('tag:yaml.org,2002:map', data.items())
  46. yaml.add_representer(OrderedDict, represent_dict_order)
  47. setup_yaml()
  48. class AkvoYamlNode(yaml.YAMLObject):
  49. yaml_tag = u'AkvoData'
  50. def __init__(self):
  51. self.Akvo_VERSION = VERSION
  52. self.Import = OrderedDict() # {}
  53. self.Processing = [] # OrderedDict()
  54. self.Stacking = OrderedDict()
  55. self.META = OrderedDict()
  56. def __repr__(self):
  57. return "%s(name=%r, Akvo_VERSION=%r, Import=%r, Processing=%r, self.Stacking=%r, self.META=%r)" % (
  58. self.__class__.__name__, self.Akvo_VERSION, self.Import, self.Processing, self.Stacking, self.META )
  59. try:
  60. import thread
  61. except ImportError:
  62. import _thread as thread #Py3K compatibility
  63. class MyPopup(QtWidgets.QWidget):
  64. def __init__(self, name):
  65. super().__init__()
  66. self.name = name
  67. self.initUI()
  68. def initUI(self):
  69. lblName = QtWidgets.QLabel(self.name, self)
  70. class ApplicationWindow(QtWidgets.QMainWindow):
  71. def __init__(self):
  72. super().__init__()
  73. #QtWidgets.QMainWindow.__init__(self)
  74. self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
  75. # alternative to calling pyuic
  76. #self.ui = uic.loadUi('main.ui', self)
  77. self.ui = Ui_MainWindow()
  78. self.ui.setupUi(self)
  79. self.RAWDataProc = None
  80. self.YamlNode = AkvoYamlNode()
  81. # initialise some stuff
  82. self.ui.lcdNumberTauPulse2.setEnabled(0)
  83. self.ui.lcdNumberTauPulse1.setEnabled(0)
  84. self.ui.lcdNumberNuTx.setEnabled(0)
  85. self.ui.lcdNumberTuneuF.setEnabled(0)
  86. self.ui.lcdNumberSampFreq.setEnabled(0)
  87. self.ui.lcdNumberTauDelay.setEnabled(0)
  88. self.ui.lcdNumberNQ.setEnabled(0)
  89. self.logText = []
  90. #######################
  91. ##################### #
  92. ## Make connections # #
  93. ##################### #
  94. #######################
  95. ##############
  96. # Menu items #
  97. ##############
  98. self.ui.actionOpen_GMR.triggered.connect(self.openGMRRAWDataset)
  99. self.ui.actionSave_Preprocessed_Dataset.triggered.connect(self.SavePreprocess)
  100. self.ui.actionExport_Preprocessed_Dataset.triggered.connect(self.ExportPreprocess)
  101. self.ui.actionExport_Preprocessed_Dataset.setEnabled(False)
  102. self.ui.actionOpen_Preprocessed_Dataset.triggered.connect(self.OpenPreprocess)
  103. self.ui.actionAboutAkvo.triggered.connect(self.about)
  104. ###########
  105. # Buttons #
  106. ###########
  107. self.ui.loadDataPushButton.pressed.connect(self.loadRAW)
  108. self.ui.sumDataGO.pressed.connect( self.sumDataChans )
  109. self.ui.bandPassGO.pressed.connect( self.bandPassFilter )
  110. self.ui.filterDesignPushButton.pressed.connect( self.designFilter )
  111. self.ui.fdDesignPushButton.pressed.connect( self.designFDFilter )
  112. self.ui.downSampleGO.pressed.connect( self.downsample )
  113. self.ui.windowFilterGO.pressed.connect( self.windowFilter )
  114. self.ui.adaptGO.pressed.connect( self.adaptFilter )
  115. self.ui.adaptFDGO.pressed.connect( self.adaptFilterFD )
  116. self.ui.qdGO.pressed.connect( self.quadDet )
  117. self.ui.gateIntegrateGO.pressed.connect( self.gateIntegrate )
  118. self.ui.calcQGO.pressed.connect( self.calcQ )
  119. self.ui.FDSmartStackGO.pressed.connect( self.FDSmartStack )
  120. self.ui.harmonicGO.pressed.connect( self.harmonicModel )
  121. self.ui.f0K1Spin.valueChanged.connect( self.LCDHarmonics )
  122. self.ui.f0KNSpin.valueChanged.connect( self.LCDHarmonics )
  123. self.ui.f0KsSpin.valueChanged.connect( self.LCDHarmonics )
  124. self.ui.f0Spin.valueChanged.connect( self.LCDHarmonics )
  125. self.ui.NHarmonicsFreqsSpin.valueChanged.connect( self.LCDHarmonics2 )
  126. self.ui.f1K1Spin.valueChanged.connect( self.LCDHarmonics2 )
  127. self.ui.f1KNSpin.valueChanged.connect( self.LCDHarmonics2 )
  128. self.ui.f1KsSpin.valueChanged.connect( self.LCDHarmonics2 )
  129. self.ui.f1Spin.valueChanged.connect( self.LCDHarmonics2 )
  130. self.ui.plotQD.setEnabled(False)
  131. self.ui.plotQD.pressed.connect( self.plotQD )
  132. self.ui.plotGI.setEnabled(False)
  133. self.ui.plotGI.pressed.connect( self.plotGI )
  134. # Kernel
  135. self.ui.calcK0.pressed.connect( self.calcK0 )
  136. # Inversion
  137. self.ui.invertButton.pressed.connect( self.QTInv )
  138. # META
  139. self.ui.locEdit.editingFinished.connect( self.logSite )
  140. self.ui.UTMzone.currentIndexChanged.connect( self.logSite )
  141. self.ui.latBand.currentIndexChanged.connect( self.logSite )
  142. self.ui.ellipsoid.currentIndexChanged.connect( self.logSite )
  143. self.ui.incSpinBox.valueChanged.connect( self.logSite )
  144. self.ui.decSpinBox.valueChanged.connect( self.logSite )
  145. self.ui.intensitySpinBox.valueChanged.connect( self.logSite )
  146. self.ui.tempSpinBox.valueChanged.connect( self.logSite )
  147. self.ui.timeEdit.timeChanged.connect( self.logSite )
  148. self.ui.dateEdit.dateChanged.connect( self.logSite )
  149. # this may call the yaml stuff too often...
  150. self.ui.txtComments.textChanged.connect( self.logSite )
  151. self.ui.plotLoops.pressed.connect( self.plotLoops2 )
  152. self.ui.removeLoopButton.pressed.connect( self.removeLoop )
  153. # Loops
  154. self.ui.addLoopButton.pressed.connect( self.loopAdd )
  155. self.loops = {}
  156. # hide header info box
  157. #self.ui.headerFileBox.setVisible(False)
  158. self.ui.headerFileBox.clicked.connect( self.headerBoxShrink )
  159. self.ui.headerBox2.setVisible(False)
  160. # Clean up the tab widget
  161. self.ui.actionPreprocessing.triggered.connect(self.addPreProc)
  162. self.ui.actionModelling.triggered.connect(self.addModelling)
  163. self.ui.actionInversion.triggered.connect(self.addInversion)
  164. # tabs
  165. #self.ui.ProcTabs.tabCloseRequested.connect( self.closeTabs )
  166. #self.ui.ProcTabs.tabBar().setTabButton(7, QtWidgets.QTabBar.RightSide,None)
  167. self.ui.ProcTabs.removeTab(4)
  168. self.ui.ProcTabs.removeTab(4)
  169. self.ui.ProcTabs.removeTab(4)
  170. self.ui.ProcTabs.removeTab(4)
  171. #self.ui.LoadTab.close( )
  172. # Add progressbar to statusbar
  173. self.ui.barProgress = QtWidgets.QProgressBar()
  174. self.ui.statusbar.addPermanentWidget(self.ui.barProgress, 0);
  175. self.ui.barProgress.setMaximumSize(100, 16777215);
  176. self.ui.barProgress.hide();
  177. self.ui.mplwidget_navigator.setCanvas(self.ui.mplwidget)
  178. #self.ui.mplwidget_navigator_2.setCanvas(self.ui.mplwidget)
  179. self.ui.txRxTable.setColumnCount(4)
  180. self.ui.txRxTable.setRowCount(0)
  181. self.ui.txRxTable.setHorizontalHeaderLabels( ["Label", "Geom.","Turns","Tx/Rx"] )
  182. ##########################################################################
  183. # layer Table
  184. self.ui.layerTableWidget.setRowCount(80)
  185. self.ui.layerTableWidget.setColumnCount(3)
  186. self.ui.layerTableWidget.setHorizontalHeaderLabels( [r"top [m]", r"bottom [m]", "σ [ Ωm]" ] )
  187. # do we want this
  188. self.ui.layerTableWidget.setDragDropOverwriteMode(False)
  189. self.ui.layerTableWidget.setDragEnabled(True)
  190. self.ui.layerTableWidget.setDragDropMode(QtWidgets.QAbstractItemView.InternalMove)
  191. pCell0 = QtWidgets.QTableWidgetItem()
  192. pCell0.setFlags(QtCore.Qt.NoItemFlags) # not selectable
  193. pCell0.setBackground( QtGui.QColor("lightgrey").lighter(110) )
  194. pCell0.setText(str("0"))
  195. self.ui.layerTableWidget.setItem(0, 0, pCell0)
  196. pCell1 = QtWidgets.QTableWidgetItem()
  197. #pCell1.setFlags(QtCore.Qt.NoItemFlags) # not selectable
  198. pCell1.setBackground( QtGui.QColor("lightgrey").lighter(110) )
  199. pCell1.setForeground( QtGui.QColor("black").lighter(110) )
  200. self.ui.layerTableWidget.setItem(0, 1, pCell1)
  201. for ir in range(1, self.ui.layerTableWidget.rowCount() ):
  202. for ic in range(0, self.ui.layerTableWidget.columnCount() ):
  203. pCell = QtWidgets.QTableWidgetItem()
  204. #pCell.setFlags(QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable)
  205. pCell.setFlags(QtCore.Qt.NoItemFlags) # not selectable
  206. pCell.setBackground( QtGui.QColor("lightgrey").lighter(110) )
  207. pCell.setForeground( QtGui.QColor("black"))
  208. self.ui.layerTableWidget.setItem(ir, ic, pCell)
  209. self.ui.layerTableWidget.cellChanged.connect(self.sigmaCellChanged)
  210. def LCDHarmonics(self):
  211. self.ui.lcdH1F.setEnabled(True)
  212. self.ui.lcdH1F.display( self.ui.f0Spin.value() * self.ui.f0K1Spin.value() )
  213. self.ui.lcdHNF.setEnabled(True)
  214. self.ui.lcdHNF.display( self.ui.f0Spin.value() * self.ui.f0KNSpin.value() )
  215. self.ui.lcdf0NK.setEnabled(True)
  216. self.ui.lcdf0NK.display( (self.ui.f0KNSpin.value()+1-self.ui.f0K1Spin.value()) * self.ui.f0KsSpin.value() )
  217. def LCDHarmonics2(self):
  218. if self.ui.NHarmonicsFreqsSpin.value() == 2:
  219. self.ui.lcdH1F2.setEnabled(True)
  220. self.ui.lcdH1F2.display( self.ui.f1Spin.value() * self.ui.f1K1Spin.value() )
  221. self.ui.lcdHNF2.setEnabled(True)
  222. self.ui.lcdHNF2.display( self.ui.f1Spin.value() * self.ui.f1KNSpin.value() )
  223. self.ui.lcdf0NK2.setEnabled(True)
  224. self.ui.lcdf0NK2.display( (self.ui.f1KNSpin.value()+1-self.ui.f1K1Spin.value()) * self.ui.f1KsSpin.value() )
  225. else:
  226. self.ui.lcdH1F2.setEnabled(False)
  227. self.ui.lcdHNF2.setEnabled(False)
  228. self.ui.lcdf0NK2.setEnabled(False)
  229. def closeTabs(self):
  230. #self.ui.ProcTabs.removeTab(idx)
  231. self.ui.ProcTabs.clear( )
  232. def addPreProc(self):
  233. if self.ui.actionPreprocessing.isChecked():
  234. self.ui.actionModelling.setChecked(False)
  235. self.ui.actionInversion.setChecked(False)
  236. self.ui.ProcTabs.clear( )
  237. self.ui.ProcTabs.insertTab( 0, self.ui.LoadTab, "Load" )
  238. self.ui.ProcTabs.insertTab( 1, self.ui.NCTab, "NC" )
  239. self.ui.ProcTabs.insertTab( 2, self.ui.QCTab, "QC" )
  240. self.ui.ProcTabs.insertTab( 3, self.ui.METATab, "META" )
  241. self.ui.ProcTabs.insertTab( 4, self.ui.LogTab, "Log" )
  242. else:
  243. self.ui.ProcTabs.removeTab(0)
  244. self.ui.ProcTabs.removeTab(0)
  245. self.ui.ProcTabs.removeTab(0)
  246. self.ui.ProcTabs.removeTab(0)
  247. def addModelling(self):
  248. if self.ui.actionModelling.isChecked():
  249. self.ui.actionPreprocessing.setChecked(False)
  250. self.ui.actionInversion.setChecked(False)
  251. self.ui.ProcTabs.clear( )
  252. self.ui.ProcTabs.insertTab( 0, self.ui.KernTab, "Kernel" )
  253. self.ui.ProcTabs.insertTab( 1, self.ui.ModelTab, "Modelling" )
  254. self.ui.ProcTabs.insertTab( 2, self.ui.LogTab, "Log" )
  255. else:
  256. self.ui.ProcTabs.removeTab(0)
  257. self.ui.ProcTabs.removeTab(0)
  258. def addInversion(self, idx):
  259. if self.ui.actionInversion.isChecked():
  260. self.ui.actionPreprocessing.setChecked(False)
  261. self.ui.actionModelling.setChecked(False)
  262. self.ui.ProcTabs.clear( )
  263. self.ui.ProcTabs.insertTab( 0, self.ui.InvertTab, "Inversion" )
  264. self.ui.ProcTabs.insertTab( 1, self.ui.AppraiseTab, "Appraisal" )
  265. self.ui.ProcTabs.insertTab( 2, self.ui.LogTab, "Log" )
  266. else:
  267. self.ui.ProcTabs.removeTab(0)
  268. self.ui.ProcTabs.removeTab(0)
  269. def QTInv(self):
  270. print("Big RED INVERT BUTTON")
  271. try:
  272. with open('.akvo.last.path') as f:
  273. fpath = f.readline()
  274. pass
  275. except IOError as e:
  276. fpath = '.'
  277. akvoDatafile = QtWidgets.QFileDialog.getOpenFileName(self, 'Select Datafile File', fpath, r"Akvo datafiles (*.yaml)")[0]
  278. K0file = QtWidgets.QFileDialog.getOpenFileName(self, 'Select Kernel File', fpath, r"Akvo kernels (*.yml)")[0]
  279. T2lo = self.ui.T2low.value()
  280. T2hi = self.ui.T2hi.value()
  281. NT2 = self.ui.NT2.value()
  282. dataChan = self.ui.invChan.currentText()
  283. invDict = dict()
  284. invDict["data"] = dict()
  285. invDict["data"] = dict()
  286. invDict["data"][akvoDatafile] = dict()
  287. invDict["data"][akvoDatafile]["channels"] = [dataChan,]
  288. invDict["K0"] = [K0file,]
  289. invDict["T2Bins"] = dict()
  290. invDict["T2Bins"]["low"] = T2lo
  291. invDict["T2Bins"]["high"] = T2hi
  292. invDict["T2Bins"]["number"] = NT2
  293. node = yaml.YAML()
  294. kpo = open( "invert.yml", 'w' )
  295. node.dump(invDict, kpo)
  296. callBox = callScript( ) #QtWidgets.QDialog()
  297. callBox.ui = Ui_callScript()
  298. callBox.ui.setupUi( callBox )
  299. callBox.setupQTInv( "invert.yml" )
  300. callBox.exec_()
  301. callBox.show()
  302. def calcK0(self):
  303. try:
  304. with open('.akvo.last.path') as f:
  305. fpath = f.readline()
  306. pass
  307. except IOError as e:
  308. fpath = '.'
  309. akvoData = QtWidgets.QFileDialog.getOpenFileName(self, 'Open Datafile File', fpath, r"Akvo datafiles (*.yaml)")[0]
  310. txCoil = QtWidgets.QFileDialog.getOpenFileName(self, 'Open Tx File', fpath, r"Akvo datafiles (*.yaml, *.yml)")[0]
  311. saveStr = QtWidgets.QFileDialog.getSaveFileName(self, "Save kernel as", fpath, r"Merlin KernelV0 (*.yml)")[0]
  312. intDict = dict()
  313. intDict["origin_n"] = self.ui.originN.value()
  314. intDict["origin_e"] = self.ui.originE.value()
  315. intDict["origin_d"] = self.ui.originD.value()
  316. intDict["size_n"] = self.ui.sizeN.value()
  317. intDict["size_e"] = self.ui.sizeE.value()
  318. intDict["size_d"] = self.ui.sizeD.value()
  319. intDict["nLay"] = self.ui.NLayers.value()
  320. intDict["thick1"] = self.ui.thick1.value()
  321. intDict["thickN"] = self.ui.thickN.value()
  322. intDict["Lspacing"] = self.ui.layerSpacing.currentText()
  323. intDict["minLevel"] = self.ui.minLevel.value()
  324. intDict["maxLevel"] = self.ui.maxLevel.value()
  325. intDict["branchTol"] = self.ui.branchTol.value()
  326. # conductivity model...
  327. #tops = self.ui.layerTableWidget.col(0)
  328. #print("Tops", tops)
  329. tops = []
  330. itop = 0
  331. while self.ui.layerTableWidget.item(itop, 0).text():
  332. tops.append( float(self.ui.layerTableWidget.item(itop,0).text()) )
  333. itop += 1
  334. bots = []
  335. ibot = 0
  336. while self.ui.layerTableWidget.item(ibot, 1).text():
  337. bots.append( float(self.ui.layerTableWidget.item(ibot, 1).text()) )
  338. ibot += 1
  339. sigs = []
  340. isig = 0
  341. while self.ui.layerTableWidget.item(isig, 2).text():
  342. sigs.append( 1./float(self.ui.layerTableWidget.item(isig, 2).text()) )
  343. isig += 1
  344. intDict["tops"] = tops
  345. intDict["bots"] = bots
  346. intDict["sigs"] = sigs
  347. node = yaml.YAML()
  348. kpo = open( "kparams.yml", 'w' )
  349. node.dump(intDict, kpo)
  350. callBox = callScript( ) #QtWidgets.QDialog()
  351. callBox.ui = Ui_callScript()
  352. callBox.ui.setupUi( callBox )
  353. callBox.setupCB( akvoData, txCoil, "kparams.yml", saveStr )
  354. callBox.exec_()
  355. callBox.show()
  356. def loopAdd(self):
  357. #print(self.ui.loopLabel.text())
  358. #print(self.ui.loopGeom.currentText())
  359. #print(self.ui.loopType.currentText())
  360. #print( "label len", len(self.ui.loopLabel.text()) )
  361. if len(self.ui.loopLabel.text().strip()) == 0:
  362. Error = QtWidgets.QMessageBox()
  363. Error.setWindowTitle("Error!")
  364. Error.setText("Loop label cannot be blank or repeated")
  365. Error.setDetailedText("Each loop label must be unique and comprise at least one character. Leading and trailing whitespace will be trimmed.")
  366. Error.exec_()
  367. else:
  368. ### Circular loop
  369. if self.ui.loopGeom.currentText() == "Circular":
  370. dialog = QtWidgets.QDialog()
  371. dialog.ui = Ui_circularLoopAdd()
  372. dialog.ui.setupUi(dialog)
  373. dialog.exec_()
  374. dialog.show()
  375. if dialog.result():
  376. cn = dialog.ui.centreNorth.value()
  377. ce = dialog.ui.centreEast.value()
  378. ht = dialog.ui.loopHeight.value()
  379. rad = dialog.ui.loopRadius.value()
  380. turns = dialog.ui.loopTurns.value()
  381. ns = dialog.ui.segments.value()
  382. cwise = dialog.ui.cwiseBox.currentIndex()
  383. #print("cwise", cwise)
  384. #dip = dialog.ui.dip.value()
  385. #azimuth = dialog.ui.az.value()
  386. self.loops[self.ui.loopLabel.text()] = FDEM1D.PolygonalWireAntenna()
  387. self.loops[self.ui.loopLabel.text()].SetNumberOfPoints( dialog.ui.segments.value() + 1 )
  388. self.loops[self.ui.loopLabel.text()].SetNumberOfTurns( dialog.ui.loopTurns.value() )
  389. points = np.linspace(0, 2*np.pi, dialog.ui.segments.value()+1)
  390. for iseg, ipt in enumerate(points):
  391. if cwise == 0:
  392. self.loops[self.ui.loopLabel.text()].SetPoint(iseg, ( cn+rad*np.sin(ipt), ce+rad*np.cos(ipt), ht) )
  393. else:
  394. self.loops[self.ui.loopLabel.text()].SetPoint(iseg, ( -cn+rad*np.sin(ipt), ce+rad*np.cos(ipt), ht) )
  395. self.loops[self.ui.loopLabel.text()].SetNumberOfFrequencies(1)
  396. self.loops[self.ui.loopLabel.text()].SetCurrent(1.)
  397. if self.ui.loopGeom.currentText() == "figure-8":
  398. dialog = QtWidgets.QDialog()
  399. dialog.ui = Ui_figure8LoopAdd()
  400. dialog.ui.setupUi(dialog)
  401. dialog.exec_()
  402. dialog.show()
  403. if dialog.result():
  404. cn1 = dialog.ui.centreNorth1.value()
  405. ce1 = dialog.ui.centreEast1.value()
  406. cn2 = dialog.ui.centreNorth2.value()
  407. ce2 = dialog.ui.centreEast2.value()
  408. ht = dialog.ui.loopHeight.value()
  409. rad = dialog.ui.loopRadius.value()
  410. turns = dialog.ui.loopTurns.value()
  411. ns = dialog.ui.segments.value()
  412. #cwise = dialog.ui.cwiseBox.currentIndex()
  413. print(cn1, ce1, cn2, ce2, ht, rad, turns, ns)
  414. if self.ui.loopGeom.currentText() == "polygon":
  415. dialog = QtWidgets.QDialog()
  416. dialog.ui = Ui_polygonalLoopAdd()
  417. dialog.ui.setupUi(dialog)
  418. ##########################################################################
  419. # Loop Table
  420. dialog.ui.loopTableWidget.setRowCount(80)
  421. dialog.ui.loopTableWidget.setColumnCount(3)
  422. #dialog.ui.loopTableWidget.horizontalHeader().setSectionResizeMode(0, QtGui.Qt.QHeaderView.Stretch)
  423. dialog.ui.loopTableWidget.setHorizontalHeaderLabels( \
  424. ["Northing [m]","Easting [m]","Height [m]"])
  425. for ir in range(0, dialog.ui.loopTableWidget.rowCount() ):
  426. for ic in range(0, 3): #dialog.ui.loopTableWidget.columnCount() ):
  427. pCell = QtWidgets.QTableWidgetItem()
  428. #pCell.setFlags(QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable)
  429. #pCell.setFlags(QtCore.Qt.NoItemFlags) # not selectable
  430. #pCell.setBackground( QtGui.QColor("lightgrey").lighter(110) )
  431. dialog.ui.loopTableWidget.setItem(ir, ic, pCell)
  432. #dialog.ui.loopTableWidget.cellChanged.connect(self.loopCellChanged)
  433. #dialog.ui.loopTableWidget.itemClicked.connect(self.loopCellClicked)
  434. #self.ui.loopTableWidget.cellPressed.connect(self.loopCellChanged)
  435. #self.ui.loopTableWidget.cellPressed.connect(self.loopCellClicked)
  436. dialog.ui.loopTableWidget.setDragDropOverwriteMode(False)
  437. dialog.ui.loopTableWidget.setDragEnabled(False)
  438. #self.ui.loopTableWidget.setDragDropMode(QtWidgets.QAbstractItemView.InternalMove)
  439. dialog.ui.loopTableWidget.resizeColumnsToContents()
  440. dialog.exec_()
  441. dialog.show()
  442. if dialog.result():
  443. self.loops[self.ui.loopLabel.text()] = FDEM1D.PolygonalWireAntenna()
  444. self.loops[self.ui.loopLabel.text()].SetNumberOfTurns( dialog.ui.loopTurns.value() )
  445. npts = 0
  446. for ir in range(0, dialog.ui.loopTableWidget.rowCount() ):
  447. if len(dialog.ui.loopTableWidget.item(ir, 0).text()) == 0:
  448. break
  449. npts += 1
  450. self.loops[self.ui.loopLabel.text()].SetNumberOfPoints( npts )
  451. for ir in range( 0, npts ):
  452. self.loops[self.ui.loopLabel.text()].SetPoint(ir, eval(dialog.ui.loopTableWidget.item(ir, 0).text()), \
  453. eval(dialog.ui.loopTableWidget.item(ir, 1).text()), \
  454. eval(dialog.ui.loopTableWidget.item(ir, 2).text()) \
  455. )
  456. self.loops[self.ui.loopLabel.text()].SetNumberOfFrequencies(1)
  457. self.loops[self.ui.loopLabel.text()].SetCurrent(1.)
  458. # general across all types
  459. if dialog.result():
  460. yml = open( self.ui.loopLabel.text() + ".yml", 'w' )
  461. print( self.loops[self.ui.loopLabel.text()], file=yml)
  462. # update the table
  463. self.ui.txRxTable.setRowCount( len(self.loops.keys()) )
  464. pCell = QtWidgets.QTableWidgetItem()
  465. pCell.setText( self.ui.loopLabel.text() )
  466. pCell.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled )
  467. self.ui.txRxTable.setItem( len(self.loops.keys())-1, 0, pCell)
  468. gCell = QtWidgets.QTableWidgetItem()
  469. gCell.setText( self.ui.loopGeom.currentText() )
  470. gCell.setFlags( QtCore.Qt.ItemIsEnabled )
  471. self.ui.txRxTable.setItem( len(self.loops.keys())-1, 1, gCell)
  472. tCell = QtWidgets.QTableWidgetItem()
  473. tCell.setText( str(dialog.ui.loopTurns.value()) )
  474. tCell.setFlags( QtCore.Qt.ItemIsEnabled )
  475. self.ui.txRxTable.setItem( len(self.loops.keys())-1, 2, tCell)
  476. txCell = QtWidgets.QTableWidgetItem()
  477. txCell.setText( str(self.ui.loopType.currentText()) )
  478. txCell.setFlags( QtCore.Qt.ItemIsEnabled )
  479. self.ui.txRxTable.setItem( len(self.loops.keys())-1, 3, txCell)
  480. def headerBoxShrink(self):
  481. #self.ui.headerFileBox.setVisible(False)
  482. if self.ui.headerFileBox.isChecked( ):
  483. #self.ui.headerFileBox.setMinimumSize(460,250)
  484. self.ui.headerBox2.setVisible(True)
  485. else:
  486. #self.ui.headerFileBox.setMinimumSize(460,50)
  487. self.ui.headerBox2.setVisible(False)
  488. def sigmaCellChanged(self):
  489. self.ui.layerTableWidget.cellChanged.disconnect(self.sigmaCellChanged)
  490. # TODO consider building the model whenever this is called. Would be nice to be able to
  491. # do that. Would require instead dist of T2 I guess.
  492. jj = self.ui.layerTableWidget.currentColumn()
  493. ii = self.ui.layerTableWidget.currentRow()
  494. val = "class 'NoneType'>"
  495. try:
  496. val = eval (str( self.ui.layerTableWidget.item(ii, jj).text() ))
  497. except:
  498. #if jj != 0:
  499. # Error = QtWidgets.QMessageBox()
  500. # Error.setWindowTitle("Error!")
  501. # Error.setText("Non-numeric value encountered")
  502. self.ui.layerTableWidget.cellChanged.connect(self.sigmaCellChanged)
  503. return
  504. if jj == 1:
  505. #item.setFlags(QtCore.Qt.ItemIsEnabled)
  506. pCell = self.ui.layerTableWidget.item(ii, jj)
  507. pCell.setBackground( QtGui.QColor("white"))
  508. pCell = self.ui.layerTableWidget.item(ii+1, jj-1)
  509. if str(type(pCell)) == "<class 'NoneType'>":
  510. pCell = QtWidgets.QTableWidgetItem()
  511. pCell.setFlags(QtCore.Qt.ItemIsEnabled)
  512. self.ui.layerTableWidget.setItem(ii+1, jj-1, pCell)
  513. if ii == 0:
  514. pCell.setText(str(val))
  515. #pCell3 = self.ui.layerTableWidget.item(ii+1, jj)
  516. #print ("setting", ii, jj, type(pCell3))
  517. #print ( "setting", ii, jj, type(pCell3))
  518. #pCell3.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEditable | QtCore.Qt.ItemIsEnabled )
  519. #pCell3.setFlags( QtCore.Qt.ItemIsEditable )
  520. elif ii > 0:
  521. val2 = eval (str( self.ui.layerTableWidget.item(ii-1, jj).text() ))
  522. #print ("val2", val2, val, type(val))
  523. #if str(type(pCell)) == "<class 'NoneType'>":
  524. if type(val) == str or val > val2:
  525. pCell.setText(str(val))
  526. else:
  527. Error = QtWidgets.QMessageBox()
  528. Error.setWindowTitle("Error!")
  529. Error.setText("Non-increasing layer detected")
  530. Error.setDetailedText("Each layer interface must be below the one above it.")
  531. Error.exec_()
  532. #err_msg = "Quadrature detection has already been done!"
  533. #reply =QtWidgets.QMessageBox.critical(self, 'Error',
  534. # err_msg)
  535. pCell2 = self.ui.layerTableWidget.item(ii, jj)
  536. pCell2.setText(str(""))
  537. self.ui.layerTableWidget.cellChanged.connect(self.sigmaCellChanged)
  538. return
  539. # enable next layer
  540. pCell4 = self.ui.layerTableWidget.item(ii+1, jj)
  541. pCell4.setBackground( QtGui.QColor("lightblue") ) #.lighter(110))
  542. pCell4.setForeground( QtGui.QColor("black"))
  543. pCell4.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEditable | QtCore.Qt.ItemIsEnabled )
  544. pCell5 = self.ui.layerTableWidget.item(ii+1, jj+1)
  545. pCell5.setBackground( QtGui.QColor("white"))
  546. pCell5.setForeground( QtGui.QColor("black"))
  547. pCell5.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEditable | QtCore.Qt.ItemIsEnabled )
  548. if ii == 0 and jj == 0:
  549. pCell = self.ui.layerTableWidget.item(0, 1)
  550. pCell.setBackground(QtGui.QColor("lightblue")) #.lighter(110) )
  551. pCell.setForeground( QtGui.QColor("black"))
  552. pCell.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEditable | QtCore.Qt.ItemIsEnabled )
  553. self.ui.layerTableWidget.cellChanged.connect(self.sigmaCellChanged)
  554. def plotLoops2(self):
  555. self.ui.mplwidget.reAxH(1)
  556. for loop in self.loops:
  557. POINTS = self.loops[loop].GetPoints().T
  558. self.ui.mplwidget.ax1.plot( POINTS[:,1], POINTS[:,0], label=loop )
  559. self.ui.mplwidget.ax1.spines['right'].set_visible(False)
  560. self.ui.mplwidget.ax1.spines['top'].set_visible(False)
  561. self.ui.mplwidget.ax1.set_xlabel("easting (m)")
  562. self.ui.mplwidget.ax1.set_ylabel("northing (m)")
  563. self.ui.mplwidget.ax1.legend()
  564. self.ui.mplwidget.ax1.set_aspect('equal') #, adjustable='box')
  565. self.ui.mplwidget.draw()
  566. def removeLoop(self):
  567. del self.loops[ self.ui.txRxTable.item( self.ui.txRxTable.currentRow(), 0).text() ]
  568. self.ui.txRxTable.removeRow(self.ui.txRxTable.currentRow())
  569. def about(self):
  570. # TODO proper popup with info
  571. #self.w = MyPopup("""About Akvo \n
  572. # Akvo is an open source project developed primarily by Trevor Irons.
  573. #""")
  574. #self.w.setGeometry(100, 100, 400, 200)
  575. #self.w.show()
  576. #print("ABOUT")
  577. # Just a splash screen for now
  578. logo = pkg_resources.resource_filename(__name__, 'akvo-about.png')
  579. pixmap = QtGui.QPixmap(logo)
  580. self.splash = QtWidgets.QSplashScreen(pixmap, QtCore.Qt.WindowStaysOnTopHint)
  581. self.splash.show()
  582. def connectGMRDataProcessor(self):
  583. self.RAWDataProc = mrsurvey.GMRDataProcessor()
  584. self.RAWDataProc.progressTrigger.connect(self.updateProgressBar)
  585. self.RAWDataProc.enableDSPTrigger.connect(self.enableDSP)
  586. self.RAWDataProc.doneTrigger.connect(self.doneStatus)
  587. self.RAWDataProc.updateProcTrigger.connect(self.updateProc)
  588. def openGMRRAWDataset(self):
  589. """ Opens a GMR header file
  590. """
  591. try:
  592. with open('.gmr.last.path') as f:
  593. fpath = f.readline()
  594. pass
  595. except IOError as e:
  596. fpath = '.'
  597. self.headerstr = QtWidgets.QFileDialog.getOpenFileName(self, 'Open File', fpath)[0] # arg2 = File Type 'All Files (*)'
  598. self.ui.headerFileTextBrowser.clear()
  599. self.ui.headerFileTextBrowser.append(self.headerstr)
  600. if len(self.headerstr) == 0:
  601. return
  602. # clear the processing log
  603. self.ui.logTextBrowser.clear()
  604. self.logText = [] #MAK 20170126
  605. path,filen=os.path.split(str(self.headerstr))
  606. f = open('.gmr.last.path', 'w')
  607. f.write( str(self.headerstr) ) # prompt last file
  608. self.connectGMRDataProcessor()
  609. self.RAWDataProc.readHeaderFile(str(self.headerstr))
  610. # If we got this far, enable all the widgets
  611. self.ui.lcdNumberTauPulse1.setEnabled(True)
  612. self.ui.lcdNumberNuTx.setEnabled(True)
  613. self.ui.lcdNumberTuneuF.setEnabled(True)
  614. self.ui.lcdNumberSampFreq.setEnabled(True)
  615. self.ui.lcdNumberNQ.setEnabled(True)
  616. self.ui.headerFileBox.setEnabled(True)
  617. self.ui.headerFileBox.setChecked( True )
  618. self.ui.headerBox2.setVisible(True)
  619. self.ui.inputRAWParametersBox.setEnabled(True)
  620. self.ui.loadDataPushButton.setEnabled(True)
  621. # make plots as you import the dataset
  622. self.ui.plotImportCheckBox.setEnabled(True)
  623. self.ui.plotImportCheckBox.setChecked(True)
  624. # Update info from the header into the GUI
  625. self.ui.pulseTypeTextBrowser.clear()
  626. self.ui.pulseTypeTextBrowser.append(self.RAWDataProc.pulseType)
  627. self.ui.lcdNumberNuTx.display(self.RAWDataProc.transFreq)
  628. self.ui.lcdNumberTauPulse1.display(1e3*self.RAWDataProc.pulseLength[0])
  629. self.ui.lcdNumberTuneuF.display(self.RAWDataProc.TuneCapacitance)
  630. self.ui.lcdNumberSampFreq.display(self.RAWDataProc.samp)
  631. self.ui.lcdNumberNQ.display(self.RAWDataProc.nPulseMoments)
  632. self.ui.DeadTimeSpinBox.setValue(1e3*self.RAWDataProc.deadTime)
  633. self.ui.CentralVSpinBox.setValue( self.RAWDataProc.transFreq )
  634. if self.RAWDataProc.pulseType != "FID":
  635. self.ui.lcdNumberTauPulse2.setEnabled(1)
  636. self.ui.lcdNumberTauPulse2.display(1e3*self.RAWDataProc.pulseLength[1])
  637. self.ui.lcdNumberTauDelay.setEnabled(1)
  638. self.ui.lcdNumberTauDelay.display(1e3*self.RAWDataProc.interpulseDelay)
  639. self.ui.FIDProcComboBox.clear()
  640. if self.RAWDataProc.pulseType == "4PhaseT1" or self.RAWDataProc.pulseType == "T1":
  641. self.ui.FIDProcComboBox.insertItem(0, "Pulse 1")
  642. self.ui.FIDProcComboBox.insertItem(1, "Pulse 2")
  643. self.ui.FIDProcComboBox.insertItem(2, "Both")
  644. self.ui.FIDProcComboBox.setCurrentIndex (1)
  645. elif self.RAWDataProc.pulseType == "FID":
  646. self.ui.FIDProcComboBox.insertItem(0, "Pulse 1")
  647. self.ui.FIDProcComboBox.setCurrentIndex (0)
  648. def ExportPreprocess(self):
  649. """ This method exports to YAML
  650. """
  651. try:
  652. with open('.akvo.last.yaml.path') as f:
  653. fpath = f.readline()
  654. pass
  655. except IOError as e:
  656. fpath = '.'
  657. fdir = os.path.dirname(fpath)
  658. # Pickle the preprocessed data dictionary
  659. SaveStr = QtWidgets.QFileDialog.getSaveFileName(self, "Save as", fdir, r"Processed data (*.yaml)")[0]
  660. spath,filen=os.path.split(str(SaveStr))
  661. f = open('.akvo.last.yaml.path', 'w')
  662. f.write( str(spath) ) # prompt last file
  663. INFO = {}
  664. INFO["headerstr"] = str(self.headerstr)
  665. INFO["pulseType"] = self.RAWDataProc.pulseType
  666. INFO["transFreq"] = self.RAWDataProc.transFreq.tolist()
  667. INFO["pulseLength"] = self.RAWDataProc.pulseLength.tolist()
  668. INFO["TuneCapacitance"] = self.RAWDataProc.TuneCapacitance.tolist()
  669. #INFO["samp"] = self.RAWDataProc.samp
  670. INFO["nPulseMoments"] = self.RAWDataProc.nPulseMoments
  671. #INFO["deadTime"] = self.RAWDataProc.deadTime
  672. INFO["processed"] = "Akvo v. 1.0, on " + time.strftime("%d/%m/%Y")
  673. # Pulse current info
  674. ip = 0
  675. INFO["Pulses"] = {}
  676. for pulse in self.RAWDataProc.DATADICT["PULSES"]:
  677. qq = []
  678. qv = []
  679. for ipm in range(self.RAWDataProc.DATADICT["nPulseMoments"]):
  680. #for istack in self.RAWDataProc.DATADICT["stacks"]:
  681. # print ("stack q", self.RAWDataProc.DATADICT[pulse]["Q"][ipm,istack-1])
  682. qq.append(np.mean( self.RAWDataProc.DATADICT[pulse]["Q"][ipm,:]) )
  683. qv.append(np.std( self.RAWDataProc.DATADICT[pulse]["Q"][ipm,:]/self.RAWDataProc.pulseLength[ip] ))
  684. qq = np.array(qq)
  685. qv = np.array(qv)
  686. iQ = np.argsort(np.array(qq))
  687. qq = np.array(qq)[iQ]
  688. qv = np.array(qv)[iQ]
  689. INFO["Pulses"][pulse] = {}
  690. INFO["Pulses"][pulse]["units"] = "A"
  691. INFO["Pulses"][pulse]["current"] = VectorXr(qq/self.RAWDataProc.pulseLength[ip])
  692. INFO["Pulses"][pulse]["variance"] = VectorXr(qv)
  693. ip += 1
  694. # Data
  695. if self.RAWDataProc.gated == True:
  696. INFO["Gated"] = {}
  697. INFO["Gated"]["abscissa units"] = "ms"
  698. INFO["Gated"]["data units"] = "nT"
  699. for pulse in self.RAWDataProc.DATADICT["PULSES"]:
  700. INFO["Gated"][pulse] = {}
  701. INFO["Gated"][pulse]["abscissa"] = VectorXr( self.RAWDataProc.GATEDABSCISSA )
  702. INFO["Gated"][pulse]["windows"] = VectorXr( self.RAWDataProc.GATEDWINDOW )
  703. for ichan in self.RAWDataProc.DATADICT[pulse]["chan"]:
  704. INFO["Gated"][pulse]["Chan. " + str(ichan)] = {}
  705. #INFO["Gated"][pulse]["Chan. " + str(ichan)]["STD"] = VectorXr( np.std(self.RAWDataProc.GATED[ichan]["NR"], axis=0) )
  706. INFO["Gated"][pulse]["Chan. " + str(ichan)]["STD"] = VectorXr( np.average(self.RAWDataProc.GATED[ichan]["BN"], axis=0) )
  707. for ipm in range(self.RAWDataProc.DATADICT["nPulseMoments"]):
  708. INFO["Gated"][pulse]["Chan. " + str(ichan)]["Q-"+str(ipm) + " CA"] = VectorXr(self.RAWDataProc.GATED[ichan]["CA"][ipm])
  709. INFO["Gated"][pulse]["Chan. " + str(ichan)]["Q-"+str(ipm) + " RE"] = VectorXr(self.RAWDataProc.GATED[ichan]["RE"][ipm])
  710. INFO["Gated"][pulse]["Chan. " + str(ichan)]["Q-"+str(ipm) + " IM"] = VectorXr(self.RAWDataProc.GATED[ichan]["IM"][ipm])
  711. #INFO["Gated"][pulse]["Chan. " + str(ichan)]["Q-"+str(ipm) + " IP"] = VectorXr(self.RAWDataProc.GATED[ichan]["IP"][ipm])
  712. #INFO["Gated"][pulse]["Chan. " + str(ichan)]["Q-"+str(ipm) + " NR"] = VectorXr(self.RAWDataProc.GATED[ichan]["NR"][ipm])
  713. #INFO["Gated"][pulse]["Chan. " + str(ichan)]["Q-"+str(ipm) + " STD" ] = VectorXr(self.RAWDataProc.GATED[ichan]["SIGMA"][ipm])
  714. # we have gated data
  715. # Window edges
  716. # Window centres
  717. with open(SaveStr, 'w') as outfile:
  718. #for line in self.logText:
  719. # outfile.write(line+"\n")
  720. yaml.dump(self.YamlNode, outfile)
  721. yaml.dump(INFO, outfile) #, default_flow_style=False)
  722. def SavePreprocess(self):
  723. #if "Saved" not in self.YamlNode.Processing.keys():
  724. # self.YamlNode.Processing["Saved"] = []
  725. #self.YamlNode.Processing["Saved"].append(datetime.datetime.now().isoformat())
  726. #self.Log()
  727. import pickle, os
  728. try:
  729. with open('.akvo.last.path') as f:
  730. fpath = f.readline()
  731. pass
  732. except IOError as e:
  733. fpath = '.'
  734. fdir = os.path.dirname(fpath)
  735. # Pickle the preprocessed data dictionary
  736. SaveStr = QtWidgets.QFileDialog.getSaveFileName(self, "Save as", fdir, r"Pickle (*.dmp)")
  737. spath,filen=os.path.split(str(SaveStr[0]))
  738. f = open('.akvo.last.path', 'w')
  739. f.write( str(spath) ) # prompt last file
  740. save = open(SaveStr[0], 'wb')
  741. # Add some extra info
  742. INFO = {}
  743. INFO["pulseType"] = self.RAWDataProc.pulseType
  744. INFO["prePulseDelay"] = self.RAWDataProc.prePulseDelay
  745. INFO["interpulseDelay"] = self.RAWDataProc.interpulseDelay
  746. INFO["transFreq"] = self.RAWDataProc.transFreq
  747. INFO["pulseLength"] = self.RAWDataProc.pulseLength
  748. INFO["TuneCapacitance"] = self.RAWDataProc.TuneCapacitance
  749. INFO["samp"] = self.RAWDataProc.samp
  750. INFO["nPulseMoments"] = self.RAWDataProc.nPulseMoments
  751. INFO["deadTime"] = self.RAWDataProc.deadTime
  752. INFO["transFreq"] = self.RAWDataProc.transFreq
  753. INFO["headerstr"] = str(self.headerstr)
  754. INFO["nDAQVersion"] = self.RAWDataProc.nDAQVersion
  755. INFO["log"] = yaml.dump( self.YamlNode )
  756. TXRX = []
  757. for ir in range(0, self.ui.txRxTable.rowCount() ):
  758. txrx = []
  759. for ic in range(0, self.ui.txRxTable.columnCount() ):
  760. txrx.append( self.ui.txRxTable.item(ir, ic).text() )
  761. TXRX.append(txrx)
  762. INFO["TXRX"] = TXRX
  763. #
  764. print("META SAVE")
  765. print("INFO log", INFO["log"])
  766. self.RAWDataProc.DATADICT["INFO"] = INFO
  767. pickle.dump(self.RAWDataProc.DATADICT, save)
  768. save.close()
  769. # Export XML file suitable for USGS ScienceBase Data Release
  770. def ExportXML(self):
  771. """ This is a filler function for use by USGS collaborators
  772. """
  773. return 42
  774. def OpenPreprocess(self):
  775. import pickle
  776. try:
  777. with open('.akvo.last.path') as f:
  778. fpath = f.readline()
  779. pass
  780. except IOError as e:
  781. fpath = '.'
  782. #filename = QtWidgets.QFileDialog.getOpenFileName(self, 'Open File', '.')
  783. fpath = QtWidgets.QFileDialog.getOpenFileName(self, 'Open preprocessed file', fpath, r"Pickle Files (*.dmp)")[0]
  784. f = open('.akvo.last.path', 'w')
  785. f.write( str(fpath) ) # prompt last file
  786. self.ui.logTextBrowser.clear()
  787. self.logText = []
  788. if len(fpath) == 0:
  789. return
  790. pfile = open(fpath,'rb')
  791. unpickle = pickle.Unpickler(pfile)
  792. self.connectGMRDataProcessor()
  793. self.RAWDataProc.DATADICT = unpickle.load()
  794. # This line causes Akvo to crash, if the header file is no longer there. We don't need to load the
  795. # file. TODO, need to disable "Load Data" in Load command though, as that is no longer possible.
  796. #self.RAWDataProc.readHeaderFile(self.RAWDataProc.DATADICT["INFO"]["headerstr"])
  797. self.headerstr = self.RAWDataProc.DATADICT["INFO"]["headerstr"]
  798. self.RAWDataProc.pulseType = self.RAWDataProc.DATADICT["INFO"]["pulseType"]
  799. self.RAWDataProc.transFreq = self.RAWDataProc.DATADICT["INFO"]["transFreq"]
  800. self.RAWDataProc.pulseLength = self.RAWDataProc.DATADICT["INFO"]["pulseLength"]
  801. self.RAWDataProc.TuneCapacitance = self.RAWDataProc.DATADICT["INFO"]["TuneCapacitance"]
  802. self.RAWDataProc.samp = self.RAWDataProc.DATADICT["INFO"]["samp"]
  803. self.RAWDataProc.nPulseMoments = self.RAWDataProc.DATADICT["INFO"]["nPulseMoments"]
  804. self.RAWDataProc.deadTime = self.RAWDataProc.DATADICT["INFO"]["deadTime"]
  805. self.RAWDataProc.transFreq = self.RAWDataProc.DATADICT["INFO"]["transFreq"]
  806. self.RAWDataProc.nDAQVersion = self.RAWDataProc.DATADICT["INFO"]["nDAQVersion"]
  807. #self.RAWDataProc.prePulseDelay = self.RAWDataProc.DATADICT["INFO"]["prePulseDelay"]
  808. self.RAWDataProc.dt = 1./self.RAWDataProc.samp
  809. self.dataChan = self.RAWDataProc.DATADICT[ self.RAWDataProc.DATADICT["PULSES"][0] ]["chan"]
  810. # Keep backwards compatibility with prior saved pickles???
  811. #self.ui.logTextBrowser.clear()
  812. #self.ui.logTextBrowser.append( yaml.dump(self.YamlNode)) #, default_flow_style=False) )
  813. #for a in self.logText:
  814. # self.ui.logTextBrowser.append(str(a))
  815. #self.ui.logTextBrowser
  816. #self.ui.logTextBrowser.clear()
  817. #print ( self.RAWDataProc.DATADICT["INFO"]["log"] )
  818. if "TXRX" in self.RAWDataProc.DATADICT["INFO"].keys():
  819. TXRX = self.RAWDataProc.DATADICT["INFO"]["TXRX"]
  820. self.ui.txRxTable.setRowCount( len(TXRX))
  821. for irow, row in enumerate(TXRX):
  822. for icol, val in enumerate(row):
  823. pCell = QtWidgets.QTableWidgetItem()
  824. pCell.setText( val )
  825. pCell.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled )
  826. self.ui.txRxTable.setItem(irow, icol, pCell)
  827. self.logText = self.RAWDataProc.DATADICT["INFO"]["log"] # YAML
  828. parse = yaml.load( self.logText, Loader=yaml.Loader )
  829. self.YamlNode = AkvoYamlNode( ) #self.logText )
  830. self.YamlNode.Akvo_VERSION = (yaml.load( self.logText, Loader=yaml.Loader )).Akvo_VERSION
  831. AKVO_VERSION = np.array(self.YamlNode.Akvo_VERSION.split("."), dtype=int)
  832. if AKVO_VERSION[0] >= 1 and AKVO_VERSION[1] >= 2 and AKVO_VERSION[2] >= 3:
  833. self.RAWDataProc.interpulseDelay = self.RAWDataProc.DATADICT["INFO"]["interpulseDelay"]
  834. self.YamlNode.Import = OrderedDict(parse.Import)
  835. self.YamlNode.Processing = list(parse.Processing)
  836. self.YamlNode.Stacking = OrderedDict(parse.Stacking)
  837. self.YamlNode.META = OrderedDict(parse.META)
  838. self.logGUI()
  839. self.Log()
  840. #self.ui.logTextBrowser.append( yaml.dump(self.YamlNode)) #, default_flow_style=False) )
  841. #except KeyError:
  842. # pass
  843. # Remove "Saved" and "Loaded" from processing flow
  844. #if "Loaded" not in self.YamlNode.Processing.keys():
  845. # self.YamlNode.Processing["Loaded"] = []
  846. #self.YamlNode.Processing["Loaded"].append(datetime.datetime.now().isoformat())
  847. #self.Log()
  848. # If we got this far, enable all the widgets
  849. self.ui.lcdNumberTauPulse1.setEnabled(True)
  850. self.ui.lcdNumberNuTx.setEnabled(True)
  851. self.ui.lcdNumberTuneuF.setEnabled(True)
  852. self.ui.lcdNumberSampFreq.setEnabled(True)
  853. self.ui.lcdNumberNQ.setEnabled(True)
  854. self.ui.headerFileBox.setEnabled(True)
  855. self.ui.headerFileBox.setChecked( True )
  856. self.headerBoxShrink()
  857. #self.ui.headerBox2.setVisible(True)
  858. self.ui.inputRAWParametersBox.setEnabled(False)
  859. self.ui.loadDataPushButton.setEnabled(True)
  860. # make plots as you import the datasetmost
  861. self.ui.plotImportCheckBox.setEnabled(True)
  862. self.ui.plotImportCheckBox.setChecked(True)
  863. # enable the LCDs
  864. self.ui.lcdNumberFID1Length.setEnabled(1)
  865. self.ui.lcdNumberFID2Length.setEnabled(1)
  866. self.ui.lcdNumberResampFreq.setEnabled(1)
  867. self.ui.lcdTotalDeadTime.setEnabled(1)
  868. # enable META tab
  869. self.ui.METATab.setEnabled(1)
  870. self.ui.siteBox.setEnabled(1)
  871. #self.ui.lcdTotalDeadTime.display( 1e3*self.RAWDataProc.DATADICT["INFO"]["deadTime"] )
  872. self.ui.headerFileTextBrowser.clear( )
  873. self.ui.headerFileTextBrowser.append( self.RAWDataProc.DATADICT["INFO"]["headerstr"] )
  874. if u"Pulse 1" in self.RAWDataProc.DATADICT.keys():
  875. self.ui.lcdNumberFID1Length.display(self.RAWDataProc.DATADICT["Pulse 1"]["TIMES"][-1]- self.RAWDataProc.DATADICT["Pulse 1"]["TIMES"][0])
  876. self.ui.lcdTotalDeadTime.display( round(1e3*(self.RAWDataProc.DATADICT["Pulse 1"]["TIMES"][0]-self.RAWDataProc.DATADICT["Pulse 1"]["PULSE_TIMES"][-1]), 3) )
  877. print("CALC DEAD", (1e3*(self.RAWDataProc.prePulseDelay))) # - (self.RAWDataProc.DATADICT["Pulse 1"]["TIMES"][0]-self.RAWDataProc.DATADICT["Pulse 1"]["PULSE_TIMES"][-1])), 3) )
  878. if u"Pulse 2" in self.RAWDataProc.DATADICT.keys():
  879. self.ui.lcdNumberFID1Length.display(self.RAWDataProc.DATADICT["Pulse 2"]["TIMES"][-1]- self.RAWDataProc.DATADICT["Pulse 2"]["TIMES"][0])
  880. self.ui.lcdTotalDeadTime.display( 1e3 * (self.RAWDataProc.DATADICT["Pulse 2"]["TIMES"][0]-self.RAWDataProc.DATADICT["Pulse 2"]["PULSE_TIMES"][-1]) )
  881. # Update info from the header into the GUI
  882. self.ui.pulseTypeTextBrowser.clear()
  883. self.ui.pulseTypeTextBrowser.append(self.RAWDataProc.pulseType)
  884. self.ui.lcdNumberNuTx.display(self.RAWDataProc.transFreq)
  885. self.ui.lcdNumberTauPulse1.display(1e3*self.RAWDataProc.pulseLength[0])
  886. self.ui.lcdNumberTuneuF.display(self.RAWDataProc.TuneCapacitance)
  887. self.ui.lcdNumberResampFreq.display(self.RAWDataProc.samp)
  888. self.ui.lcdNumberSampFreq.display(50000) # TODO, if non GMR is supported, query
  889. self.ui.lcdNumberNQ.display(self.RAWDataProc.nPulseMoments)
  890. self.ui.DeadTimeSpinBox.setValue(1e3*self.RAWDataProc.deadTime)
  891. self.ui.CentralVSpinBox.setValue( self.RAWDataProc.transFreq )
  892. if self.RAWDataProc.pulseType != "FID":
  893. self.ui.lcdNumberTauPulse2.setEnabled(1)
  894. self.ui.lcdNumberTauPulse2.display(1e3*self.RAWDataProc.pulseLength[1])
  895. self.ui.lcdNumberTauDelay.setEnabled(1)
  896. self.ui.lcdNumberTauDelay.display(1e3*self.RAWDataProc.interpulseDelay)
  897. self.ui.FIDProcComboBox.clear()
  898. if self.RAWDataProc.pulseType == "4PhaseT1" or self.RAWDataProc.pulseType == "T1":
  899. self.ui.FIDProcComboBox.insertItem(0, "Pulse 1") #, const QVariant & userData = QVariant() )
  900. self.ui.FIDProcComboBox.insertItem(1, "Pulse 2") #, const QVariant & userData = QVariant() )
  901. self.ui.FIDProcComboBox.insertItem(2, "Both") #, const QVariant & userData = QVariant() )
  902. if len( self.RAWDataProc.DATADICT["PULSES"]) == 2:
  903. self.ui.FIDProcComboBox.setCurrentIndex (2)
  904. elif self.RAWDataProc.DATADICT["PULSES"][0] == "Pulse 1":
  905. self.ui.FIDProcComboBox.setCurrentIndex (0)
  906. else:
  907. self.ui.FIDProcComboBox.setCurrentIndex (1)
  908. elif self.RAWDataProc.pulseType == "FID":
  909. self.ui.FIDProcComboBox.insertItem(0, "Pulse 1") #, const QVariant & userData = QVariant() )
  910. self.ui.FIDProcComboBox.setCurrentIndex (0)
  911. # QtCore.QObject.connect(self.RAWDataProc, QtCore.SIGNAL("updateProgress(int)"), self.updateProgressBar)
  912. # QtCore.QObject.connect(self.RAWDataProc, QtCore.SIGNAL("enableDSP()"), self.enableDSP)
  913. # QtCore.QObject.connect(self.RAWDataProc, QtCore.SIGNAL("doneStatus()"), self.doneStatus)
  914. self.RAWDataProc.progressTrigger.connect(self.updateProgressBar)
  915. self.RAWDataProc.enableDSPTrigger.connect(self.enableDSP)
  916. self.RAWDataProc.doneTrigger.connect(self.doneStatus)
  917. self.enableAll()
  918. def loadRAW(self):
  919. #################################################
  920. # Check to make sure we are ready to process
  921. # Header
  922. if self.RAWDataProc == None:
  923. err_msg = "You need to load a header first."
  924. reply = QtGui.QMessageBox.critical(self, 'Error',
  925. err_msg) #, QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
  926. return
  927. # Stacks
  928. try:
  929. self.procStacks = np.array(eval(str("np.r_["+self.ui.stacksLineEdit.text())+"]"))
  930. except:
  931. err_msg = "You need to set your stacks correctly.\n" + \
  932. "This should be a Python Numpy interpretable list\n" + \
  933. "of stack indices. For example 1:24 or 1:4,8:24"
  934. QtGui.QMessageBox.critical(self, 'Error', err_msg)
  935. return
  936. # Data Channels
  937. #Chan = np.arange(0,9,1)
  938. try:
  939. self.dataChan = np.array(eval(str("np.r_["+self.ui.dataChanLineEdit.text())+"]"))
  940. except:
  941. #QMessageBox messageBox;
  942. #messageBox.critical(0,"Error","An error has occured !");
  943. #messageBox.setFixedSize(500,200);
  944. #quit_msg = "Are you sure you want to exit the program?"
  945. #reply = QtGui.QMessageBox.question(self, 'Message',
  946. # quit_msg, QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
  947. err_msg = "You need to set your data channels correctly.\n" + \
  948. "This should be a Python Numpy interpretable list\n" + \
  949. "of indices. For example 1 or 1:3 or 1:3 5\n\n" + \
  950. "valid GMR data channels fall between 1 and 8. Note that\n" +\
  951. "1:3 is not inclusive of 3 and is the same as 1,2 "
  952. reply = QtGui.QMessageBox.critical(self, 'Error',
  953. err_msg) #, QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
  954. return
  955. #############################
  956. # Reference Channels
  957. # TODO make sure no overlap between data and ref channels
  958. self.refChan = np.array( () )
  959. if str(self.ui.refChanLineEdit.text()): # != "none":
  960. try:
  961. self.refChan = np.array(eval(str("np.r_["+self.ui.refChanLineEdit.text())+"]"))
  962. except:
  963. err_msg = "You need to set your reference channels correctly.\n" + \
  964. "This should be a Python Numpy interpretable list\n" + \
  965. "of indices. For example 1 or 1:3 or 1:3 5\n\n" + \
  966. "valid GMR data channels fall between 1 and 8. Note that\n" +\
  967. "1:3 is not inclusive of 3 and is the same as 1,2 "
  968. QtGui.QMessageBox.critical(self, 'Error', err_msg)
  969. return
  970. #####################################################
  971. # Load data
  972. self.lock("loading RAW GMR dataset")
  973. if self.RAWDataProc.pulseType == "FID":
  974. self.procThread = thread.start_new_thread(self.RAWDataProc.loadFIDData, \
  975. (str(self.headerstr), self.procStacks, self.dataChan, self.refChan, \
  976. str(self.ui.FIDProcComboBox.currentText()), self.ui.mplwidget, \
  977. 1e-3 * self.ui.DeadTimeSpinBox.value( ), self.ui.plotImportCheckBox.isChecked() )) #, self))
  978. elif self.RAWDataProc.pulseType == "4PhaseT1":
  979. self.procThread = thread.start_new_thread(self.RAWDataProc.load4PhaseT1Data, \
  980. (str(self.headerstr), self.procStacks, self.dataChan, self.refChan, \
  981. str(self.ui.FIDProcComboBox.currentText()), self.ui.mplwidget, \
  982. 1e-3 * self.ui.DeadTimeSpinBox.value( ), self.ui.plotImportCheckBox.isChecked() )) #, self))
  983. elif self.RAWDataProc.pulseType == "T1":
  984. self.procThread = thread.start_new_thread(self.RAWDataProc.loadT1Data, \
  985. (str(self.headerstr), self.procStacks, self.dataChan, self.refChan, \
  986. str(self.ui.FIDProcComboBox.currentText()), self.ui.mplwidget, \
  987. 1e-3 * self.ui.DeadTimeSpinBox.value( ), self.ui.plotImportCheckBox.isChecked() )) #, self))
  988. #self.procThread = thread.start_new_thread(self.RAWDataProc.load4PhaseT1Data, \
  989. # (str(self.headerstr), self.procStacks, self.dataChan, self.refChan, \
  990. # str(self.ui.FIDProcComboBox.currentText()), self.ui.mplwidget, \
  991. # 1e-3 * self.ui.DeadTimeSpinBox.value( ), self.ui.plotImportCheckBox.isChecked() )) #, self))
  992. self.YamlNode.Import["GMR Header"] = self.headerstr
  993. self.YamlNode.Import["opened"] = datetime.datetime.now().isoformat()
  994. self.YamlNode.Import["pulse Type"] = str(self.RAWDataProc.pulseType)
  995. self.YamlNode.Import["stacks"] = self.procStacks.tolist()
  996. self.YamlNode.Import["data channels"] = self.dataChan.tolist()
  997. self.YamlNode.Import["reference channels"] = self.refChan.tolist()
  998. self.YamlNode.Import["pulse records"] = str(self.ui.FIDProcComboBox.currentText())
  999. self.YamlNode.Import["instrument dead time"] = (1e-3 * self.ui.DeadTimeSpinBox.value( ))
  1000. self.Log ( )
  1001. # enable META tab
  1002. self.ui.METATab.setEnabled(1)
  1003. self.ui.siteBox.setEnabled(1)
  1004. # should be already done
  1005. # QtCore.QObject.connect(self.RAWDataProc, QtCore.SIGNAL("updateProgress(int)"), self.updateProgressBar)
  1006. # QtCore.QObject.connect(self.RAWDataProc, QtCore.SIGNAL("enableDSP()"), self.enableDSP)
  1007. # QtCore.QObject.connect(self.RAWDataProc, QtCore.SIGNAL("doneStatus()"), self.doneStatus)
  1008. #self.ui.ProcessedBox.setEnabled(True)
  1009. self.ui.lcdNumberFID1Length.setEnabled(1)
  1010. self.ui.lcdNumberFID2Length.setEnabled(1)
  1011. self.ui.lcdNumberResampFreq.setEnabled(1)
  1012. self.ui.lcdTotalDeadTime.setEnabled(1)
  1013. self.ui.lcdTotalDeadTime.display( self.ui.DeadTimeSpinBox.value( ) )
  1014. #self.ui.lcdTotalDeadTime.display( round(1e3*(self.RAWDataProc.DATADICT["Pulse 1"]["TIMES"][0]-self.RAWDataProc.DATADICT["Pulse 1"]["PULSE_TIMES"][-1]), 3) )
  1015. #self.ui.lcdNumberFID1Length.display(0)
  1016. #self.ui.lcdNumberFID2Length.display(0)
  1017. #self.ui.lcdNumberResampFreq.display( self.RAWDataProc.samp )
  1018. self.mpl_toolbar = NavigationToolbar2QT(self.ui.mplwidget, self.ui.mplwidget)
  1019. self.ui.mplwidget.draw()
  1020. def Log(self):
  1021. #for line in yaml.dump(self.YamlNode, default_flow_style=False):
  1022. #for line in nlogText:
  1023. # self.ui.logTextBrowser.append( line )
  1024. # self.logText.append( line )
  1025. self.ui.logTextBrowser.clear()
  1026. self.ui.logTextBrowser.append( yaml.dump(self.YamlNode ))
  1027. def disable(self):
  1028. self.ui.inputRAWParametersBox.setEnabled(False)
  1029. self.ui.BandPassBox.setEnabled(False)
  1030. self.ui.downSampleGroupBox.setEnabled(False)
  1031. self.ui.windowFilterGroupBox.setEnabled(False)
  1032. self.ui.harmonicBox.setEnabled(False)
  1033. # self.ui.despikeGroupBox.setEnabled(False)
  1034. self.ui.adaptBox.setEnabled(False)
  1035. self.ui.adaptFDBox.setEnabled(False)
  1036. self.ui.qCalcGroupBox.setEnabled(False)
  1037. self.ui.FDSmartStackGroupBox.setEnabled(False)
  1038. self.ui.sumDataBox.setEnabled(False)
  1039. self.ui.qdGroupBox.setEnabled(False)
  1040. self.ui.gateBox.setEnabled(False)
  1041. def enableAll(self):
  1042. self.enableDSP()
  1043. self.enableQC()
  1044. def enableDSP(self):
  1045. # Bandpass filter
  1046. self.ui.BandPassBox.setEnabled(True)
  1047. self.ui.BandPassBox.setChecked(True)
  1048. self.ui.bandPassGO.setEnabled(False) # need to design first
  1049. self.ui.plotBP.setEnabled(True)
  1050. self.ui.plotBP.setChecked(True)
  1051. # downsample
  1052. self.ui.downSampleGroupBox.setEnabled(True)
  1053. self.ui.downSampleGroupBox.setChecked(True)
  1054. # window
  1055. self.ui.windowFilterGroupBox.setEnabled(True)
  1056. self.ui.windowFilterGroupBox.setChecked(True)
  1057. # Despike
  1058. # self.ui.despikeGroupBox.setEnabled(True)
  1059. # self.ui.despikeGroupBox.setChecked(False)
  1060. # Adaptive filtering
  1061. self.ui.adaptBox.setEnabled(True)
  1062. self.ui.adaptBox.setChecked(True)
  1063. # FD Adaptive filtering
  1064. self.ui.adaptFDBox.setEnabled(True)
  1065. self.ui.adaptFDBox.setChecked(False)
  1066. # Harmonic
  1067. self.ui.harmonicBox.setEnabled(True)
  1068. self.ui.harmonicBox.setChecked(True)
  1069. self.LCDHarmonics()
  1070. self.LCDHarmonics2()
  1071. # sum group box
  1072. try:
  1073. if len(self.dataChan) > 1:
  1074. self.ui.sumDataBox.setEnabled(True)
  1075. self.ui.sumDataBox.setChecked(False)
  1076. except:
  1077. pass
  1078. # Quadrature Detect
  1079. self.ui.qdGroupBox.setEnabled(True)
  1080. self.ui.qdGroupBox.setChecked(True)
  1081. self.enableQC()
  1082. def enableQC(self):
  1083. # Q calc
  1084. self.ui.qCalcGroupBox.setEnabled(True)
  1085. self.ui.qCalcGroupBox.setChecked(True)
  1086. # FD SmartStack
  1087. self.ui.FDSmartStackGroupBox.setEnabled(True)
  1088. self.ui.FDSmartStackGroupBox.setChecked(True)
  1089. # Quadrature detect
  1090. try:
  1091. for pulse in self.RAWDataProc.DATADICT["PULSES"]:
  1092. np.shape(self.RAWDataProc.DATADICT[pulse]["Q"])
  1093. self.RAWDataProc.DATADICT["stack"]
  1094. self.ui.qdGroupBox.setEnabled(True)
  1095. self.ui.qdGroupBox.setChecked(True)
  1096. except:
  1097. self.ui.qdGroupBox.setEnabled(False)
  1098. self.ui.qdGroupBox.setChecked(False)
  1099. # Gating
  1100. try:
  1101. self.RAWDataProc.DATADICT["CA"]
  1102. self.ui.gateBox.setEnabled(True)
  1103. self.ui.gateBox.setChecked(True)
  1104. except:
  1105. self.ui.gateBox.setEnabled(False)
  1106. self.ui.gateBox.setChecked(False)
  1107. def despikeFilter(self):
  1108. self.lock("despike filter")
  1109. thread.start_new_thread(self.RAWDataProc.despike, \
  1110. (self.ui.windowSpinBox.value(), \
  1111. self.ui.thresholdSpinBox.value(), \
  1112. str(self.ui.replComboBox.currentText()), \
  1113. self.ui.rollOnSpinBox.value(), \
  1114. self.ui.despikeInterpWinSpinBox.value(),
  1115. self.ui.mplwidget))
  1116. def calcQ(self):
  1117. if "Calc Q" not in self.YamlNode.Stacking.keys():
  1118. #print("In CalcQ", yaml.dump(self.YamlNode.Processing) )
  1119. self.YamlNode.Stacking["Calc Q"] = True
  1120. #print( yaml.dump(self.YamlNode.Processing) )
  1121. self.Log()
  1122. else:
  1123. err_msg = "Q values have already been calculated"
  1124. reply =QtWidgets.QMessageBox.critical(self, 'Error',
  1125. err_msg)
  1126. return
  1127. self.lock("pulse moment calculation")
  1128. thread.start_new_thread(self.RAWDataProc.effectivePulseMoment, \
  1129. (self.ui.CentralVSpinBox.value(), \
  1130. self.ui.mplwidget))
  1131. def harmonicModel(self):
  1132. self.lock("harmonic noise modelling")
  1133. Harm = OrderedDict()
  1134. Harm["STEP"] = "Harmonic modelling"
  1135. Harm["NF"] = str( self.ui.NHarmonicsFreqsSpin.value() )
  1136. Harm["Segments"] = str( self.ui.NSegments.value() )
  1137. Harm["Proc. ref."] = self.ui.harmRef.isChecked()
  1138. if self.ui.searchAll.currentText() == "All":
  1139. Harm["search"] = self.ui.searchAll.currentText()
  1140. Search = False
  1141. else:
  1142. #Harm["search"] = self.ui.searchAll.currentText()
  1143. Harm["search"] = str(self.ui.Nsearch.value())
  1144. Search = self.ui.Nsearch.value()
  1145. if self.ui.boundsCheck.isChecked():
  1146. Harm["Bounds"] = str(self.ui.bounds.value())
  1147. Bounds = self.ui.bounds.value()
  1148. else:
  1149. Harm["Bounds"] = self.ui.boundsCheck.isChecked()
  1150. Bounds = 0
  1151. Harm["f0K1"] = str( self.ui.f0K1Spin.value() )
  1152. Harm["f0KN"] = str( self.ui.f0KNSpin.value() )
  1153. Harm["f0Ks"] = str( self.ui.f0KsSpin.value() )
  1154. Harm["f0"] = str( self.ui.f0Spin.value() )
  1155. if self.ui.NHarmonicsFreqsSpin.value() > 1:
  1156. Harm["f1K1"] = str( self.ui.f1K1Spin.value() )
  1157. Harm["f1KN"] = str( self.ui.f1KNSpin.value() )
  1158. Harm["f1Ks"] = str( self.ui.f1KsSpin.value() )
  1159. Harm["f1"] = str( self.ui.f1Spin.value() )
  1160. self.YamlNode.Processing.append(Harm)
  1161. self.Log()
  1162. thread.start_new_thread(self.RAWDataProc.harmonicModel, \
  1163. ( \
  1164. self.ui.NHarmonicsFreqsSpin.value(), \
  1165. self.ui.f0Spin.value(), \
  1166. self.ui.f0K1Spin.value(), \
  1167. self.ui.f0KNSpin.value(), \
  1168. self.ui.f0KsSpin.value(), \
  1169. self.ui.NSegments.value(), \
  1170. self.ui.f1Spin.value(), \
  1171. self.ui.f1K1Spin.value(), \
  1172. self.ui.f1KNSpin.value(), \
  1173. self.ui.f1KsSpin.value(), \
  1174. Search, \
  1175. Bounds, \
  1176. self.ui.harmRef.isChecked(), \
  1177. self.ui.plotHarmonic.isChecked(), \
  1178. self.ui.mplwidget \
  1179. ) \
  1180. )
  1181. def FDSmartStack(self):
  1182. if "TD stack" not in self.YamlNode.Stacking.keys():
  1183. self.YamlNode.Stacking["TD stack"] = {}
  1184. self.YamlNode.Stacking["TD stack"]["outlier"] = str( self.ui.outlierTestCB.currentText() )
  1185. self.YamlNode.Stacking["TD stack"]["cutoff"] = str( self.ui.MADCutoff.value() )
  1186. self.Log()
  1187. else:
  1188. err_msg = "TD noise cancellation has already been applied!"
  1189. reply =QtWidgets.QMessageBox.critical(self, 'Error',
  1190. err_msg)
  1191. return
  1192. self.lock("time-domain smart stack")
  1193. thread.start_new_thread(self.RAWDataProc.TDSmartStack, \
  1194. (str(self.ui.outlierTestCB.currentText()), \
  1195. self.ui.MADCutoff.value(),
  1196. self.ui.mplwidget))
  1197. def adaptFilter(self):
  1198. self.lock("TD noise cancellation filter")
  1199. # Log processing
  1200. Adapt = OrderedDict()
  1201. Adapt["STEP"] = "TD noise cancellation"
  1202. print(Adapt) # this locks STEP in as first...
  1203. Adapt["n_Taps"] = str(self.ui.MTapsSpinBox.value())
  1204. Adapt["lambda"] = str(self.ui.adaptLambdaSpinBox.value())
  1205. Adapt["truncate"] = str(self.ui.adaptTruncateSpinBox.value())
  1206. Adapt["mu"] = str(self.ui.adaptMuSpinBox.value())
  1207. Adapt["PCA"] = str(self.ui.PCAComboBox.currentText())
  1208. #print(Adapt)
  1209. self.YamlNode.Processing.append(Adapt)
  1210. self.Log( )
  1211. thread.start_new_thread(self.RAWDataProc.adaptiveFilter, \
  1212. (self.ui.MTapsSpinBox.value(), \
  1213. self.ui.adaptLambdaSpinBox.value(), \
  1214. self.ui.adaptTruncateSpinBox.value(), \
  1215. self.ui.adaptMuSpinBox.value(), \
  1216. str(self.ui.PCAComboBox.currentText()), \
  1217. self.ui.mplwidget))
  1218. def sumDataChans(self):
  1219. self.lock("Summing data channels")
  1220. Sum = OrderedDict()
  1221. Sum["STEP"] = "Channel sum"
  1222. self.YamlNode.Processing.append(Sum)
  1223. self.Log( )
  1224. self.dataChan = [self.dataChan[0]]
  1225. self.ui.sumDataBox.setEnabled(False)
  1226. thread.start_new_thread( self.RAWDataProc.sumData, ( self.ui.mplwidget, 7 ) )
  1227. def adaptFilterFD(self):
  1228. self.lock("FD noise cancellation filter")
  1229. thread.start_new_thread(self.RAWDataProc.adaptiveFilterFD, \
  1230. (str(self.ui.windowTypeComboBox.currentText()), \
  1231. self.ui.windowBandwidthSpinBox.value(), \
  1232. self.ui.CentralVSpinBox.value(), \
  1233. self.ui.mplwidget))
  1234. def logGUI(self):
  1235. # You have a race condiditon where the GUI is modifying the Yaml node while you are updating it
  1236. # hence, we need to cache these. More elegant solutions exist
  1237. if "B_0" in self.YamlNode.META:
  1238. B0 = self.YamlNode.META["B_0"]["intensity"]
  1239. Bdec = self.YamlNode.META["B_0"]["dec"]
  1240. Binc = self.YamlNode.META["B_0"]["inc"]
  1241. if "DateTime" in self.YamlNode.META:
  1242. [Date,Time] = self.YamlNode.META["DateTime"].split("T")
  1243. year,month,day = Date.split("-")
  1244. if "Temp" in self.YamlNode.META:
  1245. temp = float(self.YamlNode.META["Temp"])
  1246. if "Coordinates" in self.YamlNode.META:
  1247. UTM = self.YamlNode.META["Coordinates"]["UTM"]
  1248. LatBand = self.YamlNode.META["Coordinates"]["LatBand"]
  1249. Ellipsoid = self.YamlNode.META["Coordinates"]["ellipsoid"]
  1250. # and set
  1251. if "Location" in self.YamlNode.META:
  1252. self.ui.locEdit.setText( self.YamlNode.META["Location"] )
  1253. if "Field Notes" in self.YamlNode.META:
  1254. self.ui.txtComments.setText( self.YamlNode.META["Field Notes"] )
  1255. if "B_0" in self.YamlNode.META:
  1256. self.ui.incSpinBox.setValue( Binc )
  1257. self.ui.decSpinBox.setValue( Bdec )
  1258. self.ui.intensitySpinBox.setValue( B0 )
  1259. if "DateTime" in self.YamlNode.META:
  1260. self.ui.dateEdit.setDate( datetime.date(int(year), int(month), int(day)) )
  1261. self.ui.timeEdit.setTime( datetime.time.fromisoformat( Time ) )
  1262. if "Temp" in self.YamlNode.META:
  1263. self.ui.tempSpinBox.setValue(temp)
  1264. if "Coordinates" in self.YamlNode.META:
  1265. self.ui.UTMzone.setCurrentText(UTM)
  1266. self.ui.latBand.setCurrentText(LatBand)
  1267. self.ui.ellipsoid.setCurrentText(Ellipsoid)
  1268. def logSite(self):
  1269. self.YamlNode.META["Location"] = self.ui.locEdit.text()
  1270. self.YamlNode.META["Coordinates"] = OrderedDict()
  1271. self.YamlNode.META["Coordinates"]["UTM"] = self.ui.UTMzone.currentText()
  1272. self.YamlNode.META["Coordinates"]["LatBand"] = self.ui.latBand.currentText()
  1273. self.YamlNode.META["Coordinates"]["ellipsoid"] = self.ui.ellipsoid.currentText()
  1274. self.YamlNode.META["DateTime"] = self.ui.dateEdit.date().toString("yyyy-MM-dd") + "T" + str( self.ui.timeEdit.time().toString("hh:mm") )
  1275. self.YamlNode.META["Temp"] = self.ui.tempSpinBox.value()
  1276. self.YamlNode.META["B_0"] = OrderedDict()
  1277. self.YamlNode.META["B_0"]["inc"] = self.ui.incSpinBox.value()
  1278. self.YamlNode.META["B_0"]["dec"] = self.ui.decSpinBox.value()
  1279. self.YamlNode.META["B_0"]["intensity"] = self.ui.intensitySpinBox.value()
  1280. self.YamlNode.META["Field Notes"] = self.ui.txtComments.toPlainText()
  1281. self.YamlNode.META["Loops"] = OrderedDict()
  1282. for loop in self.loops:
  1283. print(self.loops[loop])
  1284. self.YamlNode.META["Loops"][loop] = loop + ".yml"
  1285. self.Log()
  1286. def bandPassFilter(self):
  1287. self.lock("bandpass filter")
  1288. # Log processing
  1289. Band = OrderedDict()
  1290. Band["STEP"] = "Bandpass filter"
  1291. Band["central_nu"] = str(self.ui.CentralVSpinBox.value())
  1292. Band["passband"] = str(self.ui.passBandSpinBox.value())
  1293. Band["stopband"] = str(self.ui.stopBandSpinBox.value())
  1294. Band["gpass"] = str(self.ui.gpassSpinBox.value())
  1295. Band["gstop"] = str(self.ui.gstopSpinBox.value())
  1296. Band["type"] = str(self.ui.fTypeComboBox.currentText())
  1297. self.YamlNode.Processing.append(Band)
  1298. self.Log( )
  1299. nv = self.ui.lcdTotalDeadTime.value( ) + self.ui.lcdNumberFTauDead.value()
  1300. self.ui.lcdTotalDeadTime.display( nv )
  1301. thread.start_new_thread(self.RAWDataProc.bandpassFilter, \
  1302. (self.ui.mplwidget, 0, self.ui.plotBP.isChecked() ))
  1303. def downsample(self):
  1304. self.lock("resampling")
  1305. # Log processing
  1306. Resample = OrderedDict()
  1307. Resample["STEP"] = "Resample"
  1308. Resample["downsample factor"] = str(self.ui.downSampleSpinBox.value())
  1309. Resample["truncate length"] = str(self.ui.truncateSpinBox.value())
  1310. self.YamlNode.Processing.append(Resample)
  1311. self.Log( )
  1312. thread.start_new_thread(self.RAWDataProc.downsample, \
  1313. (self.ui.truncateSpinBox.value(), \
  1314. self.ui.downSampleSpinBox.value(), \
  1315. self.ui.dsPlot.isChecked(), \
  1316. self.ui.mplwidget))
  1317. def quadDet(self):
  1318. method = ['trf','dogbox','lm'][int(self.ui.QDMethod.currentIndex())]
  1319. loss = ['linear','soft_l1','cauchy','huber'][int(self.ui.QDLoss.currentIndex())]
  1320. # allow overwrite of Quad Det.
  1321. self.YamlNode.Stacking["Quadrature detection"] = {}
  1322. self.YamlNode.Stacking["Quadrature detection"]["trim"] = str( self.ui.trimSpin.value() )
  1323. self.YamlNode.Stacking["Quadrature detection"]["method"] = method
  1324. self.YamlNode.Stacking["Quadrature detection"]["loss"] = loss
  1325. self.Log()
  1326. #if "Quadrature detection" not in self.YamlNode.Processing.keys():
  1327. # self.YamlNode.Processing["Quadrature detection"] = {}
  1328. # self.YamlNode.Processing["Quadrature detection"]["trim"] = str( self.ui.trimSpin.value() )
  1329. # self.Log()
  1330. #else:
  1331. # self.YamlNode.Processing["Quadrature detection"] = {}
  1332. # self.YamlNode.Processing["Quadrature detection"]["trim"] = str( self.ui.trimSpin.value() )
  1333. # self.Log()
  1334. #err_msg = "Quadrature detection has already been done!"
  1335. #reply =QtWidgets.QMessageBox.critical(self, 'Error',
  1336. # err_msg)
  1337. #return
  1338. self.lock("quadrature detection")
  1339. thread.start_new_thread(self.RAWDataProc.quadDet, \
  1340. (self.ui.trimSpin.value(), method, loss, self.ui.mplwidget))
  1341. self.ui.plotQD.setEnabled(True)
  1342. def plotQD(self):
  1343. self.lock("plot QD")
  1344. thread.start_new_thread(self.RAWDataProc.plotQuadDet, \
  1345. (self.ui.trimSpin.value(), int(self.ui.QDType.currentIndex()), self.ui.mplwidget))
  1346. def gateIntegrate(self):
  1347. if "Gate integrate" not in self.YamlNode.Stacking.keys():
  1348. self.YamlNode.Stacking["Gate integrate"] = {}
  1349. self.YamlNode.Stacking["Gate integrate"]["gpd"] = str(self.ui.GPDspinBox.value( ) )
  1350. self.Log()
  1351. self.lock("gate integration")
  1352. thread.start_new_thread(self.RAWDataProc.gateIntegrate, \
  1353. (self.ui.GPDspinBox.value(), self.ui.trimSpin.value(), self.ui.mplwidget))
  1354. self.ui.actionExport_Preprocessed_Dataset.setEnabled(True)
  1355. self.ui.plotGI.setEnabled(True)
  1356. def plotGI(self):
  1357. self.lock("plot gate integrate")
  1358. thread.start_new_thread(self.RAWDataProc.plotGateIntegrate, \
  1359. (self.ui.GPDspinBox.value(), self.ui.trimSpin.value(), \
  1360. self.ui.QDType_2.currentIndex(), self.ui.mplwidget))
  1361. def designFilter(self):
  1362. [bord, fe] = self.RAWDataProc.designFilter( \
  1363. self.ui.CentralVSpinBox.value(), \
  1364. self.ui.passBandSpinBox.value(), \
  1365. self.ui.stopBandSpinBox.value(), \
  1366. self.ui.gpassSpinBox.value(), \
  1367. self.ui.gstopSpinBox.value(), \
  1368. str(self.ui.fTypeComboBox.currentText()),
  1369. self.ui.mplwidget
  1370. )
  1371. self.ui.lcdNumberFilterOrder.display(bord)
  1372. self.ui.lcdNumberFTauDead.display(1e3*fe)
  1373. self.ui.bandPassGO.setEnabled(1)
  1374. ################################################################
  1375. # Hack for MacOS to force refresh of group box and plot
  1376. # this has an undesirable effect that it causes the groupbox to 'jump' up
  1377. # TODO come up with a better solution
  1378. self.ui.mplwidget.hide()
  1379. self.ui.mplwidget.show()
  1380. self.ui.BandPassBox.hide()
  1381. self.ui.BandPassBox.show()
  1382. def windowFilter(self):
  1383. self.lock("window filter")
  1384. # Log processing
  1385. Window = OrderedDict()
  1386. Window["STEP"] = "Window filter"
  1387. Window["type"] = str(self.ui.windowTypeComboBox.currentText())
  1388. Window["width"] = str(self.ui.windowBandwidthSpinBox.value())
  1389. Window["centre"] = str(self.ui.CentralVSpinBox.value() )
  1390. Window["trim"] = str(self.ui.windowTrim.isChecked())
  1391. self.YamlNode.Processing.append(Window)
  1392. self.Log( )
  1393. if self.ui.windowTrim.isChecked():
  1394. nv = self.ui.lcdTotalDeadTime.value( ) + self.ui.lcdWinDead.value()
  1395. self.ui.lcdTotalDeadTime.display( nv )
  1396. thread.start_new_thread(self.RAWDataProc.windowFilter, \
  1397. (str(self.ui.windowTypeComboBox.currentText()), \
  1398. self.ui.windowBandwidthSpinBox.value(), \
  1399. self.ui.CentralVSpinBox.value(), \
  1400. self.ui.windowTrim.isChecked(), \
  1401. self.ui.mplwidget))
  1402. def designFDFilter(self):
  1403. mPulse = "None"
  1404. if u"Pulse 1" in self.RAWDataProc.DATADICT.keys():
  1405. mPulse = u"Pulse 1"
  1406. elif u"Pulse 2" in self.RAWDataProc.DATADICT.keys():
  1407. mPulse = u"Pulse 2"
  1408. a,b,c,d,dead,ndead = self.RAWDataProc.computeWindow( \
  1409. mPulse,
  1410. self.ui.windowBandwidthSpinBox.value(), \
  1411. self.ui.CentralVSpinBox.value(), \
  1412. str(self.ui.windowTypeComboBox.currentText()), \
  1413. self.ui.mplwidget )
  1414. self.ui.lcdWinDead.display(dead)
  1415. ################################################################
  1416. # Hack for MacOS to force refresh of group box and plot
  1417. # this has an undesirable effect that it causes the groupbox to 'jump' up
  1418. # TODO come up with a better solution
  1419. self.ui.mplwidget.hide()
  1420. self.ui.mplwidget.show()
  1421. self.ui.windowFilterGroupBox.hide()
  1422. self.ui.windowFilterGroupBox.show()
  1423. def updateProgressBar(self, percent):
  1424. self.ui.barProgress.setValue(percent)
  1425. def updateProc(self):
  1426. if str(self.ui.FIDProcComboBox.currentText()) == "Pulse 1":
  1427. self.ui.lcdNumberFID1Length.display(self.RAWDataProc.DATADICT["Pulse 1"]["TIMES"][-1]- self.RAWDataProc.DATADICT["Pulse 1"]["TIMES"][0])
  1428. elif str(self.ui.FIDProcComboBox.currentText()) == "Pulse 2":
  1429. self.ui.lcdNumberFID2Length.display(self.RAWDataProc.DATADICT["Pulse 2"]["TIMES"][-1]- self.RAWDataProc.DATADICT["Pulse 2"]["TIMES"][0])
  1430. else:
  1431. self.ui.lcdNumberFID1Length.display(self.RAWDataProc.DATADICT["Pulse 1"]["TIMES"][-1]- self.RAWDataProc.DATADICT["Pulse 1"]["TIMES"][0])
  1432. self.ui.lcdNumberFID2Length.display(self.RAWDataProc.DATADICT["Pulse 2"]["TIMES"][-1]- self.RAWDataProc.DATADICT["Pulse 2"]["TIMES"][0])
  1433. self.ui.lcdNumberResampFreq.display( self.RAWDataProc.samp )
  1434. def doneStatus(self): # unlocks GUI
  1435. self.ui.statusbar.clearMessage ( )
  1436. self.ui.barProgress.hide()
  1437. self.updateProc()
  1438. self.enableAll()
  1439. def lock(self, string):
  1440. self.ui.statusbar.showMessage ( string )
  1441. self.ui.barProgress.show()
  1442. self.ui.barProgress.setValue(0)
  1443. self.disable()
  1444. def unlock(self):
  1445. self.ui.statusbar.clearMessage ( )
  1446. self.ui.barProgress.hide()
  1447. self.enableAll()
  1448. def done(self):
  1449. self.ui.statusbar.showMessage ( "" )
  1450. ################################################################
  1451. ################################################################
  1452. # Boiler plate main function
  1453. import pkg_resources
  1454. from pkg_resources import resource_string
  1455. import matplotlib.image as mpimg
  1456. import matplotlib.pyplot as plt
  1457. from akvo.gui.logo import plotLogo
  1458. def main():
  1459. # splash screen logo
  1460. logo = pkg_resources.resource_filename(__name__, 'akvo.png')
  1461. logo2 = pkg_resources.resource_filename(__name__, 'akvo2.png')
  1462. qApp = QtWidgets.QApplication(sys.argv)
  1463. ssplash = True
  1464. if ssplash:
  1465. pixmap = QtGui.QPixmap(logo)
  1466. splash = QtWidgets.QSplashScreen(pixmap, QtCore.Qt.WindowStaysOnTopHint)
  1467. splash.show()
  1468. aw = ApplicationWindow()
  1469. #img=mpimg.imread(logo)
  1470. for ax in [ aw.ui.mplwidget ]:
  1471. ax.fig.clear()
  1472. subplot = ax.fig.add_subplot(211)
  1473. # old logo plot
  1474. ax.fig.patch.set_facecolor( None )
  1475. ax.fig.patch.set_alpha( .0 )
  1476. #subplot.imshow(img)
  1477. #ax.fig.patch.set_visible(False)
  1478. subplot.axis('off')
  1479. plotLogo(subplot)
  1480. subplot.xaxis.set_major_locator(plt.NullLocator())
  1481. subplot.yaxis.set_major_locator(plt.NullLocator())
  1482. subplot2 = ax.fig.add_subplot(212)
  1483. subplot2.text(0.5, 1.,'surface NMR workbench',
  1484. horizontalalignment='center',
  1485. verticalalignment='center',
  1486. size=22,
  1487. transform = subplot2.transAxes)
  1488. subplot2.xaxis.set_major_locator(plt.NullLocator())
  1489. subplot2.yaxis.set_major_locator(plt.NullLocator())
  1490. subplot2.axis('off')
  1491. ax.draw()
  1492. if ssplash:
  1493. splash.showMessage("Loading modules")
  1494. splash.finish(aw)
  1495. #time.sleep(1)
  1496. aw.setWindowTitle("Akvo v"+str(VERSION))
  1497. aw.show()
  1498. qApp.setWindowIcon(QtGui.QIcon(logo2))
  1499. sys.exit(qApp.exec_())
  1500. if __name__ == "__main__":
  1501. main()