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.

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