From 75a8397b216b26602b6cb64a2e3d542b891ded0d Mon Sep 17 00:00:00 2001 From: Sebastianw Wehling-Benatelli Date: Fri, 30 Sep 2016 16:32:34 +0200 Subject: [PATCH 1/5] [release] edit to README and deleted duplicate LICENSE file --- LICENSE.txt | 165 ---------------------------------------------------- README.md | 35 ++++++++++- 2 files changed, 34 insertions(+), 166 deletions(-) delete mode 100644 LICENSE.txt diff --git a/LICENSE.txt b/LICENSE.txt deleted file mode 100644 index 755013bb..00000000 --- a/LICENSE.txt +++ /dev/null @@ -1,165 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser General Public License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. diff --git a/README.md b/README.md index 2d3db0ec..36643ead 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,35 @@ # PyLoT -Python picking and Location Tool + +version: 0.1a + +The Python picking and Localisation Tool + +This python library contains a graphical user interfaces for picking +seismic phases. This software needs ObsPy (http://github.com/obspy/obspy/wiki) +and the PySide Qt4 bindings for python to be installed first. + +PILOT has originally been developed in Mathworks' MatLab. In order to +distribute PILOT without facing portability problems, it has been decided +to redevelop the software package in Python. The great work of the ObsPy +group allows easy handling of a bunch of seismic data and PyLoT will +benefit a lot compared to the former MatLab version. + +The development of PyLoT is part of the joint research project MAGS2. + +staff: +====== + +original author(s): L. Kueperkoch, S. Wehling-Benatelli, M. Bischoff (PILOT) + +developer(s): S. Wehling-Benatelli, L. Kueperkoch, K. Olbert, M. Bischoff, + C. Wollin, M. Rische + +others: A. Bruestle, T. Meier, W. Friederich + +release notes: +============== + + + + +October 2016 \ No newline at end of file From 45184fd888f68ee42e1915b1cc6e7e43356e5893 Mon Sep 17 00:00:00 2001 From: Sebastianw Wehling-Benatelli Date: Mon, 3 Oct 2016 08:20:54 +0200 Subject: [PATCH 2/5] [move] acitveSeismoPick3D removed from PyLoT project will be under version control on its own --- pylot/core/active/ActiveSeismoPick3D_GUI.py | 539 -------- pylot/core/active/__init__.py | 2 - pylot/core/active/activeSeismoPick.py | 779 ------------ pylot/core/active/fmtomoUtils.py | 1108 ---------------- pylot/core/active/gui/__init__.py | 2 - pylot/core/active/gui/asp3d_layout.py | 391 ------ .../active/gui/fmtomo_parameters_layout.py | 306 ----- .../active/gui/generate_seisarray_layout.py | 175 --- .../core/active/gui/generate_survey_layout.py | 151 --- .../gui/generate_survey_layout_minimal.py | 94 -- .../active/gui/picking_parameters_layout.py | 277 ---- .../core/active/gui/postprocessing_layout.py | 178 --- pylot/core/active/gui/repicking_layout.py | 49 - pylot/core/active/gui/vtk_tools_layout.py | 224 ---- pylot/core/active/gui/windows.py | 773 ------------ pylot/core/active/run_asp3d.py | 129 -- pylot/core/active/seismicArrayPreparation.py | 1122 ----------------- pylot/core/active/seismicshot.py | 957 -------------- pylot/core/active/surveyPlotTools.py | 537 -------- pylot/core/active/surveyUtils.py | 293 ----- 20 files changed, 8086 deletions(-) delete mode 100755 pylot/core/active/ActiveSeismoPick3D_GUI.py delete mode 100644 pylot/core/active/__init__.py delete mode 100644 pylot/core/active/activeSeismoPick.py delete mode 100644 pylot/core/active/fmtomoUtils.py delete mode 100644 pylot/core/active/gui/__init__.py delete mode 100644 pylot/core/active/gui/asp3d_layout.py delete mode 100644 pylot/core/active/gui/fmtomo_parameters_layout.py delete mode 100644 pylot/core/active/gui/generate_seisarray_layout.py delete mode 100644 pylot/core/active/gui/generate_survey_layout.py delete mode 100644 pylot/core/active/gui/generate_survey_layout_minimal.py delete mode 100644 pylot/core/active/gui/picking_parameters_layout.py delete mode 100644 pylot/core/active/gui/postprocessing_layout.py delete mode 100644 pylot/core/active/gui/repicking_layout.py delete mode 100644 pylot/core/active/gui/vtk_tools_layout.py delete mode 100644 pylot/core/active/gui/windows.py delete mode 100755 pylot/core/active/run_asp3d.py delete mode 100644 pylot/core/active/seismicArrayPreparation.py delete mode 100644 pylot/core/active/seismicshot.py delete mode 100644 pylot/core/active/surveyPlotTools.py delete mode 100644 pylot/core/active/surveyUtils.py diff --git a/pylot/core/active/ActiveSeismoPick3D_GUI.py b/pylot/core/active/ActiveSeismoPick3D_GUI.py deleted file mode 100755 index d7e9fd9f..00000000 --- a/pylot/core/active/ActiveSeismoPick3D_GUI.py +++ /dev/null @@ -1,539 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -import os -import sys -import matplotlib -matplotlib.use('Qt4Agg') -matplotlib.rcParams['backend.qt4']='PySide' - -from PySide import QtCore, QtGui -from pylot.core.active import activeSeismoPick, surveyUtils, fmtomoUtils, seismicArrayPreparation -from pylot.core.active.gui.asp3d_layout import * -from pylot.core.active.gui.windows import Gen_SeisArray, Gen_Survey_from_SA, Gen_Survey_from_SR, Call_autopicker, Call_FMTOMO, Call_VTK_dialog, Postprocessing -from pylot.core.active.gui.windows import openFile, saveFile, browseDir, getMaxCPU, printDialogMessage, continueDialogExists, continueDialogMessage - -from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas -from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT as NavigationToolbar -import matplotlib.pyplot as plt -from matplotlib.figure import Figure - -class gui_control(object): - def __init__(self): - self.mainwindow = MainWindow - self.mainUI = ui - self.connectButtons() - self.survey = None - self.seisarray = None - self.seisArrayFigure = None - self.cancelpixmap = self.mainwindow.style().standardPixmap(QtGui.QStyle.SP_DialogCancelButton) - self.applypixmap = self.mainwindow.style().standardPixmap(QtGui.QStyle.SP_DialogApplyButton) - self.addArrayPlot() - self.addSurfacePlot() - self.addStatPlots() - self.setInitStates() - self.mainUI.progressBar.setVisible(False) - self.printSurveyTextbox() - self.printSeisArrayTextbox() - self.initWindowObjects() - app.aboutToQuit.connect(self.exitApp) - - def initWindowObjects(self): - self.gsa = None - self.gssa = None - self.gssr = None - self.autopicker = None - self.fmtomo = None - self.vtktools = None - self.postprocessing = None - - def setInitStates(self): - self.setPickState(False) - self.setSurveyState(False) - self.setSeisArrayState(False) - self.setConnected2SurveyState(False) - - def connectButtons(self): - QtCore.QObject.connect(self.mainUI.actionGenerate_new_Seismic_Array, QtCore.SIGNAL("triggered()"), self.gen_seisarray) - QtCore.QObject.connect(self.mainUI.actionLoad_Seismic_Array, QtCore.SIGNAL("triggered()"), self.load_seisarray) - QtCore.QObject.connect(self.mainUI.actionSave_Seismic_Array, QtCore.SIGNAL("triggered()"), self.save_seisarray) - QtCore.QObject.connect(self.mainUI.actionLoad_Survey, QtCore.SIGNAL("triggered()"), self.load_survey) - QtCore.QObject.connect(self.mainUI.actionSave_Survey, QtCore.SIGNAL("triggered()"), self.save_survey) - QtCore.QObject.connect(self.mainUI.actionConnect_to_Survey, QtCore.SIGNAL("triggered()"), self.connect2Survey) - QtCore.QObject.connect(self.mainUI.actionInterpolate_Receivers, QtCore.SIGNAL("triggered()"), self.interpolate_receivers) - QtCore.QObject.connect(self.mainUI.actionGenerate_new_Survey, QtCore.SIGNAL("triggered()"), self.gen_survey) - QtCore.QObject.connect(self.mainUI.actionAutomatic_Picking, QtCore.SIGNAL("triggered()"), self.startPicker) - QtCore.QObject.connect(self.mainUI.actionPostprocessing, QtCore.SIGNAL("triggered()"), self.postprocessing) - QtCore.QObject.connect(self.mainUI.actionStart_FMTOMO_Simulation, QtCore.SIGNAL("triggered()"), self.startFMTOMO) - QtCore.QObject.connect(self.mainUI.actionVTK_Visualization, QtCore.SIGNAL("triggered()"), self.startVTKtools) - QtCore.QObject.connect(self.mainUI.actionExit, QtCore.SIGNAL("triggered()"), self.exitApp) - QtCore.QObject.connect(self.mainUI.actionFullscreen, QtCore.SIGNAL("triggered()"), self.fullscreen) - QtCore.QObject.connect(self.mainUI.comboBox_stats, QtCore.SIGNAL("activated(int)"), self.refreshPickedWidgets) - QtCore.QObject.connect(self.mainUI.shot_left, QtCore.SIGNAL("clicked()"), self.decreaseShotnumber) - QtCore.QObject.connect(self.mainUI.shot_right, QtCore.SIGNAL("clicked()"), self.increaseShotnumber) - QtCore.QObject.connect(self.mainUI.plot_shot, QtCore.SIGNAL("clicked()"), self.plotShot) - - def fullscreen(self): - if self.mainUI.actionFullscreen.isChecked(): - MainWindow.showFullScreen() - else: - MainWindow.showNormal() - - def gen_seisarray(self): - disconnect = False - if self.checkSeisArrayState(): - if not continueDialogExists('Seismic Array'): - return - if self.checkConnected2SurveyState(): - if not continueDialogMessage('Seismic Array connected to present Survey.\n' - 'Continuation will disconnect the Seismic Array.'): - return - else: - self.survey.seisarray = None - disconnect = True - - if self.gsa is None: - self.gsa = Gen_SeisArray(self.mainwindow) - else: - self.gsa.start_dialog() - - if self.gsa.executed: - self.seisarray = self.gsa.get_seisarray() - if disconnect: - self.setConnected2SurveyState(False) - self.setSeisArrayState(True) - - def gen_survey(self): - if self.checkSurveyState(): - if not continueDialogExists('Survey'): - return - if self.checkSeisArrayState(): - if len(self.seisarray.getSourceCoordinates()) > 0: - if continueDialogMessage('Use geometry information of active Seismic Array?'): - if self.gssa is None: - self.gssa = Gen_Survey_from_SA(self.mainwindow, self.seisarray) - else: - self.gssa.start_dialog() - self.update_seisarray(self.seisarray) - if self.gssa.executed: - self.survey = self.gssa.get_survey() - self.initNewSurvey() - self.setConnected2SurveyState(True) - self.setPickState(False) - return - else: - if not continueDialogMessage('Can not use current Seismic Array,' - ' because there are no sources given.'): - return - if self.gssr is None: - self.gssr = Gen_Survey_from_SR(self.mainwindow) - else: - self.gssr.start_dialog() - if self.gssr.executed: - self.survey = self.gssr.get_survey() - self.seisarray = self.survey.seisarray - self.initNewSurvey() - self.setSeisArrayState(True) - self.setConnected2SurveyState(True) - - def initNewSurvey(self): - self.survey.setArtificialPick(0, 0) # artificial pick at source origin - self.setSurveyState(True) - self.setPickState(False) - - def addArrayPlot(self): - self.seisArrayFigure = Figure() - self.seisArrayCanvas = FigureCanvas(self.seisArrayFigure) - self.mainUI.verticalLayout_tr1.addWidget(self.seisArrayCanvas) - self.seisArrayToolbar = NavigationToolbar(self.seisArrayCanvas, self.mainwindow) - self.mainUI.verticalLayout_tr1.addWidget(self.seisArrayToolbar) - - def addSurfacePlot(self): - self.surfaceFigure = Figure() - self.surfaceCanvas = FigureCanvas(self.surfaceFigure) - self.mainUI.horizontalLayout_tr.addWidget(self.surfaceCanvas) - - def addStatPlots(self): - self.statFigure_left = Figure() - self.statCanvas_left = FigureCanvas(self.statFigure_left) - self.mainUI.verticalLayout_br1.addWidget(self.statCanvas_left) - self.statToolbar_left = NavigationToolbar(self.statCanvas_left, self.mainwindow) - self.mainUI.verticalLayout_br1.addWidget(self.statToolbar_left) - - self.statFigure_right = Figure() - self.statCanvas_right = FigureCanvas(self.statFigure_right) - self.mainUI.verticalLayout_br2.addWidget(self.statCanvas_right) - self.statToolbar_right = NavigationToolbar(self.statCanvas_right, self.mainwindow) - self.mainUI.verticalLayout_br2.addWidget(self.statToolbar_right) - - self.addItems2StatsComboBox() - - def addItems2StatsComboBox(self): - self.mainUI.comboBox_stats.insertItem(0, 'picked traces') - self.mainUI.comboBox_stats.insertItem(1, 'mean SNR') - self.mainUI.comboBox_stats.insertItem(2, 'median SNR') - self.mainUI.comboBox_stats.insertItem(3, 'mean SPE') - self.mainUI.comboBox_stats.insertItem(4, 'median SPE') - self.enablePickedTools(False) - - def addItems2ShotsComboBox(self): - shotnumbers = self.survey.data.keys() - shotnumbers.sort() - for index, shotnumber in enumerate(shotnumbers): - self.mainUI.comboBox_shots.insertItem(index, 'Shot: %s'%shotnumber) - self.mainUI.comboBox_shots.setMaxCount(len(shotnumbers)) - - def increaseShotnumber(self): - currentIndex = self.mainUI.comboBox_shots.currentIndex() - maxindex = self.mainUI.comboBox_shots.maxCount() - 1 - if currentIndex == maxindex: - self.mainUI.comboBox_shots.setCurrentIndex(0) - else: - self.mainUI.comboBox_shots.setCurrentIndex(currentIndex + 1) - - def decreaseShotnumber(self): - currentIndex = self.mainUI.comboBox_shots.currentIndex() - maxindex = self.mainUI.comboBox_shots.maxCount() - 1 - if currentIndex == 0: - self.mainUI.comboBox_shots.setCurrentIndex(maxindex) - else: - self.mainUI.comboBox_shots.setCurrentIndex(currentIndex - 1) - - - def plotShot(self): - shotnumber = int(self.mainUI.comboBox_shots.currentText().split()[1]) - self.survey.data[shotnumber].matshow() - - def addArrayAxes(self): - self.seisArrayAx = self.seisArrayFigure.add_subplot(111) - - def addSurfaceAxes(self): - self.surfaceAx = self.surfaceFigure.add_subplot(111, projection = '3d') - - def addStatAxes(self): - self.statAx_left = self.statFigure_left.add_subplot(111) - self.statAx_right = self.statFigure_right.add_subplot(111) - - def enablePickedTools(self, bool, twoDim = False): - self.mainUI.comboBox_stats.setEnabled(bool) - self.statToolbar_left.setEnabled(bool) - self.statToolbar_right.setEnabled(bool) - if not twoDim: - self.mainUI.comboBox_shots.setEnabled(bool) - self.mainUI.shot_left.setEnabled(bool) - self.mainUI.shot_right.setEnabled(bool) - self.mainUI.plot_shot.setEnabled(bool) - if bool == False: - self.mainUI.comboBox_shots.clear() - - def replotArray(self): - self.seisArrayFigure.clf() - self.addArrayAxes() - self.plotArray() - self.seisArrayCanvas.draw() - - def replotSurface(self): - self.surfaceFigure.clf() - self.addSurfaceAxes() - self.plotSurface() - self.surfaceCanvas.draw() - - def plotArray(self): - self.seisarray.plotArray2D(self.seisArrayAx, highlight_measured = True, plot_topo = True, twoDim = self.seisarray.twoDim) - - def plotSurface(self): - if not self.seisarray.twoDim: - self.seisarray.plotSurface3D(ax = self.surfaceAx, exag = True) - self.seisarray.plotArray3D(ax = self.surfaceAx, legend = False, markersize = 3) - - def InitPickedWidgets(self): - if self.checkPickState(): - surveyUtils.plotScatterStats4Receivers(self.survey, self.mainUI.comboBox_stats.currentText(), - self.statAx_left, twoDim = self.survey.twoDim) - surveyUtils.plotScatterStats4Shots(self.survey, self.mainUI.comboBox_stats.currentText(), - self.statAx_right, twoDim = self.survey.twoDim) - self.addItems2ShotsComboBox() - - def refreshPickedWidgets(self): - self.statFigure_left.clf() - self.statFigure_right.clf() - self.addStatAxes() - self.InitPickedWidgets() - self.statCanvas_left.draw() - self.statCanvas_right.draw() - - def printSurveyTextbox(self, init = True): - if init == True: - surveytup = (0, 0, 0, 0) - else: - survey = self.survey - nshots = len(survey.getShotlist()) - tt = survey.countAllTraces() - pt = survey.countAllPickedTraces() - rate = float(pt) / float(tt) * 100 - surveytup = (nshots, tt, pt, rate) - surveyTitle = 'SURVEY:\n' - surveyText = 'Number of Sources: %s\nTotal Traces: %s\nPicked Traces: %s (%4.2f%%)'%surveytup - string = surveyTitle + surveyText - self.mainUI.textBox_survey.setText(string) - - def printSeisArrayTextbox(self, init = True): - if init == True: - seistup = (0, 0, 0) - else: - seisarray = self.seisarray - nshots = len(seisarray.getSourceCoordinates()) - nrec = len(seisarray.getReceiverCoordinates()) - nadd = len(seisarray.getMeasuredTopo()) - seistup = (nshots, nrec, nadd) - seisArrayTitle = 'SEISARRAY:\n' - seisArrayText = 'Sources: %s\nReceivers: %s\nAdditional Points:%s'%seistup - string = seisArrayTitle + seisArrayText - self.mainUI.textBox_seisarray.setText(string) - - def interpolate_receivers(self): - if not self.checkSeisArrayState(): - printDialogMessage('No Seismic Array defined.') - return - self.seisarray.interpolateAll() - self.refreshSeisArrayWidgets() - - def refreshSeisArrayWidgets(self): - self.replotArray() - self.replotSurface() - self.printSeisArrayTextbox(init = False) - - - def connect2Survey(self): - if not self.checkSurveyState(): - printDialogMessage('No Survey defined.') - return - if not self.checkSeisArrayState(): - printDialogMessage('Got no Seismic Array.') - return - if self.checkConnected2SurveyState(): - if not continueDialogMessage('Existing Survey already got Seismic Array object. Continue?'): - return - self.survey.seisarray = self.seisarray - self.setConnected2SurveyState(True) - self.survey._initiate_SRfiles() - self.printSurveyTextbox(init = False) - print('Connected Seismic Array to active Survey object.') - - def startPicker(self): - if not self.checkSurveyState(): - printDialogMessage('No Survey defined.') - return - if self.checkPickState(): - if not continueDialogMessage('Survey already picked. Continue?'): - return - - if self.autopicker is None: - self.autopicker = Call_autopicker(self.mainwindow, self.survey) - else: - self.autopicker.start_dialog() - self.autopicker.update_survey(self.survey) - - if self.autopicker.executed: - self.setPickState(True) - self.printSurveyTextbox(init = False) - - def startFMTOMO(self): - if not self.checkSurveyState(): - printDialogMessage('No Survey defined.') - return - if not self.checkPickState(): - printDialogMessage('Survey not picked.') - return - - if self.fmtomo is None: - self.fmtomo = Call_FMTOMO(self.mainwindow, self.survey) - else: - self.fmtomo.start_dialog() - self.fmtomo.update_survey(self.survey) - - #if self.fmtomo.executed: - - - def startVTKtools(self): - if self.vtktools is None: - self.vtktools = Call_VTK_dialog(self.mainwindow) - else: - self.vtktools.start_dialog() - - def postprocessing(self): - if not self.checkSurveyState(): - printDialogMessage('No Survey defined.') - return - self.postprocessing = Postprocessing(self.mainwindow, self.survey) - #self.survey.plotAllPicks() - #self.refreshPickedWidgets() # wait until finished - - - def load_survey(self): - if self.checkSurveyState(): - if not continueDialogExists('Survey'): - return - filename = openFile() - if filename is None: - return - try: - survey = activeSeismoPick.Survey.from_pickle(filename) - except: - printDialogMessage('Could not load object %s.'%filename) - return - if not type(survey) == activeSeismoPick.Survey: - printDialogMessage('Wrong input file of type %s, expected %s.' - %(type(survey), activeSeismoPick.Survey)) - return - if self.checkSeisArrayState() and survey.seisarray is not None: - if not continueDialogMessage('Survey got existing Seismic Array.' - ' Do you want to overwrite the current Seismic Array?'): - return - self.survey = survey - self.setSurveyState(True) - if self.survey.picked: - self.setPickState(True) - else: - self.setPickState(False) - if self.survey.seisarray != None: - self.seisarray = self.survey.seisarray - self.setConnected2SurveyState(True) - self.setSeisArrayState(True) - printDialogMessage('Loaded Survey with active Seismic Array.') - else: - self.setConnected2SurveyState(False) - self.setSeisArrayState(False) - printDialogMessage('Loaded Survey.') - - def load_seisarray(self): - disconnect = False - if self.checkSeisArrayState(): - if not continueDialogExists('Seismic Array'): - return - if self.checkConnected2SurveyState(): - if not continueDialogMessage('Seismic Array connected to present Survey.\n' - 'Continuation will disconnect the Seismic Array.'): - return - else: - self.survey.seisarray = None - disconnect = True - - filename = openFile() - if filename is None: - return - try: - seisarray = seismicArrayPreparation.SeisArray.from_pickle(filename) - except: - printDialogMessage('Could not load object %s.'%filename) - return - if not type(seisarray) == seismicArrayPreparation.SeisArray: - printDialogMessage('Wrong input file of type %s, expected %s.' - %(type(seisarray), seismicArrayPreparation.SeisArray)) - return - if disconnect: - self.setConnected2SurveyState(False) - self.seisarray = seisarray - self.setSeisArrayState(True) - - def save_seisarray(self): - if not self.checkSeisArrayState(): - printDialogMessage('No Seismic Array defined.') - return - filename = saveFile() - if filename is None: - return - self.seisarray.saveSeisArray(filename) - - def save_survey(self): - if not self.checkSurveyState(): - printDialogMessage('No Survey defined.') - return - filename = saveFile() - if filename is None: - return - self.survey.saveSurvey(filename) - - def setSurveyState(self, state): - if state == True: - self.mainUI.survey_active.setPixmap(self.applypixmap) - self.printSurveyTextbox(init = False) - elif state == False: - self.mainUI.survey_active.setPixmap(self.cancelpixmap) - - def checkSurveyState(self): - if self.survey == None: - return False - else: - return True - - def checkSeisArrayState(self): - if self.seisarray == None: - return False - else: - return True - - def setPickState(self, state): - if state == True and self.checkSurveyState(): - self.mainUI.picked_active.setPixmap(self.applypixmap) - self.refreshPickedWidgets() - self.enablePickedTools(True, self.survey.twoDim) - self.survey.picked = True - elif state == True and self.checkSurveyState() is False: - printDialogMessage('No Survey defined.') - return - elif state == False: - self.mainUI.picked_active.setPixmap(self.cancelpixmap) - if self.checkSurveyState(): - self.statFigure_left.clf() - self.statFigure_right.clf() - self.enablePickedTools(False) - self.survey.picked = False - - def setSeisArrayState(self, state): - if state == True: - self.mainUI.seisarray_active.setPixmap(self.applypixmap) - self.refreshSeisArrayWidgets() - self.seisArrayToolbar.setEnabled(True) - elif state == False: - self.mainUI.seisarray_active.setPixmap(self.cancelpixmap) - self.seisArrayToolbar.setEnabled(False) - if self.seisArrayFigure is not None: - self.seisArrayFigure.clf() - - def setConnected2SurveyState(self, state): - if state == True: - self.mainUI.seisarray_on_survey_active.setPixmap(self.applypixmap) - elif state == False: - self.mainUI.seisarray_on_survey_active.setPixmap(self.cancelpixmap) - - def checkConnected2SurveyState(self): - if self.checkSurveyState(): - if self.survey.seisarray != None: - return True - else: - return False - - def checkPickState(self): - if not self.survey: - printDialogMessage('No Survey defined.') - return - return self.survey.picked - - def exitApp(self): - if self.checkSurveyState(): - if continueDialogMessage('Do you want to save the current Survey?'): - self.save_survey() - else: - return - QtCore.QCoreApplication.instance().quit() - - -if __name__ == "__main__": - app = QtGui.QApplication(sys.argv) - MainWindow = QtGui.QMainWindow() - ui = Ui_MainWindow() - ui.setupUi(MainWindow) - MainWindow.showMaximized() - gui = gui_control() - sys.exit(app.exec_()) - diff --git a/pylot/core/active/__init__.py b/pylot/core/active/__init__.py deleted file mode 100644 index aafb279b..00000000 --- a/pylot/core/active/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -# -*- coding: utf-8 -*- -__author__ = 'marcel' diff --git a/pylot/core/active/activeSeismoPick.py b/pylot/core/active/activeSeismoPick.py deleted file mode 100644 index 02bda997..00000000 --- a/pylot/core/active/activeSeismoPick.py +++ /dev/null @@ -1,779 +0,0 @@ -# -*- coding: utf-8 -*- -import os -import sys -import math -import numpy as np -from pylot.core.active import seismicshot -from pylot.core.active.surveyUtils import cleanUp -from pylot.core.util.utils import worker, _pickle_method - -def picker(shot): - picks = [] - for traceID in shot.getTraceIDlist(): - picks.append((shot.getShotnumber(), traceID, shot.pickTrace(traceID))) - return picks - -class Survey(object): - def __init__(self, path, sourcefile = None, receiverfile = None, seisArray = None, useDefaultParas=False, fstart = None, fend = None): - ''' - The Survey Class contains all shots [class: Seismicshot] of a survey - as well as the aquisition geometry and the topography. - - It contains methods to pick all traces of all shots. - - It contains several methods e.g. for plotting of all picks (and postprocessing), - creating plots for all shots. - ''' - self.data = {} - self.seisarray = seisArray - self._topography = None - self._recfile = receiverfile - self._sourcefile = sourcefile - self._obsdir = path - self._generateSurvey(fstart, fend) - self._initiate_SRfiles() - if useDefaultParas == True: - self.setParametersForAllShots() - self._removeAllEmptyTraces() - self._updateShots() - self.picked = False - - def _coordsFromSeisArray(self): - self._receiverCoords = self.seisarray.getReceiverCoordinates() - self._sourceCoords = self.seisarray.getSourceCoordinates() - - def _coordsFromFiles(self): - self._receiversFromFile() - self._sourcesFromFile() - - def _receiversFromFile(self): - self._receiverCoords = {} - reclist = open(self.getReceiverfile(), 'r').readlines() - for line in reclist: - line = line.split() - traceID = int(line[0]) - x = float(line[1]) - y = float(line[2]) - z = float(line[3]) - self._receiverCoords[traceID] = (x, y, z) - - def _sourcesFromFile(self): - self._sourceCoords = {} - reclist = open(self.getSourcefile(), 'r').readlines() - for line in reclist: - line = line.split() - sourceID = int(line[0]) - x = float(line[1]) - y = float(line[2]) - z = float(line[3]) - self._sourceCoords[sourceID] = (x, y, z) - - def _initiate_SRfiles(self): - if self._recfile == None and self._sourcefile == None: - if self.seisarray == None: - raise RuntimeError('No SeisArray defined. No source or receiver file given.') - self._coordsFromSeisArray() - else: - self._coordsFromFiles() - self.loadArray(self._obsdir, self._recfile, self._sourcefile) - for shotnumber in self.data.keys(): - shot = self.data[shotnumber] - shot.setShotnumber(shotnumber) - shot.setReceiverCoords(self._receiverCoords) - shot.setSourceCoords(self._sourceCoords[shotnumber]) - - def _generateSurvey(self, fstart = None, fend = None): - from obspy.core import read - - shot_dict = {} - shotlist = self.getShotlist() - for shotnumber in shotlist: # loop over data files - # generate filenames and read manual picks to a list - #fileending = '.sg2' - if fend == None: - fend = '_pickle.dat' - obsfile = os.path.join(self._obsdir, fstart + str(shotnumber)) + fend - if obsfile not in shot_dict.keys(): - shot_dict[shotnumber] = [] - shot_dict[shotnumber] = seismicshot.SeismicShot(obsfile) - shot_dict[shotnumber].setParameters('shotnumber', shotnumber) - - if self._check2D(): - print('Survey is two dimensional!') - self.twoDim = True - else: - self.twoDim = False - self.data = shot_dict - print ("Generated Survey object for %d shots" % len(shotlist)) - print ("Total number of traces: %d \n" % self.countAllTraces()) - - def _removeAllEmptyTraces(self): - ''' - Removes traces of the dataset that are not found in the input receiver files. - ''' - logfile = 'removeEmptyTraces.out' - count = 0 - for shot in self.data.values(): - removed = shot.removeEmptyTraces() - if removed is not None: - if count == 0: outfile = open(logfile, 'w') - count += 1 - outfile.writelines('shot: %s, removed empty traces: %s\n' - % (shot.getShotnumber(), removed)) - print ("\nremoveEmptyTraces: Finished! Removed %d traces" % count) - if count > 0: - print ("See %s for more information " - "on removed traces." % (logfile)) - outfile.close() - - def _updateShots(self): - ''' - Removes traces that do not exist in the dataset for any reason, - but were set in the input files. - ''' - logfile = 'updateShots.out' - count = 0 - countTraces = 0 - for shot in self.data.values(): - del_traceIDs = shot.updateTraceList() - if len(del_traceIDs) > 0: - if count == 0: outfile = open(logfile, 'w') - count += 1 - countTraces += len(del_traceIDs) - outfile.writelines("shot: %s, removed traceID(s) %s because " - "they were not found in the corresponding stream\n" - % (shot.getShotnumber(), del_traceIDs)) - - print ("\nupdateShots: Finished! Updated %d shots and removed " - "%d traces" % (count, countTraces)) - if count > 0: - print ("See %s for more information " - "on removed traces." % (logfile)) - outfile.close() - - def _check2D(self): - if self.seisarray is None: - print('Check2D: No SeisArray defined') - return - if self.seisarray.check2D(): - return True - else: - return False - - def updateSeisArray(self, SeisArray): - if not type(SeisArray) == pylot.core.active.seismicArrayPreparation.SeisArray: - print('Wrong data type.') - return - self.seisarray = SeisArray - self._initiate_SRfiles() - - def setParametersForAllShots(self, cutwindow=(0, 0.2), tmovwind=0.3, - tsignal=0.03, tgap=0.0007): - if (cutwindow == (0, 0.2) and tmovwind == 0.3 and - tsignal == 0.03 and tgap == 0.0007): - print ("Warning: Standard values used for " - "setParamters. This might not be clever.") - for shot in self.data.values(): - shot.setCut(cutwindow) - shot.setTmovwind(tmovwind) - shot.setTsignal(tsignal) - shot.setTgap(tgap) - shot.setOrder(order=4) - print ("setParametersForAllShots: Parameters set to:\n" - "cutwindow = %s, tMovingWindow = %f, tsignal = %f, tgap = %f" - % (cutwindow, tmovwind, tsignal, tgap)) - - - def loadArrayFromPickle(self, filename): - from pylot.core.active.seismicArrayPreparation import SeisArray - array = SeisArray.from_pickle(filename) - self.seisarray = array - - def loadArray(self, path, receiverfile, sourcefile): - from pylot.core.active.seismicArrayPreparation import SeisArray - - array = SeisArray(os.path.join(path, receiverfile)) - array.addSourceLocations(os.path.join(path, sourcefile)) - self.seisarray = array - - def setManualPicksFromFiles(self, directory='picks'): - ''' - Read manual picks from *.pck files in a directory. - Can be used for comparison of automatic and manual picks. - - The * must be identical with the shotnumber. - ''' - for shot in self.data.values(): - shot.setManualPicksFromFile(directory) - - def getDiffsFromManual(self): - ''' - Returns a dictionary with the differences between manual and automatic pick for all shots. - Key: Seismicshot [object] - ''' - diffs = {} - for shot in self.data.values(): - if not shot in diffs.keys(): - diffs[shot] = {} - for traceID in shot.getTraceIDlist(): - if shot.getPickFlag(traceID) == 1 and shot.getManualPickFlag( - traceID) == 1: - diffs[shot][traceID] = shot.getPick( - traceID) - shot.getManualPick(traceID) - return diffs - - def plotDiffs(self): - ''' - Creates a plot of all Picks colored by the - difference between automatic and manual pick. - ''' - import matplotlib.pyplot as plt - diffs = [] - dists = [] - mpicks = [] - picks = [] - diffsDic = self.getDiffsFromManual() - for shot in self.data.values(): - for traceID in shot.getTraceIDlist(): - if shot.getPickFlag(traceID) == 1 and shot.getManualPickFlag( - traceID) == 1: - dists.append(shot.getDistance(traceID)) - mpicks.append(shot.getManualPick(traceID)) - picks.append(shot.getPick(traceID)) - diffs.append(diffsDic[shot][traceID]) - - labelm = 'manual picks' - labela = 'automatic picks' - - fig = plt.figure() - ax = fig.add_subplot(111) - - sc_a = ax.scatter(dists, picks, c='0.5', s=10, edgecolors='none', - label=labela, alpha=0.3) - sc = ax.scatter(dists, mpicks, c=diffs, s=5, edgecolors='none', - label=labelm) - cbar = plt.colorbar(sc, fraction=0.05) - cbar.set_label(labelm) - ax.set_xlabel('Distance [m]') - ax.set_ylabel('Time [s]') - ax.text(0.5, 0.95, 'Plot of all MANUAL picks', transform=ax.transAxes, - horizontalalignment='center') - plt.legend() - - def plotHist(self, nbins=20, ax=None): - ''' - Plot a histogram of the difference between automatic and manual picks. - ''' - import matplotlib.pyplot as plt - plt.interactive(True) - diffs = [] - if ax == None: - fig = plt.figure() - ax = fig.add_subplot(111) - for shot in self.data.values(): - for traceID in shot.getTraceIDlist(): - if shot.getPickFlag(traceID) == 1 and shot.getManualPickFlag( - traceID) == 1: - diffs.append(self.getDiffsFromManual()[shot][traceID]) - hist = plt.hist(diffs, nbins, histtype='step', normed=True, - stacked=True) - plt.title( - 'Histogram of the differences between automatic and manual pick') - plt.xlabel('Difference in time (auto - manual) [s]') - return diffs - - def pickAllShots(self, vmin=333, vmax=5500, folm=0.6, HosAic='hos', - aicwindow=(15, 0), cores = 1): - ''' - Automatically pick all traces of all shots of the survey. - - :param: vmin, vmax, minimum (maximum) permitted apparent velocity on direct path between src and rec - :type: real - - :param: folm, fraction of local maximum for HOS pick (0.6 = 60% of the highest maximum) - :type: real - - :param: HosAic, pick with hos only ('hos') or use AIC ('aic') - :type: string - - :param: aicwindow, window around the initial pick to search for local AIC min (samples) - :type: tuple - ''' - from datetime import datetime - starttime = datetime.now() - count = 0 - tpicksum = starttime - starttime - - shotlist = [] - - print('pickAllShots: Setting pick parameters...') - for shot in self.data.values(): - tstartpick = datetime.now() - shot.setVmin(vmin) - shot.setVmax(vmax) - count += 1 - shot.setPickParameters(folm = folm, method = HosAic, aicwindow = aicwindow) - shotlist.append(shot) - - print('pickAllShots: Starting to pick...') - if cores > 1: - print('Picking parallel on %s cores.'%cores) - picks = worker(picker, shotlist, cores) - elif cores == 1: - print('Picking serial on one core.') - picks = [] - for shot in shotlist: - picks.append(picker(shot)) - else: - raise ValueError('cores must be >= 1') - print('Done!') - - for shot in picks: - for item in shot: - shotnumber, traceID, pick = item - self.getShotForShotnumber(shotnumber).setPick(traceID, pick) - - # tpicksum += (datetime.now() - tstartpick); - # tpick = tpicksum / count - # tremain = (tpick * (len(self.getShotDict()) - count)) - # tend = datetime.now() + tremain - # progress = float(count) / float(len(self.getShotDict())) * 100 - # self._update_progress(shot.getShotname(), tend, progress) - - self.filterSNR() - self.setEarllate() - - print('\npickAllShots: Finished\n') - self.picked = True - ntraces = self.countAllTraces() - pickedtraces = self.countAllPickedTraces() - print('Picked %s / %s traces (%d %%)\n' - % (pickedtraces, ntraces, - float(pickedtraces) / float(ntraces) * 100.)) - - def filterSNR(self): - print('Starting filterSNR...') - for shot in self.data.values(): - for traceID in shot.getTraceIDlist(): - shot.setSNR(traceID) - # if shot.getSNR(traceID)[0] < snrthreshold: - if shot.getPick(traceID) <= 0: - shot.removePick(traceID) - if shot.getSNR(traceID)[0] < shot.getSNRthreshold(traceID): - shot.removePick(traceID) - - def setEarllate(self): - print('Starting setEarllate...') - for shot in self.data.values(): - for traceID in shot.getTraceIDlist(): - # set epp and lpp if SNR > 1 (else earllatepicker cant set values) - if shot.getSNR(traceID)[0] > 1: - shot.setEarllatepick(traceID) - - def cleanBySPE(self, maxSPE): - ''' - Sets all picks as invalid if they exceed a certain value of the symmetric pick error. - ''' - for shot in self.data.values(): - for traceID in shot.getTraceIDlist(): - if shot.getPickFlag(traceID) == 1: - if shot.getSymmetricPickError(traceID) > maxSPE: - shot.setPickFlag(traceID, 0) - - def plotSPE(self): - ''' - Plots the symmetric pick error sorted by magnitude. - ''' - import matplotlib.pyplot as plt - spe = [] - for shot in self.data.values(): - for traceID in shot.getTraceIDlist(): - if shot.getPickFlag(traceID) == 1: - spe.append(shot.getSymmetricPickError(traceID)) - spe.sort() - plt.plot(spe, label='SPE') - plt.ylabel('Symmetric Pickerror') - plt.legend() - - def recover(self): - ''' - Recovers all manually removed picks. Still regards SNR threshold. - ''' - print('Recovering survey...') - numpicks = 0 - for shot in self.data.values(): - for traceID in shot.getTraceIDlist(): - if shot.getPickFlag(traceID) == 0: - shot.setPickFlag(traceID, 1) - if shot.getSNR(traceID)[0] < shot.getSNRthreshold(traceID): - shot.removePick(traceID) - else: - numpicks += 1 - print('Recovered %d picks' % numpicks) - - def setArtificialPick(self, traceID, pick): - ''' - Sets an artificial pick for a certain receiver (traceID) for all shots. - ''' - for shot in self.data.values(): - shot.setPick(traceID, pick) - shot.setPickwindow(traceID, shot.getCut()) - - def countAllTraces(self): - ''' - Returns the number of traces in total. - ''' - numtraces = 0 - for shot in self.getShotlist(): - for rec in self.getReceiverlist(): - numtraces += 1 - - return numtraces - - def getShotlist(self): - ''' - Returns a list of all shotnumbers contained in the set Sourcefile. - ''' - if self._recfile == None and self._sourcefile == None: - if self.seisarray == None: - raise RuntimeError('No SeisArray defined. No source or receiver file given.') - return self.seisarray.getSourceCoordinates().keys() - - filename = self.getSourcefile() - srcfile = open(filename, 'r') - shotlist = [] - for line in srcfile.readlines(): - line = line.split() - shotlist.append(int(line[0])) - - return shotlist - - def getReceiverlist(self): - ''' - Returns a list of all trace IDs contained in the set Receiverfile. - ''' - if self._recfile == None and self._sourcefile == None: - if self.seisarray == None: - raise RuntimeError('No SeisArray defined. No source or receiver file given.') - return self.seisarray.getReceiverCoordinates().keys() - - filename = self.getReceiverfile() - recfile = open(filename, 'r') - reclist = [] - for line in recfile.readlines(): - line = line.split() - reclist.append(int(line[0])) - - return reclist - - def getShotDict(self): - return self.data - - def getShot(self, shotnumber): - return self.data[shotnumber] - - def getSourcefile(self): - return self._sourcefile - - def getReceiverfile(self): - return self._recfile - - def getPath(self): - return self._obsdir - - def getStats(self): - ''' - Generates and returns a dictionary containing statistical information - of the survey. - - Key: shotnumber - ''' - info_dict = {} - for shot in self.data.values(): - pickedTraces = 0 - snrlist = [] - dist = [] - numtraces = len(shot.getTraceIDlist()) - for traceID in shot.getTraceIDlist(): - snrlist.append(shot.getSNR(traceID)[0]) - dist.append(shot.getDistance(traceID)) - if shot.getPickFlag(traceID) is not 0: - pickedTraces += 1 - info_dict[shot.getShotnumber()] = {'numtraces': numtraces, - 'picked traces': [pickedTraces, - '%2.2f %%' % ( - float( - pickedTraces) / - float( - numtraces) * 100)], - 'mean SNR': np.mean(snrlist), - 'mean distance': np.mean(dist)} - - return info_dict - - def getShotForShotnumber(self, shotnumber): - ''' - Returns Seismicshot [object] of a certain shotnumber if possible. - ''' - for shot in self.data.values(): - if shot.getShotnumber() == shotnumber: - return shot - - def exportFMTOMO(self, directory='FMTOMO_export', sourcefile='input_sf.in', - ttFileExtension='.tt'): - ''' - Exports all picks into a directory as travel time files readable by FMTOMO obsdata. - ''' - - def getAngle(distance): - PI = np.pi - R = 6371. - angle = distance * 180 / (PI * R) - return angle - - count = 0 - fmtomo_factor = 1000 # transforming [m/s] -> [km/s] - LatAll = [] - LonAll = [] - DepthAll = [] - srcfile = open(directory + '/' + sourcefile, 'w') - srcfile.writelines('%10s\n' % len(self.data)) # number of sources - for shotnumber in self.getShotlist(): - shot = self.getShotForShotnumber(shotnumber) - ttfilename = str( - shotnumber) + ttFileExtension # filename of travel time file for this shot - (x, y, z) = shot.getSrcLoc() # getSrcLoc returns (x, y, z) - srcfile.writelines('%10s %10s %10s\n' % ( - getAngle(y), getAngle(x), (-1) * z)) # transform to lat, lon, depth - LatAll.append(getAngle(y)) - LonAll.append(getAngle(x)) - DepthAll.append((-1) * z) - srcfile.writelines('%10s\n' % 1) - srcfile.writelines('%10s %10s %10s\n' % (1, 1, ttfilename)) - ttfile = open(directory + '/' + ttfilename, 'w') - traceIDlist = shot.getTraceIDlist() - traceIDlist.sort() - ttfile.writelines(str(self.countPickedTraces(shot)) + '\n') - for traceID in traceIDlist: - if shot.getPickFlag(traceID) is not 0: - pick = shot.getPick(traceID) * fmtomo_factor - delta = shot.getSymmetricPickError(traceID) * fmtomo_factor - (x, y, z) = shot.getRecLoc(traceID) - ttfile.writelines('%20s %20s %20s %10s %10s\n' % ( - getAngle(y), getAngle(x), (-1) * z, pick, delta)) - LatAll.append(getAngle(y)) - LonAll.append(getAngle(x)) - DepthAll.append((-1) * z) - count += 1 - ttfile.close() - srcfile.close() - msg = 'Wrote output for {0} traces\n' \ - 'WARNING: output generated for FMTOMO-obsdata. Obsdata seems ' \ - 'to take Lat, Lon, Depth and creates output for FMTOMO as ' \ - 'Depth, Lat, Lon\nDimensions of the seismic Array, ' \ - 'transformed for FMTOMO, are Depth({1}, {2}), Lat({3}, {4}), ' \ - 'Lon({5}, {6})'.format(count, - min(DepthAll), - max(DepthAll), - min(LatAll), - max(LatAll), - min(LonAll), - max(LonAll)) - print(msg) - - def countPickedTraces(self, shot): - ''' - Counts all picked traces of a shot (type Seismicshot). - ''' - count = 0 - for traceID in shot.getTraceIDlist(): - if shot.getPickFlag(traceID) is not 0: - count += 1 - return count - - def countAllPickedTraces(self): - ''' - Counts all picked traces of the survey. - ''' - count = 0 - if not self.picked: - return count - - for shot in self.data.values(): - for traceID in shot.getTraceIDlist(): - if shot.getPickFlag(traceID) is not 0: - count += 1 - return count - - def plotAllShots(self, rows=3, columns=4, mode='3d'): - ''' - Plots all shots as Matrices with the color corresponding to the traveltime for each receiver. - IMPORTANT NOTE: Topography (z - coordinate) is not considered in the diagrams! - ''' - import matplotlib.pyplot as plt - from mpl_toolkits.mplot3d import Axes3D - plt.interactive(True) - - fig = plt.figure() - ax = fig.add_subplot(111) - - figPerSubplot = columns * rows - - index = 1 - - for shotnumber in self.getShotlist(): - if index <= figPerSubplot: - ax = fig.add_subplot(rows, columns, index) - if mode == '3d': - self.getShot(shotnumber).matshow(ax=ax, colorbar=False, - annotations=True, - legend=False) - elif mode == '2d': - self.getShot(shotnumber).plot2dttc(ax) - self.getShot(shotnumber).plotmanual2dttc(ax) - index += 1 - if index > figPerSubplot: - fig.subplots_adjust(left=0, bottom=0, right=1, top=1, wspace=0, - hspace=0) - fig = plt.figure() - index = 1 - - fig.subplots_adjust(left=0, bottom=0, right=1, top=1, wspace=0, - hspace=0) - - def plotAllPicks(self, plotRemoved=False, colorByVal='log10SNR', ax=None, - cbar=None, refreshPlot=False): - ''' - Plots all picks over the distance between source and receiver. Returns (ax, region). - Picks can be checked and removed by using region class (pylot.core.active.surveyPlotTools.regions) - - :param: plotRemoved, if True plots traces that were picked but removed from the survey (flag = 0) - :type: logical - - :param: colorByVal, can be "log10SNR", "pickerror", or "spe" - :type: str - - Examples: - - regions.chooseRectangles(): - - lets the user choose several rectangular regions in the plot - - regions.plotTracesInRegions(): - - creates plots (shot.plot_traces) for all traces in the active regions (i.e. chosen by e.g. chooseRectangles) - - regions.setActiveRegionsForDeletion(): - - highlights all shots in a the active regions for deletion - - regions.deleteMarkedPicks(): - - deletes the picks (pick flag set to 0) for all shots set for deletion - - regions.deselectSelection(number): - - deselects the region of number = number - - ''' - - import matplotlib.pyplot as plt - plt.interactive(True) - from pylot.core.active.surveyPlotTools import regions - - dist, pick, snrlog, pickerror, spe = self.preparePlotAllPicks(plotRemoved) - - color = {'log10SNR': snrlog, - 'pickerror': pickerror, - 'spe': spe} - self.color = color - if refreshPlot is False: - ax, cbar, sc = self.createPlot(dist, pick, color[colorByVal], - label='%s' % colorByVal) - region = regions(ax, cbar, self) - ax.legend() - return (ax, region) - if refreshPlot is True: - ax, cbar, sc = self.createPlot(dist, pick, color[colorByVal], - label='%s' % colorByVal, ax=ax, - cbar=cbar) - ax.legend() - return ax - - def preparePlotAllPicks(self, plotRemoved = False): - dist = [] - pick = [] - snrlog = [] - pickerror = [] - spe = [] - - for shot in self.data.values(): - for traceID in shot.getTraceIDlist(): - if plotRemoved == False: - if shot.getPickFlag( - traceID) is not 0 or plotRemoved == True: - dist.append(shot.getDistance(traceID)) - pick.append(shot.getPick(traceID)) - snrlog.append(math.log10(shot.getSNR(traceID)[0])) - pickerror.append(shot.getPickError(traceID)) - spe.append(shot.getSymmetricPickError(traceID)) - - return dist, pick, snrlog, pickerror, spe - - - def createPlot(self, dist, pick, inkByVal, label, ax=None, cbar=None): - ''' - Used by plotAllPicks. - ''' - import matplotlib.pyplot as plt - #plt.interactive(True) - cm = plt.cm.jet - if ax is None: - print('Generating new plot...') - fig = plt.figure() - ax = fig.add_subplot(111) - sc = ax.scatter(dist, pick, cmap=cm, c=inkByVal, s=5, - edgecolors='none', label=label) - cbar = fig.colorbar(sc, fraction=0.05) - cbar.set_label(label) - ax.set_xlabel('Distance [m]') - ax.set_ylabel('Time [s]') - ax.text(0.5, 0.95, 'Plot of all picks', transform=ax.transAxes, - horizontalalignment='center') - else: - sc = ax.scatter(dist, pick, cmap=cm, c=inkByVal, s=5, - edgecolors='none', label=label) - if cbar is not None: - cbar.ax.clear() - cbar = ax.figure.colorbar(sc, cax=cbar.ax) - cbar.set_label(label) - ax.set_xlabel('Distance [m]') - ax.set_ylabel('Time [s]') - ax.text(0.5, 0.95, 'Plot of all picks', transform=ax.transAxes, - horizontalalignment='center') - return ax, cbar, sc - - def _update_progress(self, shotname, tend, progress): - sys.stdout.write( - 'Working on shot %s. ETC is %02d:%02d:%02d [%2.2f %%]\r' % ( - shotname, - tend.hour, - tend.minute, - tend.second, - progress)) - sys.stdout.flush() - - def saveSurvey(self, filename='survey.pickle'): - ''' - Save Survey object to a file. - Can be loaded by using Survey.from_pickle(filename). - ''' - import cPickle - cleanUp(self) - outfile = open(filename, 'wb') - - cPickle.dump(self, outfile, -1) - print('saved Survey to file %s' % (filename)) - - @staticmethod - def from_pickle(filename): - import cPickle - infile = open(filename, 'rb') - survey = cPickle.load(infile) - print('Loaded %s'%filename) - return survey diff --git a/pylot/core/active/fmtomoUtils.py b/pylot/core/active/fmtomoUtils.py deleted file mode 100644 index 5c27aed0..00000000 --- a/pylot/core/active/fmtomoUtils.py +++ /dev/null @@ -1,1108 +0,0 @@ -# -*- coding: utf-8 -*- -import os -import sys -import subprocess -import datetime -import numpy as np - -class Tomo3d(object): - def __init__(self, fmtomodir, simuldir = 'fmtomo_simulation', citer = 0, overwrite = False, buildObs = True): - ''' - Class build from FMTOMO script tomo3d. Can be used to run several instances of FMM code in parallel. - - :param: citer, current iteration (default = 0: start new model) - :type: integer - - :param: fmtomodir, directory containing a clean FMTOMO installation (v. 1.0) - :type: string (path) - - :param: simuldir, simulation directory (must contain FMTOMO input grid files) - :type: string (path) - ''' - self.simuldir = simuldir - self.setCWD() - self.buildFmtomodir(fmtomodir) - if buildObs: - self.buildObsdata() - self.defParas() - self.copyRef() - self.citer = citer # current iteration - self.sources = self.readSrcFile() - self.traces = self.readTraces() - self.directories = [] - self.overwrite = overwrite - - def defParas(self): - self.defFMMParas() - self.defInvParas() - - def buildFmtomodir(self, directory): - tomo_files = ['fm3d', - 'frechgen', - 'frechgen.in', - 'invert3d', - 'invert3d.in', - 'mode_set.in', - 'obsdata', - 'obsdata.in', - 'residuals', - 'residuals.in', - 'tomo3d', - 'tomo3d.in'] - - for name in tomo_files: - filename = os.path.join(directory, name) - linkname = os.path.join(self.cwd, name) - os.system('ln -s %s %s'%(filename, linkname)) - - def buildObsdata(self): - p = subprocess.Popen(os.path.join(self.cwd, 'obsdata'), shell=True) - p.wait() - os.system('mv sources.in sourcesref.in') - - def defFMMParas(self): - ''' - Initiates parameters for the forward calculation. - ''' - # Comments coppied from FMTOMO. - # Name of fast marching program - self.fmm = os.path.join(self.cwd, 'fm3d') - # Name of program calculating Frechet derivatives - self.frechgen = os.path.join(self.cwd, 'frechgen') - # Name of current velocity/inversion grid - self.cvg = 'vgrids.in' - # Name of current interfaces grid - self.cig = 'interfaces.in' - # Name of file containing current source locations - self.csl = 'sources.in' - # Name of file containing propagation grid - self.pg = 'propgrid.in' - # Name of file containing receiver coordinates - self.rec = 'receivers.in' - self.frech = 'frechet.in' - self.frechout = 'frechet.dat' - # Name of file containing measured data - self.ot = 'otimes.dat' - # Name of file containing output velocity information - self.ttim = 'arrivals.dat' - self.mode = 'mode_set.in' - # Name of temporary folders created for each process - self.folder = '.proc_' - - def defInvParas(self): - ''' - Initiates inversion parameters for FMTOMO. - ''' - # Name of program for performing inversion - self.inv = os.path.join(self.cwd, 'invert3d') - # Name of file containing current model traveltimes - self.mtrav = 'mtimes.dat' - # Name of file containing reference model traveltimes - self.rtrav = 'rtimes.dat' - # Name of file containing initial velocity grid - self.ivg = 'vgridsref.in' - # Name of file containing initial interface grid - self.iig = 'interfacesref.in' - # Name of file containing initial source locations - self.isl = 'sourcesref.in' - # Name of program for calculating traveltime residuals - self.resid = os.path.join(self.cwd, 'residuals') - # Name of output file for calculating traveltime residuals - self.resout = 'residuals.dat' - - def copyRef(self): - ''' - Copies reference grids to used grids (e.g. sourcesref.in to sources.in) - ''' - os.system('cp %s %s'%(self.ivg, self.cvg)) - os.system('cp %s %s'%(self.iig, self.cig)) - os.system('cp %s %s'%(self.isl, self.csl)) - - def setCWD(self, directory = None): - ''' - Set working directory containing all necessary files. - - Default: pwd - ''' - if directory == None: - directory = self.simuldir - - os.chdir(directory) - self.cwd = directory - print('Working directory is: %s'%self.cwd) - - def runFrech(self): - os.system(self.frechgen) - - def runTOMO3D(self, nproc, iterations): - ''' - Starts up the FMTOMO code for the set number of iterations on nproc parallel processes. - - :param: nproc, number of parallel processes - :type: integer - - :param: iterations, number of iterations - :type: integer - ''' - self.nproc = nproc - self.iter = iterations # number of iterations - - starttime = datetime.datetime.now() - print('Starting TOMO3D on %s parallel processes for %s iteration(s).' - %(self.nproc, self.iter)) - if self.citer == 0: - self.makeInvIterDir() - self.startForward(self.cInvIterDir) - self.raiseIter() - - while self.citer <= self.iter: - self.makeInvIterDir() - self.startInversion() - self.saveVgrid() - self.startForward(self.cInvIterDir) - self.raiseIter() - - if self.citer > self.iter: - self.removeDirectories() - self.unlink(os.path.join(self.cwd, self.frechout)) - self.unlink(os.path.join(self.cwd, self.ttim)) - - tdelta = datetime.datetime.now() - starttime - print('runTOMO3D: Finished %s iterations after %s.'%(self.iter, tdelta)) - - def runFmm(self, directory, logfile, processes): - ''' - Calls an instance of the FMM code in the process directory. - Requires a list of all active processes and returns an updated list. - ''' - os.chdir(directory) - fout = open(logfile, 'w') - processes.append(subprocess.Popen(self.fmm, stdout = fout)) - fout.close() - os.chdir(self.cwd) - return processes - - def startForward(self, logdir): - ''' - Runs an instance of the FMM code in the process directory. - ''' - self._printLine() - print('Starting forward simulation for iteration %s.'%(self.citer)) - - if self.citer == 0: - self.copyRef() - self.runFrech() - self.makeDirectories() - - starttime = datetime.datetime.now() - processes = [] - - for procID in range(1, self.nproc + 1): - directory = self.getProcDir(procID) - logfn = 'fm3dlog_' + str(procID) + '.out' - log_out = os.path.join(logdir, logfn) - - self.writeSrcFile(procID) - self.writeTracesFile(procID) - os.system('cp {cvg} {cig} {mode} {pg} {frechin} {dest}' - .format(cvg=self.cvg, cig=self.cig, frechin=self.frech, - mode=self.mode, pg=self.pg, dest=directory)) - processes = self.runFmm(directory, log_out, processes) - - for p in processes: - p.wait() - - self.mergeOutput(self.cInvIterDir) - self.clearDirectories() - self.copyArrivals() - if self.citer == 0: - self.copyArrivals(self.rtrav) - - self.calcRes() - tdelta = datetime.datetime.now() - starttime - print('Finished Forward calculation after %s'%tdelta) - - def startInversion(self): - ''' - Simply calls the inversion program. - ''' - print('Calling %s...'%self.inv) - os.system(self.inv) - - def calcRes(self): - ''' - Calls residual calculation program. - ''' - resout = os.path.join(self.cwd, self.resout) - if self.citer == 0: - os.system('%s > %s'%(self.resid, resout)) - else: - os.system('%s >> %s'%(self.resid, resout)) - - with open(resout, 'r') as infile: - residuals = infile.readlines() - RMS, var, chi2 = residuals[-1].split() - print('Residuals: RMS = %s, var = %s, Chi^2 = %s.'%(RMS, var, chi2)) - - def raiseIter(self): - self.citer +=1 - self._printLine() - invfile = open(self.cwd + '/inviter.in', 'w') - invfile.write('%s'%self.citer) - invfile.close() - - def makeDir(self, directory): - err = os.system('mkdir %s'%directory) - if err is 0: - self.directories.append(directory) - return - if err is 256: - if self.overwrite == True: - print('Overwriting existing files.') - self.clearDir(directory) - self.directories.append(directory) - return - raise RuntimeError('Could not create directory: %s'%directory) - - def makeDirectories(self): - ''' - Makes temporary directories for all processes. - ''' - for procID in range(1, self.nproc + 1): - directory = self.getProcDir(procID) - self.makeDir(directory) - - def makeInvIterDir(self): - ''' - Makes directories for each iteration step for the output. - ''' - invIterDir = self.cwd + '/it_%s'%(self.citer) - err = os.system('mkdir %s'%invIterDir) - if err is 256: - if self.overwrite: - self.clearDir(invIterDir) - elif err is not 0: - raise RuntimeError('Could not create directory: %s'%invIterDir) - self.cInvIterDir = invIterDir - - def clearDir(self, directory): - ''' - Wipes a certain directory. - ''' - #print('Wiping directory %s...'%directory) - for filename in os.listdir(directory): - filenp = os.path.join(directory, filename) - os.remove(filenp) - - def clearDirectories(self): - ''' - Wipes all generated temporary directories. - ''' - for directory in self.directories: - self.clearDir(directory) - - def rmDir(self, directory): - #print('Removing directory %s...'%directory) - return os.rmdir(directory) - - def removeDirectories(self): - ''' - Removes all generated temporary directories. - ''' - for directory in self.directories: - self.rmDir(directory) - self.directories = [] - - def getProcDir(self, procID): - ''' - Returns the temporary directory for a certain process - with procID = process number. - ''' - return os.path.join(self.cwd, self.folder) + str(procID) - - def getTraceIDs4Sources(self, sourceIDs): - ''' - Returns corresponding trace IDs for a set of given source IDs. - ''' - traceIDs = [] - for traceID in self.traces.keys(): - if self.traces[traceID]['source'] in sourceIDs: - traceIDs.append(traceID) - return traceIDs - - def getTraceIDs4Source(self, sourceID): - ''' - Returns corresponding trace IDs for a source ID. - ''' - traceIDs = [] - for traceID in self.traces.keys(): - if self.traces[traceID]['source'] == sourceID: - traceIDs.append(traceID) - return traceIDs - - def copyArrivals(self, target = None): - ''' - Copies the FMM output file (self.ttim) to a specific target file. - Default target is self.mtrav (model travel times). - ''' - if target == None: - target = os.path.join(self.cwd, self.mtrav) - os.system('cp %s %s'%(os.path.join( - self.cInvIterDir, self.ttim), target)) - - def saveVgrid(self): - ''' - Saves the current velocity grid for the current iteration step. - ''' - vgpath = os.path.join(self.cwd, self.cvg) - os.system('cp %s %s'%(vgpath, self.cInvIterDir)) - - def calcSrcPerKernel(self): - ''' - (Equally) distributes all sources depending on the number of processes (kernels). - Returns two integer values. - First: minimum number of sources for each process - Second: remaining sources (always less than number of processes) - ''' - nsrc = self.readNsrc() - if self.nproc > nsrc: - print('Warning: Number of spawned processes higher than number of sources') - return nsrc/self.nproc, nsrc%self.nproc - - def srcIDs4Kernel(self, procID): - ''' - Calculates and returns all source IDs for a given process ID. - ''' - proc = procID - 1 - nsrc = self.readNsrc() - srcPK, remain = self.calcSrcPerKernel() - if procID > self.nproc: - sys.exit('STOP: Kernel ID exceeds available number.') - if proc < remain: - start = (srcPK + 1) * (proc) + 1 - return range(start, start + srcPK + 1) - elif proc == remain: - start = (srcPK + 1) * (proc) + 1 - return range(start, start + srcPK) - elif proc > remain: - start = (srcPK + 1) * remain + srcPK * (proc - remain) + 1 - return range(start, start + srcPK) - - def readNsrc(self): - srcfile = open(self.csl, 'r') - nsrc = int(srcfile.readline()) - srcfile.close() - return nsrc - - def readNtraces(self): - ''' - Reads the total number of traces from self.rec header. - ''' - recfile = open(self.rec, 'r') - nrec = int(recfile.readline()) - recfile.close() - return nrec - - def readSrcFile(self): - ''' - Reads the whole sourcefile and returns structured information in a dictionary. - ''' - nsrc = self.readNsrc() - srcfile = open(self.csl, 'r') - - sources = {} - - temp = srcfile.readline() - for index in range(nsrc): - teleflag = int(srcfile.readline()) - coords = srcfile.readline().split() - numpaths = int(srcfile.readline()) - steps = int(srcfile.readline()) - interactions = srcfile.readline().split() - veltype = int(srcfile.readline()) - if teleflag is not 0: - sys.exit('Script not yet usable for teleseismic.') - if numpaths is not 1: - sys.exit('Script not yet usable for more than one path per source.') - - sources[index + 1] = {'teleflag': teleflag, - 'coords': coords, - 'numpaths': numpaths, - 'steps': steps, - 'interactions': interactions, - 'veltype': veltype - } - - return sources - - def readTraces(self): - ''' - Reads the receiver input file and returns the information - in a structured dictionary. - ''' - recfile = open(self.rec, 'r') - ntraces = self.readNtraces() - - traces = {} - - temp = recfile.readline() - for index in range(ntraces): - coords = recfile.readline().split() - paths = int(recfile.readline()) - source = int(recfile.readline()) - path = int(recfile.readline()) - - traces[index + 1] = { 'coords': coords, - 'paths': paths, - 'source': source, - 'path': path - } - - return traces - - def readArrivals(self, procID): - ''' - Reads the arrival times from a temporary process directory, - changes local to global sourceIDs and traceIDs and returns - a list of arrival times. - ''' - directory = self.getProcDir(procID) - arrfile = open(os.path.join(directory, self.ttim), 'r') - sourceIDs = self.srcIDs4Kernel(procID) - - arrivals = [] - for sourceID in sourceIDs: - traceIDs = self.getTraceIDs4Source(sourceID) - for traceID in traceIDs: - line = arrfile.readline().split() - if line != []: - # recID and srcID for the individual processor will not be needed - recID_proc, srcID_proc, ray, normal, arrtime, diff, head = line - arrivals.append([traceID, sourceID, ray, normal, arrtime, diff, head]) - - return arrivals - - def readRays(self, procID): - ''' - Reads rays output from a temporary process directory and returns - the information in a structured dictionary. - ''' - directory = self.getProcDir(procID) - raysfile = open(directory + '/rays.dat', 'r') - sourceIDs = self.srcIDs4Kernel(procID) - - rays = {} - for sourceID in sourceIDs: - traceIDs = self.getTraceIDs4Source(sourceID) - for traceID in traceIDs: - line1 = raysfile.readline().split() - if line1 != []: - # recID and srcID for the individual processor will not be needed - recID_proc, srcID_proc, ray, normal, nsec = line1 - raysecs = {} - - for sec in range(int(nsec)): - line2 = raysfile.readline().split() - npoints, region, diff, head = line2 - raypoints = [] - - for j in range(int(npoints)): - raypoints.append(raysfile.readline()) - - raysecs[sec] = {'npoints': npoints, - 'region': region, - 'diff': diff, - 'head': head, - 'raypoints': raypoints - } - - - rays[traceID] = {'sourceID': sourceID, - 'raypath': ray, - 'normal': normal, - 'nsec': nsec, - 'raysections': raysecs - } - return rays - - def writeSrcFile(self, procID): - ''' - Writes a source input file for a process with ID = procID. - ''' - directory = self.getProcDir(procID) - srcfile = open(os.path.join(directory, self.csl), 'w') - sourceIDs = self.srcIDs4Kernel(procID) - - srcfile.write('%s\n'%len(sourceIDs)) - for sourceID in sourceIDs: - source = self.sources[sourceID] - coords = source['coords'] - interactions = source['interactions'] - srcfile.write('%s\n'%source['teleflag']) - srcfile.write('%s %s %s\n'%(float(coords[0]), float(coords[1]), float(coords[2]))) - srcfile.write('%s\n'%source['numpaths']) - srcfile.write('%s\n'%source['steps']) - srcfile.write('%s %s\n'%(int(interactions[0]), int(interactions[1]))) - srcfile.write('%s\n'%source['veltype']) - - def writeTracesFile(self, procID): - ''' - Writes a receiver input file for a process with ID = procID. - ''' - directory = self.getProcDir(procID) - recfile = open('%s/receivers.in'%directory, 'w') - sourceIDs = self.srcIDs4Kernel(procID) - traceIDs = self.getTraceIDs4Sources(sourceIDs) - - recfile.write('%s\n'%len(traceIDs)) - for traceID in traceIDs: - trace = self.traces[traceID] - coords = trace['coords'] - source = int(trace['source']) - sourceIDs[0] + 1 - recfile.write('%s %s %s\n'%(float(coords[0]), float(coords[1]), float(coords[2]))) - recfile.write('%s\n'%trace['paths']) - recfile.write('%s\n'%source) - recfile.write('%s\n'%trace['path']) - - def mergeArrivals(self, directory): - ''' - Merges the arrival times for all processes to self.cInvIterDir. - ''' - arrfn = os.path.join(directory, self.ttim) - arrivalsOut = open(arrfn, 'w') - print('Merging %s...'%self.ttim) - for procID in range(1, self.nproc + 1): - arrivals = self.readArrivals(procID) - for line in arrivals: - arrivalsOut.write('%6s %6s %6s %6s %15s %5s %5s\n'%tuple(line)) - - os.system('ln -fs %s %s'%(arrfn, os.path.join(self.cwd, self.ttim))) - - def mergeRays(self, directory): - ''' - Merges the ray paths for all processes to self.cInvIterDir. - ''' - print('Merging rays.dat...') - with open(directory + '/rays.dat', 'w') as outfile: - for procID in range(1, self.nproc + 1): - rays = self.readRays(procID) - for traceID in rays: - ray = rays[traceID] - outfile.write('%6s %6s %6s %6s %6s\n'%(traceID, - ray['sourceID'], - ray['raypath'], - ray['normal'], - ray['nsec'])) - for sec in range(int(ray['nsec'])): - raysec = ray['raysections'][sec] - outfile.write('%6s %6s %6s %6s\n'%(raysec['npoints'], - raysec['region'], - raysec['diff'], - raysec['head'])) - outfile.writelines(raysec['raypoints']) - - def mergeFrechet(self, directory): - ''' - Merges the frechet derivatives for all processes to self.cInvIterDir. - ''' - frechfnout = os.path.join(directory, self.frechout) - print('Merging %s...'%self.frechout) - with open(frechfnout, 'w') as outfile: - for procID in range(1, self.nproc + 1): - filename = os.path.join(self.getProcDir(procID), self.frechout) - with open(filename) as infile: - for sourceID in self.srcIDs4Kernel(procID): - for traceID in self.getTraceIDs4Source(sourceID): - recID_proc, srcID_proc, ray, normal, NPDEV = infile.readline().split() - outfile.write('%6s %6s %6s %6s %6s\n'%(traceID, sourceID, ray, normal, NPDEV)) - for index in range(int(NPDEV)): - outfile.write(infile.readline()) - - os.system('ln -fs %s %s'%(frechfnout, os.path.join(self.cwd, self.frechout))) - - def mergeOutput(self, directory): - ''' - Calls self.mergeArrivals, self.mergeFrechet and self.mergeRays. - ''' - self.mergeArrivals(directory) - self.mergeFrechet(directory) - self.mergeRays(directory) - - def unlink(self, filepath): - return os.system('unlink %s'%filepath) - - def _printLine(self): - print('----------------------------------------') - -def vgrids2VTK(inputfile='vgrids.in', outputfile='vgrids.vtk', absOrRel='abs', inputfileref='vgridsref.in'): - ''' - Generate a vtk-file readable by e.g. paraview from FMTOMO output vgrids.in - ''' - R = 6371. # earth radius - outfile = open(outputfile, 'w') - - number, delta, start, vel = _readVgrid(inputfile) - - nR, nTheta, nPhi = number - dR, dTheta, dPhi = delta - sR, sTheta, sPhi = start - - thetaGrid, phiGrid, rGrid = _generateGrids(number, delta, start) - - nPoints = nR * nTheta * nPhi - - nX = nPhi; - nY = nTheta; - nZ = nR - - sZ = sR - R - sX = _getDistance(sPhi) - sY = _getDistance(sTheta) - - dX = _getDistance(dPhi) - dY = _getDistance(dTheta) - dZ = dR - - # write header - print("Writing header for VTK file...") - outfile.write('# vtk DataFile Version 3.1\n') - outfile.write('Velocity on FMTOMO vgrids.in points\n') - outfile.write('ASCII\n') - outfile.write('DATASET STRUCTURED_POINTS\n') - - outfile.write('DIMENSIONS %d %d %d\n' % (nX, nY, nZ)) - outfile.write('ORIGIN %f %f %f\n' % (sX, sY, sZ)) - outfile.write('SPACING %f %f %f\n' % (dX, dY, dZ)) - - outfile.write('POINT_DATA %15d\n' % (nPoints)) - if absOrRel == 'abs': - outfile.write('SCALARS velocity float %d\n' %(1)) - if absOrRel == 'relDepth': - outfile.write('SCALARS velocity2depthMean float %d\n' %(1)) - elif absOrRel == 'rel': - outfile.write('SCALARS velChangePercent float %d\n' % (1)) - outfile.write('LOOKUP_TABLE default\n') - - pointsPerR = nTheta * nPhi - - # write velocity - if absOrRel == 'abs': - print("Writing velocity values to VTK file...") - for velocity in vel: - outfile.write('%10f\n' %velocity) - elif absOrRel == 'relDepth': - print("Writing velocity values to VTK file relative to mean of each depth...") - index = 0; count = 0 - veldepth = [] - for velocity in vel: - count += 1 - veldepth.append(velocity) - if count%pointsPerR == 0: - velmean = np.mean(veldepth) - #print velmean, count, count/pointsPerR - for vel in veldepth: - outfile.write('%10f\n' %(vel - velmean)) - veldepth = [] - elif absOrRel == 'rel': - nref, dref, sref, velref = _readVgrid(inputfileref) - nR_ref, nTheta_ref, nPhi_ref = nref - if not len(velref) == len(vel): - print('ERROR: Number of gridpoints mismatch for %s and %s' % (inputfile, inputfileref)) - return - # velrel = [((vel - velref) / velref * 100) for vel, velref in zip(vel, velref)] - velrel = [] - for velocities in zip(vel, velref): - v, vref = velocities - if not vref == 0: - velrel.append((v - vref) / vref * 100) - else: - velrel.append(0) - - if not nR_ref == nR and nTheta_ref == nTheta and nPhi_ref == nPhi: - print('ERROR: Dimension mismatch of grids %s and %s' % (inputfile, inputfileref)) - return - print("Writing velocity values to VTK file...") - for velocity in velrel: - outfile.write('%10f\n' % velocity) - print('Pertubations: min: %s %%, max: %s %%' % (min(velrel), max(velrel))) - - outfile.close() - print("Wrote velocity grid for %d points to file: %s" % (nPoints, outputfile)) - return - - -def rays2VTK(fnin, fdirout='./vtk_files/', nthPoint=50): - ''' - Writes VTK file(s) for FMTOMO rays from rays.dat - - :param: nthPoint, plot every nth point of the ray - :type: integer - ''' - infile = open(fnin, 'r') - R = 6371 - rays = {} - raynumber = 0 - nPoints = 0 - - ### NOTE: rays.dat seems to be in km and radians - while True: - raynumber += 1 - firstline = infile.readline() - if firstline == '': - break # break at EOF - fl_list = firstline.split() - raynumber = int(fl_list[0]) - shotnumber = int(fl_list[1]) - rayValid = int(fl_list[4]) # is zero if the ray is invalid - if rayValid == 0: - print('Invalid ray number %d for shot number %d' % (raynumber, shotnumber)) - continue - nRayPoints = int(infile.readline().split()[0]) - if not shotnumber in rays.keys(): - rays[shotnumber] = {} - rays[shotnumber][raynumber] = [] - for index in range(nRayPoints): - if index % nthPoint is 0 or index == (nRayPoints - 1): - rad, lat, lon = infile.readline().split() - rays[shotnumber][raynumber].append( - [_getDistance(np.rad2deg(float(lon))), _getDistance(np.rad2deg(float(lat))), float(rad) - R]) - else: - dummy = infile.readline() - - infile.close() - - for shotnumber in rays.keys(): - fnameout = os.path.join(fdirout, 'rays%03d.vtk'%(shotnumber)) - outfile = open(fnameout, 'w') - - nPoints = 0 - for raynumber in rays[shotnumber]: - for ray in rays[shotnumber][raynumber]: - nPoints += 1 - - # write header - # print("Writing header for VTK file...") - print("Writing shot %d to file %s" % (shotnumber, fnameout)) - outfile.write('# vtk DataFile Version 3.1\n') - outfile.write('FMTOMO rays\n') - outfile.write('ASCII\n') - outfile.write('DATASET POLYDATA\n') - outfile.write('POINTS %15d float\n' % (nPoints)) - - # write coordinates - # print("Writing coordinates to VTK file...") - for raynumber in rays[shotnumber].keys(): - for raypoint in rays[shotnumber][raynumber]: - outfile.write('%10f %10f %10f \n' % (raypoint[0], raypoint[1], raypoint[2])) - - outfile.write('LINES %15d %15d\n' % (len(rays[shotnumber]), len(rays[shotnumber]) + nPoints)) - - # write indices - # print("Writing indices to VTK file...") - count = 0 - for raynumber in rays[shotnumber].keys(): - outfile.write('%d ' % (len(rays[shotnumber][raynumber]))) - for index in range(len(rays[shotnumber][raynumber])): - outfile.write('%d ' % (count)) - count += 1 - outfile.write('\n') - - -def _readVgrid(filename): - def readNumberOfPoints(filename): - fin = open(filename, 'r') - vglines = fin.readlines() - - nR = int(vglines[1].split()[0]) - nTheta = int(vglines[1].split()[1]) - nPhi = int(vglines[1].split()[2]) - - print('readNumberOf Points: Awaiting %d grid points in %s' - % (nR * nTheta * nPhi, filename)) - fin.close() - return nR, nTheta, nPhi - - def readDelta(filename): - fin = open(filename, 'r') - vglines = fin.readlines() - - dR = float(vglines[2].split()[0]) - dTheta = float(vglines[2].split()[1]) - dPhi = float(vglines[2].split()[2]) - - fin.close() - return dR, dTheta, dPhi - - def readStartpoints(filename): - fin = open(filename, 'r') - vglines = fin.readlines() - - sR = float(vglines[3].split()[0]) - sTheta = float(vglines[3].split()[1]) - sPhi = float(vglines[3].split()[2]) - - fin.close() - return sR, sTheta, sPhi - - def readVelocity(filename): - ''' - Reads in velocity from vgrids file and returns a list containing all values in the same order - ''' - vel = []; - count = 0 - fin = open(filename, 'r') - vglines = fin.readlines() - - for line in vglines: - count += 1 - if count > 4: - vel.append(float(line.split()[0])) - - print("Read %d points out of file: %s" % (count - 4, filename)) - return vel - - # Theta, Phi in radians, R in km - nR, nTheta, nPhi = readNumberOfPoints(filename) - dR, dThetaRad, dPhiRad = readDelta(filename) - sR, sThetaRad, sPhiRad = readStartpoints(filename) - vel = readVelocity(filename) - - dTheta, dPhi = np.rad2deg((dThetaRad, dPhiRad)) - sTheta, sPhi = np.rad2deg((sThetaRad, sPhiRad)) - - number = (nR, nTheta, nPhi) - delta = (dR, dTheta, dPhi) - start = (sR, sTheta, sPhi) - return number, delta, start, vel - - -def _generateGrids(number, delta, start): - nR, nTheta, nPhi = number - dR, dTheta, dPhi = delta - sR, sTheta, sPhi = start - - eR = sR + (nR - 1) * dR - ePhi = sPhi + (nPhi - 1) * dPhi - eTheta = sTheta + (nTheta - 1) * dTheta - - thetaGrid = np.linspace(sTheta, eTheta, num=nTheta) - phiGrid = np.linspace(sPhi, ePhi, num=nPhi) - rGrid = np.linspace(sR, eR, num=nR) - - return (thetaGrid, phiGrid, rGrid) - - -def addCheckerboard(spacing=10., pertubation=0.1, inputfile='vgrids.in', - outputfile='vgrids_cb.in', ampmethod='linear', rect=(None, None)): - ''' - Add a checkerboard to an existing vgrids.in velocity model. - - :param: spacing, size of the tiles - type: float - - :param: pertubation, pertubation (default: 0.1 = 10%) - type: float - ''' - - def correctSpacing(spacing, delta, disttype=None): - if spacing > delta: - spacing_corr = round(spacing / delta) * delta - elif spacing < delta: - spacing_corr = delta - print('The spacing of the checkerboard of %s (%s) was corrected to ' - 'a value of %s to fit the grid spacing of %s.' % (spacing, disttype, spacing_corr, delta)) - return spacing_corr - - def linearAmp(InCell): - decimal = InCell - np.floor(InCell) - return (-abs(decimal - 0.5) + 0.5) * 2 - - def rectAmp(InCell, rect): - decimal = InCell - np.floor(InCell) - r1, r2 = rect - if r1 <= decimal <= r2: - return 1 - else: - return 0 - - def ampFunc(InCell, method='linear', rect=None): - if method == 'linear': - return linearAmp(InCell) - if method == 'rect' and rect is not None: - return rectAmp(InCell, rect) - else: - print('ampFunc: Could not amplify cb pattern') - - decm = 0.3 # diagonal elements of the covariance matrix (grid3dg's default value is 0.3) - outfile = open(outputfile, 'w') - - number, delta, start, vel = _readVgrid(inputfile) - - nR, nTheta, nPhi = number - dR, dTheta, dPhi = delta - sR, sTheta, sPhi = start - - thetaGrid, phiGrid, rGrid = _generateGrids(number, delta, start) - - nPoints = nR * nTheta * nPhi - - # write header for velocity grid file (in RADIANS) - outfile.write('%10s %10s \n' % (1, 1)) - outfile.write('%10s %10s %10s\n' % (nR, nTheta, nPhi)) - outfile.write('%10s %10s %10s\n' % (dR, np.deg2rad(dTheta), np.deg2rad(dPhi))) - outfile.write('%10s %10s %10s\n' % (sR, np.deg2rad(sTheta), np.deg2rad(sPhi))) - - spacR = correctSpacing(spacing, dR, '[meter], R') - spacTheta = correctSpacing(_getAngle(spacing), dTheta, '[degree], Theta') - spacPhi = correctSpacing(_getAngle(spacing), dPhi, '[degree], Phi') - - count = 0 - evenOdd = 1 - even = 0; - odd = 0 - - # In the following loop it is checked whether the positive distance from the border of the model - # for a point on the grid divided by the spacing is even or odd and then pertubated. - # The position is also shifted by half of the delta so that the position is directly on the point and - # not on the border between two points. - # "InCell" points e.g. rInCell are floats with their integer number corresponding to the cell number and - # their decimal place (0 - 1) corresponding to the position inside the cell. - # The amplification factor ampFactor comes from a linear relationship and ranges between 0 (cell border) - # and 1 (cell middle) - for radius in rGrid: - rInCell = (radius - sR - dR / 2) / spacR - ampR = ampFunc(rInCell, ampmethod, rect) - if np.floor(rInCell) % 2: - evenOddR = 1 - else: - evenOddR = -1 - for theta in thetaGrid: - thetaInCell = (theta - sTheta - dTheta / 2) / spacTheta - ampTheta = ampFunc(thetaInCell, ampmethod, rect) - if np.floor(thetaInCell) % 2: - evenOddT = 1 - else: - evenOddT = -1 - for phi in phiGrid: - phiInCell = (phi - sPhi - dPhi / 2) / spacPhi - ampPhi = ampFunc(phiInCell, ampmethod, rect) - if np.floor(phiInCell) % 2: - evenOddP = 1 - else: - evenOddP = -1 - velocity = vel[count] - ampFactor = (ampR + ampTheta + ampPhi) / 3 - evenOdd = evenOddR * evenOddT * evenOddP * ampFactor - velocity += evenOdd * pertubation * velocity - - outfile.write('%10s %10s\n' % (velocity, decm)) - count += 1 - - progress = float(count) / float(nPoints) * 100 - _update_progress(progress) - - print('Added checkerboard to the grid in file %s with a spacing of %s and a pertubation of %s %%. ' - 'Outputfile: %s.' % (inputfile, spacing, pertubation * 100, outputfile)) - outfile.close() - - -def addBox(x=(None, None), y=(None, None), z=(None, None), - boxvelocity=1.0, inputfile='vgrids.in', - outputfile='vgrids_box.in'): - ''' - Add a box with constant velocity to an existing vgrids.in velocity model. - - :param: x, borders of the box (xleft, xright) - type: tuple - - :param: y, borders of the box (yleft, yright) - type: tuple - - :param: z, borders of the box (bot, top) - type: tuple - - :param: boxvelocity, default: 1.0 km/s - type: float - ''' - R = 6371. - decm = 0.3 # diagonal elements of the covariance matrix (grid3dg's default value is 0.3) - outfile = open(outputfile, 'w') - - theta1 = _getAngle(y[0]) - theta2 = _getAngle(y[1]) - phi1 = _getAngle(x[0]) - phi2 = _getAngle(x[1]) - r1 = R + z[0] - r2 = R + z[1] - - print('Adding box to grid with theta = (%s, %s), phi = (%s, %s), ' - 'r = (%s, %s), velocity = %s [km/s]' - % (theta1, theta2, phi1, phi2, r1, r2, boxvelocity)) - - number, delta, start, vel = _readVgrid(inputfile) - - nR, nTheta, nPhi = number - dR, dTheta, dPhi = delta - sR, sTheta, sPhi = start - - thetaGrid, phiGrid, rGrid = _generateGrids(number, delta, start) - - nPoints = nR * nTheta * nPhi - - # write header for velocity grid file (in RADIANS) - outfile.write('%10s %10s \n' % (1, 1)) - outfile.write('%10s %10s %10s\n' % (nR, nTheta, nPhi)) - outfile.write('%10s %10s %10s\n' % (dR, np.deg2rad(dTheta), np.deg2rad(dPhi))) - outfile.write('%10s %10s %10s\n' % (sR, np.deg2rad(sTheta), np.deg2rad(sPhi))) - - count = 0 - for radius in rGrid: - if r1 <= radius <= r2: - rFlag = 1 - else: - rFlag = 0 - for theta in thetaGrid: - if theta1 <= theta <= theta2: - thetaFlag = 1 - else: - thetaFlag = 0 - for phi in phiGrid: - if phi1 <= phi <= phi2: - phiFlag = 1 - else: - phiFlag = 0 - velocity = vel[count] - if rFlag * thetaFlag * phiFlag is not 0: - velocity = boxvelocity - - outfile.write('%10s %10s\n' % (velocity, decm)) - count += 1 - - progress = float(count) / float(nPoints) * 100 - _update_progress(progress) - - print('Added box to the grid in file %s. ' - 'Outputfile: %s.' % (inputfile, outputfile)) - outfile.close() - - -def _update_progress(progress): - sys.stdout.write("%d%% done \r" % (progress)) - sys.stdout.flush() - - -def _getAngle(distance): - ''' - Function returns the angle on a Sphere of the radius R = 6371 [km] for a distance [km]. - ''' - PI = np.pi - R = 6371. - angle = distance * 180. / (PI * R) - return angle - - -def _getDistance(angle): - PI = np.pi - R = 6371. - distance = angle / 180 * (PI * R) - return distance diff --git a/pylot/core/active/gui/__init__.py b/pylot/core/active/gui/__init__.py deleted file mode 100644 index aafb279b..00000000 --- a/pylot/core/active/gui/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -# -*- coding: utf-8 -*- -__author__ = 'marcel' diff --git a/pylot/core/active/gui/asp3d_layout.py b/pylot/core/active/gui/asp3d_layout.py deleted file mode 100644 index f355de1a..00000000 --- a/pylot/core/active/gui/asp3d_layout.py +++ /dev/null @@ -1,391 +0,0 @@ -# -*- coding: utf-8 -*- - -# Form implementation generated from reading ui file 'asp3d_layout.ui' -# -# Created: Mon Aug 29 10:26:23 2016 -# by: pyside-uic 0.2.15 running on PySide 1.2.2 -# -# WARNING! All changes made in this file will be lost! - -from PySide import QtCore, QtGui - -class Ui_MainWindow(object): - def setupUi(self, MainWindow): - MainWindow.setObjectName("MainWindow") - MainWindow.setEnabled(True) - MainWindow.resize(1280, 1024) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(MainWindow.sizePolicy().hasHeightForWidth()) - MainWindow.setSizePolicy(sizePolicy) - MainWindow.setMinimumSize(QtCore.QSize(800, 600)) - MainWindow.setMaximumSize(QtCore.QSize(250000, 350000)) - MainWindow.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) - icon = QtGui.QIcon() - icon.addPixmap(QtGui.QPixmap("../asp3d_icon.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) - MainWindow.setWindowIcon(icon) - self.centralwidget = QtGui.QWidget(MainWindow) - self.centralwidget.setObjectName("centralwidget") - self.gridLayout = QtGui.QGridLayout(self.centralwidget) - self.gridLayout.setObjectName("gridLayout") - self.formLayout = QtGui.QFormLayout() - self.formLayout.setSizeConstraint(QtGui.QLayout.SetDefaultConstraint) - self.formLayout.setFieldGrowthPolicy(QtGui.QFormLayout.AllNonFixedFieldsGrow) - self.formLayout.setObjectName("formLayout") - self.verticalLayout_5 = QtGui.QVBoxLayout() - self.verticalLayout_5.setSizeConstraint(QtGui.QLayout.SetMinimumSize) - self.verticalLayout_5.setObjectName("verticalLayout_5") - self.verticalLayout = QtGui.QVBoxLayout() - self.verticalLayout.setObjectName("verticalLayout") - self.label_2 = QtGui.QLabel(self.centralwidget) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.label_2.sizePolicy().hasHeightForWidth()) - self.label_2.setSizePolicy(sizePolicy) - font = QtGui.QFont() - font.setFamily("Sans Serif") - font.setPointSize(10) - font.setWeight(75) - font.setBold(True) - self.label_2.setFont(font) - self.label_2.setAlignment(QtCore.Qt.AlignCenter) - self.label_2.setObjectName("label_2") - self.verticalLayout.addWidget(self.label_2) - self.horizontalLayout_2 = QtGui.QHBoxLayout() - self.horizontalLayout_2.setObjectName("horizontalLayout_2") - self.seisarray_active = QtGui.QLabel(self.centralwidget) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.seisarray_active.sizePolicy().hasHeightForWidth()) - self.seisarray_active.setSizePolicy(sizePolicy) - self.seisarray_active.setMaximumSize(QtCore.QSize(20, 20)) - self.seisarray_active.setMidLineWidth(0) - self.seisarray_active.setText("") - self.seisarray_active.setObjectName("seisarray_active") - self.horizontalLayout_2.addWidget(self.seisarray_active) - self.label_5 = QtGui.QLabel(self.centralwidget) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.label_5.sizePolicy().hasHeightForWidth()) - self.label_5.setSizePolicy(sizePolicy) - self.label_5.setObjectName("label_5") - self.horizontalLayout_2.addWidget(self.label_5) - self.seisarray_on_survey_active = QtGui.QLabel(self.centralwidget) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.seisarray_on_survey_active.sizePolicy().hasHeightForWidth()) - self.seisarray_on_survey_active.setSizePolicy(sizePolicy) - self.seisarray_on_survey_active.setMaximumSize(QtCore.QSize(20, 20)) - self.seisarray_on_survey_active.setMidLineWidth(0) - self.seisarray_on_survey_active.setText("") - self.seisarray_on_survey_active.setObjectName("seisarray_on_survey_active") - self.horizontalLayout_2.addWidget(self.seisarray_on_survey_active) - self.label_6 = QtGui.QLabel(self.centralwidget) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.label_6.sizePolicy().hasHeightForWidth()) - self.label_6.setSizePolicy(sizePolicy) - self.label_6.setObjectName("label_6") - self.horizontalLayout_2.addWidget(self.label_6) - self.verticalLayout.addLayout(self.horizontalLayout_2) - self.textBox_seisarray = QtGui.QTextEdit(self.centralwidget) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Expanding) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.textBox_seisarray.sizePolicy().hasHeightForWidth()) - self.textBox_seisarray.setSizePolicy(sizePolicy) - self.textBox_seisarray.setObjectName("textBox_seisarray") - self.verticalLayout.addWidget(self.textBox_seisarray) - self.verticalLayout_5.addLayout(self.verticalLayout) - self.line = QtGui.QFrame(self.centralwidget) - self.line.setMinimumSize(QtCore.QSize(0, 5)) - self.line.setFrameShape(QtGui.QFrame.HLine) - self.line.setFrameShadow(QtGui.QFrame.Sunken) - self.line.setObjectName("line") - self.verticalLayout_5.addWidget(self.line) - self.verticalLayout_2 = QtGui.QVBoxLayout() - self.verticalLayout_2.setObjectName("verticalLayout_2") - self.label_3 = QtGui.QLabel(self.centralwidget) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.label_3.sizePolicy().hasHeightForWidth()) - self.label_3.setSizePolicy(sizePolicy) - font = QtGui.QFont() - font.setFamily("Sans Serif") - font.setPointSize(10) - font.setWeight(75) - font.setBold(True) - self.label_3.setFont(font) - self.label_3.setAlignment(QtCore.Qt.AlignCenter) - self.label_3.setObjectName("label_3") - self.verticalLayout_2.addWidget(self.label_3) - self.horizontalLayout = QtGui.QHBoxLayout() - self.horizontalLayout.setObjectName("horizontalLayout") - self.survey_active = QtGui.QLabel(self.centralwidget) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.survey_active.sizePolicy().hasHeightForWidth()) - self.survey_active.setSizePolicy(sizePolicy) - self.survey_active.setMaximumSize(QtCore.QSize(20, 20)) - self.survey_active.setMidLineWidth(0) - self.survey_active.setText("") - self.survey_active.setObjectName("survey_active") - self.horizontalLayout.addWidget(self.survey_active) - self.label_4 = QtGui.QLabel(self.centralwidget) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.label_4.sizePolicy().hasHeightForWidth()) - self.label_4.setSizePolicy(sizePolicy) - self.label_4.setObjectName("label_4") - self.horizontalLayout.addWidget(self.label_4) - self.picked_active = QtGui.QLabel(self.centralwidget) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.picked_active.sizePolicy().hasHeightForWidth()) - self.picked_active.setSizePolicy(sizePolicy) - self.picked_active.setMaximumSize(QtCore.QSize(20, 20)) - self.picked_active.setMidLineWidth(0) - self.picked_active.setText("") - self.picked_active.setObjectName("picked_active") - self.horizontalLayout.addWidget(self.picked_active) - self.label = QtGui.QLabel(self.centralwidget) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.label.sizePolicy().hasHeightForWidth()) - self.label.setSizePolicy(sizePolicy) - self.label.setObjectName("label") - self.horizontalLayout.addWidget(self.label) - self.verticalLayout_2.addLayout(self.horizontalLayout) - self.textBox_survey = QtGui.QTextEdit(self.centralwidget) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Expanding) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.textBox_survey.sizePolicy().hasHeightForWidth()) - self.textBox_survey.setSizePolicy(sizePolicy) - self.textBox_survey.setTextInteractionFlags(QtCore.Qt.TextSelectableByKeyboard|QtCore.Qt.TextSelectableByMouse) - self.textBox_survey.setObjectName("textBox_survey") - self.verticalLayout_2.addWidget(self.textBox_survey) - self.verticalLayout_5.addLayout(self.verticalLayout_2) - self.verticalLayout_3 = QtGui.QVBoxLayout() - self.verticalLayout_3.setObjectName("verticalLayout_3") - self.verticalLayout_4 = QtGui.QVBoxLayout() - self.verticalLayout_4.setObjectName("verticalLayout_4") - self.progressBar = QtGui.QProgressBar(self.centralwidget) - self.progressBar.setEnabled(True) - self.progressBar.setProperty("value", 0) - self.progressBar.setTextVisible(True) - self.progressBar.setObjectName("progressBar") - self.verticalLayout_4.addWidget(self.progressBar) - self.verticalLayout_3.addLayout(self.verticalLayout_4) - self.verticalLayout_5.addLayout(self.verticalLayout_3) - self.formLayout.setLayout(0, QtGui.QFormLayout.LabelRole, self.verticalLayout_5) - self.verticalLayout_right = QtGui.QVBoxLayout() - self.verticalLayout_right.setSizeConstraint(QtGui.QLayout.SetMaximumSize) - self.verticalLayout_right.setObjectName("verticalLayout_right") - self.horizontalLayout_tr = QtGui.QHBoxLayout() - self.horizontalLayout_tr.setSizeConstraint(QtGui.QLayout.SetDefaultConstraint) - self.horizontalLayout_tr.setObjectName("horizontalLayout_tr") - self.verticalLayout_tr1 = QtGui.QVBoxLayout() - self.verticalLayout_tr1.setObjectName("verticalLayout_tr1") - self.horizontalLayout_tr.addLayout(self.verticalLayout_tr1) - self.verticalLayout_right.addLayout(self.horizontalLayout_tr) - self.line_4 = QtGui.QFrame(self.centralwidget) - self.line_4.setFrameShape(QtGui.QFrame.HLine) - self.line_4.setFrameShadow(QtGui.QFrame.Sunken) - self.line_4.setObjectName("line_4") - self.verticalLayout_right.addWidget(self.line_4) - self.horizontalLayout_3 = QtGui.QHBoxLayout() - self.horizontalLayout_3.setObjectName("horizontalLayout_3") - self.verticalLayout_6 = QtGui.QVBoxLayout() - self.verticalLayout_6.setObjectName("verticalLayout_6") - self.label_11 = QtGui.QLabel(self.centralwidget) - self.label_11.setObjectName("label_11") - self.verticalLayout_6.addWidget(self.label_11) - self.comboBox_stats = QtGui.QComboBox(self.centralwidget) - self.comboBox_stats.setEnabled(False) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(3) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.comboBox_stats.sizePolicy().hasHeightForWidth()) - self.comboBox_stats.setSizePolicy(sizePolicy) - self.comboBox_stats.setMinimumSize(QtCore.QSize(450, 0)) - self.comboBox_stats.setObjectName("comboBox_stats") - self.verticalLayout_6.addWidget(self.comboBox_stats) - self.horizontalLayout_3.addLayout(self.verticalLayout_6) - self.line_5 = QtGui.QFrame(self.centralwidget) - self.line_5.setFrameShape(QtGui.QFrame.VLine) - self.line_5.setFrameShadow(QtGui.QFrame.Sunken) - self.line_5.setObjectName("line_5") - self.horizontalLayout_3.addWidget(self.line_5) - self.verticalLayout_9 = QtGui.QVBoxLayout() - self.verticalLayout_9.setObjectName("verticalLayout_9") - self.label_10 = QtGui.QLabel(self.centralwidget) - self.label_10.setObjectName("label_10") - self.verticalLayout_9.addWidget(self.label_10) - self.horizontalLayout_4 = QtGui.QHBoxLayout() - self.horizontalLayout_4.setObjectName("horizontalLayout_4") - self.shot_left = QtGui.QPushButton(self.centralwidget) - self.shot_left.setMaximumSize(QtCore.QSize(25, 16777215)) - self.shot_left.setObjectName("shot_left") - self.horizontalLayout_4.addWidget(self.shot_left) - self.comboBox_shots = QtGui.QComboBox(self.centralwidget) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(1) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.comboBox_shots.sizePolicy().hasHeightForWidth()) - self.comboBox_shots.setSizePolicy(sizePolicy) - self.comboBox_shots.setMinimumSize(QtCore.QSize(120, 0)) - self.comboBox_shots.setMaximumSize(QtCore.QSize(100, 16777215)) - self.comboBox_shots.setObjectName("comboBox_shots") - self.horizontalLayout_4.addWidget(self.comboBox_shots) - self.shot_right = QtGui.QPushButton(self.centralwidget) - self.shot_right.setMaximumSize(QtCore.QSize(25, 16777215)) - self.shot_right.setObjectName("shot_right") - self.horizontalLayout_4.addWidget(self.shot_right) - self.plot_shot = QtGui.QPushButton(self.centralwidget) - self.plot_shot.setMaximumSize(QtCore.QSize(80, 16777215)) - self.plot_shot.setObjectName("plot_shot") - self.horizontalLayout_4.addWidget(self.plot_shot) - self.verticalLayout_9.addLayout(self.horizontalLayout_4) - self.horizontalLayout_3.addLayout(self.verticalLayout_9) - self.verticalLayout_right.addLayout(self.horizontalLayout_3) - self.horizontalLayout_br = QtGui.QHBoxLayout() - self.horizontalLayout_br.setObjectName("horizontalLayout_br") - self.verticalLayout_br1 = QtGui.QVBoxLayout() - self.verticalLayout_br1.setObjectName("verticalLayout_br1") - self.horizontalLayout_br.addLayout(self.verticalLayout_br1) - self.verticalLayout_br2 = QtGui.QVBoxLayout() - self.verticalLayout_br2.setObjectName("verticalLayout_br2") - self.horizontalLayout_br.addLayout(self.verticalLayout_br2) - self.verticalLayout_right.addLayout(self.horizontalLayout_br) - self.formLayout.setLayout(0, QtGui.QFormLayout.FieldRole, self.verticalLayout_right) - self.gridLayout.addLayout(self.formLayout, 0, 0, 1, 1) - MainWindow.setCentralWidget(self.centralwidget) - self.menubar = QtGui.QMenuBar(MainWindow) - self.menubar.setGeometry(QtCore.QRect(0, 0, 1280, 23)) - self.menubar.setObjectName("menubar") - self.menuFile = QtGui.QMenu(self.menubar) - self.menuFile.setObjectName("menuFile") - self.menuSeismic_Array = QtGui.QMenu(self.menubar) - self.menuSeismic_Array.setObjectName("menuSeismic_Array") - self.menuSurvey = QtGui.QMenu(self.menubar) - self.menuSurvey.setObjectName("menuSurvey") - self.menuPicking = QtGui.QMenu(self.menubar) - self.menuPicking.setObjectName("menuPicking") - self.menuSimulation = QtGui.QMenu(self.menubar) - self.menuSimulation.setObjectName("menuSimulation") - self.menuTools = QtGui.QMenu(self.menubar) - self.menuTools.setObjectName("menuTools") - self.menuView = QtGui.QMenu(self.menubar) - self.menuView.setObjectName("menuView") - MainWindow.setMenuBar(self.menubar) - self.statusbar = QtGui.QStatusBar(MainWindow) - self.statusbar.setObjectName("statusbar") - MainWindow.setStatusBar(self.statusbar) - self.actionLoad_Seismic_Array = QtGui.QAction(MainWindow) - self.actionLoad_Seismic_Array.setCheckable(False) - self.actionLoad_Seismic_Array.setObjectName("actionLoad_Seismic_Array") - self.actionSave_Seismic_Array = QtGui.QAction(MainWindow) - self.actionSave_Seismic_Array.setObjectName("actionSave_Seismic_Array") - self.actionLoad_Survey = QtGui.QAction(MainWindow) - self.actionLoad_Survey.setObjectName("actionLoad_Survey") - self.actionSave_Survey = QtGui.QAction(MainWindow) - self.actionSave_Survey.setObjectName("actionSave_Survey") - self.actionExit = QtGui.QAction(MainWindow) - self.actionExit.setObjectName("actionExit") - self.actionGenerate_new_Seismic_Array = QtGui.QAction(MainWindow) - self.actionGenerate_new_Seismic_Array.setObjectName("actionGenerate_new_Seismic_Array") - self.actionInterpolate_Receivers = QtGui.QAction(MainWindow) - self.actionInterpolate_Receivers.setObjectName("actionInterpolate_Receivers") - self.actionConnect_to_Survey = QtGui.QAction(MainWindow) - self.actionConnect_to_Survey.setObjectName("actionConnect_to_Survey") - self.actionGenerate_new_Survey = QtGui.QAction(MainWindow) - self.actionGenerate_new_Survey.setObjectName("actionGenerate_new_Survey") - self.actionAutomatic_Picking = QtGui.QAction(MainWindow) - self.actionAutomatic_Picking.setObjectName("actionAutomatic_Picking") - self.actionPostprocessing = QtGui.QAction(MainWindow) - self.actionPostprocessing.setObjectName("actionPostprocessing") - self.actionStart_FMTOMO_Simulation = QtGui.QAction(MainWindow) - self.actionStart_FMTOMO_Simulation.setObjectName("actionStart_FMTOMO_Simulation") - self.actionVTK_Visualization = QtGui.QAction(MainWindow) - self.actionVTK_Visualization.setObjectName("actionVTK_Visualization") - self.actionSeismic_Array = QtGui.QAction(MainWindow) - self.actionSeismic_Array.setEnabled(False) - self.actionSeismic_Array.setObjectName("actionSeismic_Array") - self.actionFullscreen = QtGui.QAction(MainWindow) - self.actionFullscreen.setCheckable(True) - self.actionFullscreen.setObjectName("actionFullscreen") - self.menuFile.addSeparator() - self.menuFile.addAction(self.actionExit) - self.menuSeismic_Array.addAction(self.actionGenerate_new_Seismic_Array) - self.menuSeismic_Array.addAction(self.actionLoad_Seismic_Array) - self.menuSeismic_Array.addAction(self.actionSave_Seismic_Array) - self.menuSeismic_Array.addSeparator() - self.menuSeismic_Array.addAction(self.actionInterpolate_Receivers) - self.menuSeismic_Array.addAction(self.actionConnect_to_Survey) - self.menuSurvey.addAction(self.actionGenerate_new_Survey) - self.menuSurvey.addAction(self.actionLoad_Survey) - self.menuSurvey.addAction(self.actionSave_Survey) - self.menuPicking.addAction(self.actionAutomatic_Picking) - self.menuPicking.addAction(self.actionPostprocessing) - self.menuSimulation.addAction(self.actionStart_FMTOMO_Simulation) - self.menuTools.addAction(self.actionVTK_Visualization) - self.menuView.addAction(self.actionFullscreen) - self.menubar.addAction(self.menuFile.menuAction()) - self.menubar.addAction(self.menuSurvey.menuAction()) - self.menubar.addAction(self.menuSeismic_Array.menuAction()) - self.menubar.addAction(self.menuPicking.menuAction()) - self.menubar.addAction(self.menuSimulation.menuAction()) - self.menubar.addAction(self.menuTools.menuAction()) - self.menubar.addAction(self.menuView.menuAction()) - - self.retranslateUi(MainWindow) - QtCore.QMetaObject.connectSlotsByName(MainWindow) - - def retranslateUi(self, MainWindow): - MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "ActiveSeismoPick 3D", None, QtGui.QApplication.UnicodeUTF8)) - self.label_2.setText(QtGui.QApplication.translate("MainWindow", "Seismic Array", None, QtGui.QApplication.UnicodeUTF8)) - self.label_5.setText(QtGui.QApplication.translate("MainWindow", "active", None, QtGui.QApplication.UnicodeUTF8)) - self.label_6.setText(QtGui.QApplication.translate("MainWindow", "connected to Survey", None, QtGui.QApplication.UnicodeUTF8)) - self.label_3.setText(QtGui.QApplication.translate("MainWindow", "Survey", None, QtGui.QApplication.UnicodeUTF8)) - self.label_4.setText(QtGui.QApplication.translate("MainWindow", "active", None, QtGui.QApplication.UnicodeUTF8)) - self.label.setText(QtGui.QApplication.translate("MainWindow", "picked", None, QtGui.QApplication.UnicodeUTF8)) - self.label_11.setText(QtGui.QApplication.translate("MainWindow", "Plot Receiver and Shots of the Array colored by:", None, QtGui.QApplication.UnicodeUTF8)) - self.label_10.setText(QtGui.QApplication.translate("MainWindow", "Plot a single Shot:", None, QtGui.QApplication.UnicodeUTF8)) - self.shot_left.setText(QtGui.QApplication.translate("MainWindow", "<", None, QtGui.QApplication.UnicodeUTF8)) - self.shot_right.setText(QtGui.QApplication.translate("MainWindow", ">", None, QtGui.QApplication.UnicodeUTF8)) - self.plot_shot.setText(QtGui.QApplication.translate("MainWindow", "Plot", None, QtGui.QApplication.UnicodeUTF8)) - self.menuFile.setTitle(QtGui.QApplication.translate("MainWindow", "File", None, QtGui.QApplication.UnicodeUTF8)) - self.menuSeismic_Array.setTitle(QtGui.QApplication.translate("MainWindow", "Seismic Array", None, QtGui.QApplication.UnicodeUTF8)) - self.menuSurvey.setTitle(QtGui.QApplication.translate("MainWindow", "Survey", None, QtGui.QApplication.UnicodeUTF8)) - self.menuPicking.setTitle(QtGui.QApplication.translate("MainWindow", "Picking", None, QtGui.QApplication.UnicodeUTF8)) - self.menuSimulation.setTitle(QtGui.QApplication.translate("MainWindow", "Inversion", None, QtGui.QApplication.UnicodeUTF8)) - self.menuTools.setTitle(QtGui.QApplication.translate("MainWindow", "Tools", None, QtGui.QApplication.UnicodeUTF8)) - self.menuView.setTitle(QtGui.QApplication.translate("MainWindow", "View", None, QtGui.QApplication.UnicodeUTF8)) - self.actionLoad_Seismic_Array.setText(QtGui.QApplication.translate("MainWindow", "Load Seismic Array", None, QtGui.QApplication.UnicodeUTF8)) - self.actionSave_Seismic_Array.setText(QtGui.QApplication.translate("MainWindow", "Save Seismic Array", None, QtGui.QApplication.UnicodeUTF8)) - self.actionLoad_Survey.setText(QtGui.QApplication.translate("MainWindow", "Load Survey", None, QtGui.QApplication.UnicodeUTF8)) - self.actionSave_Survey.setText(QtGui.QApplication.translate("MainWindow", "Save Survey", None, QtGui.QApplication.UnicodeUTF8)) - self.actionExit.setText(QtGui.QApplication.translate("MainWindow", "Exit", None, QtGui.QApplication.UnicodeUTF8)) - self.actionGenerate_new_Seismic_Array.setText(QtGui.QApplication.translate("MainWindow", "Generate new Seismic Array", None, QtGui.QApplication.UnicodeUTF8)) - self.actionInterpolate_Receivers.setText(QtGui.QApplication.translate("MainWindow", "Interpolate Receivers", None, QtGui.QApplication.UnicodeUTF8)) - self.actionConnect_to_Survey.setText(QtGui.QApplication.translate("MainWindow", "Connect to Survey", None, QtGui.QApplication.UnicodeUTF8)) - self.actionGenerate_new_Survey.setText(QtGui.QApplication.translate("MainWindow", "Generate new Survey", None, QtGui.QApplication.UnicodeUTF8)) - self.actionAutomatic_Picking.setText(QtGui.QApplication.translate("MainWindow", "Automatic Picking", None, QtGui.QApplication.UnicodeUTF8)) - self.actionPostprocessing.setText(QtGui.QApplication.translate("MainWindow", "Postprocessing", None, QtGui.QApplication.UnicodeUTF8)) - self.actionStart_FMTOMO_Simulation.setText(QtGui.QApplication.translate("MainWindow", "Start FMTOMO Simulation", None, QtGui.QApplication.UnicodeUTF8)) - self.actionVTK_Visualization.setText(QtGui.QApplication.translate("MainWindow", "VTK Visualization", None, QtGui.QApplication.UnicodeUTF8)) - self.actionSeismic_Array.setText(QtGui.QApplication.translate("MainWindow", "Seismic Array", None, QtGui.QApplication.UnicodeUTF8)) - self.actionFullscreen.setText(QtGui.QApplication.translate("MainWindow", "Fullscreen", None, QtGui.QApplication.UnicodeUTF8)) - diff --git a/pylot/core/active/gui/fmtomo_parameters_layout.py b/pylot/core/active/gui/fmtomo_parameters_layout.py deleted file mode 100644 index d12b6317..00000000 --- a/pylot/core/active/gui/fmtomo_parameters_layout.py +++ /dev/null @@ -1,306 +0,0 @@ -# -*- coding: utf-8 -*- - -# Form implementation generated from reading ui file 'fmtomo_parameters_layout.ui' -# -# Created: Mon Aug 29 10:26:23 2016 -# by: pyside-uic 0.2.15 running on PySide 1.2.2 -# -# WARNING! All changes made in this file will be lost! - -from PySide import QtCore, QtGui - -class Ui_fmtomo_parameters(object): - def setupUi(self, fmtomo_parameters): - fmtomo_parameters.setObjectName("fmtomo_parameters") - fmtomo_parameters.resize(400, 440) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(fmtomo_parameters.sizePolicy().hasHeightForWidth()) - fmtomo_parameters.setSizePolicy(sizePolicy) - fmtomo_parameters.setMinimumSize(QtCore.QSize(400, 440)) - fmtomo_parameters.setMaximumSize(QtCore.QSize(320000, 520000)) - icon = QtGui.QIcon() - icon.addPixmap(QtGui.QPixmap("../asp3d_icon.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) - fmtomo_parameters.setWindowIcon(icon) - self.verticalLayout = QtGui.QVBoxLayout(fmtomo_parameters) - self.verticalLayout.setObjectName("verticalLayout") - self.horizontalLayout_4 = QtGui.QHBoxLayout() - self.horizontalLayout_4.setObjectName("horizontalLayout_4") - self.label_17 = QtGui.QLabel(fmtomo_parameters) - self.label_17.setObjectName("label_17") - self.horizontalLayout_4.addWidget(self.label_17) - self.fmtomo_dir = QtGui.QLineEdit(fmtomo_parameters) - self.fmtomo_dir.setObjectName("fmtomo_dir") - self.horizontalLayout_4.addWidget(self.fmtomo_dir) - self.browse_tomodir = QtGui.QPushButton(fmtomo_parameters) - self.browse_tomodir.setObjectName("browse_tomodir") - self.horizontalLayout_4.addWidget(self.browse_tomodir) - self.verticalLayout.addLayout(self.horizontalLayout_4) - self.line_5 = QtGui.QFrame(fmtomo_parameters) - self.line_5.setFrameShape(QtGui.QFrame.HLine) - self.line_5.setFrameShadow(QtGui.QFrame.Sunken) - self.line_5.setObjectName("line_5") - self.verticalLayout.addWidget(self.line_5) - self.horizontalLayout_2 = QtGui.QHBoxLayout() - self.horizontalLayout_2.setObjectName("horizontalLayout_2") - self.label_14 = QtGui.QLabel(fmtomo_parameters) - self.label_14.setObjectName("label_14") - self.horizontalLayout_2.addWidget(self.label_14) - self.nproc = QtGui.QSpinBox(fmtomo_parameters) - self.nproc.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) - self.nproc.setMinimum(1) - self.nproc.setMaximum(10000) - self.nproc.setObjectName("nproc") - self.horizontalLayout_2.addWidget(self.nproc) - self.verticalLayout.addLayout(self.horizontalLayout_2) - self.gridLayout_3 = QtGui.QGridLayout() - self.gridLayout_3.setObjectName("gridLayout_3") - self.nIter = QtGui.QSpinBox(fmtomo_parameters) - self.nIter.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) - self.nIter.setProperty("value", 1) - self.nIter.setObjectName("nIter") - self.gridLayout_3.addWidget(self.nIter, 0, 1, 1, 1) - self.label = QtGui.QLabel(fmtomo_parameters) - self.label.setObjectName("label") - self.gridLayout_3.addWidget(self.label, 0, 0, 1, 1) - self.verticalLayout.addLayout(self.gridLayout_3) - self.line_4 = QtGui.QFrame(fmtomo_parameters) - self.line_4.setFrameShape(QtGui.QFrame.HLine) - self.line_4.setFrameShadow(QtGui.QFrame.Sunken) - self.line_4.setObjectName("line_4") - self.verticalLayout.addWidget(self.line_4) - self.label_18 = QtGui.QLabel(fmtomo_parameters) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.label_18.sizePolicy().hasHeightForWidth()) - self.label_18.setSizePolicy(sizePolicy) - self.label_18.setObjectName("label_18") - self.verticalLayout.addWidget(self.label_18) - self.gridLayout_2 = QtGui.QGridLayout() - self.gridLayout_2.setObjectName("gridLayout_2") - self.label_3 = QtGui.QLabel(fmtomo_parameters) - self.label_3.setObjectName("label_3") - self.gridLayout_2.addWidget(self.label_3, 1, 0, 1, 1) - self.bbot = QtGui.QLineEdit(fmtomo_parameters) - self.bbot.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) - self.bbot.setObjectName("bbot") - self.gridLayout_2.addWidget(self.bbot, 1, 1, 1, 1) - self.label_11 = QtGui.QLabel(fmtomo_parameters) - self.label_11.setObjectName("label_11") - self.gridLayout_2.addWidget(self.label_11, 1, 2, 1, 1) - self.label_2 = QtGui.QLabel(fmtomo_parameters) - self.label_2.setObjectName("label_2") - self.gridLayout_2.addWidget(self.label_2, 0, 0, 1, 1) - self.btop = QtGui.QLineEdit(fmtomo_parameters) - self.btop.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) - self.btop.setObjectName("btop") - self.gridLayout_2.addWidget(self.btop, 0, 1, 1, 1) - self.label_10 = QtGui.QLabel(fmtomo_parameters) - self.label_10.setObjectName("label_10") - self.gridLayout_2.addWidget(self.label_10, 0, 2, 1, 1) - self.horizontalLayout = QtGui.QHBoxLayout() - self.horizontalLayout.setObjectName("horizontalLayout") - self.label_13 = QtGui.QLabel(fmtomo_parameters) - self.label_13.setObjectName("label_13") - self.horizontalLayout.addWidget(self.label_13) - self.cushion = QtGui.QSpinBox(fmtomo_parameters) - self.cushion.setMinimum(2) - self.cushion.setMaximum(100) - self.cushion.setProperty("value", 10) - self.cushion.setObjectName("cushion") - self.horizontalLayout.addWidget(self.cushion) - self.label_12 = QtGui.QLabel(fmtomo_parameters) - self.label_12.setObjectName("label_12") - self.horizontalLayout.addWidget(self.label_12) - self.gridLayout_2.addLayout(self.horizontalLayout, 0, 3, 1, 1) - self.verticalLayout.addLayout(self.gridLayout_2) - self.line = QtGui.QFrame(fmtomo_parameters) - self.line.setFrameShape(QtGui.QFrame.HLine) - self.line.setFrameShadow(QtGui.QFrame.Sunken) - self.line.setObjectName("line") - self.verticalLayout.addWidget(self.line) - self.gridLayout = QtGui.QGridLayout() - self.gridLayout.setObjectName("gridLayout") - self.label_4 = QtGui.QLabel(fmtomo_parameters) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.label_4.sizePolicy().hasHeightForWidth()) - self.label_4.setSizePolicy(sizePolicy) - self.label_4.setObjectName("label_4") - self.gridLayout.addWidget(self.label_4, 0, 0, 1, 1) - self.label_5 = QtGui.QLabel(fmtomo_parameters) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.label_5.sizePolicy().hasHeightForWidth()) - self.label_5.setSizePolicy(sizePolicy) - self.label_5.setLayoutDirection(QtCore.Qt.LeftToRight) - self.label_5.setAlignment(QtCore.Qt.AlignCenter) - self.label_5.setObjectName("label_5") - self.gridLayout.addWidget(self.label_5, 0, 1, 1, 1) - self.label_6 = QtGui.QLabel(fmtomo_parameters) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.label_6.sizePolicy().hasHeightForWidth()) - self.label_6.setSizePolicy(sizePolicy) - self.label_6.setLayoutDirection(QtCore.Qt.LeftToRight) - self.label_6.setAlignment(QtCore.Qt.AlignCenter) - self.label_6.setObjectName("label_6") - self.gridLayout.addWidget(self.label_6, 0, 2, 1, 1) - self.label_7 = QtGui.QLabel(fmtomo_parameters) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.label_7.sizePolicy().hasHeightForWidth()) - self.label_7.setSizePolicy(sizePolicy) - self.label_7.setLayoutDirection(QtCore.Qt.LeftToRight) - self.label_7.setAlignment(QtCore.Qt.AlignCenter) - self.label_7.setObjectName("label_7") - self.gridLayout.addWidget(self.label_7, 0, 3, 1, 1) - self.label_9 = QtGui.QLabel(fmtomo_parameters) - self.label_9.setObjectName("label_9") - self.gridLayout.addWidget(self.label_9, 2, 0, 1, 1) - self.pgrid_x = QtGui.QSpinBox(fmtomo_parameters) - self.pgrid_x.setMinimum(2) - self.pgrid_x.setMaximum(10000) - self.pgrid_x.setProperty("value", 100) - self.pgrid_x.setObjectName("pgrid_x") - self.gridLayout.addWidget(self.pgrid_x, 1, 1, 1, 1) - self.pgrid_y = QtGui.QSpinBox(fmtomo_parameters) - self.pgrid_y.setMinimum(2) - self.pgrid_y.setMaximum(10000) - self.pgrid_y.setProperty("value", 100) - self.pgrid_y.setObjectName("pgrid_y") - self.gridLayout.addWidget(self.pgrid_y, 1, 2, 1, 1) - self.pgrid_z = QtGui.QSpinBox(fmtomo_parameters) - self.pgrid_z.setMinimum(2) - self.pgrid_z.setMaximum(10000) - self.pgrid_z.setProperty("value", 120) - self.pgrid_z.setObjectName("pgrid_z") - self.gridLayout.addWidget(self.pgrid_z, 1, 3, 1, 1) - self.label_8 = QtGui.QLabel(fmtomo_parameters) - self.label_8.setObjectName("label_8") - self.gridLayout.addWidget(self.label_8, 1, 0, 1, 1) - self.invgrid_x = QtGui.QSpinBox(fmtomo_parameters) - self.invgrid_x.setMinimum(2) - self.invgrid_x.setMaximum(10000) - self.invgrid_x.setProperty("value", 60) - self.invgrid_x.setObjectName("invgrid_x") - self.gridLayout.addWidget(self.invgrid_x, 2, 1, 1, 1) - self.invgrid_y = QtGui.QSpinBox(fmtomo_parameters) - self.invgrid_y.setMinimum(2) - self.invgrid_y.setMaximum(10000) - self.invgrid_y.setProperty("value", 60) - self.invgrid_y.setObjectName("invgrid_y") - self.gridLayout.addWidget(self.invgrid_y, 2, 2, 1, 1) - self.invgrid_z = QtGui.QSpinBox(fmtomo_parameters) - self.invgrid_z.setMinimum(2) - self.invgrid_z.setMaximum(10000) - self.invgrid_z.setProperty("value", 80) - self.invgrid_z.setObjectName("invgrid_z") - self.gridLayout.addWidget(self.invgrid_z, 2, 3, 1, 1) - self.verticalLayout.addLayout(self.gridLayout) - self.line_2 = QtGui.QFrame(fmtomo_parameters) - self.line_2.setFrameShape(QtGui.QFrame.HLine) - self.line_2.setFrameShadow(QtGui.QFrame.Sunken) - self.line_2.setObjectName("line_2") - self.verticalLayout.addWidget(self.line_2) - self.line_3 = QtGui.QFrame(fmtomo_parameters) - self.line_3.setFrameShape(QtGui.QFrame.HLine) - self.line_3.setFrameShadow(QtGui.QFrame.Sunken) - self.line_3.setObjectName("line_3") - self.verticalLayout.addWidget(self.line_3) - self.gridLayout_4 = QtGui.QGridLayout() - self.gridLayout_4.setObjectName("gridLayout_4") - self.label_15 = QtGui.QLabel(fmtomo_parameters) - self.label_15.setObjectName("label_15") - self.gridLayout_4.addWidget(self.label_15, 0, 0, 1, 1) - self.customgrid = QtGui.QLineEdit(fmtomo_parameters) - self.customgrid.setObjectName("customgrid") - self.gridLayout_4.addWidget(self.customgrid, 0, 1, 1, 1) - self.browse_customgrid = QtGui.QPushButton(fmtomo_parameters) - self.browse_customgrid.setObjectName("browse_customgrid") - self.gridLayout_4.addWidget(self.browse_customgrid, 0, 2, 1, 1) - self.label_16 = QtGui.QLabel(fmtomo_parameters) - self.label_16.setObjectName("label_16") - self.gridLayout_4.addWidget(self.label_16, 1, 0, 1, 1) - self.simuldir = QtGui.QLineEdit(fmtomo_parameters) - self.simuldir.setObjectName("simuldir") - self.gridLayout_4.addWidget(self.simuldir, 1, 1, 1, 1) - self.browse_simuldir = QtGui.QPushButton(fmtomo_parameters) - self.browse_simuldir.setObjectName("browse_simuldir") - self.gridLayout_4.addWidget(self.browse_simuldir, 1, 2, 1, 1) - self.verticalLayout.addLayout(self.gridLayout_4) - self.buttonBox = QtGui.QDialogButtonBox(fmtomo_parameters) - self.buttonBox.setOrientation(QtCore.Qt.Horizontal) - self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok) - self.buttonBox.setObjectName("buttonBox") - self.verticalLayout.addWidget(self.buttonBox) - - self.retranslateUi(fmtomo_parameters) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), fmtomo_parameters.accept) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), fmtomo_parameters.reject) - QtCore.QMetaObject.connectSlotsByName(fmtomo_parameters) - - def retranslateUi(self, fmtomo_parameters): - fmtomo_parameters.setWindowTitle(QtGui.QApplication.translate("fmtomo_parameters", "Choose FMTOMO parameters", None, QtGui.QApplication.UnicodeUTF8)) - self.label_17.setToolTip(QtGui.QApplication.translate("fmtomo_parameters", "Directory containing a clean FMTOMO installation.", None, QtGui.QApplication.UnicodeUTF8)) - self.label_17.setText(QtGui.QApplication.translate("fmtomo_parameters", "FMTOMO\n" -"installation [?]", None, QtGui.QApplication.UnicodeUTF8)) - self.browse_tomodir.setText(QtGui.QApplication.translate("fmtomo_parameters", "Browse", None, QtGui.QApplication.UnicodeUTF8)) - self.label_14.setToolTip(QtGui.QApplication.translate("fmtomo_parameters", "Number of processes spawned for parallel forward simulation.", None, QtGui.QApplication.UnicodeUTF8)) - self.label_14.setText(QtGui.QApplication.translate("fmtomo_parameters", "Number of processes [?]", None, QtGui.QApplication.UnicodeUTF8)) - self.label.setToolTip(QtGui.QApplication.translate("fmtomo_parameters", "Number of inversion iterations.", None, QtGui.QApplication.UnicodeUTF8)) - self.label.setText(QtGui.QApplication.translate("fmtomo_parameters", "Iterations [?]", None, QtGui.QApplication.UnicodeUTF8)) - self.label_18.setText(QtGui.QApplication.translate("fmtomo_parameters", "Grid definitions from seismic Array:", None, QtGui.QApplication.UnicodeUTF8)) - self.label_3.setToolTip(QtGui.QApplication.translate("fmtomo_parameters", "Bottom boundary of the model.", None, QtGui.QApplication.UnicodeUTF8)) - self.label_3.setText(QtGui.QApplication.translate("fmtomo_parameters", "Bottom boundary [?]", None, QtGui.QApplication.UnicodeUTF8)) - self.bbot.setText(QtGui.QApplication.translate("fmtomo_parameters", "-50", None, QtGui.QApplication.UnicodeUTF8)) - self.label_11.setText(QtGui.QApplication.translate("fmtomo_parameters", "m", None, QtGui.QApplication.UnicodeUTF8)) - self.label_2.setToolTip(QtGui.QApplication.translate("fmtomo_parameters", "Top boundary of the model (must be greater than highest source or receiver position).\n" -"Too low values will cause error.", None, QtGui.QApplication.UnicodeUTF8)) - self.label_2.setText(QtGui.QApplication.translate("fmtomo_parameters", "Top boundary [?]", None, QtGui.QApplication.UnicodeUTF8)) - self.btop.setText(QtGui.QApplication.translate("fmtomo_parameters", "5", None, QtGui.QApplication.UnicodeUTF8)) - self.label_10.setText(QtGui.QApplication.translate("fmtomo_parameters", "m", None, QtGui.QApplication.UnicodeUTF8)) - self.label_13.setToolTip(QtGui.QApplication.translate("fmtomo_parameters", "Extension of the model around the maximum values of the receiver grid (X and Y).\n" -"Too low values will cause error.", None, QtGui.QApplication.UnicodeUTF8)) - self.label_13.setText(QtGui.QApplication.translate("fmtomo_parameters", "Cushion factor [?]", None, QtGui.QApplication.UnicodeUTF8)) - self.label_12.setText(QtGui.QApplication.translate("fmtomo_parameters", "%", None, QtGui.QApplication.UnicodeUTF8)) - self.label_4.setText(QtGui.QApplication.translate("fmtomo_parameters", "Number of Points", None, QtGui.QApplication.UnicodeUTF8)) - self.label_5.setText(QtGui.QApplication.translate("fmtomo_parameters", "X", None, QtGui.QApplication.UnicodeUTF8)) - self.label_6.setText(QtGui.QApplication.translate("fmtomo_parameters", "Y", None, QtGui.QApplication.UnicodeUTF8)) - self.label_7.setText(QtGui.QApplication.translate("fmtomo_parameters", "Z", None, QtGui.QApplication.UnicodeUTF8)) - self.label_9.setToolTip(QtGui.QApplication.translate("fmtomo_parameters", "Number of inversion grid (velocity grid) points in X, Y, Z.\n" -"Must be lower than for propagation grid.", None, QtGui.QApplication.UnicodeUTF8)) - self.label_9.setText(QtGui.QApplication.translate("fmtomo_parameters", "Inversion Grid [?]", None, QtGui.QApplication.UnicodeUTF8)) - self.label_8.setToolTip(QtGui.QApplication.translate("fmtomo_parameters", "Number of points for forward simulation in X, Y, Z.\n" -"Must be higher than number of inversion grid points.", None, QtGui.QApplication.UnicodeUTF8)) - self.label_8.setText(QtGui.QApplication.translate("fmtomo_parameters", "Propagation Grid [?]", None, QtGui.QApplication.UnicodeUTF8)) - self.label_15.setToolTip(QtGui.QApplication.translate("fmtomo_parameters", "\n" -"\n" -"

Specifiy simple input velocity file from which linear gradients will be evaluated.

\n" -"

\n" -"

For example:

\n" -"

\n" -"

First gradient: Surface velocity: 0.5 km/s rising to 1.0 km/s at a depth of 5 m below the surface.

\n" -"

Second gradient: Continuous change to another gradient from 1.0 km/s to 4.0 km/s at 60 m depth below the surface.

\n" -"

\n" -"

0 0.5

\n" -"

-5 1.0

\n" -"

-5 1.0

\n" -"

-60 4.0

\n" -"

", None, QtGui.QApplication.UnicodeUTF8)) - self.label_15.setText(QtGui.QApplication.translate("fmtomo_parameters", "Custom velocity\n" -"grid (earthmodel) [?]", None, QtGui.QApplication.UnicodeUTF8)) - self.browse_customgrid.setText(QtGui.QApplication.translate("fmtomo_parameters", "Browse", None, QtGui.QApplication.UnicodeUTF8)) - self.label_16.setToolTip(QtGui.QApplication.translate("fmtomo_parameters", "Specifiy directory for FMTOMO simulation.", None, QtGui.QApplication.UnicodeUTF8)) - self.label_16.setText(QtGui.QApplication.translate("fmtomo_parameters", "Simulation\n" -"Directory [?]", None, QtGui.QApplication.UnicodeUTF8)) - self.browse_simuldir.setText(QtGui.QApplication.translate("fmtomo_parameters", "Browse", None, QtGui.QApplication.UnicodeUTF8)) - diff --git a/pylot/core/active/gui/generate_seisarray_layout.py b/pylot/core/active/gui/generate_seisarray_layout.py deleted file mode 100644 index e22b7488..00000000 --- a/pylot/core/active/gui/generate_seisarray_layout.py +++ /dev/null @@ -1,175 +0,0 @@ -# -*- coding: utf-8 -*- - -# Form implementation generated from reading ui file 'generate_seisarray_layout.ui' -# -# Created: Mon Aug 29 10:26:23 2016 -# by: pyside-uic 0.2.15 running on PySide 1.2.2 -# -# WARNING! All changes made in this file will be lost! - -from PySide import QtCore, QtGui - -class Ui_generate_seisarray(object): - def setupUi(self, generate_seisarray): - generate_seisarray.setObjectName("generate_seisarray") - generate_seisarray.resize(403, 221) - generate_seisarray.setMinimumSize(QtCore.QSize(400, 220)) - icon = QtGui.QIcon() - icon.addPixmap(QtGui.QPixmap("../asp3d_icon.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) - generate_seisarray.setWindowIcon(icon) - self.verticalLayout_5 = QtGui.QVBoxLayout(generate_seisarray) - self.verticalLayout_5.setObjectName("verticalLayout_5") - self.verticalLayout = QtGui.QVBoxLayout() - self.verticalLayout.setObjectName("verticalLayout") - self.verticalLayout_4 = QtGui.QVBoxLayout() - self.verticalLayout_4.setObjectName("verticalLayout_4") - self.horizontalLayout = QtGui.QHBoxLayout() - self.horizontalLayout.setObjectName("horizontalLayout") - self.label_rec = QtGui.QLabel(generate_seisarray) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.label_rec.sizePolicy().hasHeightForWidth()) - self.label_rec.setSizePolicy(sizePolicy) - self.label_rec.setToolTip("") - self.label_rec.setObjectName("label_rec") - self.horizontalLayout.addWidget(self.label_rec) - spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) - self.horizontalLayout.addItem(spacerItem) - self.radioButton_normal = QtGui.QRadioButton(generate_seisarray) - self.radioButton_normal.setChecked(True) - self.radioButton_normal.setObjectName("radioButton_normal") - self.horizontalLayout.addWidget(self.radioButton_normal) - self.radioButton_interpolatable = QtGui.QRadioButton(generate_seisarray) - self.radioButton_interpolatable.setObjectName("radioButton_interpolatable") - self.horizontalLayout.addWidget(self.radioButton_interpolatable) - self.verticalLayout_4.addLayout(self.horizontalLayout) - self.horizontalLayout_4 = QtGui.QHBoxLayout() - self.horizontalLayout_4.setObjectName("horizontalLayout_4") - self.lineEdit_rec = QtGui.QLineEdit(generate_seisarray) - self.lineEdit_rec.setObjectName("lineEdit_rec") - self.horizontalLayout_4.addWidget(self.lineEdit_rec) - self.pushButton_rec = QtGui.QPushButton(generate_seisarray) - self.pushButton_rec.setObjectName("pushButton_rec") - self.horizontalLayout_4.addWidget(self.pushButton_rec) - self.verticalLayout_4.addLayout(self.horizontalLayout_4) - self.verticalLayout.addLayout(self.verticalLayout_4) - self.verticalLayout_2 = QtGui.QVBoxLayout() - self.verticalLayout_2.setObjectName("verticalLayout_2") - self.label_src = QtGui.QLabel(generate_seisarray) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.label_src.sizePolicy().hasHeightForWidth()) - self.label_src.setSizePolicy(sizePolicy) - self.label_src.setObjectName("label_src") - self.verticalLayout_2.addWidget(self.label_src) - self.horizontalLayout_5 = QtGui.QHBoxLayout() - self.horizontalLayout_5.setObjectName("horizontalLayout_5") - self.lineEdit_src = QtGui.QLineEdit(generate_seisarray) - self.lineEdit_src.setObjectName("lineEdit_src") - self.horizontalLayout_5.addWidget(self.lineEdit_src) - self.pushButton_src = QtGui.QPushButton(generate_seisarray) - self.pushButton_src.setObjectName("pushButton_src") - self.horizontalLayout_5.addWidget(self.pushButton_src) - self.verticalLayout_2.addLayout(self.horizontalLayout_5) - self.verticalLayout.addLayout(self.verticalLayout_2) - self.verticalLayout_3 = QtGui.QVBoxLayout() - self.verticalLayout_3.setObjectName("verticalLayout_3") - self.label_obs = QtGui.QLabel(generate_seisarray) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.label_obs.sizePolicy().hasHeightForWidth()) - self.label_obs.setSizePolicy(sizePolicy) - self.label_obs.setObjectName("label_obs") - self.verticalLayout_3.addWidget(self.label_obs) - self.horizontalLayout_6 = QtGui.QHBoxLayout() - self.horizontalLayout_6.setObjectName("horizontalLayout_6") - self.lineEdit_pts = QtGui.QLineEdit(generate_seisarray) - self.lineEdit_pts.setObjectName("lineEdit_pts") - self.horizontalLayout_6.addWidget(self.lineEdit_pts) - self.pushButton_obs = QtGui.QPushButton(generate_seisarray) - self.pushButton_obs.setObjectName("pushButton_obs") - self.horizontalLayout_6.addWidget(self.pushButton_obs) - self.verticalLayout_3.addLayout(self.horizontalLayout_6) - self.verticalLayout.addLayout(self.verticalLayout_3) - self.verticalLayout_5.addLayout(self.verticalLayout) - self.buttonBox = QtGui.QDialogButtonBox(generate_seisarray) - self.buttonBox.setOrientation(QtCore.Qt.Horizontal) - self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok) - self.buttonBox.setObjectName("buttonBox") - self.verticalLayout_5.addWidget(self.buttonBox) - - self.retranslateUi(generate_seisarray) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), generate_seisarray.reject) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), generate_seisarray.accept) - QtCore.QMetaObject.connectSlotsByName(generate_seisarray) - - def retranslateUi(self, generate_seisarray): - generate_seisarray.setWindowTitle(QtGui.QApplication.translate("generate_seisarray", "Generate new Seismic Array", None, QtGui.QApplication.UnicodeUTF8)) - self.label_rec.setText(QtGui.QApplication.translate("generate_seisarray", "Measured Receivers", None, QtGui.QApplication.UnicodeUTF8)) - self.radioButton_normal.setToolTip(QtGui.QApplication.translate("generate_seisarray", "\n" -"\n" -"

Load normal measured receiver input file. The input file must be in the following format:

\n" -"

\n" -"

Containing in each line, separated by spaces:

\n" -"

\n" -"

[trace ID (int)] [X (float)] [Y (float)] [Z (float)]

\n" -"

\n" -"

For example:

\n" -"

Geophone with the trace ID 50 and the coordinates (10.5 [m], 20.4 [m], 30.3 [m]).

\n" -"

\n" -"

50 10.5 20.4 30.3

", None, QtGui.QApplication.UnicodeUTF8)) - self.radioButton_normal.setText(QtGui.QApplication.translate("generate_seisarray", "normal [?]", None, QtGui.QApplication.UnicodeUTF8)) - self.radioButton_interpolatable.setToolTip(QtGui.QApplication.translate("generate_seisarray", "\n" -"\n" -"

Load measured receiver input file that can be interpolated. The input file must be in the following format:

\n" -"

\n" -"

Containing in each line, separated by spaces:

\n" -"

\n" -"

[trace ID (int)] [receiver line ID (int)] [number of the geophone on receiver line (int)] [X (float)] [Y (float)] [Z (float)]

\n" -"

\n" -"

For example:

\n" -"

Third geophone on the second receiver line with the trace ID 50 and the coordinates (10.5 [m], 20.4 [m], 30.3 [m]).

\n" -"

\n" -"

50 2 3 10.5 20.4 30.3

", None, QtGui.QApplication.UnicodeUTF8)) - self.radioButton_interpolatable.setText(QtGui.QApplication.translate("generate_seisarray", "interpolation [?]", None, QtGui.QApplication.UnicodeUTF8)) - self.pushButton_rec.setText(QtGui.QApplication.translate("generate_seisarray", "Browse", None, QtGui.QApplication.UnicodeUTF8)) - self.label_src.setToolTip(QtGui.QApplication.translate("generate_seisarray", "\n" -"\n" -"

Load measured sources input file to improve interpolation precision. The input file must be in the following format:

\n" -"

\n" -"

Containing in each line, separated by spaces:

\n" -"

\n" -"

[source ID (int)] [X (float)] [Y (float)] [Z (float)]

\n" -"

\n" -"

For example:

\n" -"

Shot number 100 with the coordinates (12.3 [m], 100.5 [m], 20.3 [m]).

\n" -"

\n" -"

100 12.3 100.5 20.3

", None, QtGui.QApplication.UnicodeUTF8)) - self.label_src.setText(QtGui.QApplication.translate("generate_seisarray", "Measured Sources (optional) [?]", None, QtGui.QApplication.UnicodeUTF8)) - self.pushButton_src.setText(QtGui.QApplication.translate("generate_seisarray", "Browse", None, QtGui.QApplication.UnicodeUTF8)) - self.label_obs.setToolTip(QtGui.QApplication.translate("generate_seisarray", "\n" -"\n" -"

Load measured points input file to improve interpolation precision. The input file must be in the following format:

\n" -"

\n" -"

Containing in each line, separated by spaces:

\n" -"

\n" -"

[point ID (int)] [X (float)] [Y (float)] [Z (float)]

\n" -"

\n" -"

For example:

\n" -"

Point number 100 with the coordinates (12.3 [m], 100.5 [m], 20.3 [m]).

\n" -"

\n" -"

100 12.3 100.5 20.3

", None, QtGui.QApplication.UnicodeUTF8)) - self.label_obs.setText(QtGui.QApplication.translate("generate_seisarray", "Additional measured points (optional) [?]", None, QtGui.QApplication.UnicodeUTF8)) - self.pushButton_obs.setText(QtGui.QApplication.translate("generate_seisarray", "Browse", None, QtGui.QApplication.UnicodeUTF8)) - diff --git a/pylot/core/active/gui/generate_survey_layout.py b/pylot/core/active/gui/generate_survey_layout.py deleted file mode 100644 index 8afada23..00000000 --- a/pylot/core/active/gui/generate_survey_layout.py +++ /dev/null @@ -1,151 +0,0 @@ -# -*- coding: utf-8 -*- - -# Form implementation generated from reading ui file 'generate_survey_layout.ui' -# -# Created: Mon Aug 29 10:26:23 2016 -# by: pyside-uic 0.2.15 running on PySide 1.2.2 -# -# WARNING! All changes made in this file will be lost! - -from PySide import QtCore, QtGui - -class Ui_generate_survey(object): - def setupUi(self, generate_survey): - generate_survey.setObjectName("generate_survey") - generate_survey.resize(382, 220) - icon = QtGui.QIcon() - icon.addPixmap(QtGui.QPixmap("../asp3d_icon.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) - generate_survey.setWindowIcon(icon) - self.verticalLayout_2 = QtGui.QVBoxLayout(generate_survey) - self.verticalLayout_2.setObjectName("verticalLayout_2") - self.gridLayout = QtGui.QGridLayout() - self.gridLayout.setObjectName("gridLayout") - self.lineEdit_rec = QtGui.QLineEdit(generate_survey) - self.lineEdit_rec.setObjectName("lineEdit_rec") - self.gridLayout.addWidget(self.lineEdit_rec, 0, 1, 1, 1) - self.pushButton_rec = QtGui.QPushButton(generate_survey) - self.pushButton_rec.setObjectName("pushButton_rec") - self.gridLayout.addWidget(self.pushButton_rec, 0, 2, 1, 1) - self.label_rec = QtGui.QLabel(generate_survey) - self.label_rec.setObjectName("label_rec") - self.gridLayout.addWidget(self.label_rec, 0, 0, 1, 1) - self.lineEdit_obs = QtGui.QLineEdit(generate_survey) - self.lineEdit_obs.setObjectName("lineEdit_obs") - self.gridLayout.addWidget(self.lineEdit_obs, 2, 1, 1, 1) - self.label_obs = QtGui.QLabel(generate_survey) - self.label_obs.setObjectName("label_obs") - self.gridLayout.addWidget(self.label_obs, 2, 0, 1, 1) - self.pushButton_obs = QtGui.QPushButton(generate_survey) - self.pushButton_obs.setObjectName("pushButton_obs") - self.gridLayout.addWidget(self.pushButton_obs, 2, 2, 1, 1) - self.label_src = QtGui.QLabel(generate_survey) - self.label_src.setObjectName("label_src") - self.gridLayout.addWidget(self.label_src, 1, 0, 1, 1) - self.lineEdit_src = QtGui.QLineEdit(generate_survey) - self.lineEdit_src.setObjectName("lineEdit_src") - self.gridLayout.addWidget(self.lineEdit_src, 1, 1, 1, 1) - self.pushButton_src = QtGui.QPushButton(generate_survey) - self.pushButton_src.setObjectName("pushButton_src") - self.gridLayout.addWidget(self.pushButton_src, 1, 2, 1, 1) - self.verticalLayout_2.addLayout(self.gridLayout) - self.verticalLayout = QtGui.QVBoxLayout() - self.verticalLayout.setObjectName("verticalLayout") - self.line_2 = QtGui.QFrame(generate_survey) - self.line_2.setFrameShape(QtGui.QFrame.HLine) - self.line_2.setFrameShadow(QtGui.QFrame.Sunken) - self.line_2.setObjectName("line_2") - self.verticalLayout.addWidget(self.line_2) - self.label = QtGui.QLabel(generate_survey) - self.label.setObjectName("label") - self.verticalLayout.addWidget(self.label) - self.horizontalLayout = QtGui.QHBoxLayout() - self.horizontalLayout.setObjectName("horizontalLayout") - self.fstart = QtGui.QLineEdit(generate_survey) - self.fstart.setObjectName("fstart") - self.horizontalLayout.addWidget(self.fstart) - self.label_obs_2 = QtGui.QLabel(generate_survey) - self.label_obs_2.setObjectName("label_obs_2") - self.horizontalLayout.addWidget(self.label_obs_2) - self.fend = QtGui.QLineEdit(generate_survey) - self.fend.setObjectName("fend") - self.horizontalLayout.addWidget(self.fend) - self.verticalLayout.addLayout(self.horizontalLayout) - self.verticalLayout_2.addLayout(self.verticalLayout) - self.buttonBox = QtGui.QDialogButtonBox(generate_survey) - self.buttonBox.setOrientation(QtCore.Qt.Horizontal) - self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok) - self.buttonBox.setObjectName("buttonBox") - self.verticalLayout_2.addWidget(self.buttonBox) - - self.retranslateUi(generate_survey) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), generate_survey.accept) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), generate_survey.reject) - QtCore.QMetaObject.connectSlotsByName(generate_survey) - - def retranslateUi(self, generate_survey): - generate_survey.setWindowTitle(QtGui.QApplication.translate("generate_survey", "Generate new Survey", None, QtGui.QApplication.UnicodeUTF8)) - self.pushButton_rec.setText(QtGui.QApplication.translate("generate_survey", "Browse", None, QtGui.QApplication.UnicodeUTF8)) - self.label_rec.setToolTip(QtGui.QApplication.translate("generate_survey", "\n" -"\n" -"

Load receiver input file. The input file must be in the following format:

\n" -"

\n" -"

Containing in each line, separated by spaces:

\n" -"

\n" -"

[trace ID (int)] [X (float)] [Y (float)] [Z (float)]

\n" -"

\n" -"

For example:

\n" -"

Trace ID 100 with the coordinates (12.3 [m], 100.5 [m], 20.3 [m]).

\n" -"

\n" -"

100 12.3 100.5 20.3

", None, QtGui.QApplication.UnicodeUTF8)) - self.label_rec.setText(QtGui.QApplication.translate("generate_survey", "Receiver\n" -"File [?]", None, QtGui.QApplication.UnicodeUTF8)) - self.label_obs.setToolTip(QtGui.QApplication.translate("generate_survey", "\n" -"\n" -"

Specifiy directory containing seismograms for each shot.

\n" -"

Currently in the format SEGY with each file named \'shotnumber*_pickle.dat\'.

\n" -"

\n" -"

For example:

\n" -"

\n" -"

Shot number 100 containing seismograms for all traces with the name:

\n" -"

\n" -"

100_pickle.dat

", None, QtGui.QApplication.UnicodeUTF8)) - self.label_obs.setText(QtGui.QApplication.translate("generate_survey", "Seismogram\n" -"Directory [?]", None, QtGui.QApplication.UnicodeUTF8)) - self.pushButton_obs.setText(QtGui.QApplication.translate("generate_survey", "Browse", None, QtGui.QApplication.UnicodeUTF8)) - self.label_src.setToolTip(QtGui.QApplication.translate("generate_survey", "\n" -"\n" -"

Load sources input file. The input file must be in the following format:

\n" -"

\n" -"

Containing in each line, separated by spaces:

\n" -"

\n" -"

[trace ID (int)] [X (float)] [Y (float)] [Z (float)]

\n" -"

\n" -"

For example:

\n" -"

Source number 100 with the coordinates (12.3 [m], 100.5 [m], 20.3 [m]).

\n" -"

\n" -"

100 12.3 100.5 20.3

", None, QtGui.QApplication.UnicodeUTF8)) - self.label_src.setText(QtGui.QApplication.translate("generate_survey", "Source\n" -"File [?]", None, QtGui.QApplication.UnicodeUTF8)) - self.pushButton_src.setText(QtGui.QApplication.translate("generate_survey", "Browse", None, QtGui.QApplication.UnicodeUTF8)) - self.label.setText(QtGui.QApplication.translate("generate_survey", "File structure:", None, QtGui.QApplication.UnicodeUTF8)) - self.label_obs_2.setToolTip(QtGui.QApplication.translate("generate_survey", "\n" -"\n" -"

Specifiy directory containing seismograms for each shot.

\n" -"

Currently in the format SEGY with each file named \'shotnumber*_pickle.dat\'.

\n" -"

\n" -"

For example:

\n" -"

\n" -"

Shot number 100 containing seismograms for all traces with the name:

\n" -"

\n" -"

100_pickle.dat

", None, QtGui.QApplication.UnicodeUTF8)) - self.label_obs_2.setText(QtGui.QApplication.translate("generate_survey", "*Shotnumber*", None, QtGui.QApplication.UnicodeUTF8)) - self.fend.setText(QtGui.QApplication.translate("generate_survey", ".dat", None, QtGui.QApplication.UnicodeUTF8)) - diff --git a/pylot/core/active/gui/generate_survey_layout_minimal.py b/pylot/core/active/gui/generate_survey_layout_minimal.py deleted file mode 100644 index c33302be..00000000 --- a/pylot/core/active/gui/generate_survey_layout_minimal.py +++ /dev/null @@ -1,94 +0,0 @@ -# -*- coding: utf-8 -*- - -# Form implementation generated from reading ui file 'generate_survey_layout_minimal.ui' -# -# Created: Mon Aug 29 10:26:23 2016 -# by: pyside-uic 0.2.15 running on PySide 1.2.2 -# -# WARNING! All changes made in this file will be lost! - -from PySide import QtCore, QtGui - -class Ui_generate_survey_minimal(object): - def setupUi(self, generate_survey_minimal): - generate_survey_minimal.setObjectName("generate_survey_minimal") - generate_survey_minimal.resize(382, 139) - icon = QtGui.QIcon() - icon.addPixmap(QtGui.QPixmap("../asp3d_icon.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) - generate_survey_minimal.setWindowIcon(icon) - self.verticalLayout_2 = QtGui.QVBoxLayout(generate_survey_minimal) - self.verticalLayout_2.setObjectName("verticalLayout_2") - self.gridLayout = QtGui.QGridLayout() - self.gridLayout.setObjectName("gridLayout") - self.lineEdit_obs = QtGui.QLineEdit(generate_survey_minimal) - self.lineEdit_obs.setObjectName("lineEdit_obs") - self.gridLayout.addWidget(self.lineEdit_obs, 0, 1, 1, 1) - self.label_obs = QtGui.QLabel(generate_survey_minimal) - self.label_obs.setObjectName("label_obs") - self.gridLayout.addWidget(self.label_obs, 0, 0, 1, 1) - self.pushButton_obs = QtGui.QPushButton(generate_survey_minimal) - self.pushButton_obs.setObjectName("pushButton_obs") - self.gridLayout.addWidget(self.pushButton_obs, 0, 2, 1, 1) - self.verticalLayout_2.addLayout(self.gridLayout) - self.verticalLayout = QtGui.QVBoxLayout() - self.verticalLayout.setObjectName("verticalLayout") - self.label = QtGui.QLabel(generate_survey_minimal) - self.label.setObjectName("label") - self.verticalLayout.addWidget(self.label) - self.horizontalLayout = QtGui.QHBoxLayout() - self.horizontalLayout.setObjectName("horizontalLayout") - self.fstart = QtGui.QLineEdit(generate_survey_minimal) - self.fstart.setObjectName("fstart") - self.horizontalLayout.addWidget(self.fstart) - self.label_obs_2 = QtGui.QLabel(generate_survey_minimal) - self.label_obs_2.setObjectName("label_obs_2") - self.horizontalLayout.addWidget(self.label_obs_2) - self.fend = QtGui.QLineEdit(generate_survey_minimal) - self.fend.setObjectName("fend") - self.horizontalLayout.addWidget(self.fend) - self.verticalLayout.addLayout(self.horizontalLayout) - self.verticalLayout_2.addLayout(self.verticalLayout) - self.buttonBox = QtGui.QDialogButtonBox(generate_survey_minimal) - self.buttonBox.setOrientation(QtCore.Qt.Horizontal) - self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok) - self.buttonBox.setObjectName("buttonBox") - self.verticalLayout_2.addWidget(self.buttonBox) - - self.retranslateUi(generate_survey_minimal) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), generate_survey_minimal.accept) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), generate_survey_minimal.reject) - QtCore.QMetaObject.connectSlotsByName(generate_survey_minimal) - - def retranslateUi(self, generate_survey_minimal): - generate_survey_minimal.setWindowTitle(QtGui.QApplication.translate("generate_survey_minimal", "Generate new Survey", None, QtGui.QApplication.UnicodeUTF8)) - self.label_obs.setToolTip(QtGui.QApplication.translate("generate_survey_minimal", "\n" -"\n" -"

Specifiy directory containing seismograms for each shot.

\n" -"

Currently in the format SEGY with each file named \'shotnumber*_pickle.dat\'.

\n" -"

\n" -"

For example:

\n" -"

\n" -"

Shot number 100 containing seismograms for all traces with the name:

\n" -"

\n" -"

100_pickle.dat

", None, QtGui.QApplication.UnicodeUTF8)) - self.label_obs.setText(QtGui.QApplication.translate("generate_survey_minimal", "Seismogram\n" -"Directory [?]", None, QtGui.QApplication.UnicodeUTF8)) - self.pushButton_obs.setText(QtGui.QApplication.translate("generate_survey_minimal", "Browse", None, QtGui.QApplication.UnicodeUTF8)) - self.label.setText(QtGui.QApplication.translate("generate_survey_minimal", "File structure:", None, QtGui.QApplication.UnicodeUTF8)) - self.label_obs_2.setToolTip(QtGui.QApplication.translate("generate_survey_minimal", "\n" -"\n" -"

Specifiy directory containing seismograms for each shot.

\n" -"

Currently in the format SEGY with each file named \'shotnumber*_pickle.dat\'.

\n" -"

\n" -"

For example:

\n" -"

\n" -"

Shot number 100 containing seismograms for all traces with the name:

\n" -"

\n" -"

100_pickle.dat

", None, QtGui.QApplication.UnicodeUTF8)) - self.label_obs_2.setText(QtGui.QApplication.translate("generate_survey_minimal", "*Shotnumber*", None, QtGui.QApplication.UnicodeUTF8)) - self.fend.setText(QtGui.QApplication.translate("generate_survey_minimal", ".dat", None, QtGui.QApplication.UnicodeUTF8)) - diff --git a/pylot/core/active/gui/picking_parameters_layout.py b/pylot/core/active/gui/picking_parameters_layout.py deleted file mode 100644 index a6b2c3f2..00000000 --- a/pylot/core/active/gui/picking_parameters_layout.py +++ /dev/null @@ -1,277 +0,0 @@ -# -*- coding: utf-8 -*- - -# Form implementation generated from reading ui file 'picking_parameters_layout.ui' -# -# Created: Mon Aug 29 10:26:23 2016 -# by: pyside-uic 0.2.15 running on PySide 1.2.2 -# -# WARNING! All changes made in this file will be lost! - -from PySide import QtCore, QtGui - -class Ui_picking_parameters(object): - def setupUi(self, picking_parameters): - picking_parameters.setObjectName("picking_parameters") - picking_parameters.resize(422, 798) - picking_parameters.setMinimumSize(QtCore.QSize(0, 700)) - self.verticalLayout_4 = QtGui.QVBoxLayout(picking_parameters) - self.verticalLayout_4.setObjectName("verticalLayout_4") - self.label_7 = QtGui.QLabel(picking_parameters) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.label_7.sizePolicy().hasHeightForWidth()) - self.label_7.setSizePolicy(sizePolicy) - font = QtGui.QFont() - font.setFamily("Sans Serif") - font.setWeight(75) - font.setBold(True) - self.label_7.setFont(font) - self.label_7.setObjectName("label_7") - self.verticalLayout_4.addWidget(self.label_7) - self.horizontalLayout = QtGui.QHBoxLayout() - self.horizontalLayout.setObjectName("horizontalLayout") - self.label = QtGui.QLabel(picking_parameters) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.label.sizePolicy().hasHeightForWidth()) - self.label.setSizePolicy(sizePolicy) - self.label.setObjectName("label") - self.horizontalLayout.addWidget(self.label) - self.ncores = QtGui.QSpinBox(picking_parameters) - self.ncores.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) - self.ncores.setMinimum(1) - self.ncores.setMaximum(10000) - self.ncores.setObjectName("ncores") - self.horizontalLayout.addWidget(self.ncores) - self.verticalLayout_4.addLayout(self.horizontalLayout) - self.horizontalLayout_3 = QtGui.QHBoxLayout() - self.horizontalLayout_3.setObjectName("horizontalLayout_3") - self.verticalLayout_2 = QtGui.QVBoxLayout() - self.verticalLayout_2.setObjectName("verticalLayout_2") - self.label_2 = QtGui.QLabel(picking_parameters) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.label_2.sizePolicy().hasHeightForWidth()) - self.label_2.setSizePolicy(sizePolicy) - self.label_2.setObjectName("label_2") - self.verticalLayout_2.addWidget(self.label_2) - self.lineEdit_vmin = QtGui.QLineEdit(picking_parameters) - self.lineEdit_vmin.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) - self.lineEdit_vmin.setObjectName("lineEdit_vmin") - self.verticalLayout_2.addWidget(self.lineEdit_vmin) - self.horizontalLayout_3.addLayout(self.verticalLayout_2) - self.verticalLayout = QtGui.QVBoxLayout() - self.verticalLayout.setObjectName("verticalLayout") - self.label_3 = QtGui.QLabel(picking_parameters) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.label_3.sizePolicy().hasHeightForWidth()) - self.label_3.setSizePolicy(sizePolicy) - self.label_3.setObjectName("label_3") - self.verticalLayout.addWidget(self.label_3) - self.lineEdit_vmax = QtGui.QLineEdit(picking_parameters) - self.lineEdit_vmax.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) - self.lineEdit_vmax.setObjectName("lineEdit_vmax") - self.verticalLayout.addWidget(self.lineEdit_vmax) - self.horizontalLayout_3.addLayout(self.verticalLayout) - self.verticalLayout_4.addLayout(self.horizontalLayout_3) - self.horizontalLayout_4 = QtGui.QHBoxLayout() - self.horizontalLayout_4.setObjectName("horizontalLayout_4") - self.label_4 = QtGui.QLabel(picking_parameters) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.label_4.sizePolicy().hasHeightForWidth()) - self.label_4.setSizePolicy(sizePolicy) - self.label_4.setObjectName("label_4") - self.horizontalLayout_4.addWidget(self.label_4) - self.horizontalLayout_2 = QtGui.QHBoxLayout() - self.horizontalLayout_2.setObjectName("horizontalLayout_2") - self.slider_folm = QtGui.QSlider(picking_parameters) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.slider_folm.sizePolicy().hasHeightForWidth()) - self.slider_folm.setSizePolicy(sizePolicy) - self.slider_folm.setMinimum(1) - self.slider_folm.setMaximum(100) - self.slider_folm.setProperty("value", 60) - self.slider_folm.setOrientation(QtCore.Qt.Horizontal) - self.slider_folm.setTickPosition(QtGui.QSlider.TicksBelow) - self.slider_folm.setTickInterval(10) - self.slider_folm.setObjectName("slider_folm") - self.horizontalLayout_2.addWidget(self.slider_folm) - self.label_folm = QtGui.QLabel(picking_parameters) - self.label_folm.setAlignment(QtCore.Qt.AlignCenter) - self.label_folm.setObjectName("label_folm") - self.horizontalLayout_2.addWidget(self.label_folm) - self.horizontalLayout_4.addLayout(self.horizontalLayout_2) - self.verticalLayout_4.addLayout(self.horizontalLayout_4) - self.horizontalLayout_5 = QtGui.QHBoxLayout() - self.horizontalLayout_5.setObjectName("horizontalLayout_5") - self.label_5 = QtGui.QLabel(picking_parameters) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.label_5.sizePolicy().hasHeightForWidth()) - self.label_5.setSizePolicy(sizePolicy) - self.label_5.setObjectName("label_5") - self.horizontalLayout_5.addWidget(self.label_5) - self.checkBox_AIC = QtGui.QCheckBox(picking_parameters) - self.checkBox_AIC.setText("") - self.checkBox_AIC.setChecked(True) - self.checkBox_AIC.setObjectName("checkBox_AIC") - self.horizontalLayout_5.addWidget(self.checkBox_AIC) - self.verticalLayout_4.addLayout(self.horizontalLayout_5) - self.horizontalLayout_6 = QtGui.QHBoxLayout() - self.horizontalLayout_6.setObjectName("horizontalLayout_6") - self.label_6 = QtGui.QLabel(picking_parameters) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.label_6.sizePolicy().hasHeightForWidth()) - self.label_6.setSizePolicy(sizePolicy) - self.label_6.setObjectName("label_6") - self.horizontalLayout_6.addWidget(self.label_6) - self.horizontalLayout_7 = QtGui.QHBoxLayout() - self.horizontalLayout_7.setObjectName("horizontalLayout_7") - self.lineEdit_aicleft = QtGui.QLineEdit(picking_parameters) - self.lineEdit_aicleft.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) - self.lineEdit_aicleft.setObjectName("lineEdit_aicleft") - self.horizontalLayout_7.addWidget(self.lineEdit_aicleft) - self.lineEdit_aicright = QtGui.QLineEdit(picking_parameters) - self.lineEdit_aicright.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) - self.lineEdit_aicright.setObjectName("lineEdit_aicright") - self.horizontalLayout_7.addWidget(self.lineEdit_aicright) - self.horizontalLayout_6.addLayout(self.horizontalLayout_7) - self.verticalLayout_4.addLayout(self.horizontalLayout_6) - self.verticalLayout_snr = QtGui.QVBoxLayout() - self.verticalLayout_snr.setObjectName("verticalLayout_snr") - self.line = QtGui.QFrame(picking_parameters) - self.line.setFrameShape(QtGui.QFrame.HLine) - self.line.setFrameShadow(QtGui.QFrame.Sunken) - self.line.setObjectName("line") - self.verticalLayout_snr.addWidget(self.line) - self.horizontalLayout_9 = QtGui.QHBoxLayout() - self.horizontalLayout_9.setObjectName("horizontalLayout_9") - self.label_8 = QtGui.QLabel(picking_parameters) - self.label_8.setObjectName("label_8") - self.horizontalLayout_9.addWidget(self.label_8) - self.radioButton_const = QtGui.QRadioButton(picking_parameters) - self.radioButton_const.setChecked(True) - self.radioButton_const.setObjectName("radioButton_const") - self.horizontalLayout_9.addWidget(self.radioButton_const) - self.radioButton_dyn = QtGui.QRadioButton(picking_parameters) - self.radioButton_dyn.setObjectName("radioButton_dyn") - self.horizontalLayout_9.addWidget(self.radioButton_dyn) - self.verticalLayout_snr.addLayout(self.horizontalLayout_9) - self.horizontalLayout_10 = QtGui.QHBoxLayout() - self.horizontalLayout_10.setObjectName("horizontalLayout_10") - self.label_13 = QtGui.QLabel(picking_parameters) - self.label_13.setObjectName("label_13") - self.horizontalLayout_10.addWidget(self.label_13) - self.doubleSpinBox_constSNR = QtGui.QDoubleSpinBox(picking_parameters) - self.doubleSpinBox_constSNR.setMaximumSize(QtCore.QSize(100, 16777215)) - self.doubleSpinBox_constSNR.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) - self.doubleSpinBox_constSNR.setDecimals(1) - self.doubleSpinBox_constSNR.setMinimum(1.0) - self.doubleSpinBox_constSNR.setMaximum(10000.0) - self.doubleSpinBox_constSNR.setSingleStep(0.1) - self.doubleSpinBox_constSNR.setProperty("value", 8.0) - self.doubleSpinBox_constSNR.setObjectName("doubleSpinBox_constSNR") - self.horizontalLayout_10.addWidget(self.doubleSpinBox_constSNR) - self.verticalLayout_snr.addLayout(self.horizontalLayout_10) - self.gridLayout_2 = QtGui.QGridLayout() - self.gridLayout_2.setObjectName("gridLayout_2") - self.label_9 = QtGui.QLabel(picking_parameters) - self.label_9.setObjectName("label_9") - self.gridLayout_2.addWidget(self.label_9, 1, 0, 1, 1) - self.label_10 = QtGui.QLabel(picking_parameters) - self.label_10.setObjectName("label_10") - self.gridLayout_2.addWidget(self.label_10, 2, 0, 1, 1) - self.p1 = QtGui.QDoubleSpinBox(picking_parameters) - self.p1.setDecimals(6) - self.p1.setMinimum(-100.0) - self.p1.setMaximum(100.0) - self.p1.setSingleStep(0.0001) - self.p1.setProperty("value", 0.004) - self.p1.setObjectName("p1") - self.gridLayout_2.addWidget(self.p1, 2, 1, 1, 1) - self.label_11 = QtGui.QLabel(picking_parameters) - self.label_11.setObjectName("label_11") - self.gridLayout_2.addWidget(self.label_11, 1, 2, 1, 1) - self.label_12 = QtGui.QLabel(picking_parameters) - self.label_12.setObjectName("label_12") - self.gridLayout_2.addWidget(self.label_12, 2, 2, 1, 1) - self.p2 = QtGui.QDoubleSpinBox(picking_parameters) - self.p2.setDecimals(6) - self.p2.setMinimum(-100.0) - self.p2.setMaximum(100.0) - self.p2.setSingleStep(0.001) - self.p2.setProperty("value", -0.0007) - self.p2.setObjectName("p2") - self.gridLayout_2.addWidget(self.p2, 2, 3, 1, 1) - self.shift_dist = QtGui.QSpinBox(picking_parameters) - self.shift_dist.setMinimum(-10000) - self.shift_dist.setMaximum(10000) - self.shift_dist.setProperty("value", 30) - self.shift_dist.setObjectName("shift_dist") - self.gridLayout_2.addWidget(self.shift_dist, 1, 1, 1, 1) - self.shift_snr = QtGui.QSpinBox(picking_parameters) - self.shift_snr.setMinimum(-10000) - self.shift_snr.setMaximum(10000) - self.shift_snr.setProperty("value", 100) - self.shift_snr.setObjectName("shift_snr") - self.gridLayout_2.addWidget(self.shift_snr, 1, 3, 1, 1) - self.verticalLayout_snr.addLayout(self.gridLayout_2) - self.verticalLayout_4.addLayout(self.verticalLayout_snr) - spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) - self.verticalLayout_4.addItem(spacerItem) - self.vlayout_plot = QtGui.QVBoxLayout() - self.vlayout_plot.setObjectName("vlayout_plot") - self.verticalLayout_4.addLayout(self.vlayout_plot) - self.buttonBox = QtGui.QDialogButtonBox(picking_parameters) - self.buttonBox.setOrientation(QtCore.Qt.Horizontal) - self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok) - self.buttonBox.setObjectName("buttonBox") - self.verticalLayout_4.addWidget(self.buttonBox) - - self.retranslateUi(picking_parameters) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), picking_parameters.accept) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), picking_parameters.reject) - QtCore.QMetaObject.connectSlotsByName(picking_parameters) - - def retranslateUi(self, picking_parameters): - picking_parameters.setWindowTitle(QtGui.QApplication.translate("picking_parameters", "Dialog", None, QtGui.QApplication.UnicodeUTF8)) - self.label_7.setText(QtGui.QApplication.translate("picking_parameters", "Choose parameters for FMTOMO simulation", None, QtGui.QApplication.UnicodeUTF8)) - self.label.setToolTip(QtGui.QApplication.translate("picking_parameters", "Amount of CPU kernels used.", None, QtGui.QApplication.UnicodeUTF8)) - self.label.setText(QtGui.QApplication.translate("picking_parameters", "nproc [?]", None, QtGui.QApplication.UnicodeUTF8)) - self.label_2.setToolTip(QtGui.QApplication.translate("picking_parameters", "Minimum permitted direct velocity (apparent velocity!).", None, QtGui.QApplication.UnicodeUTF8)) - self.label_2.setText(QtGui.QApplication.translate("picking_parameters", "vmin [m/s] [?]", None, QtGui.QApplication.UnicodeUTF8)) - self.lineEdit_vmin.setText(QtGui.QApplication.translate("picking_parameters", "100", None, QtGui.QApplication.UnicodeUTF8)) - self.label_3.setToolTip(QtGui.QApplication.translate("picking_parameters", "Maximum permitted direct velocity (apparent velocity!).", None, QtGui.QApplication.UnicodeUTF8)) - self.label_3.setText(QtGui.QApplication.translate("picking_parameters", "vmax [m/s] [?]", None, QtGui.QApplication.UnicodeUTF8)) - self.lineEdit_vmax.setText(QtGui.QApplication.translate("picking_parameters", "5000", None, QtGui.QApplication.UnicodeUTF8)) - self.label_4.setToolTip(QtGui.QApplication.translate("picking_parameters", "Value between 1 and 100 % for threshold picking algorithm (Default = 60%).", None, QtGui.QApplication.UnicodeUTF8)) - self.label_4.setText(QtGui.QApplication.translate("picking_parameters", "Fraction of local maximum [?]", None, QtGui.QApplication.UnicodeUTF8)) - self.label_folm.setText(QtGui.QApplication.translate("picking_parameters", "60 %", None, QtGui.QApplication.UnicodeUTF8)) - self.label_5.setToolTip(QtGui.QApplication.translate("picking_parameters", "Use additional Akaike Information Criterion for picking.", None, QtGui.QApplication.UnicodeUTF8)) - self.label_5.setText(QtGui.QApplication.translate("picking_parameters", "AIC [?]", None, QtGui.QApplication.UnicodeUTF8)) - self.label_6.setToolTip(QtGui.QApplication.translate("picking_parameters", "Samples before and after initial HOS pick.", None, QtGui.QApplication.UnicodeUTF8)) - self.label_6.setText(QtGui.QApplication.translate("picking_parameters", "AIC window samples\n" -"(only if AIC checked)", None, QtGui.QApplication.UnicodeUTF8)) - self.lineEdit_aicleft.setText(QtGui.QApplication.translate("picking_parameters", "15", None, QtGui.QApplication.UnicodeUTF8)) - self.lineEdit_aicright.setText(QtGui.QApplication.translate("picking_parameters", "0", None, QtGui.QApplication.UnicodeUTF8)) - self.label_8.setText(QtGui.QApplication.translate("picking_parameters", "SNR threshold", None, QtGui.QApplication.UnicodeUTF8)) - self.radioButton_const.setText(QtGui.QApplication.translate("picking_parameters", "constant", None, QtGui.QApplication.UnicodeUTF8)) - self.radioButton_dyn.setText(QtGui.QApplication.translate("picking_parameters", "dynamic (advanced)", None, QtGui.QApplication.UnicodeUTF8)) - self.label_13.setText(QtGui.QApplication.translate("picking_parameters", "Constant SNR threshold:", None, QtGui.QApplication.UnicodeUTF8)) - self.label_9.setText(QtGui.QApplication.translate("picking_parameters", "Shift distance", None, QtGui.QApplication.UnicodeUTF8)) - self.label_10.setText(QtGui.QApplication.translate("picking_parameters", "p1", None, QtGui.QApplication.UnicodeUTF8)) - self.label_11.setText(QtGui.QApplication.translate("picking_parameters", "Shift SNR", None, QtGui.QApplication.UnicodeUTF8)) - self.label_12.setText(QtGui.QApplication.translate("picking_parameters", "p2", None, QtGui.QApplication.UnicodeUTF8)) - diff --git a/pylot/core/active/gui/postprocessing_layout.py b/pylot/core/active/gui/postprocessing_layout.py deleted file mode 100644 index 0cb3d539..00000000 --- a/pylot/core/active/gui/postprocessing_layout.py +++ /dev/null @@ -1,178 +0,0 @@ -# -*- coding: utf-8 -*- - -# Form implementation generated from reading ui file 'postprocessing_layout.ui' -# -# Created: Mon Aug 29 10:26:23 2016 -# by: pyside-uic 0.2.15 running on PySide 1.2.2 -# -# WARNING! All changes made in this file will be lost! - -from PySide import QtCore, QtGui - -class Ui_postprocessing(object): - def setupUi(self, postprocessing): - postprocessing.setObjectName("postprocessing") - postprocessing.resize(825, 617) - self.verticalLayout = QtGui.QVBoxLayout(postprocessing) - self.verticalLayout.setObjectName("verticalLayout") - self.horizontalLayout_2 = QtGui.QHBoxLayout() - self.horizontalLayout_2.setObjectName("horizontalLayout_2") - self.verticalLayout_3 = QtGui.QVBoxLayout() - self.verticalLayout_3.setObjectName("verticalLayout_3") - self.label = QtGui.QLabel(postprocessing) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Minimum) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.label.sizePolicy().hasHeightForWidth()) - self.label.setSizePolicy(sizePolicy) - self.label.setMinimumSize(QtCore.QSize(0, 20)) - self.label.setMaximumSize(QtCore.QSize(16777215, 30)) - self.label.setObjectName("label") - self.verticalLayout_3.addWidget(self.label) - self.horizontalLayout_4 = QtGui.QHBoxLayout() - self.horizontalLayout_4.setObjectName("horizontalLayout_4") - self.pushButton_rect = QtGui.QPushButton(postprocessing) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.pushButton_rect.sizePolicy().hasHeightForWidth()) - self.pushButton_rect.setSizePolicy(sizePolicy) - self.pushButton_rect.setMaximumSize(QtCore.QSize(16777215, 30)) - self.pushButton_rect.setCheckable(False) - self.pushButton_rect.setObjectName("pushButton_rect") - self.buttonGroup = QtGui.QButtonGroup(postprocessing) - self.buttonGroup.setObjectName("buttonGroup") - self.buttonGroup.addButton(self.pushButton_rect) - self.horizontalLayout_4.addWidget(self.pushButton_rect) - self.pushButton_poly = QtGui.QPushButton(postprocessing) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.pushButton_poly.sizePolicy().hasHeightForWidth()) - self.pushButton_poly.setSizePolicy(sizePolicy) - self.pushButton_poly.setMaximumSize(QtCore.QSize(16777215, 30)) - self.pushButton_poly.setCheckable(False) - self.pushButton_poly.setObjectName("pushButton_poly") - self.buttonGroup.addButton(self.pushButton_poly) - self.horizontalLayout_4.addWidget(self.pushButton_poly) - self.pushButton_undo = QtGui.QPushButton(postprocessing) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.pushButton_undo.sizePolicy().hasHeightForWidth()) - self.pushButton_undo.setSizePolicy(sizePolicy) - self.pushButton_undo.setMaximumSize(QtCore.QSize(16777215, 30)) - self.pushButton_undo.setCheckable(False) - self.pushButton_undo.setObjectName("pushButton_undo") - self.horizontalLayout_4.addWidget(self.pushButton_undo) - self.verticalLayout_3.addLayout(self.horizontalLayout_4) - self.horizontalLayout_2.addLayout(self.verticalLayout_3) - self.line = QtGui.QFrame(postprocessing) - self.line.setFrameShape(QtGui.QFrame.VLine) - self.line.setFrameShadow(QtGui.QFrame.Sunken) - self.line.setObjectName("line") - self.horizontalLayout_2.addWidget(self.line) - self.verticalLayout_4 = QtGui.QVBoxLayout() - self.verticalLayout_4.setObjectName("verticalLayout_4") - self.label_3 = QtGui.QLabel(postprocessing) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Minimum) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.label_3.sizePolicy().hasHeightForWidth()) - self.label_3.setSizePolicy(sizePolicy) - self.label_3.setMinimumSize(QtCore.QSize(0, 20)) - self.label_3.setMaximumSize(QtCore.QSize(16777215, 30)) - self.label_3.setObjectName("label_3") - self.verticalLayout_4.addWidget(self.label_3) - self.horizontalLayout_6 = QtGui.QHBoxLayout() - self.horizontalLayout_6.setObjectName("horizontalLayout_6") - self.pushButton_plot = QtGui.QPushButton(postprocessing) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.pushButton_plot.sizePolicy().hasHeightForWidth()) - self.pushButton_plot.setSizePolicy(sizePolicy) - self.pushButton_plot.setMaximumSize(QtCore.QSize(16777215, 30)) - self.pushButton_plot.setCheckable(False) - self.pushButton_plot.setDefault(False) - self.pushButton_plot.setFlat(False) - self.pushButton_plot.setObjectName("pushButton_plot") - self.horizontalLayout_6.addWidget(self.pushButton_plot) - self.pushButton_delete = QtGui.QPushButton(postprocessing) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.pushButton_delete.sizePolicy().hasHeightForWidth()) - self.pushButton_delete.setSizePolicy(sizePolicy) - self.pushButton_delete.setMaximumSize(QtCore.QSize(16777215, 30)) - self.pushButton_delete.setObjectName("pushButton_delete") - self.horizontalLayout_6.addWidget(self.pushButton_delete) - self.verticalLayout_4.addLayout(self.horizontalLayout_6) - self.horizontalLayout_2.addLayout(self.verticalLayout_4) - spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) - self.horizontalLayout_2.addItem(spacerItem) - self.verticalLayout_2 = QtGui.QVBoxLayout() - self.verticalLayout_2.setObjectName("verticalLayout_2") - self.label_2 = QtGui.QLabel(postprocessing) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Minimum) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.label_2.sizePolicy().hasHeightForWidth()) - self.label_2.setSizePolicy(sizePolicy) - self.label_2.setMinimumSize(QtCore.QSize(0, 20)) - self.label_2.setMaximumSize(QtCore.QSize(16777215, 30)) - self.label_2.setObjectName("label_2") - self.verticalLayout_2.addWidget(self.label_2) - self.horizontalLayout_5 = QtGui.QHBoxLayout() - self.horizontalLayout_5.setObjectName("horizontalLayout_5") - self.pushButton_snr = QtGui.QPushButton(postprocessing) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.pushButton_snr.sizePolicy().hasHeightForWidth()) - self.pushButton_snr.setSizePolicy(sizePolicy) - self.pushButton_snr.setMaximumSize(QtCore.QSize(16777215, 30)) - self.pushButton_snr.setObjectName("pushButton_snr") - self.horizontalLayout_5.addWidget(self.pushButton_snr) - self.pushButton_pe = QtGui.QPushButton(postprocessing) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.pushButton_pe.sizePolicy().hasHeightForWidth()) - self.pushButton_pe.setSizePolicy(sizePolicy) - self.pushButton_pe.setMaximumSize(QtCore.QSize(16777215, 30)) - self.pushButton_pe.setObjectName("pushButton_pe") - self.horizontalLayout_5.addWidget(self.pushButton_pe) - self.pushButton_spe = QtGui.QPushButton(postprocessing) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.pushButton_spe.sizePolicy().hasHeightForWidth()) - self.pushButton_spe.setSizePolicy(sizePolicy) - self.pushButton_spe.setMaximumSize(QtCore.QSize(16777215, 30)) - self.pushButton_spe.setObjectName("pushButton_spe") - self.horizontalLayout_5.addWidget(self.pushButton_spe) - self.verticalLayout_2.addLayout(self.horizontalLayout_5) - self.horizontalLayout_2.addLayout(self.verticalLayout_2) - self.verticalLayout.addLayout(self.horizontalLayout_2) - self.verticalLayout_plot = QtGui.QVBoxLayout() - self.verticalLayout_plot.setObjectName("verticalLayout_plot") - self.verticalLayout.addLayout(self.verticalLayout_plot) - - self.retranslateUi(postprocessing) - QtCore.QMetaObject.connectSlotsByName(postprocessing) - - def retranslateUi(self, postprocessing): - postprocessing.setWindowTitle(QtGui.QApplication.translate("postprocessing", "Postprocessing", None, QtGui.QApplication.UnicodeUTF8)) - self.label.setText(QtGui.QApplication.translate("postprocessing", "Selection", None, QtGui.QApplication.UnicodeUTF8)) - self.pushButton_rect.setText(QtGui.QApplication.translate("postprocessing", "Rectangle", None, QtGui.QApplication.UnicodeUTF8)) - self.pushButton_poly.setText(QtGui.QApplication.translate("postprocessing", "Polygon", None, QtGui.QApplication.UnicodeUTF8)) - self.pushButton_undo.setText(QtGui.QApplication.translate("postprocessing", "Unselect", None, QtGui.QApplication.UnicodeUTF8)) - self.label_3.setText(QtGui.QApplication.translate("postprocessing", "Action", None, QtGui.QApplication.UnicodeUTF8)) - self.pushButton_plot.setText(QtGui.QApplication.translate("postprocessing", "Plot", None, QtGui.QApplication.UnicodeUTF8)) - self.pushButton_delete.setText(QtGui.QApplication.translate("postprocessing", "Delete", None, QtGui.QApplication.UnicodeUTF8)) - self.label_2.setText(QtGui.QApplication.translate("postprocessing", "Color by (refreshes plot)", None, QtGui.QApplication.UnicodeUTF8)) - self.pushButton_snr.setText(QtGui.QApplication.translate("postprocessing", "SNR", None, QtGui.QApplication.UnicodeUTF8)) - self.pushButton_pe.setText(QtGui.QApplication.translate("postprocessing", "PE", None, QtGui.QApplication.UnicodeUTF8)) - self.pushButton_spe.setText(QtGui.QApplication.translate("postprocessing", "SPE", None, QtGui.QApplication.UnicodeUTF8)) - diff --git a/pylot/core/active/gui/repicking_layout.py b/pylot/core/active/gui/repicking_layout.py deleted file mode 100644 index 717cc7d1..00000000 --- a/pylot/core/active/gui/repicking_layout.py +++ /dev/null @@ -1,49 +0,0 @@ -# -*- coding: utf-8 -*- - -# Form implementation generated from reading ui file 'repicking_layout.ui' -# -# Created: Mon Aug 29 10:26:23 2016 -# by: pyside-uic 0.2.15 running on PySide 1.2.2 -# -# WARNING! All changes made in this file will be lost! - -from PySide import QtCore, QtGui - -class Ui_repicking(object): - def setupUi(self, repicking): - repicking.setObjectName("repicking") - repicking.resize(640, 480) - self.verticalLayout = QtGui.QVBoxLayout(repicking) - self.verticalLayout.setObjectName("verticalLayout") - self.horizontalLayout = QtGui.QHBoxLayout() - self.horizontalLayout.setObjectName("horizontalLayout") - self.pushButton_repick = QtGui.QPushButton(repicking) - self.pushButton_repick.setMaximumSize(QtCore.QSize(16777215, 30)) - self.pushButton_repick.setObjectName("pushButton_repick") - self.horizontalLayout.addWidget(self.pushButton_repick) - self.pushButton_delete = QtGui.QPushButton(repicking) - self.pushButton_delete.setMaximumSize(QtCore.QSize(16777215, 30)) - self.pushButton_delete.setObjectName("pushButton_delete") - self.horizontalLayout.addWidget(self.pushButton_delete) - spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) - self.horizontalLayout.addItem(spacerItem) - self.verticalLayout.addLayout(self.horizontalLayout) - self.verticalLayout_plot = QtGui.QVBoxLayout() - self.verticalLayout_plot.setObjectName("verticalLayout_plot") - self.verticalLayout.addLayout(self.verticalLayout_plot) - self.buttonBox = QtGui.QDialogButtonBox(repicking) - self.buttonBox.setOrientation(QtCore.Qt.Horizontal) - self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Close) - self.buttonBox.setObjectName("buttonBox") - self.verticalLayout.addWidget(self.buttonBox) - - self.retranslateUi(repicking) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), repicking.accept) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), repicking.reject) - QtCore.QMetaObject.connectSlotsByName(repicking) - - def retranslateUi(self, repicking): - repicking.setWindowTitle(QtGui.QApplication.translate("repicking", "Repicking", None, QtGui.QApplication.UnicodeUTF8)) - self.pushButton_repick.setText(QtGui.QApplication.translate("repicking", "Repick", None, QtGui.QApplication.UnicodeUTF8)) - self.pushButton_delete.setText(QtGui.QApplication.translate("repicking", "Delete", None, QtGui.QApplication.UnicodeUTF8)) - diff --git a/pylot/core/active/gui/vtk_tools_layout.py b/pylot/core/active/gui/vtk_tools_layout.py deleted file mode 100644 index 53d05106..00000000 --- a/pylot/core/active/gui/vtk_tools_layout.py +++ /dev/null @@ -1,224 +0,0 @@ -# -*- coding: utf-8 -*- - -# Form implementation generated from reading ui file 'vtk_tools_layout.ui' -# -# Created: Mon Aug 29 10:26:23 2016 -# by: pyside-uic 0.2.15 running on PySide 1.2.2 -# -# WARNING! All changes made in this file will be lost! - -from PySide import QtCore, QtGui - -class Ui_vtk_tools(object): - def setupUi(self, vtk_tools): - vtk_tools.setObjectName("vtk_tools") - vtk_tools.resize(422, 471) - self.verticalLayout_9 = QtGui.QVBoxLayout(vtk_tools) - self.verticalLayout_9.setObjectName("verticalLayout_9") - self.verticalLayout = QtGui.QVBoxLayout() - self.verticalLayout.setObjectName("verticalLayout") - self.verticalLayout_4 = QtGui.QVBoxLayout() - self.verticalLayout_4.setObjectName("verticalLayout_4") - self.horizontalLayout = QtGui.QHBoxLayout() - self.horizontalLayout.setObjectName("horizontalLayout") - self.label_rec = QtGui.QLabel(vtk_tools) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.label_rec.sizePolicy().hasHeightForWidth()) - self.label_rec.setSizePolicy(sizePolicy) - font = QtGui.QFont() - font.setWeight(75) - font.setBold(True) - self.label_rec.setFont(font) - self.label_rec.setToolTip("") - self.label_rec.setObjectName("label_rec") - self.horizontalLayout.addWidget(self.label_rec) - spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) - self.horizontalLayout.addItem(spacerItem) - self.radioButton_abs = QtGui.QRadioButton(vtk_tools) - self.radioButton_abs.setChecked(True) - self.radioButton_abs.setObjectName("radioButton_abs") - self.horizontalLayout.addWidget(self.radioButton_abs) - self.radioButton_rel = QtGui.QRadioButton(vtk_tools) - self.radioButton_rel.setObjectName("radioButton_rel") - self.horizontalLayout.addWidget(self.radioButton_rel) - self.verticalLayout_4.addLayout(self.horizontalLayout) - self.verticalLayout_6 = QtGui.QVBoxLayout() - self.verticalLayout_6.setObjectName("verticalLayout_6") - self.label_3 = QtGui.QLabel(vtk_tools) - self.label_3.setObjectName("label_3") - self.verticalLayout_6.addWidget(self.label_3) - self.horizontalLayout_2 = QtGui.QHBoxLayout() - self.horizontalLayout_2.setObjectName("horizontalLayout_2") - self.lineEdit_vg = QtGui.QLineEdit(vtk_tools) - self.lineEdit_vg.setObjectName("lineEdit_vg") - self.horizontalLayout_2.addWidget(self.lineEdit_vg) - self.pushButton_vg = QtGui.QPushButton(vtk_tools) - self.pushButton_vg.setObjectName("pushButton_vg") - self.horizontalLayout_2.addWidget(self.pushButton_vg) - self.verticalLayout_6.addLayout(self.horizontalLayout_2) - self.verticalLayout_4.addLayout(self.verticalLayout_6) - self.verticalLayout_7 = QtGui.QVBoxLayout() - self.verticalLayout_7.setObjectName("verticalLayout_7") - self.label_4 = QtGui.QLabel(vtk_tools) - self.label_4.setObjectName("label_4") - self.verticalLayout_7.addWidget(self.label_4) - self.horizontalLayout_4 = QtGui.QHBoxLayout() - self.horizontalLayout_4.setObjectName("horizontalLayout_4") - self.lineEdit_vgref = QtGui.QLineEdit(vtk_tools) - self.lineEdit_vgref.setEnabled(False) - self.lineEdit_vgref.setObjectName("lineEdit_vgref") - self.horizontalLayout_4.addWidget(self.lineEdit_vgref) - self.pushButton_vgref = QtGui.QPushButton(vtk_tools) - self.pushButton_vgref.setEnabled(False) - self.pushButton_vgref.setObjectName("pushButton_vgref") - self.horizontalLayout_4.addWidget(self.pushButton_vgref) - self.verticalLayout_7.addLayout(self.horizontalLayout_4) - self.verticalLayout_8 = QtGui.QVBoxLayout() - self.verticalLayout_8.setObjectName("verticalLayout_8") - self.verticalLayout_7.addLayout(self.verticalLayout_8) - self.label_5 = QtGui.QLabel(vtk_tools) - self.label_5.setObjectName("label_5") - self.verticalLayout_7.addWidget(self.label_5) - self.horizontalLayout_3 = QtGui.QHBoxLayout() - self.horizontalLayout_3.setObjectName("horizontalLayout_3") - self.lineEdit_vgout = QtGui.QLineEdit(vtk_tools) - self.lineEdit_vgout.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) - self.lineEdit_vgout.setObjectName("lineEdit_vgout") - self.horizontalLayout_3.addWidget(self.lineEdit_vgout) - self.pushButton_vtkout = QtGui.QPushButton(vtk_tools) - self.pushButton_vtkout.setObjectName("pushButton_vtkout") - self.horizontalLayout_3.addWidget(self.pushButton_vtkout) - self.pushButton_parav = QtGui.QPushButton(vtk_tools) - self.pushButton_parav.setObjectName("pushButton_parav") - self.horizontalLayout_3.addWidget(self.pushButton_parav) - self.verticalLayout_7.addLayout(self.horizontalLayout_3) - self.start_vg = QtGui.QPushButton(vtk_tools) - self.start_vg.setEnabled(False) - self.start_vg.setObjectName("start_vg") - self.verticalLayout_7.addWidget(self.start_vg) - self.verticalLayout_4.addLayout(self.verticalLayout_7) - self.verticalLayout.addLayout(self.verticalLayout_4) - self.verticalLayout_2 = QtGui.QVBoxLayout() - self.verticalLayout_2.setObjectName("verticalLayout_2") - self.line = QtGui.QFrame(vtk_tools) - self.line.setFrameShape(QtGui.QFrame.HLine) - self.line.setFrameShadow(QtGui.QFrame.Sunken) - self.line.setObjectName("line") - self.verticalLayout_2.addWidget(self.line) - self.label_src = QtGui.QLabel(vtk_tools) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.label_src.sizePolicy().hasHeightForWidth()) - self.label_src.setSizePolicy(sizePolicy) - font = QtGui.QFont() - font.setWeight(75) - font.setBold(True) - self.label_src.setFont(font) - self.label_src.setObjectName("label_src") - self.verticalLayout_2.addWidget(self.label_src) - self.verticalLayout_3 = QtGui.QVBoxLayout() - self.verticalLayout_3.setObjectName("verticalLayout_3") - self.label = QtGui.QLabel(vtk_tools) - self.label.setObjectName("label") - self.verticalLayout_3.addWidget(self.label) - self.horizontalLayout_6 = QtGui.QHBoxLayout() - self.horizontalLayout_6.setObjectName("horizontalLayout_6") - self.lineEdit_rays = QtGui.QLineEdit(vtk_tools) - self.lineEdit_rays.setObjectName("lineEdit_rays") - self.horizontalLayout_6.addWidget(self.lineEdit_rays) - self.pushButton_rays = QtGui.QPushButton(vtk_tools) - self.pushButton_rays.setObjectName("pushButton_rays") - self.horizontalLayout_6.addWidget(self.pushButton_rays) - self.verticalLayout_3.addLayout(self.horizontalLayout_6) - self.verticalLayout_2.addLayout(self.verticalLayout_3) - self.verticalLayout_5 = QtGui.QVBoxLayout() - self.verticalLayout_5.setObjectName("verticalLayout_5") - self.label_2 = QtGui.QLabel(vtk_tools) - self.label_2.setObjectName("label_2") - self.verticalLayout_5.addWidget(self.label_2) - self.horizontalLayout_5 = QtGui.QHBoxLayout() - self.horizontalLayout_5.setObjectName("horizontalLayout_5") - self.lineEdit_raysout = QtGui.QLineEdit(vtk_tools) - self.lineEdit_raysout.setObjectName("lineEdit_raysout") - self.horizontalLayout_5.addWidget(self.lineEdit_raysout) - self.pushButton_raysout = QtGui.QPushButton(vtk_tools) - self.pushButton_raysout.setObjectName("pushButton_raysout") - self.horizontalLayout_5.addWidget(self.pushButton_raysout) - self.verticalLayout_5.addLayout(self.horizontalLayout_5) - self.start_rays = QtGui.QPushButton(vtk_tools) - self.start_rays.setEnabled(False) - self.start_rays.setObjectName("start_rays") - self.verticalLayout_5.addWidget(self.start_rays) - self.verticalLayout_2.addLayout(self.verticalLayout_5) - self.verticalLayout.addLayout(self.verticalLayout_2) - self.verticalLayout_9.addLayout(self.verticalLayout) - self.buttonBox = QtGui.QDialogButtonBox(vtk_tools) - self.buttonBox.setOrientation(QtCore.Qt.Horizontal) - self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok) - self.buttonBox.setObjectName("buttonBox") - self.verticalLayout_9.addWidget(self.buttonBox) - - self.retranslateUi(vtk_tools) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), vtk_tools.accept) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), vtk_tools.reject) - QtCore.QMetaObject.connectSlotsByName(vtk_tools) - - def retranslateUi(self, vtk_tools): - vtk_tools.setWindowTitle(QtGui.QApplication.translate("vtk_tools", "VTK tools", None, QtGui.QApplication.UnicodeUTF8)) - self.label_rec.setText(QtGui.QApplication.translate("vtk_tools", "Velocity grid to VTK", None, QtGui.QApplication.UnicodeUTF8)) - self.radioButton_abs.setToolTip(QtGui.QApplication.translate("vtk_tools", "\n" -"\n" -"

Load normal measured receiver input file. The input file must be in the following format:

\n" -"

\n" -"

Containing in each line, separated by spaces:

\n" -"

\n" -"

[trace ID (int)] [X (float)] [Y (float)] [Z (float)]

\n" -"

\n" -"

For example:

\n" -"

Geophone with the trace ID 50 and the coordinates (10.5 [m], 20.4 [m], 30.3 [m]).

\n" -"

\n" -"

50 10.5 20.4 30.3

", None, QtGui.QApplication.UnicodeUTF8)) - self.radioButton_abs.setText(QtGui.QApplication.translate("vtk_tools", "absolute [?]", None, QtGui.QApplication.UnicodeUTF8)) - self.radioButton_rel.setToolTip(QtGui.QApplication.translate("vtk_tools", "\n" -"\n" -"

Load measured receiver input file that can be interpolated. The input file must be in the following format:

\n" -"

\n" -"

Containing in each line, separated by spaces:

\n" -"

\n" -"

[trace ID (int)] [receiver line ID (int)] [number of the geophone on receiver line (int)] [X (float)] [Y (float)] [Z (float)]

\n" -"

\n" -"

For example:

\n" -"

Third geophone on the second receiver line with the trace ID 50 and the coordinates (10.5 [m], 20.4 [m], 30.3 [m]).

\n" -"

\n" -"

50 2 3 10.5 20.4 30.3

", None, QtGui.QApplication.UnicodeUTF8)) - self.radioButton_rel.setText(QtGui.QApplication.translate("vtk_tools", "relative [?]", None, QtGui.QApplication.UnicodeUTF8)) - self.label_3.setText(QtGui.QApplication.translate("vtk_tools", "Browse for velocity grid file (\'vgrids.in\'):", None, QtGui.QApplication.UnicodeUTF8)) - self.pushButton_vg.setText(QtGui.QApplication.translate("vtk_tools", "Browse", None, QtGui.QApplication.UnicodeUTF8)) - self.label_4.setText(QtGui.QApplication.translate("vtk_tools", "Browse for reference velocity grid file (\'vgridsref.in\'):", None, QtGui.QApplication.UnicodeUTF8)) - self.pushButton_vgref.setText(QtGui.QApplication.translate("vtk_tools", "Browse", None, QtGui.QApplication.UnicodeUTF8)) - self.label_5.setText(QtGui.QApplication.translate("vtk_tools", "Output Filename:", None, QtGui.QApplication.UnicodeUTF8)) - self.lineEdit_vgout.setText(QtGui.QApplication.translate("vtk_tools", "vgrids.vtk", None, QtGui.QApplication.UnicodeUTF8)) - self.pushButton_vtkout.setText(QtGui.QApplication.translate("vtk_tools", "Browse", None, QtGui.QApplication.UnicodeUTF8)) - self.pushButton_parav.setToolTip(QtGui.QApplication.translate("vtk_tools", "\n" -"\n" -"

Call Paraview (Shell command: paraview) for the specified output filename in the current directory.

", None, QtGui.QApplication.UnicodeUTF8)) - self.pushButton_parav.setText(QtGui.QApplication.translate("vtk_tools", "<- Paraview", None, QtGui.QApplication.UnicodeUTF8)) - self.start_vg.setText(QtGui.QApplication.translate("vtk_tools", "Start", None, QtGui.QApplication.UnicodeUTF8)) - self.label_src.setToolTip(QtGui.QApplication.translate("vtk_tools", "Create VTK files from the FMTOMO output file \'rays.dat\'.\n" -"This will generate one file of ray paths for each individual source.", None, QtGui.QApplication.UnicodeUTF8)) - self.label_src.setText(QtGui.QApplication.translate("vtk_tools", "Rays to VTK [?]", None, QtGui.QApplication.UnicodeUTF8)) - self.label.setText(QtGui.QApplication.translate("vtk_tools", "Browse for input file (\'rays.dat\'):", None, QtGui.QApplication.UnicodeUTF8)) - self.pushButton_rays.setText(QtGui.QApplication.translate("vtk_tools", "Browse", None, QtGui.QApplication.UnicodeUTF8)) - self.label_2.setText(QtGui.QApplication.translate("vtk_tools", "Specify output directory:", None, QtGui.QApplication.UnicodeUTF8)) - self.pushButton_raysout.setText(QtGui.QApplication.translate("vtk_tools", "Browse", None, QtGui.QApplication.UnicodeUTF8)) - self.start_rays.setText(QtGui.QApplication.translate("vtk_tools", "Start", None, QtGui.QApplication.UnicodeUTF8)) - diff --git a/pylot/core/active/gui/windows.py b/pylot/core/active/gui/windows.py deleted file mode 100644 index 00bb7119..00000000 --- a/pylot/core/active/gui/windows.py +++ /dev/null @@ -1,773 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -import os -import numpy as np -import matplotlib -import matplotlib.pyplot as plt -from PySide import QtCore, QtGui -from pylot.core.active import surveyUtils, activeSeismoPick, seismicArrayPreparation, fmtomoUtils -from generate_survey_layout import Ui_generate_survey -from generate_survey_layout_minimal import Ui_generate_survey_minimal -from generate_seisarray_layout import Ui_generate_seisarray -from picking_parameters_layout import Ui_picking_parameters -from fmtomo_parameters_layout import Ui_fmtomo_parameters -from vtk_tools_layout import Ui_vtk_tools -from postprocessing_layout import Ui_postprocessing -from repicking_layout import Ui_repicking - -from pylot.core.active.surveyPlotTools import regions - -matplotlib.use('Qt4Agg') -matplotlib.rcParams['backend.qt4']='PySide' - -from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas -from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT as NavigationToolbar -from matplotlib.figure import Figure - -def openFile(name = 'Open'): - dialog = QtGui.QFileDialog() - dialog.setWindowTitle(name) #not working yet - filename = dialog.getOpenFileName() - if len(filename[0]) > 0: - return filename[0] - -def saveFile(name = 'Save'): - dialog = QtGui.QFileDialog() - dialog.setWindowTitle(name) - filename = dialog.getSaveFileName() - if len(filename[0]) > 0: - return filename[0] - -def browseDir(name = 'Open Directory'): - dialog = QtGui.QFileDialog() - dialog.setWindowTitle(name) - directory = dialog.getExistingDirectory() - if len(directory) > 0: - return directory - -def getMaxCPU(): - import multiprocessing - return multiprocessing.cpu_count() - -def printDialogMessage(message): - qmb = QtGui.QMessageBox() - qmb.setText(message) - qmb.setStandardButtons(QtGui.QMessageBox.Ok) - qmb.setIcon(QtGui.QMessageBox.Warning) - qmb.exec_() - -def continueDialogExists(name): - qmb = QtGui.QMessageBox() - qmb.setText('%s object already exists. Overwrite?'%name) - qmb.setStandardButtons(QtGui.QMessageBox.Ok | QtGui.QMessageBox.Cancel) - qmb.setIcon(QtGui.QMessageBox.Warning) - answer = qmb.exec_() - if answer == 1024: - return True - else: - return False - -def continueDialogMessage(message): - qmb = QtGui.QMessageBox() - qmb.setText(message) - qmb.setStandardButtons(QtGui.QMessageBox.Ok | QtGui.QMessageBox.Cancel) - qmb.setIcon(QtGui.QMessageBox.Warning) - answer = qmb.exec_() - if answer == 1024: - return True - else: - return False - - -class Gen_SeisArray(object): - def __init__(self, mainwindow): - self.mainwindow = mainwindow - self.seisarray = None - self.srcfile = None - self.recfile = None - self.ptsfile = None - self.init_dialog() - self.start_dialog() - - def init_dialog(self): - qdialog = QtGui.QDialog(self.mainwindow) - ui = Ui_generate_seisarray() - ui.setupUi(qdialog) - self.ui = ui - self.qdialog = qdialog - self.connectButtons() - - def start_dialog(self): - if self.qdialog.exec_(): - self.refresh_selection() - if self.ui.radioButton_interpolatable.isChecked(): - self.seisarray = seismicArrayPreparation.SeisArray(self.recfile, True) - elif self.ui.radioButton_normal.isChecked(): - self.seisarray = seismicArrayPreparation.SeisArray(self.recfile, False) - if len(self.srcfile) > 0: - self.seisarray.addSourceLocations(self.srcfile) - if len(self.ptsfile) > 0: - self.seisarray.addMeasuredTopographyPoints(self.ptsfile) - self.executed = True - else: - self.refresh_selection() - self.executed = False - - def refresh_selection(self): - self.srcfile = self.ui.lineEdit_src.text() - self.recfile = self.ui.lineEdit_rec.text() - self.ptsfile = self.ui.lineEdit_pts.text() - - def get_seisarray(self): - if self.seisarray is not None: - return self.seisarray - - def connectButtons(self): - QtCore.QObject.connect(self.ui.pushButton_rec, QtCore.SIGNAL("clicked()"), self.chooseMeasuredRec) - QtCore.QObject.connect(self.ui.pushButton_src, QtCore.SIGNAL("clicked()"), self.chooseMeasuredSrc) - QtCore.QObject.connect(self.ui.pushButton_obs, QtCore.SIGNAL("clicked()"), self.chooseMeasuredPts) - - def chooseMeasuredSrc(self): - self.ui.lineEdit_src.setText(openFile('Open measured sources file.')) - - def chooseMeasuredRec(self): - self.ui.lineEdit_rec.setText(openFile('Open measured receivers file.')) - - def chooseMeasuredPts(self): - self.ui.lineEdit_pts.setText(openFile('Open measured points file.')) - - -class Gen_Survey_from_SA(object): - def __init__(self, mainwindow, seisarray): - self.mainwindow = mainwindow - self.seisarray = seisarray - self.survey = None - self.obsdir = None - self.fstart = 'shot' - self.fend = '.dat' - self.init_dialog() - self.start_dialog() - - def init_dialog(self): - qdialog = QtGui.QDialog(self.mainwindow) - ui = Ui_generate_survey_minimal() - ui.setupUi(qdialog) - self.ui = ui - self.qdialog = qdialog - self.connectButtons() - - def start_dialog(self): - if self.qdialog.exec_(): - self.refresh_selection() - self.survey = activeSeismoPick.Survey(self.obsdir, seisArray = self.seisarray, - useDefaultParas = True, fstart = self.fstart, - fend = self.fend) - self.executed = True - else: - self.refresh_selection() - self.executed = False - - def update_seisarray(self, seisarray): - self.seisarray = seisarray - - def refresh_selection(self): - self.obsdir = self.ui.lineEdit_obs.text() - self.fstart = self.ui.fstart.text() - self.fend = self.ui.fend.text() - - def get_survey(self): - return self.survey - - def connectButtons(self): - QtCore.QObject.connect(self.ui.pushButton_obs, QtCore.SIGNAL("clicked()"), self.chooseObsdir) - - def chooseObsdir(self): - self.ui.lineEdit_obs.setText(browseDir('Choose observation directory.')) - - -class Gen_Survey_from_SR(object): - def __init__(self, mainwindow): - self.mainwindow = mainwindow - self.survey = None - self.obsdir = None - self.srcfile = None - self.recfile = None - self.fstart = 'shot' - self.fend = '.dat' - self.init_dialog() - self.start_dialog() - - def init_dialog(self): - qdialog = QtGui.QDialog(self.mainwindow) - ui = Ui_generate_survey() - ui.setupUi(qdialog) - self.ui = ui - self.qdialog = qdialog - self.connectButtons() - - def start_dialog(self): - if self.qdialog.exec_(): - self.refresh_selection() - self.survey = activeSeismoPick.Survey(self.obsdir, self.srcfile, self.recfile, - useDefaultParas = True, - fstart = self.fstart, fend = self.fend) - self.executed = True - else: - self.refresh_selection() - self.executed = False - - def refresh_selection(self): - self.obsdir = self.ui.lineEdit_obs.text() - self.srcfile = self.ui.lineEdit_src.text() - self.recfile = self.ui.lineEdit_rec.text() - self.fstart = self.ui.fstart.text() - self.fend = self.ui.fend.text() - - def get_survey(self): - return self.survey - - def connectButtons(self): - QtCore.QObject.connect(self.ui.pushButton_obs, QtCore.SIGNAL("clicked()"), self.chooseObsdir) - QtCore.QObject.connect(self.ui.pushButton_src, QtCore.SIGNAL("clicked()"), self.chooseSourcefile) - QtCore.QObject.connect(self.ui.pushButton_rec, QtCore.SIGNAL("clicked()"), self.chooseRecfile) - - def chooseObsdir(self): - self.ui.lineEdit_obs.setText(browseDir('Choose observation directory.')) - - def chooseSourcefile(self): - self.ui.lineEdit_src.setText(openFile('Open sourcefile.')) - - def chooseRecfile(self): - self.ui.lineEdit_rec.setText(openFile('Open receiverfile.')) - - -class Call_autopicker(object): - def __init__(self, mainwindow, survey): - self.mainwindow = mainwindow - self.survey = survey - self.maxSRdist = None - self.dists_p = [] - self.snr_p = [] - self.lines = [] - self.init_dialog() - self.refresh_selection() - self.enableDynSNR(False) - self.start_dialog() - - def init_dialog(self): - qdialog = QtGui.QDialog(self.mainwindow) - ui = Ui_picking_parameters() - ui.setupUi(qdialog) - ui.ncores.setMaximum(getMaxCPU()) - self.ui = ui - self.qdialog = qdialog - self.initSNRplot() - self.connectButtons() - - def getMaxSRdist(self): - if self.maxSRdist is not None: - return self.maxSRdist - else: - SRdists = [] - for shot in self.survey.data.values(): - for traceID in shot.getTraceIDlist(): - SRdists.append(shot.getDistance(traceID)) - self.maxSRdist = max(SRdists) - return self.maxSRdist - - def update_survey(self, survey): - self.survey = survey - - def initSNRplot(self): - self.snrFig = Figure() - self.snrCanvas = FigureCanvas(self.snrFig) - self.ui.vlayout_plot.addWidget(self.snrCanvas) - self.snrToolbar = NavigationToolbar(self.snrCanvas, self.mainwindow) - self.ui.vlayout_plot.addWidget(self.snrToolbar) - - def prepFigure(self, refresh = True): - fig = self.snrFig - if fig.axes == []: - ax = fig.add_subplot(111) - xlim = None - ylim = None - else: - ax = fig.axes[0] - xlim = ax.get_xlim() - ylim = ax.get_ylim() - #ax.clear() - if not refresh: - self.plotPicks(ax) - else: - self.clear_lines() - - return fig, ax, xlim, ylim - - def clear_lines(self): - for line in self.lines: - line.remove() - self.lines = [] - - def finishFigure(self, ax, xlim, ylim): - ax.set_xlim(xlim) - ax.set_ylim(ylim) - - def finishNewFigure(self, ax): - xlim = None - ylim = None - ax.set_xlabel('Distance [m]') - ax.set_ylabel('SNR') - return xlim, ylim - - def plotPicks(self, ax): - if self.survey.picked: - if self.dists_p == [] or self.snr_p == []: - for shot in self.survey.data.values(): - for traceID in shot.getTraceIDlist(): - self.dists_p.append(shot.getDistance(traceID)) - self.snr_p.append(shot.getSNR(traceID)[0]) - - ax.scatter(self.dists_p, self.snr_p, s = 0.5, c='k') - - def plotConstSNR(self, refresh = True): - fig, ax, xlim, ylim = self.prepFigure(refresh) - - snrthreshold = float(self.ui.doubleSpinBox_constSNR.text()) - line = ax.hlines(snrthreshold, 0, self.getMaxSRdist(), 'b') - self.lines.append(line) - - if refresh == False: - xlim, ylim = self.finishNewFigure(ax) - - if self.survey.picked: - self.finishFigure(ax, xlim, ylim) - - self.snrCanvas.draw() - - def plotDynSNR(self, refresh = True): - fig, ax, xlim, ylim = self.prepFigure(refresh) - snrthresholds = [] - shiftSNR = float(self.ui.shift_snr.value()) - shiftDist = float(self.ui.shift_dist.value()) - p1 = float(self.ui.p1.value()) - p2 = float(self.ui.p2.value()) - dists = np.arange(0, self.getMaxSRdist() + 1, 1) - - for dist in dists: - dist += shiftDist - snrthresholds.append(surveyUtils.snr_fit_func(surveyUtils.get_fit_fn(p1, p2), dist, shiftSNR)) - self.lines = ax.plot(dists, snrthresholds, 'b') - - if refresh == False: - xlim, ylim = self.finishNewFigure(ax) - - if self.survey.picked: - self.finishFigure(ax, xlim, ylim) - - self.snrCanvas.draw() - - def plotSNR(self, refresh = True): - if self.ui.radioButton_const.isChecked(): - self.plotConstSNR(refresh) - if self.ui.radioButton_dyn.isChecked(): - self.plotDynSNR(refresh) - - def snr_toggle(self): - if self.ui.radioButton_const.isChecked(): - self.enableDynSNR(False) - self.enableConstSNR(True) - if self.ui.radioButton_dyn.isChecked(): - self.enableConstSNR(False) - self.enableDynSNR(True) - self.plotSNR(refresh = True) - - def enableDynSNR(self, bool): - self.ui.shift_dist.setEnabled(bool) - self.ui.shift_snr.setEnabled(bool) - self.ui.p1.setEnabled(bool) - self.ui.p2.setEnabled(bool) - - def enableConstSNR(self, bool): - self.ui.doubleSpinBox_constSNR.setEnabled(bool) - - def start_dialog(self): - self.plotSNR(refresh = False) - if self.qdialog.exec_(): - self.refresh_selection() - - if self.AIC == True: - HosAic = 'aic' - else: - HosAic = 'hos' - - surveyUtils.setDynamicFittedSNR(self.survey.getShotDict(), shiftdist = self.shiftDist, - shiftSNR = self.shiftSNR, p1 = self.p1, p2 = self.p2) - - self.survey.pickAllShots(vmin = self.vmin, vmax = self.vmax, - folm = self.folm/100., HosAic = HosAic, - aicwindow = self.aicwindow, cores = self.ncores) - - #QtGui.qApp.processEvents() # test - self.executed = True - self.clear_lines() - else: - self.refresh_selection() - self.executed = False - self.clear_lines() - - def refreshFolm(self): - self.ui.label_folm.setText('%s %%'%self.ui.slider_folm.value()) - - def refresh_selection(self): - self.ncores = int(self.ui.ncores.value()) - self.vmin = float(self.ui.lineEdit_vmin.text()) - self.vmax = float(self.ui.lineEdit_vmax.text()) - self.folm = float(self.ui.slider_folm.value()) - self.AIC = self.ui.checkBox_AIC.isChecked() - self.aicwindow = (int(self.ui.lineEdit_aicleft.text()), int(self.ui.lineEdit_aicright.text())) - self.shiftSNR = float(self.ui.shift_snr.value()) - self.shiftDist = float(self.ui.shift_dist.value()) - self.p1 = float(self.ui.p1.value()) - self.p2 = float(self.ui.p2.value()) - - def connectButtons(self): - QtCore.QObject.connect(self.ui.slider_folm, QtCore.SIGNAL("valueChanged(int)"), self.refreshFolm) - QtCore.QObject.connect(self.ui.shift_snr, QtCore.SIGNAL("valueChanged(int)"), self.plotSNR) - QtCore.QObject.connect(self.ui.shift_dist, QtCore.SIGNAL("valueChanged(int)"), self.plotSNR) - QtCore.QObject.connect(self.ui.p1, QtCore.SIGNAL("valueChanged(double)"), self.plotSNR) - QtCore.QObject.connect(self.ui.p2, QtCore.SIGNAL("valueChanged(double)"), self.plotSNR) - QtCore.QObject.connect(self.ui.doubleSpinBox_constSNR, QtCore.SIGNAL("valueChanged(double)"), self.plotSNR) - QtCore.QObject.connect(self.ui.radioButton_const, QtCore.SIGNAL("clicked()"), self.snr_toggle) - QtCore.QObject.connect(self.ui.radioButton_dyn, QtCore.SIGNAL("clicked()"), self.snr_toggle) - - def chooseObsdir(self): - self.ui.lineEdit_obs.setText(browseDir('Choose observation directory.')) - - def chooseSourcefile(self): - self.ui.lineEdit_src.setText(openFile('Open sourcefile.')) - - def chooseRecfile(self): - self.ui.lineEdit_rec.setText(openFile('Open receiverfile.')) - - -class Call_FMTOMO(object): - def __init__(self, mainwindow, survey): - self.mainwindow = mainwindow - self.survey = survey - self.init_dialog() - self.refresh_selection() - self.start_dialog() - - def init_dialog(self): - qdialog = QtGui.QDialog(self.mainwindow) - ui = Ui_fmtomo_parameters() - ui.setupUi(qdialog) - ui.nproc.setMaximum(getMaxCPU()) - self.ui = ui - self.qdialog = qdialog - self.connectButtons() - - def start_dialog(self): - if self.qdialog.exec_(): - self.refresh_selection() - - if not os.path.isdir(self.picks_dir): - err = os.mkdir(self.picks_dir) # error not handled yet - - self.survey.exportFMTOMO(self.picks_dir) - - cwd = os.getcwd() - interpolationMethod = 'linear' - os.chdir(self.simuldir) - if self.survey.seisarray.twoDim: - interpolationMethod = 'nearest' - self.survey.seisarray.generateFMTOMOinputFromArray(self.propgrid, self.vgrid, (self.bbot, self.btop), - self.cushionfactor/100., interpolationMethod, - customgrid = self.customgrid, writeVTK = True) - os.chdir(cwd) - - tomo = fmtomoUtils.Tomo3d(self.fmtomo_dir, self.simuldir) - tomo.runTOMO3D(self.nproc, self.nIter) - - self.executed = True - else: - self.refresh_selection() - self.executed = False - - def update_survey(self, survey): - self.survey = survey - - def refresh_selection(self): - self.fmtomo_dir = self.ui.fmtomo_dir.text() - self.nIter = int(self.ui.nIter.value()) - self.nproc = int(self.ui.nproc.value()) - self.btop = float(self.ui.btop.text()) - self.bbot = float(self.ui.bbot.text()) - self.propgrid = (int(self.ui.pgrid_x.value()), int(self.ui.pgrid_y.value()), int(self.ui.pgrid_z.value())) - self.vgrid = (int(self.ui.invgrid_x.value()), int(self.ui.invgrid_y.value()), int(self.ui.invgrid_z.value())) - self.cushionfactor = float(self.ui.cushion.value()) - self.customgrid = self.ui.customgrid.text() - self.simuldir = self.ui.simuldir.text() - self.picks_dir = os.path.join(self.simuldir, 'picks') - - def connectButtons(self): - QtCore.QObject.connect(self.ui.browse_tomodir, QtCore.SIGNAL("clicked()"), self.chooseFMTOMOdir) - QtCore.QObject.connect(self.ui.browse_customgrid, QtCore.SIGNAL("clicked()"), self.chooseCustomgrid) - QtCore.QObject.connect(self.ui.browse_simuldir, QtCore.SIGNAL("clicked()"), self.chooseSimuldir) - - def chooseFMTOMOdir(self): - self.ui.fmtomo_dir.setText(browseDir()) - - def chooseCustomgrid(self): - self.ui.customgrid.setText(openFile()) - - def chooseSimuldir(self): - self.ui.simuldir.setText(browseDir()) - - -class Call_VTK_dialog(object): - def __init__(self, mainwindow): - self.mainwindow = mainwindow - self.init_dialog() - self.refresh_selection() - self.start_dialog() - - def init_dialog(self): - qdialog = QtGui.QDialog(self.mainwindow) - ui = Ui_vtk_tools() - ui.setupUi(qdialog) - self.ui = ui - self.qdialog = qdialog - self.connectButtons() - - def start_dialog(self): - self.qdialog.exec_() - self.refresh_selection() - - def refresh_selection(self): - self.vg = self.ui.lineEdit_vg.text() - self.vgout = self.ui.lineEdit_vgout.text() - self.rays = self.ui.lineEdit_rays.text() - self.raysout = self.ui.lineEdit_raysout.text() - - def checkVgStartButton(self): - ui = self.ui - if ui.radioButton_rel.isChecked(): - if ui.lineEdit_vg.text() != '' and ui.lineEdit_vgref.text() != '': - ui.start_vg.setEnabled(True) - else: - ui.start_vg.setEnabled(False) - if ui.radioButton_abs.isChecked(): - if ui.lineEdit_vg.text() != '': - ui.start_vg.setEnabled(True) - else: - ui.start_vg.setEnabled(False) - - def checkRaysStartButton(self): - ui = self.ui - if ui.lineEdit_rays.text() != '' and ui.lineEdit_raysout.text() != '': - ui.start_rays.setEnabled(True) - else: - ui.start_rays.setEnabled(False) - - def connectButtons(self): - QtCore.QObject.connect(self.ui.pushButton_vg, QtCore.SIGNAL("clicked()"), self.chooseVgrid) - QtCore.QObject.connect(self.ui.pushButton_vgref, QtCore.SIGNAL("clicked()"), self.chooseVgridref) - QtCore.QObject.connect(self.ui.pushButton_rays, QtCore.SIGNAL("clicked()"), self.chooseRaysIn) - QtCore.QObject.connect(self.ui.pushButton_raysout, QtCore.SIGNAL("clicked()"), self.chooseRaysOutDir) - QtCore.QObject.connect(self.ui.pushButton_vtkout, QtCore.SIGNAL("clicked()"), self.newFileVTK) - QtCore.QObject.connect(self.ui.pushButton_parav, QtCore.SIGNAL("clicked()"), self.openFileParaview) - QtCore.QObject.connect(self.ui.start_vg, QtCore.SIGNAL("clicked()"), self.startvgvtk) - QtCore.QObject.connect(self.ui.start_rays, QtCore.SIGNAL("clicked()"), self.startraysvtk) - QtCore.QObject.connect(self.ui.radioButton_rel, QtCore.SIGNAL("clicked()"), self.activateVgref) - QtCore.QObject.connect(self.ui.radioButton_abs, QtCore.SIGNAL("clicked()"), self.deactivateVgref) - - def openFileParaview(self): - os.system('paraview %s &'%self.ui.lineEdit_vgout.text()) - - def activateVgref(self): - self.ui.lineEdit_vgref.setEnabled(True) - self.ui.pushButton_vgref.setEnabled(True) - - def deactivateVgref(self): - self.ui.lineEdit_vgref.setEnabled(False) - self.ui.pushButton_vgref.setEnabled(False) - - def chooseVgrid(self): - self.ui.lineEdit_vg.setText(openFile()) - self.checkVgStartButton() - - def chooseVgridref(self): - self.ui.lineEdit_vgref.setText(openFile()) - self.checkVgStartButton() - - def chooseRaysIn(self): - self.ui.lineEdit_rays.setText(openFile()) - self.checkRaysStartButton() - - def chooseRaysOutDir(self): - self.ui.lineEdit_raysout.setText(browseDir()) - self.checkRaysStartButton() - - def startvgvtk(self): - ui = self.ui - if ui.lineEdit_vgout.text() == '': - return - if ui.radioButton_abs.isChecked(): - fmtomoUtils.vgrids2VTK(inputfile = ui.lineEdit_vg.text(), - outputfile = ui.lineEdit_vgout.text(), - absOrRel='abs') - elif ui.radioButton_rel.isChecked(): - fmtomoUtils.vgrids2VTK(inputfile = ui.lineEdit_vg.text(), - outputfile = ui.lineEdit_vgout.text(), - absOrRel='rel', - inputfileref = ui.lineEdit_vgref.text()) - - def startraysvtk(self): - ui = self.ui - fmtomoUtils.rays2VTK(ui.lineEdit_rays.text(), ui.lineEdit_raysout.text()) - - def newFileVTK(self): - self.ui.lineEdit_vgout.setText(saveFile()) - -class Postprocessing(object): - def __init__(self, mainwindow, survey): - self.mainwindow = mainwindow - self.survey = survey - self.init_widget() - self.start_widget() - self.inkByVal = 'snrlog' - - def init_widget(self): - qwidget = QtGui.QWidget()# - ui = Ui_postprocessing() - ui.setupUi(qwidget) - self.ui = ui - self.qwidget = qwidget - self.initPlot() - self.newPlot() - self.connectButtons() - self.region = regions(self.ax, self.cbar, self.survey, qt_interface = True) - - def start_widget(self): - self.qwidget.show() - - def initPlot(self): - self.figure = Figure() - self.canvas = FigureCanvas(self.figure) - self.ui.verticalLayout_plot.addWidget(self.canvas) - self.toolbar = NavigationToolbar(self.canvas, self.mainwindow) - self.ui.verticalLayout_plot.addWidget(self.toolbar) - - def newPlot(self): - ax = self.figure.add_subplot(111) - dists, picks, snrlog, pe, spe = self.survey.preparePlotAllPicks(plotRemoved = False) - self.dists = dists - self.picks = picks - self.inkDict = {'snrlog': snrlog, - 'pe': pe, - 'spe': spe} - - ax, cbar, sc = self.survey.createPlot(dists, picks, snrlog, 'log10(SNR)', ax = ax, cbar = None) - self.cbar = self.figure.colorbar(sc, ax = ax, fraction=0.05) - self.ax = ax - self.draw() - - def refreshPlot(self): - self.ax.clear() - ax = self.ax - ax, cbar, sc = self.survey.createPlot(self.dists, self.picks, self.inkDict[self.inkByVal], - self.inkByVal, ax = ax, cbar = self.cbar) - #self.cbar = self.figure.colorbar(sc, fraction=0.05) - self.draw() - - def update_survey(self, survey): - self.survey = survey - - def get_survey(self): - return self.survey - - def draw(self): - self.canvas.draw() - - def connectButtons(self): - QtCore.QObject.connect(self.ui.pushButton_rect, QtCore.SIGNAL("clicked()"), self.chooseRect) - QtCore.QObject.connect(self.ui.pushButton_poly, QtCore.SIGNAL("clicked()"), self.choosePoly) - QtCore.QObject.connect(self.ui.pushButton_plot, QtCore.SIGNAL("clicked()"), self.plotPicks) - QtCore.QObject.connect(self.ui.pushButton_delete, QtCore.SIGNAL("clicked()"), self.deleteSelected) - QtCore.QObject.connect(self.ui.pushButton_undo, QtCore.SIGNAL("clicked()"), self.undoSelection) - QtCore.QObject.connect(self.ui.pushButton_snr, QtCore.SIGNAL("clicked()"), self.refrSNR) - QtCore.QObject.connect(self.ui.pushButton_pe, QtCore.SIGNAL("clicked()"), self.refrPE) - QtCore.QObject.connect(self.ui.pushButton_spe, QtCore.SIGNAL("clicked()"), self.refrSPE) - - def chooseRect(self): - self.region.chooseRectangles() - - def choosePoly(self): - self.region.choosePolygon() - - def disconnectRect(self): - self.region.disconnectRect() - - def disconnectPoly(self): - self.region.disconnectPoly() - - def plotPicks(self): - self.region.plotTracesInActiveRegions() - - def deleteSelected(self): - self.region.setAllActiveRegionsForDeletion() - message = 'Are you sure you want to delete all marked picks?' - if continueDialogMessage(message): - self.region.deleteAllMarkedPicks() - else: - self.region.refreshFigure() - - def undoSelection(self): - self.region.deselectLastSelection() - - def refrSNR(self): - self.region.refreshLog10SNR() - - def refrPE(self): - self.region.refreshPickerror() - - def refrSPE(self): - self.region.refreshSPE() - - -class Repicking(object): - def __init__(self, mainwindow, region, shot, traceID): - self.mainwindow = mainwindow - self.region = region - self.shot = shot - self.traceID = traceID - self.init_dialog() - self.start_dialog() - - def init_dialog(self): - qdialog = QtGui.QDialog(self.mainwindow) - ui = Ui_repicking() - ui.setupUi(qdialog) - self.ui = ui - self.qdialog = qdialog - self.connectButtons() - - def start_dialog(self): - self.qdialog.exec_() - - def connectButtons(self): - QtCore.QObject.connect(self.ui.pushButton_repick, QtCore.SIGNAL("clicked()"), self.repick) - QtCore.QObject.connect(self.ui.pushButton_delete, QtCore.SIGNAL("clicked()"), self.delete) - - def initPlot(self): - self.figure = Figure() - self.canvas = FigureCanvas(self.figure) - self.ui.verticalLayout_plot.addWidget(self.canvas) - self.toolbar = NavigationToolbar(self.canvas, self.mainwindow) - self.ui.verticalLayout_plot.addWidget(self.toolbar) - - def plot(self): - self.shot.plot_traces(self.traceID, figure = self.figure, buttons = False) - self.ax = ax - self.draw() diff --git a/pylot/core/active/run_asp3d.py b/pylot/core/active/run_asp3d.py deleted file mode 100755 index 0b7202e1..00000000 --- a/pylot/core/active/run_asp3d.py +++ /dev/null @@ -1,129 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -import sys -import os -from obspy import read -from obspy import Stream -from obspy import Trace -from datetime import datetime -import numpy as np - -from pylot.core.active import surveyUtils -from pylot.core.active import seismicshot -from pylot.core.active import activeSeismoPick -from pylot.core.active import fmtomoUtils -from pylot.core.active import seismicArrayPreparation -# reload(seismicshot) -# reload(surveyUtils) -# reload(activeSeismoPick) - -##################################################################################### -# parameter definitions:############################################################# -cutwindow = (0, 0.15) # cut out a part of the trace [seconds] -tmovwind = 0.1 # size of the moving window -windowsize = (30, 0) # windowsize for AIC picker (indices around HOS picks [time/sampling rate] !!!) -folm = 0.6 # fraction of local maximum for threshold picker -tsignal = 0.03 -tgap = 0.0007 - -nproc = 1 - -vmin = 333 -vmax = 5500 - -HosAic = 'aic' # can be 'hos' or 'aic' - -rockeskyll = False -GZB = True -bb1 = False - -# Simulation parameters ############################################################# -simulation = True - -niter = 4 - -bottomBoundary = -50.0 -topBoundary = 5.0 -nPointsPropgrid = (100, 100, 100) -nPointsVgrid = (30, 30, 30) -cushionfactor = 0.1 -interpolationMethod = 'linear' -mygrid = '../mygrid.in' - -cwd = os.getcwd() -simuldir = 'fmtomo_simulation' -pickdir = 'picks' -fmtomopath = '/rscratch/minos22/marcel/flachseismik/fmtomo/GZB_clean/' -###################################################################################### -###################################################################################### -if rockeskyll == True: - receiverfile = "Geophone_interpoliert_rockes" - sourcefile = "Schusspunkte_rockes" - obsdir = "/rscratch/minos22/marcel/flachseismik/rockeskyll_200615_270615/" - filename = 'survey_rockes.pickle' -elif GZB == True: - receiverfile = "Geophone_interpoliert_GZB" - sourcefile = "Schusspunkte_GZB" - #sourcefile = "Schusspunkte_GZB_1shot" - obsdir = "/rscratch/minos22/marcel/flachseismik/GZB_26_06_15_01/" - filename = 'survey_GZB.pickle' -elif bb1 == True: - receiverfile = "Geophone_Marcel" - sourcefile = "Schusspunkte_Marcel" - obsdir = "/rscratch/minos22/marcel/flachseismik/bachelor_bausenberg/" - filename = 'survey_bb1.pickle' -###################################################################################### - -starttime = datetime.now() - -print('\n--------------------Starting Script at %s -------------------\n' %starttime.time()) -print('directory: %s\nsourcefile: %s\nreceiverfile: %s\nsurvey output filename: %s\n' %(obsdir, sourcefile, receiverfile, filename)) -if HosAic == 'aic': print('picking with AIC\n') -if HosAic == 'hos': print('picking with HOS\n') - -survey = activeSeismoPick.Survey(obsdir, os.path.join(obsdir, sourcefile), - os.path.join(obsdir, receiverfile), useDefaultParas = False) -survey.setParametersForAllShots(cutwindow, tmovwind, tsignal, tgap) -surveyUtils.setDynamicFittedSNR(survey.getShotDict()) -#surveyUtils.setConstantSNR(survey.getShotDict(), 0) -survey.setArtificialPick(0, 0) # artificial pick at source origin -print('\nDone after %s seconds!\n------------------------------------------------------------------------------\n' % (datetime.now() - starttime).seconds) -survey.pickAllShots(vmin, vmax, folm, HosAic, windowsize, cores = nproc) -survey.cleanBySPE(maxSPE = 0.0075) -survey.saveSurvey(filename) -print('\n--- Finished picking ---') -print'Elapsed time:', datetime.now()-starttime - - -###################################################################################### -if simulation == False: - sys.exit() - -survey = activeSeismoPick.Survey.from_pickle(filename) - -if not os.path.isdir(os.path.join(cwd, simuldir)): - err = os.mkdir(os.path.join(cwd, simuldir)) - -picks = os.path.join(simuldir, pickdir) - -if not os.path.isdir(os.path.join(cwd, picks)): - err2 = os.mkdir(os.path.join(cwd, picks)) - -survey.exportFMTOMO(picks) - -####### hard coded -os.chdir(simuldir) -survey.loadArray(obsdir, 'Geophone_eingemessen_GZB', 'Schusspunkte_GZB') -survey.seisArray.generateFMTOMOinputFromArray(nPointsPropgrid, nPointsVgrid, - (bottomBoundary, topBoundary), cushionfactor, - interpolationMethod, customgrid = mygrid, - writeVTK = False) - -os.chdir(cwd) -####### test - -tomo = fmtomoUtils.Tomo3d(fmtomopath, simuldir) -tomo.runTOMO3D(nproc, niter) - -print('\n--- Finished script ---') -print'Elapsed time:', datetime.now()-starttime diff --git a/pylot/core/active/seismicArrayPreparation.py b/pylot/core/active/seismicArrayPreparation.py deleted file mode 100644 index 907e9161..00000000 --- a/pylot/core/active/seismicArrayPreparation.py +++ /dev/null @@ -1,1122 +0,0 @@ -# -*- coding: utf-8 -*- -import sys -import numpy as np -from scipy.interpolate import griddata - -def readMygridNlayers(filename): - infile = open(filename, 'r') - nlayers = len(infile.readlines()) / 2 - infile.close() - - return nlayers - -def readMygrid(filename): - ztop = []; - zbot = []; - vtop = []; - vbot = [] - infile = open(filename, 'r') - nlayers = readMygridNlayers(filename) - - print('\nreadMygrid: Reading file %s.' % filename) - for index in range(nlayers): - line1 = infile.readline() - line2 = infile.readline() - ztop.append(float(line1.split()[0])) - vtop.append(float(line1.split()[1])) - zbot.append(float(line2.split()[0])) - vbot.append(float(line2.split()[1])) - print('Layer %s:\n[Top: v = %s [km/s], z = %s [m]]' - '\n[Bot: v = %s [km/s], z = %s [m]]' - % (index + 1, vtop[index], ztop[index], - vbot[index], zbot[index])) - - if not ztop[0] == 0: - print('ERROR: there must be a velocity set for z = 0 in the file %s' % filename) - print('e.g.:\n0 0.33\n-5 1.0\netc.') - - infile.close() - return ztop, zbot, vtop, vbot - - -class SeisArray(object): - ''' - Can be used to interpolate missing values of a receiver grid, if only support points were measured. - Input file should contain in each line: ('traceID' 'receiverLineID' 'number of the geophone on recLine' 'X' 'Y' 'Z') - - Can be used to generate a velocity grid file (vgrids.in) for FMTOMO with a topography adapting gradient. - - Can be used to generate an interface file for FMTOMO (right now only interface.z used by grid3dg) for the topography. - - Supports vtk output for sources and receivers. - Note: Source and Receiver files for FMTOMO will be generated by the Survey object (because traveltimes will be added directly). - ''' - - def __init__(self, recfile, interpolatable = False): - self.recfile = recfile - self._receiverCoords = {} - self._measuredReceivers = {} - self._measuredTopo = {} - self._sourceCoords = {} - self._receiverlist = open(self.recfile, 'r').readlines() - if interpolatable == True: - self._init_interpolatable() - elif interpolatable == False: - self._init_normal() - self.set2D() - - def _init_normal(self): - self.interpolatable = False - self._setReceiverCoords_normal() - - def _init_interpolatable(self): - self.interpolatable = True - self._receiverlines = {} - self._geophoneNumbers = {} - self._setReceiverCoords_interp() - self._setGeophoneNumbers() - self._generateReceiverlines() - - def _generateReceiverlines(self): - ''' - Connects the traceIDs to the lineIDs - for each receiverline in a dictionary. - ''' - for receiver in self._receiverlist: - traceID = int(receiver.split()[0]) - lineID = int(receiver.split()[1]) - if not lineID in self._receiverlines.keys(): - self._receiverlines[lineID] = [] - self._receiverlines[lineID].append(traceID) - - def _setReceiverCoords_interp(self): - ''' - Fills the three x, y, z dictionaries with measured coordinates - in case of interpolatable measured input data. - ''' - for line in self._getReceiverlist(): - traceID = int(line.split()[0]) - x = float(line.split()[3]) - y = float(line.split()[4]) - z = float(line.split()[5]) - self._receiverCoords[traceID] = (x, y, z) - self._measuredReceivers[traceID] = (x, y, z) - - def _setReceiverCoords_normal(self): - ''' - Fills the three x, y, z dictionaries with measured coordinates - ''' - for line in self._getReceiverlist(): - traceID = int(line.split()[0]) - x = float(line.split()[1]) - y = float(line.split()[2]) - z = float(line.split()[3]) - self._receiverCoords[traceID] = (x, y, z) - self._measuredReceivers[traceID] = (x, y, z) - - def _setGeophoneNumbers(self): - for line in self._getReceiverlist(): - traceID = int(line.split()[0]) - gphoneNum = float(line.split()[2]) - self._geophoneNumbers[traceID] = gphoneNum - - def check2D(self): - x, y, z = self.getAllMeasuredPointsLists() - if self._check0(x) or self._check0(y): - return True - else: - return False - - def set2D(self): - if self.check2D(): - self.twoDim = True - else: - self.twoDim = False - - def _check0(self, lst): - for element in lst: - if element == 0: - pass - else: - return False - return True - - def _getReceiverlines(self): - return self._receiverlines - - def _getReceiverlist(self): - return self._receiverlist - - def getReceiverCoordinates(self): - return self._receiverCoords - - def _getXreceiver(self, traceID): - return self._receiverCoords[traceID][0] - - def _getYreceiver(self, traceID): - return self._receiverCoords[traceID][1] - - def _getZreceiver(self, traceID): - return self._receiverCoords[traceID][2] - - def _getXshot(self, shotnumber): - return self._sourceCoords[shotnumber][0] - - def _getYshot(self, shotnumber): - return self._sourceCoords[shotnumber][1] - - def _getZshot(self, shotnumber): - return self._sourceCoords[shotnumber][2] - - def _getReceiverValue(self, traceID, coordinate): - setCoordinate = {'X': self._getXreceiver, - 'Y': self._getYreceiver, - 'Z': self._getZreceiver} - return setCoordinate[coordinate](traceID) - - def _getGeophoneNumber(self, traceID): - return self._geophoneNumbers[traceID] - - def getMeasuredReceivers(self): - return self._measuredReceivers - - def getMeasuredTopo(self): - return self._measuredTopo - - def getSourceCoordinates(self): - return self._sourceCoords - - def _setXvalue(self, traceID, value): - self._checkKey(traceID) - self._receiverCoords[traceID][0] = value - - def _setYvalue(self, traceID, value): - self._checkKey(traceID) - self._receiverCoords[traceID][1] = value - - def _setZvalue(self, traceID, value): - self._checkKey(traceID) - self._receiverCoords[traceID][2] = value - - def _setValue(self, traceID, coordinate, value): - setCoordinate = {'X': self._setXvalue, - 'Y': self._setYvalue, - 'Z': self._setZvalue} - setCoordinate[coordinate](traceID, value) - - def _checkKey(self, traceID): - if not traceID in self._receiverCoords.keys(): - self._receiverCoords[traceID] = [None, None, None] - - def _checkTraceIDdirection(self, traceID1, traceID2): - if traceID2 > traceID1: - direction = +1 - return direction - if traceID2 < traceID1: - direction = -1 - return direction - err_msg = "Same Value for traceID1 = %s and traceID2 = %s" % (traceID1, traceID2) - raise RuntimeError(err_msg) - - def _checkCoordDirection(self, traceID1, traceID2, coordinate): - ''' - Checks whether the interpolation direction is positive or negative - ''' - if self._getReceiverValue(traceID1, coordinate) < self._getReceiverValue(traceID2, coordinate): - direction = +1 - return direction - if self._getReceiverValue(traceID1, coordinate) > self._getReceiverValue(traceID2, coordinate): - direction = -1 - return direction - err_msg = "Same Value for traceID1 = %s and traceID2 = %s" % (traceID1, traceID2) - raise RuntimeError(err_msg) - - def _interpolateMeanDistances(self, traceID1, traceID2, coordinate): - ''' - Returns the mean distance between two traceID's depending on the number of geophones in between - ''' - num_spaces = abs(self._getGeophoneNumber(traceID1) - self._getGeophoneNumber(traceID2)) - mean_distance = abs( - self._getReceiverValue(traceID1, coordinate) - self._getReceiverValue(traceID2, coordinate)) / num_spaces - return mean_distance - - def checkInterpolatable(self): - if self.interpolatable == False: - print('Not interpolatable.') - return self.interpolatable - - def interpolateValues(self, coordinate): - ''' - Interpolates and sets all values (linear) for coordinate = 'X', 'Y' or 'Z' - ''' - if not self.checkInterpolatable(): - return - for lineID in self._getReceiverlines().keys(): - number_measured = len(self._getReceiverlines()[lineID]) - for index, traceID1 in enumerate(self._getReceiverlines()[lineID]): - if index + 1 < number_measured: - traceID2 = self._getReceiverlines()[lineID][index + 1] - - traceID_dir = self._checkTraceIDdirection(traceID1, traceID2) - traceID_interp = traceID1 + traceID_dir - - coord_dir = self._checkCoordDirection(traceID1, traceID2, coordinate) - mean_distance = self._interpolateMeanDistances(traceID1, traceID2, coordinate) - - while (traceID_dir * traceID_interp) < (traceID_dir * traceID2): - self._setValue(traceID_interp, coordinate, - (self._getReceiverValue(traceID_interp - traceID_dir, coordinate) - + coord_dir * (mean_distance))) - traceID_interp += traceID_dir - - def addMeasuredTopographyPoints(self, filename): - ''' - Use more measured points for a higher precision of height interpolation. - Input file should contain in each line: ('point ID' 'X' 'Y' 'Z') - ''' - topolist = open(filename, 'r').readlines() - for line in topolist: - line = line.split() - pointID = int(line[0]) - x = float(line[1]) - y = float(line[2]) - z = float(line[3]) - self._measuredTopo[pointID] = (x, y, z) - - def addSourceLocations(self, filename): - ''' - Use source locations for a higher precision of height interpolation. - Input file should contain in each line: ('point ID' 'X' 'Y' 'Z') - - Source locations must be added before they can be written to vtk files. - ''' - topolist = open(filename, 'r').readlines() - for line in topolist: - line = line.split() - pointID = int(line[0]) - x = float(line[1]) - y = float(line[2]) - z = float(line[3]) - self._sourceCoords[pointID] = (x, y, z) - - def interpZcoords4rec(self, method='linear'): - ''' - Interpolates z values for all receivers. - ''' - measured_x, measured_y, measured_z = self.getAllMeasuredPointsLists() - - for traceID in self.getReceiverCoordinates().keys(): - if type(self.getReceiverCoordinates()[traceID]) is not tuple: - z = griddata((measured_x, measured_y), measured_z, - (self._getXreceiver(traceID), self._getYreceiver(traceID)), method=method) - self._setZvalue(traceID, float(z)) - - def _getAngle(self, distance): - ''' - Function returns the angle on a Sphere of the radius R = 6371 [km] for a distance [km]. - ''' - PI = np.pi - R = 6371. - angle = distance * 180. / (PI * R) - return angle - - def _getDistance(self, angle): - ''' - Function returns the distance [km] on a Sphere of the radius R = 6371 [km] for an angle. - ''' - PI = np.pi - R = 6371. - distance = angle / 180. * (PI * R) - return distance - - def getMeasuredReceiverLists(self): - ''' - Returns a list of all measured receivers known to SeisArray. - ''' - x = []; - y = []; - z = [] - for traceID in self.getMeasuredReceivers().keys(): - x.append(self.getMeasuredReceivers()[traceID][0]) - y.append(self.getMeasuredReceivers()[traceID][1]) - z.append(self.getMeasuredReceivers()[traceID][2]) - return x, y, z - - def getMeasuredTopoLists(self): - ''' - Returns a list of all measured topography points known to the SeisArray. - ''' - x = []; - y = []; - z = [] - for pointID in self.getMeasuredTopo().keys(): - x.append(self.getMeasuredTopo()[pointID][0]) - y.append(self.getMeasuredTopo()[pointID][1]) - z.append(self.getMeasuredTopo()[pointID][2]) - return x, y, z - - def getSourceLocsLists(self): - ''' - Returns a list of all measured source locations known to SeisArray. - ''' - x = []; - y = []; - z = [] - for pointID in self.getSourceCoordinates().keys(): - x.append(self.getSourceCoordinates()[pointID][0]) - y.append(self.getSourceCoordinates()[pointID][1]) - z.append(self.getSourceCoordinates()[pointID][2]) - return x, y, z - - def getAllMeasuredPointsLists(self): - ''' - Returns a list of all measured points known to SeisArray. - ''' - mtopo_x, mtopo_y, mtopo_z = self.getMeasuredTopoLists() - msource_x, msource_y, msource_z = self.getSourceLocsLists() - mrec_x, mrec_y, mrec_z = self.getMeasuredReceiverLists() - - x = mtopo_x + mrec_x + msource_x - y = mtopo_y + mrec_y + msource_y - z = mtopo_z + mrec_z + msource_z - return x, y, z - - def getReceiverLists(self): - ''' - Returns a list of all receivers (measured and interpolated). - ''' - x = []; - y = []; - z = [] - for traceID in self.getReceiverCoordinates().keys(): - x.append(self.getReceiverCoordinates()[traceID][0]) - y.append(self.getReceiverCoordinates()[traceID][1]) - z.append(self.getReceiverCoordinates()[traceID][2]) - return x, y, z - - def _interpolateXY4rec(self): - ''' - Interpolates the X and Y coordinates for all receivers. - ''' - for coordinate in ('X', 'Y'): - self.interpolateValues(coordinate) - - def interpolateAll(self): - if not self.checkInterpolatable(): - return - self._interpolateXY4rec() - self.interpZcoords4rec() - print('Interpolated receiver locations.') - - def interpolateTopography(self, nTheta, nPhi, thetaSN, phiWE, elevation=0.25, method='linear'): - ''' - Interpolate Z values on a regular grid with cushion nodes e.g. to use it as FMTOMO topography interface. - Returns a surface in form of a list of points [[x1, y1, z1], [x2, y2, y2], ...] (cartesian). - - :param: nTheta, number of points in theta (NS) - type: integer - - :param: nPhi, number of points in phi (WE) - type: integer - - :param: thetaSN (S, N) extensions of the model in degree - type: tuple - - :param: phiWE (W, E) extensions of the model in degree - type: tuple - - :param: elevation, default: 0.25 (elevate topography so that no source lies above the surface) - type: float - ''' - return self.interpolateOnRegularGrid(nTheta, nPhi, thetaSN, phiWE, elevation, method) - - def interpolateOnRegularGrid(self, nTheta, nPhi, thetaSN, phiWE, elevation, method='linear'): - ''' - Interpolate Z values on a regular grid with cushion nodes e.g. to use it as FMTOMO topography interface. - Returns a surface in form of a list of points [[x1, y1, z1], [x2, y2, y2], ...] (cartesian). - - :param: nTheta, number of points in theta (NS) - type: integer - - :param: nPhi, number of points in phi (WE) - type: integer - - :param: thetaSN (S, N) extensions of the model in degree - type: tuple - - :param: phiWE (W, E) extensions of the model in degree - type: tuple - - :param: elevation, default: 0.25 (elevate topography so that no source lies above the surface) - type: float - ''' - - surface = [] - - print "Interpolating interface on regular grid with the dimensions:" - print "nTheta = %s, nPhi = %s, thetaSN = %s, phiWE = %s" % (nTheta, nPhi, thetaSN, phiWE) - print "method = %s, elevation = %s" % (method, elevation) - - thetaS, thetaN = thetaSN - phiW, phiE = phiWE - - measured_x, measured_y, measured_z = self.getAllMeasuredPointsLists() - - # need to determine the delta to add two cushion nodes around the min/max values - deltaTheta = (thetaN - thetaS) / (nTheta - 1) - deltaPhi = (phiE - phiW) / (nPhi - 1) - - thetaGrid = np.linspace(thetaS - deltaTheta, thetaN + deltaTheta, num=nTheta + 2) # +2 cushion nodes - phiGrid = np.linspace(phiW - deltaPhi, phiE + deltaPhi, num=nPhi + 2) # +2 cushion nodes - - nTotal = len(thetaGrid) * len(phiGrid); - count = 0 - for theta in thetaGrid: - for phi in phiGrid: - xval = self._getDistance(phi) - yval = self._getDistance(theta) - - z = griddata((measured_x, measured_y), measured_z, (xval, yval), method=method) - # in case the point lies outside, nan will be returned. Find nearest: - if np.isnan(z) == True: - z = griddata((measured_x, measured_y), measured_z, (xval, yval), method='nearest') - z = float(z) + elevation - surface.append((xval, yval, z)) - count += 1 - progress = float(count) / float(nTotal) * 100 - self._update_progress(progress) - - return surface - - def generateFMTOMOinputFromArray(self, nPointsPropgrid, nPointsInvgrid, - zBotTop, cushionfactor, interpolationMethod='linear', - customgrid='mygrid.in', writeVTK=True): - ''' - Generate FMTOMO input files from the SeisArray dimensions. - Generates: vgridsref.in, interfacesref.in, propgrid.in - - :param: nPointsPropgrid, number of points in each direction of the propagation grid (x, y, z) - :type: tuple - - :param: nPointsInvgrid, number of points in each direction of the inversion grid (x, y, z) - :type: tuple - - :param: zBotTop, (bottom, top) dimensions of the model - :type: tuple - - :param: cushionfactor, adds cushioning around the model (0.1 = 10%) - :type: float - ''' - - nPhiP, nThetaP, nRP = nPointsPropgrid - nPhiI, nThetaI, nRI = nPointsInvgrid - - print('\n------------------------------------------------------------') - print('Automatically generating input for FMTOMO from array size.') - print('Propgrid: nR = %s, nTheta = %s, nPhi = %s' % (nRP, nThetaP, nPhiP)) - print('Interpolation Grid and Interfaces Grid: nR = %s, nTheta = %s, nPhi = %s' % (nRI, nThetaI, nPhiI)) - print('Bottom and Top of model: (%s, %s)' % (zBotTop[0], zBotTop[1])) - print('Method: %s, customgrid = %s' % (interpolationMethod, customgrid)) - print('------------------------------------------------------------') - - def getZmin(surface): - z = [] - for point in surface: - z.append(point[2]) - return min(z) - - self.generatePropgrid(nThetaP, nPhiP, nRP, zBotTop, cushionfactor=cushionfactor, - cushionpropgrid=0.05) - surface = self.generateVgrid(nThetaI, nPhiI, nRI, zBotTop, method=interpolationMethod, - cushionfactor=cushionfactor, infilename=customgrid, - returnTopo=True) - - depthmax = abs(zBotTop[0] - getZmin(surface)) - 1.0 # cushioning for the bottom interface - - interf1, interf2 = self.generateInterfaces(nThetaI, nPhiI, depthmax, cushionfactor=cushionfactor, - returnInterfaces=True, method=interpolationMethod) - - if writeVTK == True: - from pylot.core.active import fmtomoUtils - self.surface2VTK(interf1, filename='interface1.vtk') - self.surface2VTK(interf2, filename='interface2.vtk') - self.receivers2VTK() - self.sources2VTK() - #fmtomoUtils.vgrids2VTK() - - def generateReceiversIn(self, outfilename='receivers.in'): - outfile = open(outfilename, 'w') - - recx, recy, recz = self.getReceiverLists() - nsrc = len(self.getSourceCoordinates()) - outfile.write('%s\n' % (len(zip(recx, recy, recz)) * nsrc)) - - for index in range(nsrc): - for point in zip(recx, recy, recz): - rx, ry, rz = point - rad = - rz - lat = self._getAngle(ry) - lon = self._getAngle(rx) - outfile.write('%15s %15s %15s\n' % (rad, lat, lon)) - outfile.write('%15s\n' % (1)) - outfile.write('%15s\n' % (index + 1)) - outfile.write('%15s\n' % (1)) - - outfile.close() - - def generateInterfaces(self, nTheta, nPhi, depthmax, cushionfactor=0.1, - outfilename='interfacesref.in', method='linear', - returnInterfaces=False): - ''' - Create an interfacesref.in file for FMTOMO from the SeisArray boundaries. - :param: nTheta, number of points in Theta - type: int - - :param: nPhi, number of points in Phi - type: int - - :param: depthmax, maximum depth of the model (below topography) - type: float - - :param: cushionfactor, add some extra space to the model (default: 0.1 = 10%) - type: float - ''' - - print('\n------------------------------------------------------------') - print('Generating interfaces...') - nInterfaces = 2 - - # generate dimensions of the grid from array - thetaSN, phiWE = self.getThetaPhiFromArray(cushionfactor) - - thetaS, thetaN = thetaSN - phiW, phiE = phiWE - R = 6371. - - outfile = open(outfilename, 'w') - - # determine the deltas - deltaTheta = abs(thetaN - thetaS) / float((nTheta - 1)) - deltaPhi = abs(phiE - phiW) / float((nPhi - 1)) - - # write header for interfaces grid file (in RADIANS) - outfile.write('%10s\n' % (nInterfaces)) - outfile.write('%10s %10s\n' % (nTheta + 2, nPhi + 2)) # +2 cushion nodes - outfile.write('%10s %10s\n' % (np.deg2rad(deltaTheta), np.deg2rad(deltaPhi))) - outfile.write('%10s %10s\n' % (np.deg2rad(thetaS - deltaTheta), np.deg2rad(phiW - deltaPhi))) - - interface1 = self.interpolateTopography(nTheta, nPhi, thetaSN, phiWE, method=method) - interface2 = self.interpolateOnRegularGrid(nTheta, nPhi, thetaSN, phiWE, -depthmax, method=method) - - for point in interface1: - z = point[2] - outfile.write('%10s\n' % (z + R)) - - outfile.write('\n') - for point in interface2: - z = point[2] - outfile.write('%10s\n' % (z + R)) - - outfile.close() - - if returnInterfaces == True: - return interface1, interface2 - - print('Finished generating interfaces.') - print('------------------------------------------------------------') - - def getThetaPhiFromArray(self, cushionfactor=0.1): - ''' - Determine and returns PhiWE (tuple: (West, East)) and thetaSN (tuple (South, North)) from the SeisArray boundaries. - - :param: cushionfactor, add some extra space to the model (default: 0.1 = 10%) - type: float - ''' - x, y, _ = self.getAllMeasuredPointsLists() - phi_min, phi_max = (self._getAngle(min(x)), self._getAngle(max(x))) - theta_min, theta_max = (self._getAngle(min(y)), self._getAngle(max(y))) - cushionPhi = abs(phi_max - phi_min) * cushionfactor - cushionTheta = abs(theta_max - theta_min) * cushionfactor - # 2D Case only: - if cushionPhi == 0.: - cushionPhi = 0.1 - if cushionTheta == 0.: - cushionTheta = 0.1 - phiWE = (phi_min - cushionPhi, phi_max + cushionPhi) - thetaSN = (theta_min - cushionTheta, theta_max + cushionTheta) - return thetaSN, phiWE - - def generatePropgrid(self, nTheta, nPhi, nR, Rbt, cushionfactor, cushionpropgrid=0.05, - refinement=(5, 5), outfilename='propgrid.in'): - ''' - Create a propergation grid file for FMTOMO using SeisArray boundaries - - :param: nTheta, number of points in Theta - type: int - - :param: nPhi, number of points in Phi - type: int - - :param: nR, number of points in R - type: int - - :param: Rbt (bot, top) extensions of the model in m - type: tuple - - :param: cushionfactor, add some extra space to the model (default: 0.1 = 10%) - type: float - - :param: cushionpropogrid, cushionfactor for the propagationgrid (cushion direction - opposing to vgrids cushionfactor) - type: float - - :param: refinement, (refinement factor, number of local cells for refinement) used by FMTOMO - type: tuple - ''' - outfile = open(outfilename, 'w') - - print('\n------------------------------------------------------------') - print('Generating Propagation Grid for nTheta = %s, nPhi' - ' = %s, nR = %s and a cushioning of %s' - % (nTheta, nPhi, nR, cushionpropgrid)) - print('Bottom of the grid: %s, top of the grid %s' - % (Rbt[0], Rbt[1])) - - thetaSN, phiWE = self.getThetaPhiFromArray(cushionfactor) - - # +2 cushion nodes - nTheta += 2 - nPhi += 2 - nR += 2 - - thetaS = thetaSN[0] + cushionpropgrid - thetaN = thetaSN[1] - cushionpropgrid - phiW = phiWE[0] + cushionpropgrid - phiE = phiWE[1] - cushionpropgrid - rbot = Rbt[0] - rtop = Rbt[1] - - deltaTheta = abs(thetaN - thetaS) / float(nTheta - 1) - deltaPhi = abs(phiE - phiW) / float(nPhi - 1) - deltaR = abs(rbot - rtop) / float(nR - 1) - - outfile.write('%10s %10s %10s\n' % (nR, nTheta, nPhi)) - outfile.write('%10s %10s %10s\n' % (deltaR, deltaTheta, deltaPhi)) - outfile.write('%10s %10s %10s\n' % (rtop, thetaS, phiW)) - outfile.write('%10s %10s\n' % refinement) - - outfile.close() - - print('Created Propagation Grid and saved it to %s' % outfilename) - print('------------------------------------------------------------') - - def generateVgrid(self, nTheta, nPhi, nR, Rbt, thetaSN=None, - phiWE=None, cushionfactor=0.1, - outfilename='vgridsref.in', method='linear', - infilename='mygrid.in', returnTopo=False): - ''' - Generate a velocity grid for fmtomo regarding topography with a linear gradient starting at the topography with 0.34 [km/s]. - - :param: nTheta, number of points in theta (NS) - type: integer - - :param: nPhi, number of points in phi (WE) - type: integer - - :param: nR, number of points in depth - type: integer - - :param: thetaSN (S, N) extensions of the model in degree - type: tuple - - :param: phiWE (W, E) extensions of the model in degree - type: tuple - - :param: Rbt (bot, top) extensions of the model in m - type: tuple - - :param: vbot, velocity at the bottom of the model - type: real - - :param: method, interpolation method for topography - type: str - ''' - print('\n------------------------------------------------------------') - print('generateVgrid: Starting...') - - # def getRad(angle): - # PI = np.pi - # rad = angle / 180 * PI - # return rad - - R = 6371. - vmin = 0.34 - decm = 0.3 # diagonal elements of the covariance matrix (grid3dg's default value is 0.3) - outfile = open(outfilename, 'w') - - # generate dimensions of the grid from array - if thetaSN is None and phiWE is None: - thetaSN, phiWE = self.getThetaPhiFromArray(cushionfactor) - - thetaS, thetaN = thetaSN - phiW, phiE = phiWE - rbot = Rbt[0] + R - rtop = Rbt[1] + R - - # need to determine the delta to add two cushion nodes around the min/max values - deltaTheta = abs(thetaN - thetaS) / float((nTheta - 1)) - deltaPhi = abs(phiE - phiW) / float((nPhi - 1)) - deltaR = abs(rbot - rtop) / float((nR - 1)) - - # create a regular grid including +2 cushion nodes in every direction - thetaGrid = np.linspace(thetaS - deltaTheta, thetaN + deltaTheta, num=nTheta + 2) # +2 cushion nodes - phiGrid = np.linspace(phiW - deltaPhi, phiE + deltaPhi, num=nPhi + 2) # +2 cushion nodes - rGrid = np.linspace(rbot - deltaR, rtop + deltaR, num=nR + 2) # +2 cushion nodes - - nTotal = len(rGrid) * len(thetaGrid) * len(phiGrid) - print("Total number of grid nodes: %s" % nTotal) - - # write header for velocity grid file (in RADIANS) - outfile.write('%10s %10s \n' % (1, 1)) - outfile.write('%10s %10s %10s\n' % (nR + 2, nTheta + 2, nPhi + 2)) - outfile.write('%10s %10s %10s\n' % (deltaR, np.deg2rad(deltaTheta), np.deg2rad(deltaPhi))) - outfile.write( - '%10s %10s %10s\n' % (rbot - deltaR, np.deg2rad(thetaS - deltaTheta), np.deg2rad(phiW - deltaPhi))) - - surface = self.interpolateTopography(nTheta, nPhi, thetaSN, phiWE, method=method) - - nlayers = readMygridNlayers(infilename) - ztop, zbot, vtop, vbot = readMygrid(infilename) - - print("\nGenerating velocity grid for FMTOMO. " - "Output filename = %s, interpolation method = %s" % (outfilename, method)) - print("nTheta = %s, nPhi = %s, nR = %s, " - "thetaSN = %s, phiWE = %s, Rbt = %s" % (nTheta, nPhi, nR, thetaSN, phiWE, Rbt)) - count = 0 - - for radius in rGrid: - for theta in thetaGrid: - for phi in phiGrid: - xval = self._getDistance(phi) - yval = self._getDistance(theta) - for point in surface: - if point[0] == xval and point[1] == yval: - topo = point[2] - break - depth = -(R + topo - radius) - if depth > 1: - vel = 0.0 - elif 1 >= depth > 0: # cushioning around topography - vel = vtop[0] - else: - for index in range(nlayers): - if (ztop[index]) >= depth > (zbot[index]): - vel = (depth - ztop[index]) / (zbot[index] - ztop[index]) * ( - vbot[index] - vtop[index]) + vtop[index] - break - if not (ztop[index]) >= depth > (zbot[index]): - err_msg = 'ERROR in grid inputfile, could not find velocity' - 'for a z-value of %s in the inputfile' % (depth - topo) - raise ValueError(err_msg) - count += 1 - if not vel >= 0: - err_msg = 'vel < 0; z, topo, zbot, vbot, vtop:', - depth, topo, zbot[index], vbot[index], vtop[index] - raise ValueError(err_msg) - - outfile.write('%10s %10s\n' % (vel, decm)) - - progress = float(count) / float(nTotal) * 100 - self._update_progress(progress) - - print('\nWrote %d points to file %s for %d layers' % (count, outfilename, nlayers)) - print('------------------------------------------------------------') - outfile.close() - - if returnTopo == True: - return surface - - def exportAll(self, filename='interpolated_receivers.out'): - ''' - Exports all receivers to an input file for ActiveSeismoPick3D. - ''' - recfile_out = open(filename, 'w') - count = 0 - for traceID in self.getReceiverCoordinates().keys(): - count += 1 - x, y, z = self.getReceiverCoordinates()[traceID] - recfile_out.write('%5s %15s %15s %15s\n' % (traceID, x, y, z)) - print "Exported coordinates for %s traces to file > %s" % (count, filename) - recfile_out.close() - - def plotArray2D(self, ax = None, plot_topo=False, highlight_measured=False, annotations=True, pointsize=10, twoDim = False): - import matplotlib.pyplot as plt - if ax == None: - plt.interactive(True) - fig = plt.figure() - ax = plt.axes() - xmt, ymt, zmt = self.getMeasuredTopoLists() - xsc, ysc, zsc = self.getSourceLocsLists() - xmr, ymr, zmr = self.getMeasuredReceiverLists() - xrc, yrc, zrc = self.getReceiverLists() - - if len(xrc) > 0: - ax.plot(xrc, yrc, 'k.', markersize=pointsize, label='all receivers') - if len(xsc) > 0: - ax.plot(xsc, ysc, 'b*', markersize=pointsize, label='shot locations') - - if plot_topo == True: - ax.plot(xmt, ymt, 'b.', markersize=pointsize, label='measured topo points') - if highlight_measured == True: - ax.plot(xmr, ymr, 'r.', markersize=pointsize, label='measured receivers') - - ax.figure.text(0.5, 0.95,'2D plot of seismic array\n %s'%self.recfile, - horizontalalignment='center', verticalalignment='center', - transform = ax.figure.transFigure) - - ax.set_xlabel('X [m]') - ax.set_ylabel('Y [m]') - if twoDim == False: - ax.set_aspect('equal') - ax.legend(prop={'size':7}) - if annotations == True: - for traceID in self.getReceiverCoordinates().keys(): - ax.annotate((' ' + str(traceID)), xy=(self._getXreceiver(traceID), self._getYreceiver(traceID)), - fontsize='x-small', color='k') - for shotnumber in self.getSourceCoordinates().keys(): - ax.annotate((' ' + str(shotnumber)), xy=(self._getXshot(shotnumber), self._getYshot(shotnumber)), - fontsize='x-small', color='b') - - def plotArray3D(self, ax=None, legend = True, markersize = 10): - import matplotlib.pyplot as plt - from mpl_toolkits.mplot3d import Axes3D - - if ax == None: - plt.interactive(True) - fig = plt.figure() - ax = plt.axes(projection='3d') - - xmt, ymt, zmt = self.getMeasuredTopoLists() - xmr, ymr, zmr = self.getMeasuredReceiverLists() - xrc, yrc, zrc = self.getReceiverLists() - xsc, ysc, zsc = self.getSourceLocsLists() - - ax.figure.text(0.5, 0.95,'3D plot of seismic array\n %s'%self.recfile, - horizontalalignment='center', verticalalignment='center', - transform = ax.figure.transFigure) - - if len(xmt) > 0: - ax.plot(xmt, ymt, zmt, 'b.', markersize=markersize, label='measured topo points') - if len(xrc) > 0: - ax.plot(xrc, yrc, zrc, 'k.', markersize=markersize, label='all receivers') - if len(xmr) > 0: - ax.plot(xmr, ymr, zmr, 'ro', markersize=markersize, label='measured receivers') - if len(xsc) > 0: - ax.plot(xsc, ysc, zsc, 'b*', markersize=markersize, label='shot locations') - ax.set_xlabel('X [m]'); - ax.set_ylabel('Y [m]'); - ax.set_zlabel('Z [m]') - if legend == True: - ax.legend() - - return ax - - def plotSurface3D(self, ax=None, step=0.5, method='linear', exag=False, twoDim = False): - from matplotlib import cm - import matplotlib.pyplot as plt - from mpl_toolkits.mplot3d import Axes3D - - if ax == None: - plt.interactive(True) - fig = plt.figure() - ax = plt.axes(projection='3d') - - xmt, ymt, zmt = self.getMeasuredTopoLists() - xmr, ymr, zmr = self.getMeasuredReceiverLists() - - x = xmt + xmr - y = ymt + ymr - z = zmt + zmr - - xaxis = np.arange(min(x) + 1, max(x), step) - yaxis = np.arange(min(y) + 1, max(y), step) - - xgrid, ygrid = np.meshgrid(xaxis, yaxis) - - zgrid = griddata((x, y), z, (xgrid, ygrid), method=method) - - surf = ax.plot_surface(xgrid, ygrid, zgrid, linewidth=0, cmap=cm.jet, vmin=min(z), vmax=max(z)) - cbar = ax.figure.colorbar(surf) - cbar.set_label('Elevation [m]') - - if exag == False: - ax.set_zlim(-(max(x) - min(x) / 2), (max(x) - min(x) / 2)) - if twoDim == False: - ax.set_aspect('equal') - - ax.set_xlabel('X [m]'); - ax.set_ylabel('Y [m]'); - ax.set_zlabel('Z [m]') - ax.legend() - - return ax - - def _update_progress(self, progress): - sys.stdout.write("%d%% done \r" % (progress)) - sys.stdout.flush() - - def surface2VTK(self, surface, filename='surface.vtk'): - ''' - Generates a vtk file from all points of a surface as generated by interpolateTopography. - ''' - outfile = open(filename, 'w') - - nPoints = len(surface) - - # write header - print("Writing header for VTK file...") - outfile.write('# vtk DataFile Version 3.1\n') - outfile.write('Surface Points\n') - outfile.write('ASCII\n') - outfile.write('DATASET POLYDATA\n') - outfile.write('POINTS %15d float\n' % (nPoints)) - - # write coordinates - print("Writing coordinates to VTK file...") - for point in surface: - x = point[0] - y = point[1] - z = point[2] - - outfile.write('%10f %10f %10f \n' % (x, y, z)) - - outfile.write('VERTICES %15d %15d\n' % (nPoints, 2 * nPoints)) - - # write indices - print("Writing indices to VTK file...") - for index in range(nPoints): - outfile.write('%10d %10d\n' % (1, index)) - - # outfile.write('POINT_DATA %15d\n' %(nPoints)) - # outfile.write('SCALARS traceIDs int %d\n' %(1)) - # outfile.write('LOOKUP_TABLE default\n') - - # # write traceIDs - # print("Writing traceIDs to VTK file...") - # for traceID in traceIDs: - # outfile.write('%10d\n' %traceID) - - outfile.close() - print("Wrote %d points to file: %s" % (nPoints, filename)) - return - - def receivers2VTK(self, filename='receivers.vtk'): - ''' - Generates a vtk file from all receivers of the SeisArray object. - ''' - outfile = open(filename, 'w') - traceIDs = [] - - for traceID in self.getReceiverCoordinates(): - traceIDs.append(traceID) - - nPoints = len(traceIDs) - - # write header - print("Writing header for VTK file...") - outfile.write('# vtk DataFile Version 3.1\n') - outfile.write('Receivers with traceIDs\n') - outfile.write('ASCII\n') - outfile.write('DATASET POLYDATA\n') - outfile.write('POINTS %15d float\n' % (nPoints)) - - # write coordinates - print("Writing coordinates to VTK file...") - for traceID in traceIDs: - x = self._getXreceiver(traceID) - y = self._getYreceiver(traceID) - z = self._getZreceiver(traceID) - - outfile.write('%10f %10f %10f \n' % (x, y, z)) - - outfile.write('VERTICES %15d %15d\n' % (nPoints, 2 * nPoints)) - - # write indices - print("Writing indices to VTK file...") - for index in range(nPoints): - outfile.write('%10d %10d\n' % (1, index)) - - outfile.write('POINT_DATA %15d\n' % (nPoints)) - outfile.write('SCALARS traceIDs int %d\n' % (1)) - outfile.write('LOOKUP_TABLE default\n') - - # write traceIDs - print("Writing traceIDs to VTK file...") - for traceID in traceIDs: - outfile.write('%10d\n' % traceID) - - outfile.close() - print("Wrote %d receiver for to file: %s" % (nPoints, filename)) - return - - def sources2VTK(self, filename='sources.vtk'): - ''' - Generates a vtk-file for all source locations in the SeisArray object. - ''' - outfile = open(filename, 'w') - shotnumbers = [] - - for shotnumber in self.getSourceCoordinates(): - shotnumbers.append(shotnumber) - - nPoints = len(shotnumbers) - - # write header - print("Writing header for VTK file...") - outfile.write('# vtk DataFile Version 3.1\n') - outfile.write('Shots with shotnumbers\n') - outfile.write('ASCII\n') - outfile.write('DATASET POLYDATA\n') - outfile.write('POINTS %15d float\n' % (nPoints)) - - # write coordinates - print("Writing coordinates to VTK file...") - for shotnumber in shotnumbers: - x = self._getXshot(shotnumber) - y = self._getYshot(shotnumber) - z = self._getZshot(shotnumber) - - outfile.write('%10f %10f %10f \n' % (x, y, z)) - - outfile.write('VERTICES %15d %15d\n' % (nPoints, 2 * nPoints)) - - # write indices - print("Writing indices to VTK file...") - for index in range(nPoints): - outfile.write('%10d %10d\n' % (1, index)) - - outfile.write('POINT_DATA %15d\n' % (nPoints)) - outfile.write('SCALARS shotnumbers int %d\n' % (1)) - outfile.write('LOOKUP_TABLE default\n') - - # write shotnumber - print("Writing shotnumbers to VTK file...") - for shotnumber in shotnumbers: - outfile.write('%10d\n' % shotnumber) - - outfile.close() - print("Wrote %d sources to file: %s" % (nPoints, filename)) - return - - def saveSeisArray(self, filename='seisArray.pickle'): - import cPickle - outfile = open(filename, 'wb') - - cPickle.dump(self, outfile, -1) - print('saved SeisArray to file %s' % (filename)) - - @staticmethod - def from_pickle(filename): - import cPickle - infile = open(filename, 'rb') - return cPickle.load(infile) diff --git a/pylot/core/active/seismicshot.py b/pylot/core/active/seismicshot.py deleted file mode 100644 index e74ecaed..00000000 --- a/pylot/core/active/seismicshot.py +++ /dev/null @@ -1,957 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -import os -import numpy as np -from obspy.core import read -from obspy import Stream -from obspy import Trace -from pylot.core.pick.charfuns import HOScf -from pylot.core.pick.charfuns import AICcf -from pylot.core.pick.utils import getSNR -from pylot.core.pick.utils import earllatepicker -import matplotlib.pyplot as plt -import warnings -import copy_reg -import types -from pylot.core.util.utils import worker, _pickle_method - -copy_reg.pickle(types.MethodType, _pickle_method) - -plt.interactive('True') - -class SeismicShot(object): - ''' - SuperClass for a seismic shot object. - ''' - def __init__(self, obsfile): - ''' - Initialize seismic shot object giving an inputfile. - - :param: obsfile, ((!SEG2/SEGY!)) file readable by obspy - :type: string - ''' - self.traces = read(obsfile) - self.renameChannelIDs() - # self.recCoordlist = None - # self.srcCoordlist = None - self.traceIDs = None - self.picks = {} - self.pwindow = {} - self.manualpicks = {} - self.snr = {} - self.snrthreshold = {} - self.timeArray = {} - self.traces4plot = {} - self.paras = {} - self.paras['shotname'] = obsfile - self.folm = None - - def renameChannelIDs(self): - for trace in self.traces: - if trace.stats._format == 'SEG2': - trace.stats.channel = int(trace.stats.seg2['CHANNEL_NUMBER']) - - def removeEmptyTraces(self): - traceIDs = [] - removed = [] - traceIDs = self.getReceiverCoords().keys() - - for trace in self.traces: - try: - traceIDs.index(int(trace.stats.channel)) - except: - self.traces.remove(trace) - removed.append(int(trace.stats.channel)) - - if len(removed) > 0: - return removed - - def removeTrace(self, traceID): - for trace in self.traces: - if traceID == trace.stats.channel: - self.traces.remove(trace) - - def updateTraceList(self): - ''' - Looks for empty traces, returns a list of deleted traceIDs. - ''' - traceIDs = [] - for traceID in self.getTraceIDlist(): - if traceID not in self.getStreamTraceIDs(): - self.traceIDs.remove(traceID) - traceIDs.append(traceID) - return traceIDs - - def setParameters(self, name, value): - self.paras[name] = value - - def setVmin(self, vmin): - self.setParameters('vmin', vmin) - - def setVmax(self, vmax): - self.setParameters('vmax', vmax) - - def setCut(self, cut): - self.setParameters('cut', cut) - - def setTmovwind(self, tmovwind): - self.setParameters('tmovwind', tmovwind) - - def setOrder(self, order): - self.setParameters('order', order) - - def setTsignal(self, tsignal): - self.setParameters('tsignal', tsignal) - - def setTgap(self, tgap): - self.setParameters('tgap', tgap) - - def setShotnumber(self, shotnumber): - self.setParameters('shotnumber', shotnumber) - - def setReceiverCoords(self, receiver): - self.setParameters('receiverLoc', receiver) - - def setSourceCoords(self, source): - self.setParameters('sourceLoc', source) - - def setMethod(self, method): - self.setParameters('method', method) - - def setAicwindow(self, aicwindow): - self.setParameters('aicwindow', aicwindow) - - def setFolm(self, folm): - self.setParameters('folm', folm) - - def setDynPickwindow(self, traceID, cutdist = 5.): - distance = self.getDistance(traceID) # receive distance - - vmin = self.getVmin() - vmax = self.getVmax() - - pickwin_used = self.getCut() - cutwindow = self.getCut() - - # for higher distances use a linear vmin/vmax to cut out late/early regions with high noise - if distance > cutdist: - pwleft = distance / vmax - pwright = distance / vmin - if pwright > cutwindow[1]: - pwright = cutwindow[1] - pickwin_used = (pwleft, pwright) - - self.setPickwindow(traceID, pickwin_used) - - def getMethod(self): - return self.paras['method'] - - def getAicwindow(self): - return self.paras['aicwindow'] - - def getFolm(self): - return self.paras['folm'] - - def getParas(self): - return self.paras - - def getShotnumber(self): - return self.paras['shotnumber'] - - def getSourceCoords(self): - return self.paras['sourceLoc'] - - def getReceiverCoords(self): - return self.paras['receiverLoc'] - - def getCut(self): - return self.paras['cut'] - - def getTmovwind(self): - return self.paras['tmovwind'] - - def getOrder(self): - return self.paras['order'] - - def getTsignal(self): - return self.paras['tsignal'] - - def getTgap(self): - return self.paras['tgap'] - - def getShotnumber(self): - return self.paras['shotnumber'] - - def getVmin(self): - return self.paras['vmin'] - - def getVmax(self): - return self.paras['vmax'] - - def getManualPick(self, traceID): - if not self.getManualPickFlag(traceID) == 0: - return self.manualpicks[traceID]['mpp'] - - def getManualEarliest(self, traceID): - return self.manualpicks[traceID]['epp'] - - def getManualLatest(self, traceID): - return self.manualpicks[traceID]['lpp'] - - def getPick(self, traceID, returnRemoved=False): - if not self.getPickFlag(traceID) == 0: - return self.picks[traceID]['mpp'] - if returnRemoved == True: - return self.picks[traceID]['mpp'] - - def getPickIncludeRemoved(self, traceID): - return self.getPick(traceID, returnRemoved=True) - - def getEarliest(self, traceID): - return self.picks[traceID]['epp'] - - def getLatest(self, traceID): - return self.picks[traceID]['lpp'] - - def getSymmetricPickError(self, traceID): - pickerror = self.picks[traceID]['spe'] - if np.isnan(pickerror) == True: - print "SPE is NaN for shot %s, traceID %s" % (self.getShotnumber(), traceID) - return pickerror - - def getPickError(self, traceID): - pickerror = abs(self.getEarliest(traceID) - self.getLatest(traceID)) / 2 - if np.isnan(pickerror) == True: - print("PE is NaN for shot %s, traceID %s" % (self.getShotnumber(), traceID)) - return pickerror - - def getStreamTraceIDs(self): - traceIDs = [] - for trace in self.traces: - traceIDs.append(int(trace.stats.channel)) - return traceIDs - - def getTraceIDlist(self): - ''' - Returns a list containing the traceIDs. - ''' - traceIDs = [] - if self.traceIDs == None: - traceIDs = self.getReceiverCoords().keys() - self.traceIDs = traceIDs - return self.traceIDs - - def getPickwindow(self, traceID): - try: - self.pwindow[traceID] - except KeyError as e: - print('no pickwindow for trace %s, set to %s' % (traceID, self.getCut())) - self.setPickwindow(traceID, self.getCut()) - return self.pwindow[traceID] - - def getSNR(self, traceID): - return self.snr[traceID] - - def getSNRthreshold(self, traceID): - return self.snrthreshold[traceID] - - # def getRecCoordlist(self): - # if self.recCoordlist is None: - # coordlist = open(self.getRecfile(), 'r').readlines() - # # print 'Reading receiver coordinates from %s' %(self.getRecfile()) - # self.recCoordlist = coordlist - # return self.recCoordlist - - # def getSrcCoordlist(self): - # if self.srcCoordlist is None: - # coordlist = open(self.getSourcefile(), 'r').readlines() - # # print 'Reading shot coordinates from %s' %(self.getSourcefile()) - # self.srcCoordlist = coordlist - # return self.srcCoordlist - - def getTimeArray(self, traceID): - return self.timeArray[traceID] - - def getHOScf(self, traceID): - ''' - Returns the higher order statistics characteristic function for a trace using pylot. - - :param: traceID - :type: int - - :param: cut, cut out a part of the trace (t_start, t_end) [s] - :type: tuple - - :param: t2, size of the moving window [s] - :type: float - - :param: order, order of the characteristic function - :type: int - ''' - return HOScf(self.getSingleStream(traceID), self.getCut(), - self.getTmovwind(), self.getOrder(), stealthMode=True) - - def getAICcf(self, traceID): - ''' - Returns the Akaike criterion for a trace using pylot and the higher order statistics characteristic function. - - :param: traceID - :type: int - - :param: cut, cut out a part of the trace (t_start, t_end) [s] - :type: tuple - - :param: t2, size of the moving window [s] - :type: float - - :param: order, order of the characteristic function - :type: int - ''' - - st_cf = Stream() - tr_cf = Trace() - tr_cf.data = self.getHOScf(traceID).getCF() - st_cf += tr_cf - return AICcf(st_cf, self.getCut(), self.getTmovwind(), stealthMode=True) - - def getSingleStream(self, traceID): ########## SEG2 / SEGY ? ########## - ''' - Returns a Stream with only one trace (instead of just one trace) because it is needed for pylot. - - :param: traceID - :type: int - ''' - # traces = [trace for trace in self.traces if int(trace.stats.seg2['CHANNEL_NUMBER']) == traceID] - traces = [trace for trace in self.traces if int(trace.stats.channel) == traceID] - if len(traces) == 1: - return Stream(traces) - self.setPick(traceID, None) - warnings.warn('ambigious or empty traceID: %s' % traceID) - - def setPickParameters(self, folm, method = 'hos', aicwindow = (10, 0)): - self.setFolm(folm) - self.setMethod(method) - self.setAicwindow(aicwindow) - - # def pickParallel(self): - # traceIDs = self.getTraceIDlist() - # picks = [] - # #picks = worker(self.pickTrace, traceIDs) - - # # for traceID, pick in picks: - # # self.setPick(traceID, pick) - - # for traceID in traceIDs: - # trID, pick = self.pickTrace(traceID) - # picks.append([trID, pick]) - # #self.setPick(traceID, pick) - # return picks - - def pickTrace(self, traceID): - ''' - Intitiate picking for a trace. - - :param: traceID - :type: int - - :param: cutwindow (equals HOScf 'cut' variable) - :type: tuple - - :param: t2 (equals HOScf t2 variable) - :type: float - - :param: order (equals HOScf 'order' variable) - :type: int - - :param: windowsize, window around the returned HOS picktime, to search for the AIC minumum - :type: 'tuple' - - :param: folm, fraction of local maximumm - :type: 'real' - - :param: HosAic, get hos or aic pick (can be 'hos'(default) or 'aic') - :type: 'string' - ''' - self.setDynPickwindow(traceID) - - hoscf = self.getHOScf(traceID) ### determination of both, HOS and AIC (need to change threshold-picker) ### - aiccf = self.getAICcf(traceID) - - self.timeArray[traceID] = hoscf.getTimeArray() - aiccftime, hoscftime = self.threshold(hoscf, aiccf, self.getAicwindow(), self.getPickwindow(traceID), self.getFolm()) - setHosAic = {'hos': hoscftime, - 'aic': aiccftime} - - if aiccftime < self.getPickwindow(traceID)[0] and 'aic' in self.getMethod(): - return 0 - - return setHosAic[self.getMethod()] - - def setEarllatepick(self, traceID, nfac=1.5): - tgap = self.getTgap() - tsignal = self.getTsignal() - tnoise = self.getPickIncludeRemoved(traceID) - tgap - - (self.picks[traceID]['epp'], - self.picks[traceID]['lpp'], - self.picks[traceID]['spe']) = earllatepicker(self.getSingleStream(traceID), - nfac, (tnoise, tgap, tsignal), - self.getPickIncludeRemoved(traceID), - stealth_mode=True) - - def threshold(self, hoscf, aiccf, windowsize, pickwindow, folm): - ''' - Threshold picker, using the local maximum in a pickwindow to find the time at - which a fraction of the local maximum is reached for the first time. - - :param: hoscf, Higher Order Statistics Characteristic Function - :type: 'Characteristic Function' - - :param: aiccf, Characteristic Function after Akaike - :type: 'Characteristic Function' - - :param: windowsize, window around the returned HOS picktime, to search for the AIC minumum - :type: 'tuple' - - :param: pickwindow [seconds] - :type: 'tuple' - - :param: cutwindow [seconds], cut a part of the trace as in Characteristic Function - :type: 'tuple' - - :param: folm, fraction of local maximum - :type: 'real' - ''' - hoscflist = list(hoscf.getCF()) - leftb = int(pickwindow[0] / self.getCut()[1] * len(hoscflist)) - rightb = int(pickwindow[1] / self.getCut()[1] * len(hoscflist)) - - threshold = folm * (max(hoscflist[leftb: rightb]) - min(hoscflist[leftb: rightb])) + min( - hoscflist[leftb: rightb]) # combination of local maximum and threshold - - m = leftb - - while hoscflist[m] < threshold: - m += 1 - - hoscftime = list(hoscf.getTimeArray())[m] - - lb = max(0, m - windowsize[0]) # if window exceeds t = 0 - aiccfcut = list(aiccf.getCF())[lb: m + windowsize[1]] - if len(aiccfcut) > 0: - n = aiccfcut.index(min(aiccfcut)) - else: - n = 0 - - m = lb + n - - aiccftime = list(hoscf.getTimeArray())[m] - - return aiccftime, hoscftime - - def getDistance(self, traceID): - ''' - Returns the distance of the receiver with the ID == traceID to the source location (shot location). - Uses getSrcLoc and getRecLoc. - - :param: traceID - :type: int - ''' - shotX, shotY, shotZ = self.getSrcLoc() - recX, recY, recZ = self.getRecLoc(traceID) - dist = np.sqrt((shotX - recX) ** 2 + (shotY - recY) ** 2 + (shotZ - recZ) ** 2) - - if np.isnan(dist) == True: - raise ValueError("Distance is NaN for traceID %s" % traceID) - - return dist - - def getRecLoc(self, traceID): ########## input FILENAME ########## - ''' - Returns the location (x, y, z) of the receiver with the ID == traceID. - RECEIVEIVER FILE MUST BE SET FIRST, TO BE IMPROVED. - - :param: traceID - :type: int - ''' - if traceID == 0: # artificial traceID 0 with pick at t = 0 - return self.getSrcLoc() - - return self.getReceiverCoords()[traceID] - - raise ValueError("traceID %s not found" % traceID) - - def getSrcLoc(self): ########## input FILENAME ########## - ''' - Returns the location (x, y, z) of the shot. - SOURCE FILE MUST BE SET FIRST, TO BE IMPROVED. - ''' - return self.getSourceCoords() - - def getTraceIDs4Dist(self, distance=0, - distancebin=(0, 0)): ########## nur fuer 2D benutzt, 'distance bins' ########## - ''' - Returns the traceID(s) for a certain distance between source and receiver. - Used for 2D Tomography. TO BE IMPROVED. - - :param: distance - :type: real - - :param: distancebin - :type: tuple - ''' - - traceID_list = [] - for trace in self.traces: - # traceID = int(trace.stats.seg2['CHANNEL_NUMBER']) - traceID = int(trace.stats.channel) - if distance != 0: - if self.getDistance(traceID) == distance: - traceID_list.append(traceID) - if distancebin[0] >= 0 and distancebin[1] > 0: - if distancebin[0] < self.getDistance(traceID) < distancebin[1]: - traceID_list.append(traceID) - - if len(traceID_list) > 0: - return traceID_list - - def setManualPicksFromFile(self, directory='picks'): - ''' - Read manual picks from *.pck file. - The * must be identical with the shotnumber. - ''' - if directory[-1] == '/': - filename = directory + str(self.getShotnumber()) + '.pck' - else: - filename = directory + '/' + str(self.getShotnumber()) + '.pck' - infile = open(filename, 'r') - mpicks = infile.readlines() - for line in mpicks: - if line.split()[0] == []: - continue - traceID, mpp, epp, lpp = line.split() - traceID = int(traceID) - if traceID in self.picks.keys(): - self.manualpicks[traceID] = {'mpp': float(mpp), - 'epp': float(epp), - 'lpp': float(lpp)} - if float(mpp) <= 0: - self.setManualPickFlag(traceID, 0) - else: - self.setManualPickFlag(traceID, 1) - - def setPick(self, traceID, pick): ########## siehe Kommentar ########## - if not traceID in self.picks.keys(): - self.picks[traceID] = {} - self.picks[traceID]['mpp'] = pick - self.picks[traceID]['flag'] = 1 - # ++++++++++++++ Block raus genommen, da Error beim 2ten Mal picken! (Ueberschreiben von erstem Pick!) - # if not self.picks.has_key(traceID): - # self.getPick(traceID) = picks - # else: - # raise KeyError('pick to be set more than once for traceID %s' % traceID) - - # def readParameter(self, parfile): - # parlist = open(parfile,'r').readlines() - - def removePick(self, traceID): - self.setPickFlag(traceID, 0) - - def setPickFlag(self, traceID, flag): - 'Set flag = 0 if pick is invalid, else flag = 1' - self.picks[traceID]['flag'] = flag - - def getPickFlag(self, traceID): - return self.picks[traceID]['flag'] - - def setManualPickFlag(self, traceID, flag): - 'Set flag = 0 if pick is invalid, else flag = 1' - self.manualpicks[traceID]['flag'] = flag - - def getManualPickFlag(self, traceID): - return self.manualpicks[traceID]['flag'] - - def setPickwindow(self, traceID, pickwindow): - self.pwindow[traceID] = pickwindow - - def setSNR(self, traceID): ########## FORCED HOS PICK ########## - ''' - Gets the SNR using pylot and then sets the SNR for the traceID. - - :param: traceID - :type: int - - :param: (tnoise, tgap, tsignal), as used in pylot SNR - ''' - from pylot.core.pick.utils import getSNR - - tgap = self.getTgap() - tsignal = self.getTsignal() - tnoise = self.getPick(traceID) - tgap - - self.snr[traceID] = getSNR(self.getSingleStream(traceID), (tnoise, tgap, tsignal), self.getPick(traceID)) - - def setSNRthreshold(self, traceID, snrthreshold): - self.snrthreshold[traceID] = snrthreshold - - def getDistArray4ttcPlot(self): ########## nur fuer 2D benoetigt ########## - ''' - Function to create a distance array for the plots. 2D only! X DIRECTION!! - ''' - distancearray = [] - - for traceID in self.picks.keys(): - if self.getRecLoc(traceID)[0] > self.getSrcLoc()[0]: - distancearray.append(self.getDistance(traceID)) - elif self.getRecLoc(traceID)[0] <= self.getSrcLoc()[0]: - distancearray.append((-1) * self.getDistance(traceID)) - - return distancearray - - def plot2dttc(self, ax=None): - ''' - Function to plot the traveltime curve for automated picks of a shot. 2d only! ATM: X DIRECTION!! - ''' - import matplotlib.pyplot as plt - plt.interactive('True') - picks = [] - - for traceID in self.picks.keys(): - picks.append(self.getPick(traceID)) - - if ax is None: - fig = plt.figure() - ax = fig.add_subplot(111) - - # shotnumbers = [shotnumbers for (shotnumbers, shotnames) in sorted(zip(shotnumbers, shotnames))] - plotarray = sorted(zip(self.getDistArray4ttcPlot(), picks)) - x = []; - y = [] - for point in plotarray: - x.append(point[0]) - y.append(point[1]) - ax.plot(x, y, 'r', label="Automatic Picks") - ax.text(0.5, 0.9, 'shot: %s' % self.getShotnumber(), transform=ax.transAxes - , horizontalalignment='center') - - def plotmanual2dttc(self, ax=None): - ''' - Function to plot the traveltime curve for manual picks of a shot. 2D only! - ''' - import matplotlib.pyplot as plt - plt.interactive('True') - manualpicktimesarray = [] - - for traceID in self.picks.keys(): - if not traceID in self.manualpicks.keys() or self.getManualPickFlag(traceID) == 0: - manualpicktimesarray.append(None) - else: - manualpicktimesarray.append(self.getManualPick(traceID)) - - if ax is None: - fig = plt.figure() - ax = fig.add_subplot(111) - - plotarray = sorted(zip(self.getDistArray4ttcPlot(), manualpicktimesarray)) - x = []; - y = [] - for point in plotarray: - x.append(point[0]) - y.append(point[1]) - ax.plot(x, y, 'b', label="Manual Picks") - - def plotTrace(self, traceID, plotSNR=True, lw=1): - fig = plt.figure() - ax = fig.add_subplot(111) - ax = self._drawStream(traceID, ax=ax) - - tgap = self.getTgap() - tsignal = self.getTsignal() - pick = self.getPick(traceID) - tnoise = pick - tgap - snr, snrdb, noiselevel = self.getSNR(traceID) - - ax.plot([0, tnoise], [noiselevel, noiselevel], 'm', linewidth=lw, label='noise level') - ax.plot([tnoise, pick], [noiselevel, noiselevel], 'g:', linewidth=lw, label='gap') - ax.plot([tnoise + tgap, pick + tsignal], [noiselevel * snr, noiselevel * snr], 'b', linewidth=lw, - label='signal level') - ax.legend() - ax.text(0.05, 0.9, 'SNR: %s' % snr, transform=ax.transAxes) - - def plot_traces(self, traceID, figure = None, buttons = True): - from matplotlib.widgets import Button - - def onclick(event): - self.setPick(traceID, event.xdata) - if self.getSNR(traceID)[0] > 1: - self.setEarllatepick(traceID) - self._drawStream(traceID, refresh=True) - self._drawCFs(traceID, folm, refresh=True) - fig.canvas.mpl_disconnect(self.traces4plot[traceID]['cid']) - plt.draw() - - def rmPick(event=None): - self.removePick(traceID) - self._drawStream(traceID, refresh=True) - self._drawCFs(traceID, folm, refresh=True) - plt.draw() - - def connectButton(event=None): - cid = fig.canvas.mpl_connect('button_press_event', onclick) - self.traces4plot[traceID]['cid'] = cid - - def cleanup(event): - self.traces4plot[traceID] = {} - - def addButtons(fig): - axb1 = fig.add_axes([0.15, 0.91, 0.05, 0.03]) - axb2 = fig.add_axes([0.22, 0.91, 0.05, 0.03]) - button1 = Button(axb1, 'repick', color='red', hovercolor='grey') - button1.on_clicked(connectButton) - button2 = Button(axb2, 'delete', color='green', hovercolor='grey') - button2.on_clicked(rmPick) - return axb1, axb2, button1, button2 - - folm = self.folm - - if figure == None: - fig = plt.figure() - else: - fig = figure - - ax1 = fig.add_subplot(2, 1, 1) - ax2 = fig.add_subplot(2, 1, 2, sharex=ax1) - - if buttons: - axb1, axb2, button1, button2 = addButtons(fig) - else: - axb1 = None - axb2 = None - button1 = None - button2 = None - - fig.canvas.mpl_connect('close_event', cleanup) - - self.traces4plot[traceID] = dict(fig=fig, ax1=ax1, ax2=ax2, axb1=axb1, axb2=axb2, button1=button1, - button2=button2, cid=None) - - self._drawStream(traceID) - self._drawCFs(traceID, folm) - - def _drawStream(self, traceID, refresh=False, ax=None): - from pylot.core.util.utils import full_range - from pylot.core.util.utils import prepTimeAxis - - stream = self.getSingleStream(traceID) - stime = full_range(stream)[0] - timeaxis = prepTimeAxis(stime, stream[0]) - timeaxis -= stime - - if ax is None: - ax = self.traces4plot[traceID]['ax1'] - - if refresh == True: - xlim, ylim = ax.get_xlim(), ax.get_ylim() - ax.clear() - if refresh == True: - ax.set_xlim(xlim) - ax.set_ylim(ylim) - - ax.set_title('Shot: %s, traceID: %s, pick: %s' - % (self.getShotnumber(), traceID, self.getPick(traceID))) - ax.plot(timeaxis, stream[0].data, 'k', label='trace') - ax.plot([self.getPick(traceID), self.getPick(traceID)], - [ax.get_ylim()[0], - ax.get_ylim()[1]], - 'r', label='most likely') - if self.getEarliest(traceID) is not None: - ax.plot([self.getEarliest(traceID), self.getEarliest(traceID)], - [ax.get_ylim()[0], - ax.get_ylim()[1]], - 'g:', label='earliest') - if self.getLatest(traceID) is not None: - ax.plot([self.getLatest(traceID), self.getLatest(traceID)], - [ax.get_ylim()[0], - ax.get_ylim()[1]], - 'b:', label='latest') - - ax.legend() - return ax - - def _drawCFs(self, traceID, folm=None, refresh=False): - hoscf = self.getHOScf(traceID) - aiccf = self.getAICcf(traceID) - ax = self.traces4plot[traceID]['ax2'] - - if refresh == True: - xlim, ylim = ax.get_xlim(), ax.get_ylim() - ax.clear() - if refresh == True: - ax.set_xlim(xlim) - ax.set_ylim(ylim) - - ax.plot(hoscf.getTimeArray(), hoscf.getCF(), 'b', label='HOS') - ax.plot(hoscf.getTimeArray(), aiccf.getCF(), 'g', label='AIC') - ax.plot([self.getPick(traceID), self.getPick(traceID)], - [ax.get_ylim()[0], - ax.get_ylim()[1]], - 'r', label='most likely') - if self.getEarliest(traceID) is not None: - ax.plot([self.getEarliest(traceID), self.getEarliest(traceID)], - [ax.get_ylim()[0], - ax.get_ylim()[1]], - 'g:', label='earliest') - if self.getLatest(traceID) is not None: - ax.plot([self.getLatest(traceID), self.getLatest(traceID)], - [ax.get_ylim()[0], - ax.get_ylim()[1]], - 'b:', label='latest') - if folm is not None: - ax.plot([0, self.getPick(traceID)], - [folm * max(hoscf.getCF()), folm * max(hoscf.getCF())], - 'm:', label='folm = %s' % folm) - ax.set_xlabel('Time [s]') - ax.legend() - - def plot3dttc(self, step=0.5, contour=False, plotpicks=False, method='linear', ax=None): - ''' - Plots a 3D 'traveltime cone' as surface plot by interpolating on a regular grid over the traveltimes, not yet regarding the vertical offset of the receivers. - - :param: step (optional), gives the stepsize for the interpolated grid. Default is 0.5 - :type: 'float' - - :param: contour (optional), plot contour plot instead of surface plot - :type: 'logical' - - :param: plotpicks (optional), plot the data points onto the interpolated grid - :type: 'logical' - - :param: method (optional), interpolation method; can be 'linear' (default) or 'cubic' - :type: 'string' - ''' - from scipy.interpolate import griddata - from matplotlib import cm - from mpl_toolkits.mplot3d import Axes3D - - x = [] - y = [] - z = [] - for traceID in self.picks.keys(): - if self.getPickFlag(traceID) != 0: - x.append(self.getRecLoc(traceID)[0]) - y.append(self.getRecLoc(traceID)[1]) - z.append(self.getPick(traceID)) - - xaxis = np.arange(min(x) + step, max(x), step) - yaxis = np.arange(min(y) + step, max(y), step) - xgrid, ygrid = np.meshgrid(xaxis, yaxis) - zgrid = griddata((x, y), z, (xgrid, ygrid), method=method) - - if ax == None: - fig = plt.figure() - ax = plt.axes(projection='3d') - - xsrc, ysrc, zsrc = self.getSrcLoc() - - if contour == True: - ax.contour3D(xgrid, ygrid, zgrid, 20) - else: - ax.plot_surface(xgrid, ygrid, zgrid, linewidth=0, cmap=cm.jet, vmin=min(z), vmax=max(z)) - ax.plot([xsrc], [ysrc], [self.getPick(0)], 'k*', markersize=20) # plot source location - ax.plot([xsrc], [ysrc], [self.getPick(0)], 'r*', markersize=15) # plot source location - - if plotpicks == True: - ax.plot(x, y, z, 'k.') - - def plotttc(self, method, *args): - plotmethod = {'2d': self.plot2dttc, '3d': self.plot3dttc} - - plotmethod[method](*args) - - def matshow(self, ax=None, step=0.5, method='linear', plotRec=True, annotations=True, colorbar=True, legend=True): - ''' - Plots a 2D matrix of the interpolated traveltimes. This needs less performance than plot3dttc - - :param: step (optional), gives the stepsize for the interpolated grid. Default is 0.5 - :type: 'float' - - :param: method (optional), interpolation method; can be 'linear' (default) or 'cubic' - :type: 'string' - - :param: plotRec (optional), plot the receiver positions (colored scatter plot, should not be - deactivated because there might be receivers that are not inside the interpolated area) - :type: 'logical' - - :param: annotations (optional), displays traceIDs as annotations - :type: 'logical' - ''' - from scipy.interpolate import griddata - from matplotlib import cm - cmap = cm.jet - - x = []; - xcut = [] - y = []; - ycut = [] - z = []; - zcut = [] - - for traceID in self.picks.keys(): - if self.getPickFlag(traceID) != 0: - x.append(self.getRecLoc(traceID)[0]) - y.append(self.getRecLoc(traceID)[1]) - z.append(self.getPick(traceID)) - if self.getPickFlag(traceID) == 0 and self.getPickIncludeRemoved(traceID) is not None: - xcut.append(self.getRecLoc(traceID)[0]) - ycut.append(self.getRecLoc(traceID)[1]) - zcut.append(self.getPickIncludeRemoved(traceID)) - - tmin = 0.8 * min(z) # 20% cushion for colorbar - tmax = 1.2 * max(z) - - xaxis = np.arange(min(x), max(x), step) - yaxis = np.arange(min(y), max(y), step) - xgrid, ygrid = np.meshgrid(xaxis, yaxis) - zgrid = griddata((x, y), z, (xgrid, ygrid), method='linear') - - if ax == None: - fig = plt.figure() - ax = plt.axes() - - count = 0 - ax.imshow(zgrid, extent=[min(x), max(x), min(y), max(y)], vmin=tmin, vmax=tmax, cmap=cmap, origin='lower', - alpha=0.85) - ax.text(0.5, 0.95, 'shot: %s' % self.getShotnumber(), transform=ax.transAxes - , horizontalalignment='center') - sc = ax.scatter(x, y, c=z, s=30, label='active traces', vmin=tmin, vmax=tmax, cmap=cmap, linewidths=1.5) - for xyz in zip(xcut, ycut, zcut): - x, y, z = xyz - count += 1 - if z > tmax: - z = 'w' - if count == 1: - label = 'inactive traces' - else: - label = None - ax.scatter(x, y, c=z, s=30, edgecolor='m', label=label, vmin=tmin, vmax=tmax, cmap=cmap, linewidths=1.5) - if colorbar == True: - cbar = plt.colorbar(sc) - cbar.set_label('Time [s]') - - if legend == True: - ax.legend() - ax.set_xlabel('X') - ax.set_ylabel('Y') - ax.plot(self.getSrcLoc()[0], self.getSrcLoc()[1], '*k', markersize=15) # plot source location - - if annotations == True: - for traceID in self.getTraceIDlist(): - if self.getPickFlag(traceID) is not 0: - ax.annotate(' %s' % traceID, xy=(self.getRecLoc(traceID)[0], self.getRecLoc(traceID)[1]), - fontsize='x-small', color='k') - else: - ax.annotate(' %s' % traceID, xy=(self.getRecLoc(traceID)[0], self.getRecLoc(traceID)[1]), - fontsize='x-small', color='r') - - plt.show() diff --git a/pylot/core/active/surveyPlotTools.py b/pylot/core/active/surveyPlotTools.py deleted file mode 100644 index d6303d79..00000000 --- a/pylot/core/active/surveyPlotTools.py +++ /dev/null @@ -1,537 +0,0 @@ -# -*- coding: utf-8 -*- -import matplotlib.pyplot as plt -import math -import numpy as np - -plt.interactive(True) - - -class regions(object): - ''' - A class used for manual inspection and processing of all picks for the user. - - Examples: - - regions.chooseRectangles(): - - lets the user choose several rectangular regions in the plot - - regions.plotTracesInActiveRegions(): - - creates plots (shot.plot_traces) for all traces in the active regions (i.e. chosen by e.g. chooseRectangles) - - regions.setAllActiveRegionsForDeletion(): - - highlights all shots in a the active regions for deletion - - regions.deleteAllMarkedPicks(): - - deletes the picks (pick flag set to 0) for all shots set for deletion - - regions.deselectSelection(number): - - deselects the region of number = number - - ''' - - def __init__(self, ax, cbar, survey, qt_interface = False): - self.ax = ax - self.cbar = cbar - self.cbv = 'log10SNR' - self._xlim0 = self.ax.get_xlim() - self._ylim0 = self.ax.get_ylim() - self._xlim = self.ax.get_xlim() - self._ylim = self.ax.get_ylim() - self.survey = survey - self.shot_dict = self.survey.getShotDict() - self._x0 = [] - self._y0 = [] - self._x1 = [] - self._y1 = [] - self._polyx = [] - self._polyy = [] - self._allpicks = None - self.shots_found = {} - self.shots_for_deletion = {} - self._generateList() - if not qt_interface: - self.buttons = {} - self._addButtons() - self.addTextfield() - self.drawFigure() - - def _generateList(self): - allpicks = [] - for shot in self.shot_dict.values(): - for traceID in shot.getTraceIDlist(): - allpicks.append((shot.getDistance(traceID), - shot.getPickIncludeRemoved(traceID), - shot.getShotnumber(), - traceID, - shot.getPickFlag(traceID))) - - allpicks.sort() - self._allpicks = allpicks - - def getShotDict(self): - return self.shot_dict - - def getShotsForDeletion(self): - return self.shots_for_deletion - - def _onselect_clicks(self, eclick, erelease): - '''eclick and erelease are matplotlib events at press and release''' - print 'region selected x0, y0 = (%3s, %3s), x1, y1 = (%3s, %3s)' % (eclick.xdata, - eclick.ydata, - erelease.xdata, - erelease.ydata) - x0 = min(eclick.xdata, erelease.xdata) - x1 = max(eclick.xdata, erelease.xdata) - y0 = min(eclick.ydata, erelease.ydata) - y1 = max(eclick.ydata, erelease.ydata) - - shots, numtraces = self.findTracesInShotDict((x0, x1), (y0, y1)) - self.printOutput('Found %d traces in rectangle: %s' % (numtraces, shots)) - key = self.getKey() - self.shots_found[key] = {'shots': shots, - 'selection': 'rect', - 'xvalues': (x0, x1), - 'yvalues': (y0, y1)} - self.markRectangle((x0, x1), (y0, y1), key) - self.disconnectRect() - - def _onselect_verts(self, verts): - x = verts[0][0] - y = verts[0][1] - self._polyx.append(x) - self._polyy.append(y) - - self.drawPolyLine() - - def _onpress(self, event): - if event.button == 3: - self.disconnectPoly() - self.printOutput('Disconnected polygon selection') - - def addTextfield(self, xpos=0, ypos=0.95, width=1, height=0.03): - ''' - Adds an ax for text output to the plot. - ''' - self.axtext = self.ax.figure.add_axes([xpos, - ypos, - width, - height]) - self.axtext.xaxis.set_visible(False) - self.axtext.yaxis.set_visible(False) - - def writeInTextfield(self, text=None): - self.setXYlim(self.ax.get_xlim(), self.ax.get_ylim()) - self.axtext.clear() - self.axtext.text(0.01, 0.5, text, verticalalignment='center', horizontalalignment='left') - self.drawFigure() - - def _addButtons(self): - xpos1 = 0.13 - xpos2 = 0.6 - dx = 0.06 - self.addButton('Rect', self.chooseRectangles, xpos=xpos1, color='white') - self.addButton('Poly', self.choosePolygon, xpos=xpos1 + dx, color='white') - self.addButton('Plot', self.plotTracesInActiveRegions, xpos=xpos1 + 2 * dx, color='yellow') - self.addButton('SNR', self.refreshLog10SNR, xpos=xpos1 + 3 * dx, color='cyan') - self.addButton('PE', self.refreshPickerror, xpos=xpos1 + 4 * dx, color='cyan') - self.addButton('SPE', self.refreshSPE, xpos=xpos1 + 5 * dx, color='cyan') - self.addButton('DesLst', self.deselectLastSelection, xpos=xpos2 + dx, color='green') - self.addButton('SelAll', self.setAllActiveRegionsForDeletion, xpos=xpos2 + 2 * dx) - self.addButton('DelAll', self.deleteAllMarkedPicks, xpos=xpos2 + 3 * dx, color='red') - - def addButton(self, name, action, xpos, ypos=0.91, color=None): - from matplotlib.widgets import Button - self.buttons[name] = {'ax': None, - 'button': None, - 'action': action, - 'xpos': xpos} - ax = self.ax.figure.add_axes([xpos, - ypos, - 0.05, - 0.03]) - button = Button(ax, name, color=color, hovercolor='grey') - button.on_clicked(action) - self.buttons[name]['ax'] = ax - self.buttons[name]['button'] = button - self.buttons[name]['xpos'] = xpos - - def getKey(self): - if self.shots_found.keys() == []: - key = 1 - else: - key = max(self.shots_found.keys()) + 1 - return key - - def drawPolyLine(self): - self.setXYlim(self.ax.get_xlim(), self.ax.get_ylim()) - x = self._polyx - y = self._polyy - if len(x) >= 2 and len(y) >= 2: - self.ax.plot(x[-2:], y[-2:], 'k', alpha=0.1) - self.drawFigure() - - def drawLastPolyLine(self): - self.setXYlim(self.ax.get_xlim(), self.ax.get_ylim()) - x = self._polyx - y = self._polyy - if len(x) >= 2 and len(y) >= 2: - self.ax.plot((x[-1], x[0]), (y[-1], y[0]), 'k', alpha=0.1) - self.drawFigure() - - def finishPolygon(self): - self.drawLastPolyLine() - x = self._polyx - y = self._polyy - self._polyx = []; - self._polyy = [] - - key = self.getKey() - self.markPolygon(x, y, key=key) - - shots, numtraces = self.findTracesInPoly(x, y) - self.shots_found[key] = {'shots': shots, - 'selection': 'poly', - 'xvalues': x, - 'yvalues': y} - self.printOutput('Found %d traces in polygon: %s' % (numtraces, shots)) - - def printOutput(self, text): - print text - self.writeInTextfield(text) - - def chooseRectangles(self, event=None): - ''' - Activates matplotlib widget RectangleSelector. - ''' - from matplotlib.widgets import RectangleSelector - if hasattr(self, '_cidPoly'): - self.disconnectPoly() - self.printOutput('Select rectangle is active. Press and hold left mousebutton.') - self._cidRect = None - self._cidRect = self.ax.figure.canvas.mpl_connect('button_press_event', self._onpress) - self._rectangle = RectangleSelector(self.ax, self._onselect_clicks) - return self._rectangle - - def choosePolygon(self, event=None): - ''' - Activates matplotlib widget LassoSelector. - ''' - from matplotlib.widgets import LassoSelector - if hasattr(self, '_cidRect'): - self.disconnectRect() - self.printOutput('Select polygon is active. Add points with leftclick. Finish with rightclick.') - self._cidPoly = None - self._cidPoly = self.ax.figure.canvas.mpl_connect('button_press_event', self._onpress) - self._lasso = LassoSelector(self.ax, self._onselect_verts) - return self._lasso - - def disconnectPoly(self, event=None): - if not hasattr(self, '_cidPoly'): - self.printOutput('no poly selection found') - return - self.ax.figure.canvas.mpl_disconnect(self._cidPoly) - del self._cidPoly - self.finishPolygon() - self._lasso.disconnect_events() - print 'disconnected poly selection\n' - - def disconnectRect(self, event=None): - if not hasattr(self, '_cidRect'): - self.printOutput('no rectangle selection found') - return - self.ax.figure.canvas.mpl_disconnect(self._cidRect) - del self._cidRect - self._rectangle.disconnect_events() - print 'disconnected rectangle selection\n' - - def deselectLastSelection(self, event=None): - if self.shots_found.keys() == []: - self.printOutput('No selection found.') - return - key = max(self.shots_found.keys()) - self.deselectSelection(key) - self.refreshFigure() - - def deselectSelection(self, key, color='green', alpha=0.1): - if key not in self.shots_found.keys(): - self.printOutput('No selection found.') - return - if color is not None: - if self.shots_found[key]['selection'] == 'rect': - self.markRectangle(self.shots_found[key]['xvalues'], - self.shots_found[key]['yvalues'], - key=key, color=color, alpha=alpha, - linewidth=1) - elif self.shots_found[key]['selection'] == 'poly': - self.markPolygon(self.shots_found[key]['xvalues'], - self.shots_found[key]['yvalues'], - key=key, color=color, alpha=alpha, - linewidth=1) - value = self.shots_found.pop(key) - self.printOutput('Deselected selection number %d' % key) - - def findTracesInPoly(self, x, y, picks='normal', highlight=True): - def dotproduct(v1, v2): - return sum((a * b for a, b in zip(v1, v2))) - - def getlength(v): - return math.sqrt(dotproduct(v, v)) - - def getangle(v1, v2): - return np.rad2deg(math.acos(dotproduct(v1, v2) / (getlength(v1) * getlength(v2)))) - - def insidePoly(x, y, pickX, pickY): - angle = 0 - epsilon = 1e-07 - for index in range(len(x)): - xval1 = x[index - 1]; - yval1 = y[index - 1] - xval2 = x[index]; - yval2 = y[index] - angle += getangle([xval1 - pickX, yval1 - pickY], [xval2 - pickX, yval2 - pickY]) - if 360 - epsilon <= angle <= 360 + epsilon: ### IMPROVE THAT?? - return True - - if len(x) == 0 or len(y) == 0: - self.printOutput('No polygon defined.') - return - - shots_found = {}; - numtraces = 0 - x0 = min(x); - x1 = max(x) - y0 = min(y); - y1 = max(y) - - shots, numtracesrect = self.findTracesInShotDict((x0, x1), (y0, y1), highlight=False) - for shotnumber in shots.keys(): - shot = self.shot_dict[shotnumber] - for traceID in shots[shotnumber]: - if shot.getPickFlag(traceID) is not 0: - pickX = shot.getDistance(traceID) - pickY = shot.getPick(traceID) - if insidePoly(x, y, pickX, pickY): - if shotnumber not in shots_found.keys(): - shots_found[shotnumber] = [] - shots_found[shotnumber].append(traceID) - if highlight == True: - self.highlightPick(shot, traceID) - numtraces += 1 - - self.drawFigure() - return shots_found, numtraces - - def findTracesInShotDict(self, (x0, x1), (y0, y1), picks='normal', highlight=True): - ''' - Returns traces corresponding to a certain area in the plot with all picks over the distances. - ''' - shots_found = {}; - numtraces = 0 - if picks == 'normal': - pickflag = 0 - elif picks == 'includeCutOut': - pickflag = None - - for line in self._allpicks: - dist, pick, shotnumber, traceID, flag = line - if flag == pickflag: continue ### IMPROVE THAT - if (x0 <= dist <= x1 and y0 <= pick <= y1): - if shotnumber not in shots_found.keys(): - shots_found[shotnumber] = [] - shots_found[shotnumber].append(traceID) - if highlight == True: - self.highlightPick(self.shot_dict[shotnumber], traceID) - numtraces += 1 - - self.drawFigure() - return shots_found, numtraces - - def highlightPick(self, shot, traceID, annotations=True): - ''' - Highlights a single pick for a shot(object)/shotnumber and traceID. - If annotations == True: Displays shotnumber and traceID in the plot. - ''' - if type(shot) == int: - shot = self.survey.getShotDict()[shot] - - if shot.getPickFlag(traceID) is 0: - return - - self.ax.scatter(shot.getDistance(traceID), shot.getPick(traceID), s=50, marker='o', facecolors='none', - edgecolors='m', alpha=1) - if annotations == True: - self.ax.annotate(s='s%s|t%s' % (shot.getShotnumber(), traceID), - xy=(shot.getDistance(traceID), shot.getPick(traceID)), fontsize='xx-small') - - def highlightAllActiveRegions(self): - ''' - Highlights all picks in all active regions. - ''' - for key in self.shots_found.keys(): - for shotnumber in self.shots_found[key]['shots'].keys(): - for traceID in self.shots_found[key]['shots'][shotnumber]: - self.highlightPick(self.shot_dict[shotnumber], traceID) - self.drawFigure() - - def plotTracesInActiveRegions(self, event=None, keys='all', maxfigures=20, qt = False): - ''' - Plots all traces in the active region or for all specified keys. - - :param: keys - :type: int or list - - :param: maxfigures, maximum value of figures opened - :type: int - ''' - if qt: - from pylot.core.active.gui import Repicking - - count = 0 - if keys == 'all': - keys = self.shots_found.keys() - elif type(keys) == int: - keys = [keys] - - if len(self.shots_found) > 0: - for shot in self.shot_dict.values(): - for key in keys: - for shotnumber in self.shots_found[key]['shots']: - if shot.getShotnumber() == shotnumber: - for traceID in self.shots_found[key]['shots'][shotnumber]: - count += 1 - if count > maxfigures: - print 'Maximum number of figures (%s) reached. %sth figure was not opened.' % ( - maxfigures, count) - break - shot.plot_traces(traceID) - else: - self.printOutput('No picks defined in that region(s)') - - def setAllActiveRegionsForDeletion(self, event=None): - keys = [] - for key in self.shots_found.keys(): - keys.append(key) - self.setRegionForDeletion(keys) - - def setRegionForDeletion(self, keys): - if type(keys) == int: - keys = [keys] - - for key in keys: - for shotnumber in self.shots_found[key]['shots'].keys(): - if shotnumber not in self.shots_for_deletion: - self.shots_for_deletion[shotnumber] = [] - for traceID in self.shots_found[key]['shots'][shotnumber]: - if traceID not in self.shots_for_deletion[shotnumber]: - self.shots_for_deletion[shotnumber].append(traceID) - self.deselectSelection(key, color='red', alpha=0.2) - - self.deselectSelection(key, color='red', alpha=0.2) - - self.printOutput('Set region(s) %s for deletion' % keys) - - def markAllActiveRegions(self): - for key in self.shots_found.keys(): - if self.shots_found[key]['selection'] == 'rect': - self.markRectangle(self.shots_found[key]['xvalues'], - self.shots_found[key]['yvalues'], key=key) - if self.shots_found[key]['selection'] == 'poly': - self.markPolygon(self.shots_found[key]['xvalues'], - self.shots_found[key]['yvalues'], key=key) - - def markRectangle(self, (x0, x1), (y0, y1), key=None, color='grey', alpha=0.1, linewidth=1): - ''' - Mark a rectangular region on the axes. - ''' - from matplotlib.patches import Rectangle - self.ax.add_patch(Rectangle((x0, y0), x1 - x0, y1 - y0, alpha=alpha, facecolor=color, linewidth=linewidth)) - if key is not None: - self.ax.text(x0 + (x1 - x0) / 2, y0 + (y1 - y0) / 2, str(key)) - self.drawFigure() - - def markPolygon(self, x, y, key=None, color='grey', alpha=0.1, linewidth=1): - from matplotlib.patches import Polygon - poly = Polygon(np.array(zip(x, y)), color=color, alpha=alpha, lw=linewidth) - self.ax.add_patch(poly) - if key is not None: - self.ax.text(min(x) + (max(x) - min(x)) / 2, min(y) + (max(y) - min(y)) / 2, str(key)) - self.drawFigure() - - def clearShotsForDeletion(self): - ''' - Clears the list of shots marked for deletion. - ''' - self.shots_for_deletion = {} - print('Cleared all shots that were set for deletion.') - - def getShotsForDeletion(self): - return self.shots_for_deletion - - def deleteAllMarkedPicks(self, event=None): - ''' - Deletes all shots set for deletion. - ''' - if len(self.getShotsForDeletion()) is 0: - self.printOutput('No shots set for deletion.') - return - - for shot in self.getShotDict().values(): - for shotnumber in self.getShotsForDeletion(): - if shot.getShotnumber() == shotnumber: - for traceID in self.getShotsForDeletion()[shotnumber]: - shot.removePick(traceID) - print "Deleted the pick for traceID %s on shot number %s" % (traceID, shotnumber) - self.clearShotsForDeletion() - self.refreshFigure() - - def highlightPicksForShot(self, shot, annotations=False): - ''' - Highlight all picks for a given shot. - ''' - if type(shot) is int: - shot = self.survey.getShotDict()[shotnumber] - - for traceID in shot.getTraceIDlist(): - if shot.getPickFlag(traceID) is not 0: - self.highlightPick(shot, traceID, annotations) - - self.drawFigure() - - def setXYlim(self, xlim, ylim): - self._xlim, self._ylim = xlim, ylim - - def refreshLog10SNR(self, event=None): - cbv = 'log10SNR' - self.cbv = cbv - self.refreshFigure(self, colorByVal=cbv) - - def refreshPickerror(self, event=None): - cbv = 'pickerror' - self.cbv = cbv - self.refreshFigure(self, colorByVal=cbv) - - def refreshSPE(self, event=None): - cbv = 'spe' - self.cbv = cbv - self.refreshFigure(self, colorByVal=cbv) - - def refreshFigure(self, event=None, colorByVal=None): - if colorByVal == None: - colorByVal = self.cbv - else: - self.cbv = colorByVal - self.printOutput('Refreshing figure...') - self.ax.clear() - self.ax = self.survey.plotAllPicks(ax=self.ax, cbar=self.cbar, refreshPlot=True, colorByVal=colorByVal) - self.setXYlim(self.ax.get_xlim(), self.ax.get_ylim()) - self.markAllActiveRegions() - self.highlightAllActiveRegions() - self.drawFigure() - self.printOutput('Done!') - - def drawFigure(self, resetAxes=True): - if resetAxes == True: - self.ax.set_xlim(self._xlim) - self.ax.set_ylim(self._ylim) - self.ax.figure.canvas.draw() - diff --git a/pylot/core/active/surveyUtils.py b/pylot/core/active/surveyUtils.py deleted file mode 100644 index 3d19650c..00000000 --- a/pylot/core/active/surveyUtils.py +++ /dev/null @@ -1,293 +0,0 @@ -from __future__ import print_function -import numpy as np - -def readParameters(parfile, parameter): - """ - - :param parfile: - :param parameter: - :return: - """ - from ConfigParser import ConfigParser - parameterConfig = ConfigParser() - parameterConfig.read('parfile') - - value = parameterConfig.get('vars', parameter).split('\t')[0] - - return value - - -def fitSNR4dist(shot_dict, shiftdist=30, shiftSNR=100): - """ - Approach to fit the decreasing SNR with wave travel distance. - - :param shot_dict: dictionary containing Seismicshot objects (e.g. survey.getShotDict()) - :param shiftdist: shift compensating curve by a certain distance to the left - :param shiftSNR: shift compensating curve by a certain SNR value to the bottom - :return: - """ - import numpy as np - dists = [] - picks = [] - snrs = [] - snr_sqrt_inv = [] - snrthresholds = [] - snrBestFit = [] - for shot in shot_dict.values(): - for traceID in shot.getTraceIDlist(): - if shot.getSNR(traceID)[0] >= 1: - dists.append(shot.getDistance(traceID)) - picks.append(shot.getPickIncludeRemoved(traceID)) - snrs.append(shot.getSNR(traceID)[0]) - snr_sqrt_inv.append(1 / np.sqrt(shot.getSNR(traceID)[0])) - fit = np.polyfit(dists, snr_sqrt_inv, 1) - fit_fn = np.poly1d(fit) - for dist in dists: - snrBestFit.append((1 / (fit_fn(dist) ** 2))) - dist += shiftdist - snrthresholds.append((1 / (fit_fn(dist) ** 2)) - shiftSNR * np.exp(-0.05 * dist)) - plotFittedSNR(dists, snrthresholds, snrs, snrBestFit) - return fit_fn #### ZU VERBESSERN, sollte fertige funktion wiedergeben - - -def plotFittedSNR(dists, snrthresholds, snrs, snrBestFit): - """ - - :param dists: - :param snrthresholds: - :param snrs: - :param snrBestFit: - :return: - """ - import matplotlib.pyplot as plt - plt.interactive(True) - fig = plt.figure() - plt.plot(dists, snrs, 'b.', markersize=2.0, label='SNR values') - dists.sort() - snrthresholds.sort(reverse=True) - snrBestFit.sort(reverse=True) - plt.plot(dists, snrthresholds, 'r', markersize=1, label='Fitted threshold') - plt.plot(dists, snrBestFit, 'k', markersize=1, label='Best fitted curve') - plt.xlabel('Distance[m]') - plt.ylabel('SNR') - plt.legend() - - -def setDynamicFittedSNR(shot_dict, shiftdist=30, shiftSNR=100, p1=0.004, p2=-0.0007): - """ - Set SNR values for a dictionary containing Seismicshots (e.g. survey.getShotDict()) - by parameters calulated from fitSNR4dist. - - :param shot_dict: - :type shot_dict: dict - :param shiftdist: - :type shiftdist: int - :param shiftSNR: - :type shiftSNR: int - :param p1: - :type p1: float - :param p2: - :type p2: float - :return: - """ - minSNR = 2.5 - # fit_fn = fitSNR4dist(shot_dict) - fit_fn = get_fit_fn(p1, p2) - for shot in shot_dict.values(): - for traceID in shot.getTraceIDlist(): ### IMPROVE - dist = shot.getDistance(traceID) + shiftdist - snrthreshold = snr_fit_func(fit_fn, dist, shiftSNR) - if snrthreshold < minSNR: - print('WARNING: SNR threshold %s lower %s. Set SNR threshold to %s.' - % (snrthreshold, minSNR, minSNR)) - shot.setSNRthreshold(traceID, minSNR) - else: - shot.setSNRthreshold(traceID, snrthreshold) - print("setDynamicFittedSNR: Finished setting of fitted SNR-threshold.\n" - "Parameters: ShiftDist = %s, ShiftSNR = %s, p1 = %s, p2 = %s" - %(shiftdist, shiftSNR, p1, p2)) - -def snr_fit_func(fit_fn, dist, shiftSNR): - snrthreshold = (1 / (fit_fn(dist) ** 2)) - shiftSNR * np.exp(-0.05 * dist) - return snrthreshold - -def get_fit_fn(p1, p2): - return np.poly1d([p1, p2]) - -def setConstantSNR(shot_dict, snrthreshold=2.5): - """ - Set a constant SNR value to all Seismicshots in a dictionary (e.g. survey.getShotDict()). - - :param shot_dict: - :param snrthreshold: - :return: - """ - for shot in shot_dict.values(): - for traceID in shot.getTraceIDlist(): - shot.setSNRthreshold(traceID, snrthreshold) - print("setConstantSNR: Finished setting of SNR threshold to a constant value of %s" % snrthreshold) - - -def findTracesInRanges(shot_dict, distancebin, pickbin): - ''' - Returns traces corresponding to a certain area in a plot with all picks over the distances. - - :param: shot_dict, dictionary containing all shots that are used - :type: dictionary - - :param: distancebin - :type: tuple, (dist1[m], dist2[m]) - - :param: pickbin - :type: tuple, (t1[s], t2[s]) - - ''' - shots_found = {} - for shot in shot_dict.values(): - if shot.getTraceIDs4Dist(distancebin=distancebin) is not None: - for traceID in shot.getTraceIDs4Dist(distancebin=distancebin): - if pickbin[0] < shot.getPick(traceID) < pickbin[1]: - if shot.getShotnumber() not in shots_found.keys(): - shots_found[shot.getShotnumber()] = [] - shots_found[shot.getShotnumber()].append(traceID) - - return shots_found - - -def cleanUp(survey): - """ - Cleans up a Survey object by removing frontend information - which can not be saved in the pickle format. - """ - for shot in survey.data.values(): - shot.traces4plot = {} - -def plotScatterStats4Shots(survey, variable, ax = None, twoDim = False): - """ - Statistics, scatter plot. - - :param survey: - :param variable: can be 'mean SNR', 'median SNR', 'mean SPE', 'median SPE', or 'picked traces' - :return: - """ - import matplotlib.pyplot as plt - import numpy as np - statsShot = {} - x = [] - y = [] - value = [] - for shot in survey.data.values(): - for traceID in shot.getTraceIDlist(): - if not shot in statsShot.keys(): - statsShot[shot] = {'x': shot.getSrcLoc()[0], - 'y': shot.getSrcLoc()[1], - 'SNR': [], - 'SPE': [], - 'picked traces': 0} - - SNR = shot.getSNR(traceID)[0] - if not SNR == np.inf: - statsShot[shot]['SNR'].append(SNR) - if shot.getPickFlag(traceID) == 1: - statsShot[shot]['picked traces'] += 1 - statsShot[shot]['SPE'].append(shot.getSymmetricPickError(traceID)) - - for shot in statsShot.keys(): - statsShot[shot]['mean SNR'] = np.mean(statsShot[shot]['SNR']) - statsShot[shot]['median SNR'] = np.median(statsShot[shot]['SNR']) - statsShot[shot]['mean SPE'] = np.mean(statsShot[shot]['SPE']) - statsShot[shot]['median SPE'] = np.median(statsShot[shot]['SPE']) - - for shot in statsShot.keys(): - x.append(statsShot[shot]['x']) - y.append(statsShot[shot]['y']) - value.append(statsShot[shot][variable]) - - if ax is None: - fig = plt.figure() - ax = fig.add_subplot(111) - - size = [] - for val in value: - size.append(100 * val / max(value)) - - sc = ax.scatter(x, y, s=size, c=value) - ax.text(0.5, 1.05,'Plot of all shots', - horizontalalignment='center', verticalalignment='center', - transform=ax.transAxes) - ax.set_xlabel('X [m]') - ax.set_ylabel('Y [m]') - if not twoDim: - ax.set_aspect('equal') - cbar = ax.figure.colorbar(sc) - cbar.set_label(variable) - - for shot in statsShot.keys(): - ax.annotate(' %s' % shot.getShotnumber(), xy=(shot.getSrcLoc()[0], shot.getSrcLoc()[1]), - fontsize='x-small', color='k') - - -def plotScatterStats4Receivers(survey, variable, ax = None, twoDim = False): - """ - Statistics, scatter plot. - - :param survey: - :param variable: can be 'mean SNR', 'median SNR', 'mean SPE', 'median SPE', or 'picked traces' - :return: - """ - import matplotlib.pyplot as plt - import numpy as np - statsRec = {} - x = [] - y = [] - value = [] - for shot in survey.data.values(): - for traceID in shot.getTraceIDlist(): - if not traceID in statsRec.keys(): - statsRec[traceID] = {'x': shot.getRecLoc(traceID)[0], - 'y': shot.getRecLoc(traceID)[1], - 'SNR': [], - 'SPE': [], - 'picked traces': 0} - - SNR = shot.getSNR(traceID)[0] - if not SNR == np.inf: - statsRec[traceID]['SNR'].append(SNR) - if shot.getPickFlag(traceID) == 1: - statsRec[traceID]['picked traces'] += 1 - statsRec[traceID]['SPE'].append(shot.getSymmetricPickError(traceID)) - - for traceID in statsRec.keys(): - statsRec[traceID]['mean SNR'] = np.mean(statsRec[traceID]['SNR']) - statsRec[traceID]['median SNR'] = np.median(statsRec[traceID]['SNR']) - statsRec[traceID]['mean SPE'] = np.mean(statsRec[traceID]['SPE']) - statsRec[traceID]['median SPE'] = np.median(statsRec[traceID]['SPE']) - - for traceID in statsRec.keys(): - x.append(statsRec[traceID]['x']) - y.append(statsRec[traceID]['y']) - value.append(statsRec[traceID][variable]) - - if ax is None: - fig = plt.figure() - ax = fig.add_subplot(111) - - size = [] - for val in value: - size.append(100 * val / max(value)) - - sc = ax.scatter(x, y, s=size, c=value) - ax.text(0.5, 1.05,'Plot of all receivers', - horizontalalignment='center', verticalalignment='center', - transform=ax.transAxes) - ax.set_xlabel('X [m]') - ax.set_ylabel('Y [m]') - if not twoDim: - ax.set_aspect('equal') - cbar = ax.figure.colorbar(sc) - cbar.set_label(variable) - - shot = survey.data.values()[0] - for traceID in shot.getTraceIDlist(): - ax.annotate(' %s' % traceID, xy=(shot.getRecLoc(traceID)[0], shot.getRecLoc(traceID)[1]), - fontsize='x-small', color='k') From ae0cc5e1600845ef5ff86626ff68654075707620 Mon Sep 17 00:00:00 2001 From: Sebastian Wehling-Benatelli Date: Mon, 3 Oct 2016 08:54:09 +0200 Subject: [PATCH 3/5] [remove] moved correlation code from PyLoT to the seisobs utils scope --- README | 35 ---------- README.md | 9 ++- pylot/core/analysis/coinctimes.py | 55 --------------- pylot/core/analysis/correlation.py | 107 ----------------------------- pylot/core/analysis/trigger.py | 50 -------------- 5 files changed, 7 insertions(+), 249 deletions(-) delete mode 100644 README delete mode 100644 pylot/core/analysis/coinctimes.py delete mode 100644 pylot/core/analysis/correlation.py delete mode 100644 pylot/core/analysis/trigger.py diff --git a/README b/README deleted file mode 100644 index c5452495..00000000 --- a/README +++ /dev/null @@ -1,35 +0,0 @@ -PyLoT - -version: 0.1 - -The Python picking and Localisation Tool - -This python library contains a graphical user interfaces for picking -seismic phases. This software needs ObsPy (http://github.com/obspy/obspy/wiki) -and the PySide Qt4 bindings for python to be installed first. - -PILOT has originally been developed in Mathworks' MatLab. In order to -distribute PILOT without facing portability problems, it has been decided -to redevelop the software package in Python. The great work of the ObsPy -group allows easy handling of a bunch of seismic data and PyLoT will -benefit a lot compared to the former MatLab version. - -The development of PyLoT is part of the joint research project MAGS2. - -staff: -====== - -original author(s): L. Kueperkoch, S. Wehling-Benatelli, M. Bischoff (PILOT) - -developer(s): S. Wehling-Benatelli, L. Kueperkoch, K. Olbert, M. Bischoff, - C. Wollin, M. Rische - -others: A. Bruestle, T. Meier, W. Friederich - -release notes: -============== - - - -October 2013 - diff --git a/README.md b/README.md index 36643ead..b54f8166 100644 --- a/README.md +++ b/README.md @@ -22,14 +22,19 @@ staff: original author(s): L. Kueperkoch, S. Wehling-Benatelli, M. Bischoff (PILOT) developer(s): S. Wehling-Benatelli, L. Kueperkoch, K. Olbert, M. Bischoff, - C. Wollin, M. Rische + C. Wollin, M. Rische, M. Paffrath others: A. Bruestle, T. Meier, W. Friederich release notes: ============== +### Features + +- consistent manual phase picking through: + 1. predefined SNR dependant zoom level + 2. -October 2016 \ No newline at end of file +October 2016 diff --git a/pylot/core/analysis/coinctimes.py b/pylot/core/analysis/coinctimes.py deleted file mode 100644 index 9b41b0c3..00000000 --- a/pylot/core/analysis/coinctimes.py +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -from obspy.core import read -from obspy.signal.trigger import coincidenceTrigger - - -class CoincidenceTimes(object): - def __init__(self, st, comp='Z', coinum=4, sta=1., lta=10., on=5., off=1.): - _type = 'recstalta' - self.coinclist = self.createCoincTriggerlist(data=st, trigcomp=comp, - coinum=coinum, sta=sta, - lta=lta, trigon=on, - trigoff=off, type=_type) - - def __str__(self): - n = 1 - out = '' - for time in self.getCoincTimes(): - out += 'event no. {0}: starttime is {1}\n'.format(n, time) - n += 1 - return out - - def getCoincTimes(self): - timelist = [] - for info in self.getCoincList(): - timelist.append(info['time']) - - return timelist - - def getCoincList(self): - return self.coinclist - - def createCoincTriggerlist(self, data, trigcomp, coinum, sta, lta, - trigon, trigoff, type): - ''' - uses a coincidence trigger to detect all events in the given - dataset - ''' - - triggerlist = coincidenceTrigger(type, trigon, trigoff, - data.select(component=trigcomp), - coinum, sta=sta, lta=lta) - return triggerlist - - -def main(): - data = read('/data/SDS/2014/1A/ZV??/?H?.D/*.365') - data.filter(type='bandpass', freqmin=5., freqmax=30.) - coincs = CoincidenceTimes(data) - print(coincs) - - -if __name__ == '__main__': - main() diff --git a/pylot/core/analysis/correlation.py b/pylot/core/analysis/correlation.py deleted file mode 100644 index 2cf97231..00000000 --- a/pylot/core/analysis/correlation.py +++ /dev/null @@ -1,107 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -import numpy as np - - -def crosscorrsingle(wf1, wf2, taumax): - ''' - Calculates the crosscorrelation between two waveforms with a defined maximum timedifference. - :param wf1: first waveformdata - :type wf1: list - :param wf2: second waveformdata - :type wf2: list - :param taumax: maximum time difference between waveforms - :type taumax: positive integer - :return: returns the crosscorrelation funktion 'c' and the lagvector 'l' - :rtype: c and l are lists - ''' - N = len(wf1) - c = np.zeros(2 * taumax - 1) - l = np.zeros(2 * taumax - 1) - for tau in range(taumax): - Cxyplus = 0 - Cxyminus = 0 - for n in range(N - tau): - Cxy1plus = wf1[n] * wf2[n + tau] - Cxy1minus = wf1[n + tau] * wf2[n] - Cxyplus = Cxyplus + Cxy1plus - Cxyminus = Cxyminus + Cxy1minus - - c[(taumax - 1) - tau] = Cxyminus - c[(taumax - 1) + tau] = Cxyplus - l[(taumax - 1) - tau] = -tau - l[(taumax - 1) + tau] = tau - return c, l - - -def crosscorrnormcalc(weights, wfs): - ''' - crosscorrnormcalc - function that calculates the normalization for the - cross correlation carried out by 'wfscrosscorr' - :param weights: weighting factors for the single components - :type weights: tuple - :param wfs: tuple of `~numpy.array` object containing waveform data - :type wfs: tuple - :return: a floating point number yielding the by 'weights' weighted energy - of the waveforms in 'wfs' - :rtype: float - ''' - - # check if the parameters are of the right type - if not isinstance(weights, tuple): - raise TypeError("type of 'weight' should be 'tuple', but is {0}".format( - type(weights))) - if not isinstance(wfs, tuple): - raise TypeError( - "type of parameter 'wfs' should be 'tuple', but is {0}".format( - type(wfs))) - sqrsumwfs = 0. - for n, wf in enumerate(wfs): - sqrsumwf = np.sum(weights[n] ** 2. * wf ** 2.) - sqrsumwfs += sqrsumwf - return np.sqrt(sqrsumwfs) - - -def wfscrosscorr(weights, wfs, taumax): - ''' - wfscrosscorr - function that calculates successive cross-correlations from a set of waveforms stored in a matrix - - base formula is: - C(i)=SUM[p=1:nComponent](eP(p)*(SUM[n=1:N]APp(x,n)*APp(y,n+i)))/(SQRT(SUM[p=1:nComponent]eP(p)^2*(SUM[n=1:N](APp(x,n)^2)))*SQRT(SUM[p=1:nComponent]eP(p)^2*(SUM[n=1:N]APp(y,n)^2))) - whereas - nComponent is the number of components - N is the number of samples - i is the lag-index - - input: - APp rowvectors containing the waveforms of each component p for which the cross-correlation is calculated - tPp rowvectros containing times - eP vector containing the weighting factors for the components (maxsize = [1x3]) - - output: - C cross-correlation function - L lag-vector - - author(s): - - SWB 26.01.2010 as arranged with Thomas Meier and Monika Bischoff - - :param weights: weighting factors for the single components - :type weights: tuple - :param wfs: tuple of `~numpy.array` object containing waveform data - :type wfs: tuple - :param taumax: maximum time difference - :type taumax: positive integer - :return: returns cross correlation function normalized by the waveform energy - ''' - - ccnorm = 0. - ccnorm = crosscorrnormcalc(weights, wfs[0]) - ccnorm *= crosscorrnormcalc(weights, wfs[1]) - - c = 0. - for n in range(len(wfs)): - cc, l = crosscorrsingle(wfs[0][n], wfs[1][n], taumax) - c += cc - return c / ccnorm, l diff --git a/pylot/core/analysis/trigger.py b/pylot/core/analysis/trigger.py deleted file mode 100644 index a1e61b36..00000000 --- a/pylot/core/analysis/trigger.py +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -from obspy.signal.trigger import recursive_sta_lta, trigger_onset - - -def createSingleTriggerlist(st, station='ZV01', trigcomp='Z', stalta=(1, 10), - trigonoff=(6, 1)): - ''' - uses a single-station trigger to create a triggerlist for this station - :param st: obspy stream - :type st: - :param station: station name to get triggers for (optional, default = ZV01) - :type station: str - :param trigcomp: (optional, default = Z) - :type trigcomp: str - :param stalta: (optional, default = (1,10)) - :type stalta: tuple - :param trigonoff: (optional, default = (6,1)) - :type trigonoff: tuple - :return: list of triggtimes - :rtype: list - ''' - tr = st.copy().select(component=trigcomp, station=station)[0] - df = tr.stats.sampling_rate - - cft = recursive_sta_lta(tr.data, int(stalta[0] * df), int(stalta[1] * df)) - triggers = trigger_onset(cft, trigonoff[0], trigonoff[1]) - trigg = [] - for time in triggers: - trigg.append(tr.stats.starttime + time[0] / df) - return trigg - - -def createSubCoincTriggerlist(trig, station='ZV01'): - ''' - makes a triggerlist with the events, that are triggered by the - coincidence trigger and are seen at the demanded station - :param trig: list containing triggers from coincidence trigger - :type trig: list - :param station: station name to get triggers for (optional, default = ZV01) - :type station: str - :return: list of triggertimes - :rtype: list - ''' - trigg = [] - for tri in trig: - if station in tri['stations']: - trigg.append(tri['time']) - return trigg From 91c181ef2d7a6ae9ec1f33c842432815b704f621 Mon Sep 17 00:00:00 2001 From: Sebastian Wehling-Benatelli Date: Tue, 4 Oct 2016 06:32:10 +0200 Subject: [PATCH 4/5] [README] added some necessary information to the README for first release; renamed pylot_sample.in for convenience and removed an obsolete import --- README.md | 74 +++++++++++++++++++++++----- inputs/{pylot_sample.in => pylot.in} | 0 pylot/core/pick/autopick.py | 1 - 3 files changed, 63 insertions(+), 12 deletions(-) rename inputs/{pylot_sample.in => pylot.in} (100%) diff --git a/README.md b/README.md index b54f8166..be3e6e49 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ version: 0.1a The Python picking and Localisation Tool This python library contains a graphical user interfaces for picking -seismic phases. This software needs ObsPy (http://github.com/obspy/obspy/wiki) +seismic phases. This software needs [ObsPy][ObsPy] and the PySide Qt4 bindings for python to be installed first. PILOT has originally been developed in Mathworks' MatLab. In order to @@ -16,7 +16,67 @@ benefit a lot compared to the former MatLab version. The development of PyLoT is part of the joint research project MAGS2. -staff: +##Installation + +At the moment there is no automatic installation procedure available for PyLoT. +Best way to install is to clone the repository and add the path to your Python path. + +####prerequisites: + +In order to run PyLoT you need to install: + +- python +- scipy +- numpy +- matplotlib +- obspy +- pyside + +####some handwork + +PyLoT needs a properties folder on your system to work. It should be situated in your home directory: + + mkdir ~/.pylot + +In the next step you have to copy some files to this directory: + + cp path-to-pylot/inputs/pylot.in ~/.pylot/ + +for local distance seismicity + + cp path-to-pylot/inputs/autoPyLoT_local.in ~/.pylot/autoPyLoT.in + +for regional distance seismicity + + cp path-to-pylot/inputs/autoPyLoT_regional.in ~/.pylot/autoPyLoT.in + +and some extra information on filtering, error estimates (just needed for reading old PILOT data) and the Richter magnitude scaling relation + + cp path-to-pylot/inputs/filter.in path-to-pylot/inputs/PILOT_TimeErrors.in path-to-pylot/inputs/richter_scaling.data ~/.pylot/ + +You may need to do some modifications to these files. Especially folder names should be reviewed. + +PyLoT has been tested on Mac OSX (10.11) and Debian Linux 8. + + +##release notes: +============== + +#### Features + +- consistent manual phase picking through predefined SNR dependant zoom level +- uniform uncertainty estimation from waveform's properties for automatic and manual picks +- pdf representation and comparison of picks taking the uncertainty intrinsically into account +- Richter and moment magnitude estimation +- location determination with external installation of [NonLinLoc](http://alomax.free.fr/nlloc/index.html) + +#### Known issues + +- Magnitude estimation from manual PyLoT takes some time (instrument correction) + +We hope to solve these with the next release. + +####staff: ====== original author(s): L. Kueperkoch, S. Wehling-Benatelli, M. Bischoff (PILOT) @@ -26,15 +86,7 @@ developer(s): S. Wehling-Benatelli, L. Kueperkoch, K. Olbert, M. Bischoff, others: A. Bruestle, T. Meier, W. Friederich -release notes: -============== - -### Features - -- consistent manual phase picking through: - 1. predefined SNR dependant zoom level - 2. - +[ObsPy]: http://github.com/obspy/obspy/wiki October 2016 diff --git a/inputs/pylot_sample.in b/inputs/pylot.in similarity index 100% rename from inputs/pylot_sample.in rename to inputs/pylot.in diff --git a/pylot/core/pick/autopick.py b/pylot/core/pick/autopick.py index f1a186cb..35111071 100755 --- a/pylot/core/pick/autopick.py +++ b/pylot/core/pick/autopick.py @@ -17,7 +17,6 @@ from pylot.core.pick.charfuns import CharacteristicFunction from pylot.core.pick.charfuns import HOScf, AICcf, ARZcf, ARHcf, AR3Ccf from pylot.core.pick.utils import checksignallength, checkZ4S, earllatepicker, \ getSNR, fmpicker, checkPonsets, wadaticheck -from pylot.core.util.dataprocessing import restitute_data from pylot.core.util.utils import getPatternLine from pylot.core.io.data import Data From b8840dff13e43ef073cc3a218256151c5fe6d0bd Mon Sep 17 00:00:00 2001 From: Sebastianw Wehling-Benatelli Date: Tue, 4 Oct 2016 06:40:48 +0200 Subject: [PATCH 5/5] [version] edited release version --- pylot/RELEASE-VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pylot/RELEASE-VERSION b/pylot/RELEASE-VERSION index 4c41ac0c..be128064 100644 --- a/pylot/RELEASE-VERSION +++ b/pylot/RELEASE-VERSION @@ -1 +1 @@ -5f92-dirty +0.1a