Merge branch 'develop' into feature/port-to-py3
This commit is contained in:
commit
d236d3d80f
32
PyLoT.py
32
PyLoT.py
@ -487,7 +487,8 @@ class MainWindow(QMainWindow):
|
|||||||
icon=qualities_icon, tip='Histogram of pick qualities')
|
icon=qualities_icon, tip='Histogram of pick qualities')
|
||||||
self.qualities_action.setEnabled(False)
|
self.qualities_action.setEnabled(False)
|
||||||
# MP MP not yet implemented, therefore hide:
|
# MP MP not yet implemented, therefore hide:
|
||||||
self.qualities_action.setVisible(False)
|
# LK will be implemented soon, basic script has already (03/2021) been finished
|
||||||
|
self.qualities_action.setVisible(True)
|
||||||
|
|
||||||
printAction = self.createAction(self, "&Print event ...",
|
printAction = self.createAction(self, "&Print event ...",
|
||||||
self.show_event_information, QKeySequence.Print,
|
self.show_event_information, QKeySequence.Print,
|
||||||
@ -1529,7 +1530,6 @@ class MainWindow(QMainWindow):
|
|||||||
event = self.get_current_event()
|
event = self.get_current_event()
|
||||||
if not type(outformats) == list:
|
if not type(outformats) == list:
|
||||||
outformats = [outformats]
|
outformats = [outformats]
|
||||||
|
|
||||||
def getSavePath(event, directory, outformats):
|
def getSavePath(event, directory, outformats):
|
||||||
if not directory:
|
if not directory:
|
||||||
title = 'Save event data as {} to directory ...'.format(outformats)
|
title = 'Save event data as {} to directory ...'.format(outformats)
|
||||||
@ -1548,13 +1548,13 @@ class MainWindow(QMainWindow):
|
|||||||
|
|
||||||
uppererrorP = self._inputs['timeerrorsP']
|
uppererrorP = self._inputs['timeerrorsP']
|
||||||
uppererrorS = self._inputs['timeerrorsS']
|
uppererrorS = self._inputs['timeerrorsS']
|
||||||
|
# Inserted to prevent Bug in Eventlist
|
||||||
|
self.get_data().setEvtData(event)
|
||||||
try:
|
try:
|
||||||
self.get_data().applyEVTData(event, typ='event') # getPicks())
|
self.get_data().applyEVTData(event, typ='event') # getPicks())
|
||||||
except OverwriteError:
|
except OverwriteError:
|
||||||
self.get_data().resetPicks()
|
self.get_data().resetPicks()
|
||||||
return self.saveData(event, directory, outformats)
|
return self.saveData(event, directory, outformats)
|
||||||
|
|
||||||
fcheck = ['auto', 'manual', 'origins', 'magnitude']
|
fcheck = ['auto', 'manual', 'origins', 'magnitude']
|
||||||
|
|
||||||
saved_as = str()
|
saved_as = str()
|
||||||
@ -1570,7 +1570,6 @@ class MainWindow(QMainWindow):
|
|||||||
msg = 'Event {} saved as {} in format(s) {}'.format(event.pylot_id, fbasename, saved_as.strip())
|
msg = 'Event {} saved as {} in format(s) {}'.format(event.pylot_id, fbasename, saved_as.strip())
|
||||||
self.update_status(msg)
|
self.update_status(msg)
|
||||||
print(msg)
|
print(msg)
|
||||||
|
|
||||||
event.dirty = False
|
event.dirty = False
|
||||||
self.fill_eventbox()
|
self.fill_eventbox()
|
||||||
return True
|
return True
|
||||||
@ -3045,7 +3044,6 @@ class MainWindow(QMainWindow):
|
|||||||
self.locate_event()
|
self.locate_event()
|
||||||
|
|
||||||
ctrfile = os.path.join(locroot, 'run', parameter['ctrfile'])
|
ctrfile = os.path.join(locroot, 'run', parameter['ctrfile'])
|
||||||
|
|
||||||
ttt = parameter['ttpatter']
|
ttt = parameter['ttpatter']
|
||||||
outfile = parameter['outpatter']
|
outfile = parameter['outpatter']
|
||||||
eventname = self.get_current_event_name()
|
eventname = self.get_current_event_name()
|
||||||
@ -3061,7 +3059,6 @@ class MainWindow(QMainWindow):
|
|||||||
print(e.message)
|
print(e.message)
|
||||||
# finally:
|
# finally:
|
||||||
# os.remove(phasefile)
|
# os.remove(phasefile)
|
||||||
|
|
||||||
self.get_data().applyEVTData(lt.read_location(locpath), typ='event')
|
self.get_data().applyEVTData(lt.read_location(locpath), typ='event')
|
||||||
for event in self.calc_magnitude():
|
for event in self.calc_magnitude():
|
||||||
self.get_data().applyEVTData(event, typ='event')
|
self.get_data().applyEVTData(event, typ='event')
|
||||||
@ -3297,17 +3294,24 @@ class MainWindow(QMainWindow):
|
|||||||
item_depth.setText(str(origin.depth))
|
item_depth.setText(str(origin.depth))
|
||||||
if hasattr(event, 'magnitudes'):
|
if hasattr(event, 'magnitudes'):
|
||||||
if event.magnitudes:
|
if event.magnitudes:
|
||||||
moment_magnitude = event.magnitudes[0]
|
|
||||||
moment_magnitude.mag = '%4.1f' % moment_magnitude.mag
|
|
||||||
moment_mag = str(moment_magnitude.mag)
|
|
||||||
if len(event.magnitudes) > 1:
|
if len(event.magnitudes) > 1:
|
||||||
|
moment_magnitude = event.magnitudes[0]
|
||||||
|
moment_magnitude.mag = '%4.1f' % moment_magnitude.mag
|
||||||
|
item_momentmag.setText(str(moment_magnitude.mag))
|
||||||
local_magnitude = event.magnitudes[1]
|
local_magnitude = event.magnitudes[1]
|
||||||
local_magnitude.mag = '%4.1f' % local_magnitude.mag
|
local_magnitude.mag = '%4.1f' % local_magnitude.mag
|
||||||
local_mag = str(local_magnitude.mag)
|
item_localmag.setText(str(local_magnitude.mag))
|
||||||
else:
|
else:
|
||||||
local_mag = None
|
# check type of magnitude
|
||||||
item_momentmag.setText(moment_mag)
|
if event.magnitudes[0].magnitude_type == 'Mw':
|
||||||
item_localmag.setText(local_mag)
|
moment_magnitude = event.magnitudes[0]
|
||||||
|
moment_magnitude.mag = '%4.1f' % moment_magnitude.mag
|
||||||
|
item_momentmag.setText(str(moment_magnitude.mag))
|
||||||
|
elif event.magnitudes[0].magnitude_type == 'ML':
|
||||||
|
local_magnitude = event.magnitudes[0]
|
||||||
|
local_magnitude.mag = '%4.1f' % local_magnitude.mag
|
||||||
|
item_localmag.setText(str(local_magnitude.mag))
|
||||||
|
|
||||||
item_notes.setText(event.notes)
|
item_notes.setText(event.notes)
|
||||||
|
|
||||||
set_enabled(item_path, True, False)
|
set_enabled(item_path, True, False)
|
||||||
|
@ -221,11 +221,16 @@ class LocalMagnitude(Magnitude):
|
|||||||
|
|
||||||
power = [np.power(tr.data, 2) for tr in st if tr.stats.channel[-1] not
|
power = [np.power(tr.data, 2) for tr in st if tr.stats.channel[-1] not
|
||||||
in 'Z3']
|
in 'Z3']
|
||||||
if len(power) != 2:
|
# checking horizontal count and calculating power_sum accordingly
|
||||||
raise ValueError('Wood-Anderson amplitude defintion only valid for '
|
if len(power) == 1:
|
||||||
'two horizontals: {0} given'.format(len(power)))
|
print ('WARNING: Only one horizontal found for station {0}.'.format(st[0].stats.station))
|
||||||
power_sum = power[0] + power[1]
|
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)
|
sqH = np.sqrt(power_sum)
|
||||||
|
|
||||||
# get time array
|
# get time array
|
||||||
@ -277,12 +282,13 @@ class LocalMagnitude(Magnitude):
|
|||||||
for a in self.arrivals:
|
for a in self.arrivals:
|
||||||
if a.phase not in 'sS':
|
if a.phase not in 'sS':
|
||||||
continue
|
continue
|
||||||
|
pick = a.pick_id.get_referred_object()
|
||||||
|
station = pick.waveform_id.station_code
|
||||||
# make sure calculating Ml only from reliable onsets
|
# make sure calculating Ml only from reliable onsets
|
||||||
# NLLoc: time_weight = 0 => do not use onset!
|
# NLLoc: time_weight = 0 => do not use onset!
|
||||||
if a.time_weight == 0:
|
if a.time_weight == 0:
|
||||||
|
print("Uncertain pick at Station {}, do not use it!".format(station))
|
||||||
continue
|
continue
|
||||||
pick = a.pick_id.get_referred_object()
|
|
||||||
station = pick.waveform_id.station_code
|
|
||||||
wf = select_for_phase(self.stream.select(
|
wf = select_for_phase(self.stream.select(
|
||||||
station=station), a.phase)
|
station=station), a.phase)
|
||||||
if not wf:
|
if not wf:
|
||||||
@ -394,24 +400,28 @@ class MomentMagnitude(Magnitude):
|
|||||||
print("WARNING: No instrument corrected data available,"
|
print("WARNING: No instrument corrected data available,"
|
||||||
" no magnitude calculation possible! Go on.")
|
" no magnitude calculation possible! Go on.")
|
||||||
continue
|
continue
|
||||||
scopy = self.stream.copy()
|
wf = self.stream.select(station=station)
|
||||||
wf = scopy.select(station=station)
|
|
||||||
if not wf:
|
if not wf:
|
||||||
continue
|
continue
|
||||||
|
try:
|
||||||
|
scopy = wf.copy()
|
||||||
|
except AssertionError:
|
||||||
|
print("WARNING: Something's wrong with the data,"
|
||||||
|
"station {},"
|
||||||
|
"no calculation of moment magnitude possible! Go on.".format(station))
|
||||||
|
continue
|
||||||
onset = pick.time
|
onset = pick.time
|
||||||
distance = degrees2kilometers(a.distance)
|
distance = degrees2kilometers(a.distance)
|
||||||
azimuth = a.azimuth
|
azimuth = a.azimuth
|
||||||
incidence = a.takeoff_angle
|
incidence = a.takeoff_angle
|
||||||
w0, fc = calcsourcespec(wf, onset, self.p_velocity, distance,
|
w0, fc = calcsourcespec(scopy, onset, self.p_velocity, distance,
|
||||||
azimuth, incidence, self.p_attenuation,
|
azimuth, incidence, self.p_attenuation,
|
||||||
self.plot_flag, self.verbose)
|
self.plot_flag, self.verbose)
|
||||||
if w0 is None or fc is None:
|
if w0 is None or fc is None:
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
print("WARNING: insufficient frequency information")
|
print("WARNING: insufficient frequency information")
|
||||||
continue
|
continue
|
||||||
WF = select_for_phase(self.stream.select(
|
WF = select_for_phase(scopy, "P")
|
||||||
station=station), a.phase)
|
|
||||||
WF = select_for_phase(WF, "P")
|
|
||||||
m0, mw = calcMoMw(WF, w0, self.rock_density, self.p_velocity,
|
m0, mw = calcMoMw(WF, w0, self.rock_density, self.p_velocity,
|
||||||
distance, self.verbose)
|
distance, self.verbose)
|
||||||
self.moment_props = (station, dict(w0=w0, fc=fc, Mo=m0))
|
self.moment_props = (station, dict(w0=w0, fc=fc, Mo=m0))
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env pyth n
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
@ -297,7 +297,9 @@ class Data(object):
|
|||||||
return
|
return
|
||||||
self.checkEvent(event, fcheck)
|
self.checkEvent(event, fcheck)
|
||||||
self.setEvtData(event)
|
self.setEvtData(event)
|
||||||
|
|
||||||
self.get_evt_data().write(fnout + fnext, format=evtformat)
|
self.get_evt_data().write(fnout + fnext, format=evtformat)
|
||||||
|
|
||||||
# try exporting event
|
# try exporting event
|
||||||
else:
|
else:
|
||||||
evtdata_org = self.get_evt_data()
|
evtdata_org = self.get_evt_data()
|
||||||
@ -361,6 +363,14 @@ class Data(object):
|
|||||||
header = '# EQEVENT: Label: EQ%s Loc: X 0.00 Y 0.00 Z 10.00 OT 0.00 \n' % evid
|
header = '# EQEVENT: Label: EQ%s Loc: X 0.00 Y 0.00 Z 10.00 OT 0.00 \n' % evid
|
||||||
nllocfile = open(fnout + fnext)
|
nllocfile = open(fnout + fnext)
|
||||||
l = nllocfile.readlines()
|
l = nllocfile.readlines()
|
||||||
|
# Adding A0/Generic Amplitude to .obs file
|
||||||
|
#l2 = []
|
||||||
|
#for li in l:
|
||||||
|
# for amp in evtdata_org.amplitudes:
|
||||||
|
# if amp.waveform_id.station_code == li[0:5].strip():
|
||||||
|
# li = li[0:64] + '{:0.2e}'.format(amp.generic_amplitude) + li[73:-1] + '\n'
|
||||||
|
# l2.append(li)
|
||||||
|
#l = l2
|
||||||
nllocfile.close()
|
nllocfile.close()
|
||||||
l.insert(0, header)
|
l.insert(0, header)
|
||||||
nllocfile = open(fnout + fnext, 'w')
|
nllocfile = open(fnout + fnext, 'w')
|
||||||
|
@ -511,7 +511,7 @@ defaults = {'rootpath': {'type': str,
|
|||||||
|
|
||||||
'taup_model': {'type': str,
|
'taup_model': {'type': str,
|
||||||
'tooltip': 'Define TauPy model for traveltime estimation. Possible values: 1066a, 1066b, ak135, ak135f, herrin, iasp91, jb, prem, pwdk, sp6',
|
'tooltip': 'Define TauPy model for traveltime estimation. Possible values: 1066a, 1066b, ak135, ak135f, herrin, iasp91, jb, prem, pwdk, sp6',
|
||||||
'value': 'iasp91',
|
'value': None,
|
||||||
'namestring': 'TauPy model'},
|
'namestring': 'TauPy model'},
|
||||||
|
|
||||||
'taup_phases': {'type': str,
|
'taup_phases': {'type': str,
|
||||||
|
@ -543,6 +543,7 @@ def writephases(arrivals, fformat, filename, parameter=None, eventinfo=None):
|
|||||||
try:
|
try:
|
||||||
if arrivals[key]['P']['weight'] >= 4:
|
if arrivals[key]['P']['weight'] >= 4:
|
||||||
pweight = 0 # do not use pick
|
pweight = 0 # do not use pick
|
||||||
|
print("Station {}: Uncertain pick, do not use it!".format(key))
|
||||||
except KeyError as e:
|
except KeyError as e:
|
||||||
print(e.message + '; no weight set during processing')
|
print(e.message + '; no weight set during processing')
|
||||||
fid.write('%s ? ? ? P %s %d%02d%02d %02d%02d %7.4f GAU 0 0 0 0 %d \n' % (key,
|
fid.write('%s ? ? ? P %s %d%02d%02d %02d%02d %7.4f GAU 0 0 0 0 %d \n' % (key,
|
||||||
|
@ -81,7 +81,6 @@ def locate(fnin, parameter=None):
|
|||||||
:param fnin: external program name
|
:param fnin: external program name
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
|
|
||||||
exe_path = which('NLLoc', parameter)
|
exe_path = which('NLLoc', parameter)
|
||||||
if exe_path is None:
|
if exe_path is None:
|
||||||
raise NLLocError('NonLinLoc executable not found; check your '
|
raise NLLocError('NonLinLoc executable not found; check your '
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
:author: Ludger Kueperkoch, BESTEC GmbH
|
:author: Ludger Kueperkoch, BESTEC GmbH
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import warnings
|
import warnings
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
import numpy as np
|
import numpy as np
|
||||||
@ -595,6 +596,8 @@ def select_for_phase(st, phase):
|
|||||||
alter_comp = compclass.getCompPosition(comp)
|
alter_comp = compclass.getCompPosition(comp)
|
||||||
alter_comp = str(alter_comp[0])
|
alter_comp = str(alter_comp[0])
|
||||||
sel_st += st.select(component=comp)
|
sel_st += st.select(component=comp)
|
||||||
|
if len(sel_st) < 1:
|
||||||
|
sel_st += st.select(component="Q")
|
||||||
sel_st += st.select(component=alter_comp)
|
sel_st += st.select(component=alter_comp)
|
||||||
elif phase.upper() == 'S':
|
elif phase.upper() == 'S':
|
||||||
comps = 'NE'
|
comps = 'NE'
|
||||||
|
@ -101,3 +101,4 @@ def make_pen(picktype, phase, key, quality):
|
|||||||
linestyle, width = pick_linestyle_pg(picktype, key)
|
linestyle, width = pick_linestyle_pg(picktype, key)
|
||||||
pen = pg.mkPen(rgba, width=width, style=linestyle)
|
pen = pg.mkPen(rgba, width=width, style=linestyle)
|
||||||
return pen
|
return pen
|
||||||
|
|
||||||
|
@ -1594,7 +1594,7 @@ class PickDlg(QDialog):
|
|||||||
|
|
||||||
def __init__(self, parent=None, data=None, station=None, network=None, location=None, picks=None,
|
def __init__(self, parent=None, data=None, station=None, network=None, location=None, picks=None,
|
||||||
autopicks=None, rotate=False, parameter=None, embedded=False, metadata=None,
|
autopicks=None, rotate=False, parameter=None, embedded=False, metadata=None,
|
||||||
event=None, filteroptions=None, model='iasp91', wftype=None):
|
event=None, filteroptions=None, model=None, wftype=None):
|
||||||
super(PickDlg, self).__init__(parent, Qt.Window)
|
super(PickDlg, self).__init__(parent, Qt.Window)
|
||||||
self.orig_parent = parent
|
self.orig_parent = parent
|
||||||
self.setAttribute(Qt.WA_DeleteOnClose)
|
self.setAttribute(Qt.WA_DeleteOnClose)
|
||||||
@ -1719,7 +1719,7 @@ class PickDlg(QDialog):
|
|||||||
|
|
||||||
# init expected picks using obspy Taup
|
# init expected picks using obspy Taup
|
||||||
try:
|
try:
|
||||||
if self.metadata:
|
if self.metadata and model is not None:
|
||||||
self.model = TauPyModel(model)
|
self.model = TauPyModel(model)
|
||||||
self.get_arrivals()
|
self.get_arrivals()
|
||||||
self.drawArrivals()
|
self.drawArrivals()
|
||||||
@ -2704,7 +2704,10 @@ class PickDlg(QDialog):
|
|||||||
# append phase text (if textOnly: draw with current ylims)
|
# append phase text (if textOnly: draw with current ylims)
|
||||||
self.phaseText.append(ax.text(mpp, ylims[1], phase, color=color, zorder=baseorder + 10))
|
self.phaseText.append(ax.text(mpp, ylims[1], phase, color=color, zorder=baseorder + 10))
|
||||||
# indicate first motion
|
# indicate first motion
|
||||||
self.phaseText.append(ax.text(mpp - 0.03 * mpp, ylims[1] - ylims[1] / 12, picks['fm'], color=color, zorder=baseorder + 10))
|
fm = picks.get('fm')
|
||||||
|
if fm:
|
||||||
|
self.phaseText.append(ax.text(mpp - 0.03 * mpp, ylims[1] - ylims[1] / 12, fm, color=color,
|
||||||
|
zorder=baseorder + 10))
|
||||||
ax.legend(loc=1)
|
ax.legend(loc=1)
|
||||||
|
|
||||||
def connect_mouse_motion(self):
|
def connect_mouse_motion(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user