[fix] made PyLoT start again
This commit is contained in:
parent
f11ffc67ff
commit
50c35d981a
6
.idea/inspectionProfiles/profiles_settings.xml
Normal file
6
.idea/inspectionProfiles/profiles_settings.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||
<version value="1.0" />
|
||||
</settings>
|
||||
</component>
|
4
.idea/misc.xml
Normal file
4
.idea/misc.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9 (pylot)" project-jdk-type="Python SDK" />
|
||||
</project>
|
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/pylot.iml" filepath="$PROJECT_DIR$/.idea/pylot.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
12
.idea/pylot.iml
Normal file
12
.idea/pylot.iml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="jdk" jdkName="Python 3.9 (pylot)" jdkType="Python SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
<component name="PyDocumentationSettings">
|
||||
<option name="format" value="PLAIN" />
|
||||
<option name="myDocStringFormat" value="Plain" />
|
||||
</component>
|
||||
</module>
|
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
97
PyLoT.py
97
PyLoT.py
@ -35,18 +35,17 @@ import traceback
|
||||
import json
|
||||
from datetime import datetime
|
||||
|
||||
matplotlib.use('Qt4Agg')
|
||||
matplotlib.rcParams['backend.qt4'] = 'PySide'
|
||||
matplotlib.use('Qt5Agg')
|
||||
matplotlib.rcParams['savefig.dpi'] = 300
|
||||
|
||||
|
||||
from PySide import QtGui, QtCore
|
||||
from PySide.QtCore import QCoreApplication, QSettings, Signal, QFile, \
|
||||
from PySide2 import QtGui, QtCore, QtWidgets
|
||||
from PySide2.QtCore import QCoreApplication, QSettings, Signal, QFile, \
|
||||
QFileInfo, Qt, QSize
|
||||
from PySide.QtGui import QMainWindow, QInputDialog, QIcon, QFileDialog, \
|
||||
QWidget, QHBoxLayout, QVBoxLayout, QStyle, QKeySequence, QLabel, QFrame, QAction, \
|
||||
QDialog, QApplication, QPixmap, QMessageBox, QSplashScreen, \
|
||||
QActionGroup, QListWidget, QListView, QAbstractItemView, \
|
||||
from PySide2.QtGui import QIcon, QKeySequence, QPixmap
|
||||
from PySide2.QtWidgets import QMainWindow, QInputDialog, QFileDialog, \
|
||||
QWidget, QHBoxLayout, QVBoxLayout, QStyle, QLabel, QFrame, QAction, \
|
||||
QDialog, QErrorMessage, QApplication, QMessageBox, QSplashScreen, \
|
||||
QActionGroup, QListWidget, QLineEdit, QListView, QAbstractItemView, \
|
||||
QTreeView, QComboBox, QTabWidget, QPushButton, QGridLayout
|
||||
import numpy as np
|
||||
from obspy import UTCDateTime, Stream
|
||||
@ -58,9 +57,10 @@ from pylot.core.util.obspyDMT_interface import check_obspydmt_structure
|
||||
import pyqtgraph as pg
|
||||
|
||||
try:
|
||||
from matplotlib.backends.backend_qt4agg import FigureCanvas
|
||||
from matplotlib.backends.backend_qt5agg import FigureCanvas
|
||||
except ImportError:
|
||||
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
|
||||
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
|
||||
from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar
|
||||
from matplotlib.figure import Figure
|
||||
|
||||
from pylot.core.analysis.magnitude import LocalMagnitude, MomentMagnitude
|
||||
@ -87,7 +87,7 @@ from pylot.core.util.widgets import FilterOptionsDialog, NewEventDlg, \
|
||||
PylotCanvas, WaveformWidgetPG, PropertiesDlg, HelpForm, createAction, PickDlg, \
|
||||
ComparisonWidget, TuneAutopicker, PylotParaBox, AutoPickDlg, CanvasWidget, AutoPickWidget, \
|
||||
CompareEventsWidget, ProgressBarWidget, AddMetadataWidget, SingleTextLineDialog
|
||||
from pylot.core.util.array_map import Array_map
|
||||
#from pylot.core.util.array_map import Array_map
|
||||
from pylot.core.util.structure import DATASTRUCTURE
|
||||
from pylot.core.util.thread import Thread, Worker
|
||||
from pylot.core.util.version import get_git_version as _getVersionString
|
||||
@ -418,9 +418,9 @@ class MainWindow(QMainWindow):
|
||||
None, paraIcon,
|
||||
"Modify Parameter")
|
||||
self.deleteAutopicksAction = self.createAction(self, "Delete Autopicks",
|
||||
self.deleteAllAutopicks,
|
||||
None, deleteIcon,
|
||||
"Delete all automatic picks from Project.")
|
||||
self.deleteAllAutopicks,
|
||||
None, deleteIcon,
|
||||
"Delete all automatic picks from Project.")
|
||||
self.filterActionP = createAction(parent=self, text='Apply P Filter',
|
||||
slot=self.filterP,
|
||||
icon=self.filter_icon_p,
|
||||
@ -551,7 +551,7 @@ class MainWindow(QMainWindow):
|
||||
shortcut='Alt+Ctrl+L',
|
||||
icon=locate_icon,
|
||||
tip='Locate the event using '
|
||||
'the displayed manual arrivals.')
|
||||
'the displayed manual arrivals.')
|
||||
self.locateEventAction.setEnabled(False)
|
||||
|
||||
locationToolActions = (self.locateEventAction,)
|
||||
@ -581,7 +581,6 @@ class MainWindow(QMainWindow):
|
||||
self.autoPickMenu = self.pickMenu.addMenu(self.autopicksicon_small, 'Automatic picking')
|
||||
self.autoPickMenu.setEnabled(False)
|
||||
|
||||
|
||||
autoPickActions = (self.auto_pick, self.auto_pick_local, self.auto_pick_sge)
|
||||
|
||||
self.helpMenu = self.menuBar().addMenu('&Help')
|
||||
@ -714,7 +713,6 @@ class MainWindow(QMainWindow):
|
||||
|
||||
self.setCentralWidget(_widget)
|
||||
|
||||
|
||||
def init_wfWidget(self):
|
||||
xlab = self.startTime.strftime('seconds since %Y/%m/%d %H:%M:%S (%Z)')
|
||||
plottitle = None # "Overview: {0} components ".format(self.getComponent())
|
||||
@ -760,7 +758,6 @@ class MainWindow(QMainWindow):
|
||||
if event.key() == QtCore.Qt.Key.Key_R:
|
||||
self.reset_gain()
|
||||
|
||||
|
||||
def keyReleaseEvent(self, event):
|
||||
if event.key() == QtCore.Qt.Key.Key_Control:
|
||||
self._ctrl = False
|
||||
@ -780,7 +777,7 @@ class MainWindow(QMainWindow):
|
||||
def modify_gain(self, direction, factor):
|
||||
assert (direction in ['+', '-']), 'unknown direction'
|
||||
if self._ctrl:
|
||||
factor = factor**3
|
||||
factor = factor ** 3
|
||||
if direction == '+':
|
||||
self.gain *= factor
|
||||
elif direction == '-':
|
||||
@ -932,7 +929,6 @@ class MainWindow(QMainWindow):
|
||||
|
||||
self.recentProjectsMenu.addAction(action)
|
||||
|
||||
|
||||
@property
|
||||
def inputs(self):
|
||||
return self._inputs
|
||||
@ -970,7 +966,7 @@ class MainWindow(QMainWindow):
|
||||
if not sld.exec_():
|
||||
return
|
||||
fext = sld.lineEdit.text()
|
||||
#fext = '.xml'
|
||||
# fext = '.xml'
|
||||
for event in events:
|
||||
path = event.path
|
||||
eventname = path.split('/')[-1] # or event.pylot_id
|
||||
@ -1002,7 +998,7 @@ class MainWindow(QMainWindow):
|
||||
data_new = Data(self, evtdata=str(fname))
|
||||
# MP MP commented because adding several picks might cause inconsistencies
|
||||
data = data_new
|
||||
#data += data_new
|
||||
# data += data_new
|
||||
except ValueError:
|
||||
qmb = QMessageBox(self, icon=QMessageBox.Question,
|
||||
text='Warning: Missmatch in event identifiers {} and {}. Continue?'.format(
|
||||
@ -1151,7 +1147,8 @@ class MainWindow(QMainWindow):
|
||||
eventlist_file = os.path.join(basepath, 'eventlist.txt')
|
||||
if os.path.isfile(eventlist_file):
|
||||
with open(eventlist_file, 'r') as infile:
|
||||
eventlist_subset = [os.path.join(basepath, filename.split('\n')[0]) for filename in infile.readlines()]
|
||||
eventlist_subset = [os.path.join(basepath, filename.split('\n')[0]) for filename in
|
||||
infile.readlines()]
|
||||
msg = 'Found file "eventlist.txt" in database path. WILL ONLY USE SELECTED EVENTS out of {} events ' \
|
||||
'contained in this subset'
|
||||
print(msg.format(len(eventlist_subset)))
|
||||
@ -1393,7 +1390,7 @@ class MainWindow(QMainWindow):
|
||||
moment_magnitude = event.magnitudes[0]
|
||||
local_magnitude = event.magnitudes[1]
|
||||
localmag = '%4.1f' % local_magnitude.mag
|
||||
momentmag = '%4.1f'% moment_magnitude.mag
|
||||
momentmag = '%4.1f' % moment_magnitude.mag
|
||||
|
||||
# text = '{path:{plen}} | manual: [{p:3d}] | auto: [{a:3d}]'
|
||||
# text = text.format(path=event_path,
|
||||
@ -1501,11 +1498,12 @@ class MainWindow(QMainWindow):
|
||||
:param outformats: str/list of output formats
|
||||
:return:
|
||||
'''
|
||||
if not event:
|
||||
if not event:
|
||||
event = self.get_current_event()
|
||||
if not type(outformats) == list:
|
||||
outformats = [outformats]
|
||||
def getSavePath(event, directory, outformats):
|
||||
|
||||
def getSavePath(event, directory, outformats):
|
||||
if not directory:
|
||||
title = 'Save event data as {} to directory ...'.format(outformats)
|
||||
directory = QFileDialog.getExistingDirectory(self,
|
||||
@ -1523,8 +1521,8 @@ class MainWindow(QMainWindow):
|
||||
|
||||
uppererrorP = self._inputs['timeerrorsP']
|
||||
uppererrorS = self._inputs['timeerrorsS']
|
||||
# Inserted to prevent Bug in Eventlist
|
||||
self.get_data().setEvtData(event)
|
||||
# Inserted to prevent Bug in Eventlist
|
||||
self.get_data().setEvtData(event)
|
||||
try:
|
||||
self.get_data().applyEVTData(event, typ='event') # getPicks())
|
||||
except OverwriteError:
|
||||
@ -1881,7 +1879,7 @@ class MainWindow(QMainWindow):
|
||||
checkRotated=True,
|
||||
metadata=self.metadata,
|
||||
tstart=tstart,
|
||||
tstop=tstop,)
|
||||
tstop=tstop, )
|
||||
|
||||
def prepareObspyDMT_data(self, eventpath):
|
||||
qcbox_processed = self.dataPlot.qcombo_processed
|
||||
@ -2077,7 +2075,7 @@ class MainWindow(QMainWindow):
|
||||
if self.obspy_dmt:
|
||||
invpath = os.path.join(self.get_current_event_path(), 'resp')
|
||||
if not invpath in self.metadata.inventories:
|
||||
self.metadata.add_inventory(invpath, obspy_dmt_inv = True)
|
||||
self.metadata.add_inventory(invpath, obspy_dmt_inv=True)
|
||||
# check if directory is empty
|
||||
if os.listdir(invpath):
|
||||
self.init_map_button.setEnabled(True)
|
||||
@ -2479,7 +2477,7 @@ class MainWindow(QMainWindow):
|
||||
if not seed_id:
|
||||
seed_id = self.getTraceID(wfID)
|
||||
try:
|
||||
network, station, location = seed_id.split('.')[:3]
|
||||
network, station, location = seed_id.split('.')[:3]
|
||||
except:
|
||||
print("Warning! No network, station, and location info available!")
|
||||
return
|
||||
@ -2643,9 +2641,9 @@ class MainWindow(QMainWindow):
|
||||
# init event selection options for autopick
|
||||
self.pickoptions = [('current event', self.get_current_event, None),
|
||||
('tune events', self.get_ref_events, self._style['ref']['rgba']),
|
||||
('test events', self.get_test_events, self._style['test']['rgba']),]
|
||||
#('all (picked) events', self.get_manu_picked_events, None),
|
||||
#('all events', self.get_all_events, None)]
|
||||
('test events', self.get_test_events, self._style['test']['rgba']), ]
|
||||
# ('all (picked) events', self.get_manu_picked_events, None),
|
||||
# ('all events', self.get_all_events, None)]
|
||||
|
||||
self.listWidget = QListWidget()
|
||||
self.setDirty(True)
|
||||
@ -2843,7 +2841,7 @@ class MainWindow(QMainWindow):
|
||||
|
||||
def safetyCopy(self, event_path):
|
||||
fpath = self.get_deleted_picks_fpath(event_path)
|
||||
fpath_new = fpath.split('.json')[0] + '_copy_{}.json'.format(datetime.now()).replace(' ', '_')
|
||||
fpath_new = fpath.split('.json')[0] + '_copy_{}.json'.format(datetime.now()).replace(' ', '_')
|
||||
shutil.move(fpath, fpath_new)
|
||||
|
||||
def load_deleted_picks(self, event_path):
|
||||
@ -2870,7 +2868,6 @@ class MainWindow(QMainWindow):
|
||||
else:
|
||||
event.addAutopicks(picksdict['auto'])
|
||||
|
||||
|
||||
def drawPicks(self, station=None, picktype=None, stime=None):
|
||||
# if picktype not specified, draw both
|
||||
if not stime:
|
||||
@ -2923,7 +2920,7 @@ class MainWindow(QMainWindow):
|
||||
|
||||
phaseID = self.getPhaseID(phase)
|
||||
# get quality classes
|
||||
if phaseID == 'P':
|
||||
if phaseID == 'P':
|
||||
quality = getQualityFromUncertainty(picks['spe'], self._inputs['timeerrorsP'])
|
||||
elif phaseID == 'S':
|
||||
quality = getQualityFromUncertainty(picks['spe'], self._inputs['timeerrorsS'])
|
||||
@ -3023,7 +3020,7 @@ class MainWindow(QMainWindow):
|
||||
outfile = parameter['outpatter']
|
||||
eventname = self.get_current_event_name()
|
||||
obsdir = os.path.join(self._inputs['rootpath'], self._inputs['datapath'], self._inputs['database'], eventname)
|
||||
self.saveData(event=self.get_current_event(), directory=obsdir, outformats='.obs')
|
||||
self.saveData(event=self.get_current_event(), directory=obsdir, outformats='.obs')
|
||||
filename = 'PyLoT_' + eventname
|
||||
locpath = os.path.join(locroot, 'loc', filename)
|
||||
phasefile = os.path.join(obsdir, filename + '.obs')
|
||||
@ -3215,7 +3212,7 @@ class MainWindow(QMainWindow):
|
||||
|
||||
# iterate through eventlist and generate items for table rows
|
||||
self.project._table = []
|
||||
for index, event in enumerate(eventlist):
|
||||
for index, event in enumerate(eventlist):
|
||||
phaseErrors = {'P': self._inputs['timeerrorsP'],
|
||||
'S': self._inputs['timeerrorsS']}
|
||||
|
||||
@ -3297,7 +3294,7 @@ class MainWindow(QMainWindow):
|
||||
item_test.setCheckState(QtCore.Qt.Unchecked)
|
||||
|
||||
row = [item_delete, item_path, item_time, item_lat, item_lon, item_depth, item_localmag,
|
||||
item_momentmag, item_nmp, item_nap, item_ref, item_test, item_notes]
|
||||
item_momentmag, item_nmp, item_nap, item_ref, item_test, item_notes]
|
||||
self.project._table.append(row)
|
||||
|
||||
self.setItemColor(row, index, event, current_event)
|
||||
@ -3363,7 +3360,7 @@ class MainWindow(QMainWindow):
|
||||
event, time, lat, lon, depth, mag, nmp, nap, tune, test, notes = row
|
||||
row_str = ''
|
||||
for index in range(len(row)):
|
||||
row_str += '{}'+'{}'.format(separator)
|
||||
row_str += '{}' + '{}'.format(separator)
|
||||
|
||||
row_str = row_str.format(event.text(), time.text(), lat.text(), lon.text(), depth.text(), mag.text(),
|
||||
nmp.text(), nap.text(), bool(tune.checkState()), bool(test.checkState()),
|
||||
@ -3392,7 +3389,6 @@ class MainWindow(QMainWindow):
|
||||
if event == current_event:
|
||||
set_background_color(item_list, QtGui.QColor(*(0, 143, 143, 255)))
|
||||
|
||||
|
||||
def set_metadata(self):
|
||||
self.project.inventories = self.metadata.inventories
|
||||
if self.metadata.inventories:
|
||||
@ -3404,7 +3400,7 @@ class MainWindow(QMainWindow):
|
||||
self.init_map_button.setEnabled(False)
|
||||
self.initMapAction.setEnabled(False)
|
||||
self.inventory_label.setText("No inventory set...")
|
||||
#self.setDirty(False)
|
||||
# self.setDirty(False)
|
||||
|
||||
def add_metadata(self):
|
||||
self.add_metadata_widget = AddMetadataWidget(self, metadata=self.metadata)
|
||||
@ -3652,7 +3648,7 @@ class MainWindow(QMainWindow):
|
||||
else:
|
||||
self.dataPlot.setPermText(1)
|
||||
self.dataPlot.setPermText(0, '| Number of traces: {} | Gain: {}'.format(len(self.getPlotWidget().getPlotDict()),
|
||||
self.gain))
|
||||
self.gain))
|
||||
|
||||
def _setDirty(self):
|
||||
self.setDirty(True)
|
||||
@ -3697,7 +3693,6 @@ class MainWindow(QMainWindow):
|
||||
self.plotWaveformDataThread()
|
||||
self.refreshTabs()
|
||||
|
||||
|
||||
def PyLoTprefs(self):
|
||||
if not self._props:
|
||||
self._props = PropertiesDlg(self, infile=self.infile,
|
||||
@ -3756,7 +3751,7 @@ class Project(object):
|
||||
self.search_eventfile_info()
|
||||
|
||||
def remove_event(self, event):
|
||||
self.eventlist.remove(event)
|
||||
self.eventlist.remove(event)
|
||||
|
||||
def remove_event_by_id(self, eventID):
|
||||
for event in self.eventlist:
|
||||
@ -3765,11 +3760,11 @@ class Project(object):
|
||||
break
|
||||
|
||||
def read_eventfile_info(self, filename, separator=','):
|
||||
'''
|
||||
Try to read event information from file (:param:filename) comparing specific event datetimes.
|
||||
File structure (each row): event, date, time, magnitude, latitude, longitude, depth
|
||||
separated by :param:separator each.
|
||||
'''
|
||||
Try to read event information from file (:param:filename) comparing specific event datetimes.
|
||||
File structure (each row): event, date, time, magnitude, latitude, longitude, depth
|
||||
separated by :param:separator each.
|
||||
'''
|
||||
with open(filename, 'r') as infile:
|
||||
for line in infile.readlines():
|
||||
eventID, date, time, mag, lat, lon, depth = line.split(separator)[:7]
|
||||
|
@ -29,7 +29,6 @@
|
||||
<file>icons/map.png</file>
|
||||
<file>icons/openloc.png</file>
|
||||
<file>icons/compare_button.png</file>
|
||||
<file>icons/pick_qualities_button.png</file>
|
||||
<file>icons/locate_button.png</file>
|
||||
<file>icons/Matlab_PILOT_icon.png</file>
|
||||
<file>icons/printer.png</file>
|
||||
|
217791
icons_rc_3.py
217791
icons_rc_3.py
File diff suppressed because it is too large
Load Diff
@ -221,16 +221,16 @@ class LocalMagnitude(Magnitude):
|
||||
|
||||
power = [np.power(tr.data, 2) for tr in st if tr.stats.channel[-1] not
|
||||
in 'Z3']
|
||||
# checking horizontal count and calculating power_sum accordingly
|
||||
if len(power) == 1:
|
||||
print ('WARNING: Only one horizontal found for station {0}.'.format(st[0].stats.station))
|
||||
power_sum = power[0]
|
||||
elif len(power) == 2:
|
||||
power_sum = power[0] + power[1]
|
||||
else:
|
||||
raise ValueError('Wood-Anderson aomplitude defintion only valid for'
|
||||
' up to two horizontals: {0} given'.format(len(power)))
|
||||
|
||||
# checking horizontal count and calculating power_sum accordingly
|
||||
if len(power) == 1:
|
||||
print('WARNING: Only one horizontal found for station {0}.'.format(st[0].stats.station))
|
||||
power_sum = power[0]
|
||||
elif len(power) == 2:
|
||||
power_sum = power[0] + power[1]
|
||||
else:
|
||||
raise ValueError('Wood-Anderson aomplitude defintion only valid for'
|
||||
' up to two horizontals: {0} given'.format(len(power)))
|
||||
|
||||
sqH = np.sqrt(power_sum)
|
||||
|
||||
# get time array
|
||||
@ -324,7 +324,7 @@ class LocalMagnitude(Magnitude):
|
||||
if self.verbose:
|
||||
print(
|
||||
"Local Magnitude for station {0}: ML = {1:3.1f}".format(
|
||||
station, magnitude.mag))
|
||||
station, magnitude.mag))
|
||||
magnitude.origin_id = self.origin_id
|
||||
magnitude.waveform_id = pick.waveform_id
|
||||
magnitude.amplitude_id = amplitude.resource_id
|
||||
@ -459,7 +459,7 @@ def calcMoMw(wfstream, w0, rho, vp, delta, verbosity=False):
|
||||
|
||||
# additional common parameters for calculating Mo
|
||||
# average radiation pattern of P waves (Aki & Richards, 1980)
|
||||
rP = 2 / np.sqrt(15)
|
||||
rP = 2 / np.sqrt(15)
|
||||
freesurf = 2.0 # free surface correction, assuming vertical incidence
|
||||
|
||||
Mo = w0 * 4 * np.pi * rho * np.power(vp, 3) * delta / (rP * freesurf)
|
||||
@ -519,7 +519,7 @@ def calcsourcespec(wfstream, onset, vp, delta, azimuth, incidence,
|
||||
iplot = 2
|
||||
else:
|
||||
iplot = 0
|
||||
|
||||
|
||||
# get Q value
|
||||
Q, A = qp
|
||||
|
||||
@ -589,13 +589,13 @@ def calcsourcespec(wfstream, onset, vp, delta, azimuth, incidence,
|
||||
|
||||
# fft
|
||||
fny = freq / 2
|
||||
#l = len(xdat) / freq
|
||||
# l = len(xdat) / freq
|
||||
# number of fft bins after Bath
|
||||
#n = freq * l
|
||||
# n = freq * l
|
||||
# find next power of 2 of data length
|
||||
m = pow(2, np.ceil(np.log(len(xdat)) / np.log(2)))
|
||||
N = min(int(np.power(m, 2)), 16384)
|
||||
#N = int(np.power(m, 2))
|
||||
# N = int(np.power(m, 2))
|
||||
y = dt * np.fft.fft(xdat, N)
|
||||
Y = abs(y[: N / 2])
|
||||
L = (N - 1) / freq
|
||||
@ -638,8 +638,8 @@ def calcsourcespec(wfstream, onset, vp, delta, azimuth, incidence,
|
||||
w0 = np.median([w01, w02])
|
||||
Fc = np.median([fc1, fc2])
|
||||
if verbosity:
|
||||
print("calcsourcespec: Using w0-value = %e m/Hz and fc = %f Hz" % (
|
||||
w0, Fc))
|
||||
print("calcsourcespec: Using w0-value = %e m/Hz and fc = %f Hz" % (
|
||||
w0, Fc))
|
||||
if iplot >= 1:
|
||||
f1 = plt.figure()
|
||||
tLdat = np.arange(0, len(Ldat) * dt, dt)
|
||||
@ -728,7 +728,7 @@ def fitSourceModel(f, S, fc0, iplot, verbosity=False):
|
||||
iplot = 2
|
||||
else:
|
||||
iplot = 0
|
||||
|
||||
|
||||
w0 = []
|
||||
stdw0 = []
|
||||
fc = []
|
||||
|
@ -8,7 +8,7 @@ from obspy.core import read, Stream, UTCDateTime
|
||||
from obspy.core.event import Event as ObsPyEvent
|
||||
from obspy.io.sac import SacIOError
|
||||
|
||||
from PySide.QtGui import QMessageBox
|
||||
from PySide2.QtWidgets import QMessageBox
|
||||
|
||||
import pylot.core.loc.velest as velest
|
||||
import pylot.core.loc.focmec as focmec
|
||||
@ -21,6 +21,7 @@ from pylot.core.util.obspyDMT_interface import qml_from_obspyDMT
|
||||
from pylot.core.util.utils import fnConstructor, full_range, check4rotated, \
|
||||
check4gapsAndMerge, trim_station_components
|
||||
|
||||
|
||||
class Data(object):
|
||||
"""
|
||||
Data container with attributes wfdata holding ~obspy.core.stream.
|
||||
@ -47,7 +48,7 @@ class Data(object):
|
||||
elif isinstance(evtdata, dict):
|
||||
evt = readPILOTEvent(**evtdata)
|
||||
evtdata = evt
|
||||
elif type(evtdata) in [str, unicode]:
|
||||
elif type(evtdata) == str:
|
||||
try:
|
||||
cat = read_events(evtdata)
|
||||
if len(cat) is not 1:
|
||||
@ -99,7 +100,7 @@ class Data(object):
|
||||
old_pick.phase_hint == new_pick.phase_hint,
|
||||
old_pick.method_id == new_pick.method_id]
|
||||
if all(comparison):
|
||||
del(old_pick)
|
||||
del (old_pick)
|
||||
old_picks.append(new_pick)
|
||||
elif not other.isNew() and self.isNew():
|
||||
new = other + self
|
||||
@ -111,7 +112,7 @@ class Data(object):
|
||||
return self + other
|
||||
else:
|
||||
raise ValueError("both Data objects have differing "
|
||||
"unique Event identifiers")
|
||||
"unique Event identifiers")
|
||||
return self
|
||||
|
||||
def getPicksStr(self):
|
||||
@ -247,7 +248,7 @@ class Data(object):
|
||||
for pick in self.get_evt_data().picks:
|
||||
if picktype in str(pick.method_id.id):
|
||||
picks.append(pick)
|
||||
|
||||
|
||||
def exportEvent(self, fnout, fnext='.xml', fcheck='auto', upperErrors=None):
|
||||
"""
|
||||
Export event to file
|
||||
@ -257,7 +258,7 @@ class Data(object):
|
||||
can be a str or a list of strings of ['manual', 'auto', 'origin', 'magnitude']
|
||||
"""
|
||||
from pylot.core.util.defaults import OUTPUTFORMATS
|
||||
|
||||
|
||||
if not type(fcheck) == list:
|
||||
fcheck = [fcheck]
|
||||
|
||||
@ -275,7 +276,7 @@ class Data(object):
|
||||
# check for already existing xml-file
|
||||
if fnext == '.xml':
|
||||
if os.path.isfile(fnout + fnext):
|
||||
print("xml-file already exists! Check content ...")
|
||||
print("xml-file already exists! Check content ...")
|
||||
cat = read_events(fnout + fnext)
|
||||
if len(cat) > 1:
|
||||
raise IOError('Ambigious event information in file {}'.format(fnout + fnext))
|
||||
@ -287,7 +288,7 @@ class Data(object):
|
||||
return
|
||||
self.checkEvent(event, fcheck)
|
||||
self.setEvtData(event)
|
||||
|
||||
|
||||
self.get_evt_data().write(fnout + fnext, format=evtformat)
|
||||
|
||||
# try exporting event
|
||||
@ -489,7 +490,8 @@ class Data(object):
|
||||
real_or_syn_data[synthetic] += read(fname, format='GSE2', starttime=self.tstart, endtime=self.tstop)
|
||||
except Exception as e:
|
||||
try:
|
||||
real_or_syn_data[synthetic] += read(fname, format='SEGY', starttime=self.tstart, endtime=self.tstop)
|
||||
real_or_syn_data[synthetic] += read(fname, format='SEGY', starttime=self.tstart,
|
||||
endtime=self.tstop)
|
||||
except Exception as e:
|
||||
warnmsg += '{0}\n{1}\n'.format(fname, e)
|
||||
except SacIOError as se:
|
||||
|
@ -252,7 +252,7 @@ def picksdict_from_picks(evt):
|
||||
if picker == 'None':
|
||||
picker = 'manual'
|
||||
try:
|
||||
#onsets = picksdict[picker][station]
|
||||
# onsets = picksdict[picker][station]
|
||||
onsets = picksdict[station]
|
||||
except KeyError as e:
|
||||
# print(e)
|
||||
@ -572,18 +572,18 @@ def writephases(arrivals, fformat, filename, parameter=None, eventinfo=None):
|
||||
sweight = 0 # do not use pick
|
||||
except KeyError as e:
|
||||
print(str(e) + '; no weight set during processing')
|
||||
Ao = arrivals[key]['S']['Ao'] # peak-to-peak amplitude
|
||||
#fid.write('%s ? ? ? S %s %d%02d%02d %02d%02d %7.4f GAU 0 0 0 0 %d \n' % (key,
|
||||
Ao = arrivals[key]['S']['Ao'] # peak-to-peak amplitude
|
||||
# fid.write('%s ? ? ? S %s %d%02d%02d %02d%02d %7.4f GAU 0 0 0 0 %d \n' % (key,
|
||||
fid.write('%s ? ? ? S %s %d%02d%02d %02d%02d %7.4f GAU 0 %9.2f 0 0 %d \n' % (key,
|
||||
fm,
|
||||
year,
|
||||
month,
|
||||
day,
|
||||
hh,
|
||||
mm,
|
||||
ss_ms,
|
||||
Ao,
|
||||
sweight))
|
||||
fm,
|
||||
year,
|
||||
month,
|
||||
day,
|
||||
hh,
|
||||
mm,
|
||||
ss_ms,
|
||||
Ao,
|
||||
sweight))
|
||||
|
||||
fid.close()
|
||||
elif fformat == 'HYPO71':
|
||||
@ -805,7 +805,7 @@ def writephases(arrivals, fformat, filename, parameter=None, eventinfo=None):
|
||||
return
|
||||
stime = eventsource['time']
|
||||
event = parameter.get('eventID')
|
||||
hddID = event.split('.')[0][1:5]
|
||||
hddID = event.split('.')[0][1:5]
|
||||
# write header
|
||||
fid.write('# %d %d %d %d %d %5.2f %7.4f +%6.4f %7.4f %4.2f 0.1 0.5 %4.2f %s\n' % (
|
||||
stime.year, stime.month, stime.day, stime.hour, stime.minute, stime.second,
|
||||
|
@ -6,7 +6,8 @@ import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
import obspy
|
||||
import traceback
|
||||
from PySide import QtGui
|
||||
#from PySide2 import QtGui
|
||||
from PySide2 import QtWidgets as QtGui
|
||||
from matplotlib.figure import Figure
|
||||
from mpl_toolkits.axes_grid1.inset_locator import inset_axes
|
||||
from mpl_toolkits.basemap import Basemap
|
||||
|
@ -4,8 +4,8 @@ import os
|
||||
import sys
|
||||
import traceback
|
||||
|
||||
from PySide.QtCore import QThread, Signal, Qt, Slot, QRunnable, QObject
|
||||
from PySide.QtGui import QDialog, QProgressBar, QLabel, QHBoxLayout
|
||||
from PySide2.QtCore import QThread, Signal, Qt, Slot, QRunnable, QObject
|
||||
from PySide2.QtWidgets import QDialog, QProgressBar, QLabel, QHBoxLayout
|
||||
|
||||
|
||||
class Thread(QThread):
|
||||
|
@ -17,27 +17,28 @@ import sys
|
||||
import time
|
||||
import traceback
|
||||
|
||||
matplotlib.use('QT4Agg')
|
||||
matplotlib.use('QT5Agg')
|
||||
|
||||
from matplotlib.figure import Figure
|
||||
|
||||
try:
|
||||
from matplotlib.backends.backend_qt4agg import FigureCanvas
|
||||
from matplotlib.backends.backend_qt5agg import FigureCanvas
|
||||
except ImportError:
|
||||
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
|
||||
from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT
|
||||
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
|
||||
from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT
|
||||
from matplotlib.widgets import MultiCursor
|
||||
from obspy import read
|
||||
|
||||
from PySide import QtCore, QtGui
|
||||
from PySide.QtGui import QAction, QApplication, QCheckBox, QComboBox, \
|
||||
from PySide2 import QtCore, QtGui
|
||||
from PySide2.QtGui import QIcon, QPixmap, QKeySequence
|
||||
from PySide2.QtWidgets import QAction, QApplication, QCheckBox, QComboBox, \
|
||||
QDateTimeEdit, QDialog, QDialogButtonBox, QDoubleSpinBox, QGroupBox, \
|
||||
QGridLayout, QFormLayout, QIcon, QLabel, QLineEdit, QMessageBox, \
|
||||
QPixmap, QSpinBox, QTabWidget, QToolBar, QVBoxLayout, QHBoxLayout, QWidget, \
|
||||
QPushButton, QFileDialog, QInputDialog, QKeySequence
|
||||
from PySide.QtCore import QSettings, Qt, QUrl, Signal
|
||||
from PySide.QtWebKit import QWebView
|
||||
from obspy import Stream, Trace, UTCDateTime
|
||||
QGridLayout, QFormLayout, QLabel, QLineEdit, QMessageBox, \
|
||||
QSpinBox, QTabWidget, QToolBar, QVBoxLayout, QHBoxLayout, QWidget, \
|
||||
QPushButton, QFileDialog, QInputDialog
|
||||
from PySide2.QtCore import QSettings, Qt, QUrl, Signal, Slot
|
||||
from PySide2.QtWebEngineWidgets import QWebEngineView as QWebView
|
||||
from obspy import Stream, UTCDateTime
|
||||
from obspy.core.util import AttribDict
|
||||
from obspy.taup import TauPyModel
|
||||
from obspy.taup.utils import get_phase_names
|
||||
|
Loading…
Reference in New Issue
Block a user