Compare commits
4 Commits
9fce4998d3
...
b3fdbc811e
Author | SHA1 | Date | |
---|---|---|---|
b3fdbc811e | |||
a1f6c5ffca | |||
e4e7afa996 | |||
43c2b97b3d |
61
PyLoT.py
61
PyLoT.py
@ -84,7 +84,7 @@ from pylot.core.util.widgets import FilterOptionsDialog, NewEventDlg, \
|
|||||||
PylotCanvas, WaveformWidgetPG, PropertiesDlg, HelpForm, createAction, PickDlg, \
|
PylotCanvas, WaveformWidgetPG, PropertiesDlg, HelpForm, createAction, PickDlg, \
|
||||||
ComparisonWidget, TuneAutopicker, PylotParaBox, AutoPickDlg, CanvasWidget, AutoPickWidget, \
|
ComparisonWidget, TuneAutopicker, PylotParaBox, AutoPickDlg, CanvasWidget, AutoPickWidget, \
|
||||||
CompareEventsWidget, ProgressBarWidget, AddMetadataWidget, SingleTextLineDialog, LogWidget, PickQualitiesFromXml, \
|
CompareEventsWidget, ProgressBarWidget, AddMetadataWidget, SingleTextLineDialog, LogWidget, PickQualitiesFromXml, \
|
||||||
SourceSpecWindow, ChooseWaveFormWindow
|
SourceSpecWindow, ChooseWaveFormWindow, SpectrogramTab
|
||||||
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.structure import DATASTRUCTURE
|
||||||
from pylot.core.util.thread import Thread, Worker
|
from pylot.core.util.thread import Thread, Worker
|
||||||
@ -496,7 +496,6 @@ class MainWindow(QMainWindow):
|
|||||||
icon=eventlist_xml_icon,
|
icon=eventlist_xml_icon,
|
||||||
tip='Create an Eventlist from a XML File')
|
tip='Create an Eventlist from a XML File')
|
||||||
self.eventlist_xml_action.setEnabled(False)
|
self.eventlist_xml_action.setEnabled(False)
|
||||||
|
|
||||||
printAction = self.createAction(self, "&Print event ...",
|
printAction = self.createAction(self, "&Print event ...",
|
||||||
self.show_event_information, QKeySequence.Print,
|
self.show_event_information, QKeySequence.Print,
|
||||||
print_icon,
|
print_icon,
|
||||||
@ -698,14 +697,17 @@ class MainWindow(QMainWindow):
|
|||||||
wf_tab = QtWidgets.QWidget(self)
|
wf_tab = QtWidgets.QWidget(self)
|
||||||
array_tab = QtWidgets.QWidget(self)
|
array_tab = QtWidgets.QWidget(self)
|
||||||
events_tab = QtWidgets.QWidget(self)
|
events_tab = QtWidgets.QWidget(self)
|
||||||
|
spectro_tab = QtWidgets.QWidget(self)
|
||||||
|
|
||||||
# init main widgets layouts
|
# init main widgets layouts
|
||||||
self.wf_layout = QtWidgets.QVBoxLayout()
|
self.wf_layout = QtWidgets.QVBoxLayout()
|
||||||
self.array_layout = QtWidgets.QVBoxLayout()
|
self.array_layout = QtWidgets.QVBoxLayout()
|
||||||
self.events_layout = QtWidgets.QVBoxLayout()
|
self.events_layout = QtWidgets.QVBoxLayout()
|
||||||
|
self.spectro_layout = QtWidgets.QVBoxLayout()
|
||||||
wf_tab.setLayout(self.wf_layout)
|
wf_tab.setLayout(self.wf_layout)
|
||||||
array_tab.setLayout(self.array_layout)
|
array_tab.setLayout(self.array_layout)
|
||||||
events_tab.setLayout(self.events_layout)
|
events_tab.setLayout(self.events_layout)
|
||||||
|
spectro_tab.setLayout(self.spectro_layout)
|
||||||
|
|
||||||
# tighten up layouts inside tabs
|
# tighten up layouts inside tabs
|
||||||
for layout in [self.wf_layout, self.array_layout, self.events_layout]:
|
for layout in [self.wf_layout, self.array_layout, self.events_layout]:
|
||||||
@ -716,12 +718,14 @@ class MainWindow(QMainWindow):
|
|||||||
self.tabs.addTab(wf_tab, 'Waveform Plot')
|
self.tabs.addTab(wf_tab, 'Waveform Plot')
|
||||||
self.tabs.addTab(array_tab, 'Array Map')
|
self.tabs.addTab(array_tab, 'Array Map')
|
||||||
self.tabs.addTab(events_tab, 'Eventlist')
|
self.tabs.addTab(events_tab, 'Eventlist')
|
||||||
|
self.tabs.addTab(spectro_tab, 'Spectro')
|
||||||
|
|
||||||
self.wf_layout.addWidget(self.no_data_label)
|
self.wf_layout.addWidget(self.no_data_label)
|
||||||
self.wf_layout.addWidget(self.wf_scroll_area)
|
self.wf_layout.addWidget(self.wf_scroll_area)
|
||||||
self.wf_scroll_area.setWidgetResizable(True)
|
self.wf_scroll_area.setWidgetResizable(True)
|
||||||
self.init_array_tab()
|
self.init_array_tab()
|
||||||
self.init_event_table()
|
self.init_event_table()
|
||||||
|
self.init_spectro_tab()
|
||||||
self.tabs.setCurrentIndex(0)
|
self.tabs.setCurrentIndex(0)
|
||||||
|
|
||||||
self.eventLabel = QLabel()
|
self.eventLabel = QLabel()
|
||||||
@ -734,16 +738,13 @@ class MainWindow(QMainWindow):
|
|||||||
_widget.setLayout(self._main_layout)
|
_widget.setLayout(self._main_layout)
|
||||||
_widget.showFullScreen()
|
_widget.showFullScreen()
|
||||||
|
|
||||||
self.logwidget = LogWidget(parent=None)
|
|
||||||
if use_logwidget:
|
if use_logwidget:
|
||||||
|
self.logwidget = LogWidget(parent=None)
|
||||||
self.logwidget.show()
|
self.logwidget.show()
|
||||||
self.stdout = self.logwidget.stdout
|
self.stdout = self.logwidget.stdout
|
||||||
self.stderr = self.logwidget.stderr
|
self.stderr = self.logwidget.stderr
|
||||||
|
|
||||||
# Not sure why but the lines above kept messing with the Ouput even with use_logwidget disabled
|
|
||||||
sys.stdout = self.stdout
|
|
||||||
sys.stderr = self.stderr
|
|
||||||
|
|
||||||
self.setCentralWidget(_widget)
|
self.setCentralWidget(_widget)
|
||||||
|
|
||||||
# Need to store PickQualities Window somewhere so it doesnt disappear
|
# Need to store PickQualities Window somewhere so it doesnt disappear
|
||||||
@ -1678,20 +1679,20 @@ class MainWindow(QMainWindow):
|
|||||||
|
|
||||||
def pickQualities(self):
|
def pickQualities(self):
|
||||||
path = self.get_current_event_path()
|
path = self.get_current_event_path()
|
||||||
(_, _, plot) = getQualitiesfromxml(path, self._inputs.get('timeerrorsP'), self._inputs.get('timeerrorsS'),plotflag=1)
|
(_, plot) = getQualitiesfromxml(path, self._inputs.get('timeerrorsP'), self._inputs.get('timeerrorsS'),plotflag=1)
|
||||||
self.pickQualitiesWindow = PickQualitiesFromXml(figure=plot, path=self.get_current_event_path(),inputVar=self._inputs)
|
self.pickQualitiesWindow = PickQualitiesFromXml(figure=plot, path=self.get_current_event_path(),inputVar=self._inputs)
|
||||||
self.pickQualitiesWindow.showUI()
|
self.pickQualitiesWindow.showUI()
|
||||||
return
|
return
|
||||||
|
|
||||||
# WIP JG
|
# WIP JG
|
||||||
def eventlistXml2(self):
|
def eventlistXml(self):
|
||||||
path = self._inputs['rootpath'] + '/' + self._inputs['datapath'] + '/' + self._inputs['database']
|
path = self._inputs['rootpath'] + '/' + self._inputs['datapath'] + '/' + self._inputs['database']
|
||||||
outpath = self.project.location[:self.project.location.rfind('/')]
|
outpath = self.project.location[:self.project.location.rfind('/')]
|
||||||
geteventlistfromxml(path, outpath)
|
geteventlistfromxml(path, outpath)
|
||||||
return
|
return
|
||||||
|
|
||||||
# WIP JG
|
# WIP JG
|
||||||
def eventlistXml(self):
|
def spectogramView(self):
|
||||||
global test
|
global test
|
||||||
stations = []
|
stations = []
|
||||||
names = []
|
names = []
|
||||||
@ -1706,12 +1707,25 @@ class MainWindow(QMainWindow):
|
|||||||
for tr in self.get_data().wfdata.select(component=ch).traces:
|
for tr in self.get_data().wfdata.select(component=ch).traces:
|
||||||
traces[tr.stats.station][ch] = tr
|
traces[tr.stats.station][ch] = tr
|
||||||
|
|
||||||
|
|
||||||
names.sort()
|
names.sort()
|
||||||
a = self.get_current_event()
|
a = self.get_current_event()
|
||||||
test = ChooseWaveFormWindow(WaveForms=names, traces=traces, stream=self.get_data())
|
|
||||||
|
print (self.get_data().wfdata.traces[0])
|
||||||
|
|
||||||
|
test = SpectrogramTab(traces, self.get_data().wfdata)
|
||||||
|
height = self.tabs.widget(0).height()
|
||||||
|
width = self.tabs.widget(0).width()
|
||||||
|
self.tabs.setCurrentIndex(3)
|
||||||
|
figCanvas = test.makeSpecFig(direction=self.dispComponent, height = height, width = width, parent = self.tabs.widget)
|
||||||
|
return figCanvas
|
||||||
|
#self.spectro_layout.addWidget()
|
||||||
# self.get_data().wfdata.spectrogram()
|
# self.get_data().wfdata.spectrogram()
|
||||||
test.show()
|
# self.tabs.addTab(figCanvas, 'Spectrogram')
|
||||||
|
# self.tabs[3] = figCanvas
|
||||||
|
# self.refreshTabs()
|
||||||
|
# test.show()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def compareMulti(self):
|
def compareMulti(self):
|
||||||
if not self.compareoptions:
|
if not self.compareoptions:
|
||||||
@ -1898,6 +1912,13 @@ class MainWindow(QMainWindow):
|
|||||||
self.newWF(plot=False)
|
self.newWF(plot=False)
|
||||||
self.update_obspy_dmt()
|
self.update_obspy_dmt()
|
||||||
self.refresh_array_map()
|
self.refresh_array_map()
|
||||||
|
if self.tabs.currentIndex() == 3:
|
||||||
|
if self.spectroWidget != None:
|
||||||
|
self.spectro_layout.removeWidget(self.spectroWidget)
|
||||||
|
newSpectroWidget = self.spectogramView()
|
||||||
|
self.spectro_layout.addWidget(newSpectroWidget)
|
||||||
|
self.spectroWidget = newSpectroWidget
|
||||||
|
|
||||||
|
|
||||||
def newWF(self, event=None, plot=True):
|
def newWF(self, event=None, plot=True):
|
||||||
'''
|
'''
|
||||||
@ -2155,6 +2176,7 @@ class MainWindow(QMainWindow):
|
|||||||
self.locateEventAction.setEnabled(True)
|
self.locateEventAction.setEnabled(True)
|
||||||
self.qualities_action.setEnabled(True)
|
self.qualities_action.setEnabled(True)
|
||||||
self.eventlist_xml_action.setEnabled(True)
|
self.eventlist_xml_action.setEnabled(True)
|
||||||
|
|
||||||
if True in self.comparable.values():
|
if True in self.comparable.values():
|
||||||
self.compare_action.setEnabled(True)
|
self.compare_action.setEnabled(True)
|
||||||
self.draw()
|
self.draw()
|
||||||
@ -3128,7 +3150,7 @@ class MainWindow(QMainWindow):
|
|||||||
phasefile = os.path.join(obsdir, filename + '.obs')
|
phasefile = os.path.join(obsdir, filename + '.obs')
|
||||||
lt.modify_inputs(ctrfile, locroot, filename, phasefile, ttt)
|
lt.modify_inputs(ctrfile, locroot, filename, phasefile, ttt)
|
||||||
try:
|
try:
|
||||||
lt.locate(ctrfile, self.obspy_dmt)
|
lt.locate(ctrfile, self._inputs)
|
||||||
except RuntimeError as e:
|
except RuntimeError as e:
|
||||||
print(e.message)
|
print(e.message)
|
||||||
# finally:
|
# finally:
|
||||||
@ -3182,7 +3204,7 @@ class MainWindow(QMainWindow):
|
|||||||
'''
|
'''
|
||||||
if checked: pass # dummy argument for QAction trigger signal
|
if checked: pass # dummy argument for QAction trigger signal
|
||||||
self.tabs.setCurrentIndex(1)
|
self.tabs.setCurrentIndex(1)
|
||||||
# if there is no metadata (invetories is an empty list), just initialize the default empty tab
|
# if there is no metadata (inventories is an empty list), just initialize the default empty tab
|
||||||
if not self.metadata.inventories:
|
if not self.metadata.inventories:
|
||||||
self.init_array_tab()
|
self.init_array_tab()
|
||||||
return
|
return
|
||||||
@ -3204,6 +3226,15 @@ class MainWindow(QMainWindow):
|
|||||||
self.tabs.setCurrentIndex(index)
|
self.tabs.setCurrentIndex(index)
|
||||||
self.refresh_array_map()
|
self.refresh_array_map()
|
||||||
|
|
||||||
|
def init_spectro_tab(self):
|
||||||
|
'''
|
||||||
|
Init spectrogram tab with currently selected event.
|
||||||
|
'''
|
||||||
|
self.spectroWidget = None
|
||||||
|
#self.spectro_layout.addWidget( self.spectogramView() )
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def array_map_thread(self):
|
def array_map_thread(self):
|
||||||
'''
|
'''
|
||||||
Start modal thread to init the array_map object.
|
Start modal thread to init the array_map object.
|
||||||
|
@ -260,7 +260,6 @@ class Data(object):
|
|||||||
can be a str or a list of strings of ['manual', 'auto', 'origin', 'magnitude']
|
can be a str or a list of strings of ['manual', 'auto', 'origin', 'magnitude']
|
||||||
"""
|
"""
|
||||||
from pylot.core.util.defaults import OUTPUTFORMATS
|
from pylot.core.util.defaults import OUTPUTFORMATS
|
||||||
|
|
||||||
if not type(fcheck) == list:
|
if not type(fcheck) == list:
|
||||||
fcheck = [fcheck]
|
fcheck = [fcheck]
|
||||||
|
|
||||||
@ -321,35 +320,61 @@ class Data(object):
|
|||||||
if lendiff != 0:
|
if lendiff != 0:
|
||||||
print("Manual as well as automatic picks available. Prefered the {} manual ones!".format(lendiff))
|
print("Manual as well as automatic picks available. Prefered the {} manual ones!".format(lendiff))
|
||||||
|
|
||||||
|
|
||||||
|
no_uncertainties_p = []
|
||||||
|
no_uncertainties_s = []
|
||||||
if upperErrors:
|
if upperErrors:
|
||||||
# check for pick uncertainties exceeding adjusted upper errors
|
# check for pick uncertainties exceeding adjusted upper errors
|
||||||
# Picks with larger uncertainties will not be saved in output file!
|
# Picks with larger uncertainties will not be saved in output file!
|
||||||
for j in range(len(picks)):
|
for j in range(len(picks)):
|
||||||
for i in range(len(picks_copy)):
|
for i in range(len(picks_copy)):
|
||||||
if picks_copy[i].phase_hint[0] == 'P':
|
if picks_copy[i].phase_hint[0] == 'P':
|
||||||
if (picks_copy[i].time_errors['upper_uncertainty'] >= upperErrors[0]) or \
|
# Skipping pick if no upper_uncertainty is found and warning user
|
||||||
(picks_copy[i].time_errors['uncertainty'] is None):
|
if picks_copy[i].time_errors['upper_uncertainty'] is None:
|
||||||
|
#print("{1} P-Pick of station {0} does not have upper_uncertainty and cant be checked".format(
|
||||||
|
# picks_copy[i].waveform_id.station_code,
|
||||||
|
# picks_copy[i].method_id))
|
||||||
|
if not picks_copy[i].waveform_id.station_code in no_uncertainties_p:
|
||||||
|
no_uncertainties_p.append(picks_copy[i].waveform_id.station_code)
|
||||||
|
continue
|
||||||
|
|
||||||
|
#print ("checking for upper_uncertainty")
|
||||||
|
if (picks_copy[i].time_errors['uncertainty'] is None) or \
|
||||||
|
(picks_copy[i].time_errors['upper_uncertainty'] >= upperErrors[0]):
|
||||||
print("Uncertainty exceeds or equal adjusted upper time error!")
|
print("Uncertainty exceeds or equal adjusted upper time error!")
|
||||||
print("Adjusted uncertainty: {}".format(upperErrors[0]))
|
print("Adjusted uncertainty: {}".format(upperErrors[0]))
|
||||||
print("Pick uncertainty: {}".format(picks_copy[i].time_errors['uncertainty']))
|
print("Pick uncertainty: {}".format(picks_copy[i].time_errors['uncertainty']))
|
||||||
print("{1} P-Pick of station {0} will not be saved in outputfile".format(
|
print("{1} P-Pick of station {0} will not be saved in outputfile".format(
|
||||||
picks_copy[i].waveform_id.station_code,
|
picks_copy[i].waveform_id.station_code,
|
||||||
picks_copy[i].method_id))
|
picks_copy[i].method_id))
|
||||||
print("#")
|
|
||||||
del picks_copy[i]
|
del picks_copy[i]
|
||||||
break
|
break
|
||||||
if picks_copy[i].phase_hint[0] == 'S':
|
if picks_copy[i].phase_hint[0] == 'S':
|
||||||
if (picks_copy[i].time_errors['upper_uncertainty'] >= upperErrors[1]) or \
|
|
||||||
(picks_copy[i].time_errors['uncertainty'] is None):
|
# Skipping pick if no upper_uncertainty is found and warning user
|
||||||
|
if picks_copy[i].time_errors['upper_uncertainty'] is None:
|
||||||
|
#print("{1} S-Pick of station {0} does not have upper_uncertainty and cant be checked".format(
|
||||||
|
#picks_copy[i].waveform_id.station_code,
|
||||||
|
#picks_copy[i].method_id))
|
||||||
|
if not picks_copy[i].waveform_id.station_code in no_uncertainties_s:
|
||||||
|
no_uncertainties_s.append(picks_copy[i].waveform_id.station_code)
|
||||||
|
continue
|
||||||
|
|
||||||
|
|
||||||
|
if (picks_copy[i].time_errors['uncertainty'] is None) or \
|
||||||
|
(picks_copy[i].time_errors['upper_uncertainty'] >= upperErrors[1]):
|
||||||
print("Uncertainty exceeds or equal adjusted upper time error!")
|
print("Uncertainty exceeds or equal adjusted upper time error!")
|
||||||
print("Adjusted uncertainty: {}".format(upperErrors[1]))
|
print("Adjusted uncertainty: {}".format(upperErrors[1]))
|
||||||
print("Pick uncertainty: {}".format(picks_copy[i].time_errors['uncertainty']))
|
print("Pick uncertainty: {}".format(picks_copy[i].time_errors['uncertainty']))
|
||||||
print("{1} S-Pick of station {0} will not be saved in outputfile".format(
|
print("{1} S-Pick of station {0} will not be saved in outputfile".format(
|
||||||
picks_copy[i].waveform_id.station_code,
|
picks_copy[i].waveform_id.station_code,
|
||||||
picks_copy[i].method_id))
|
picks_copy[i].method_id))
|
||||||
print("#")
|
|
||||||
del picks_copy[i]
|
del picks_copy[i]
|
||||||
break
|
break
|
||||||
|
for s in no_uncertainties_p:
|
||||||
|
print("P-Pick of station {0} does not have upper_uncertainty and cant be checked".format(s))
|
||||||
|
for s in no_uncertainties_s:
|
||||||
|
print("S-Pick of station {0} does not have upper_uncertainty and cant be checked".format(s))
|
||||||
|
|
||||||
if fnext == '.obs':
|
if fnext == '.obs':
|
||||||
try:
|
try:
|
||||||
|
@ -517,7 +517,7 @@ def writephases(arrivals, fformat, filename, parameter=None, eventinfo=None):
|
|||||||
arrivals = chooseArrivals(arrivals) # MP MP what is chooseArrivals? It is not defined anywhere
|
arrivals = chooseArrivals(arrivals) # MP MP what is chooseArrivals? It is not defined anywhere
|
||||||
for key in arrivals:
|
for key in arrivals:
|
||||||
# P onsets
|
# P onsets
|
||||||
if arrivals[key].has_key('P'):
|
if 'P' in arrivals[key]:
|
||||||
try:
|
try:
|
||||||
fm = arrivals[key]['P']['fm']
|
fm = arrivals[key]['P']['fm']
|
||||||
except KeyError as e:
|
except KeyError as e:
|
||||||
@ -551,7 +551,7 @@ def writephases(arrivals, fformat, filename, parameter=None, eventinfo=None):
|
|||||||
ss_ms,
|
ss_ms,
|
||||||
pweight))
|
pweight))
|
||||||
# S onsets
|
# S onsets
|
||||||
if arrivals[key].has_key('S') and arrivals[key]['S']['mpp'] is not None:
|
if 'S' in arrivals[key] and arrivals[key]['S']['mpp'] is not None:
|
||||||
fm = '?'
|
fm = '?'
|
||||||
onset = arrivals[key]['S']['mpp']
|
onset = arrivals[key]['S']['mpp']
|
||||||
year = onset.year
|
year = onset.year
|
||||||
@ -670,7 +670,7 @@ def writephases(arrivals, fformat, filename, parameter=None, eventinfo=None):
|
|||||||
arrivals = chooseArrivals(arrivals) # MP MP what is chooseArrivals? It is not defined anywhere
|
arrivals = chooseArrivals(arrivals) # MP MP what is chooseArrivals? It is not defined anywhere
|
||||||
for key in arrivals:
|
for key in arrivals:
|
||||||
# P onsets
|
# P onsets
|
||||||
if arrivals[key].has_key('P') and arrivals[key]['P']['mpp'] is not None:
|
if 'P' in arrivals[key] and arrivals[key]['P']['mpp'] is not None:
|
||||||
if arrivals[key]['P']['weight'] < 4:
|
if arrivals[key]['P']['weight'] < 4:
|
||||||
Ponset = arrivals[key]['P']['mpp']
|
Ponset = arrivals[key]['P']['mpp']
|
||||||
pyear = Ponset.year
|
pyear = Ponset.year
|
||||||
@ -699,7 +699,7 @@ def writephases(arrivals, fformat, filename, parameter=None, eventinfo=None):
|
|||||||
fid.write('%-5s P1 %4.0f %02d %02d %02d %02d %05.02f %5.3f -999. 0.00 -999. 0.00\n'
|
fid.write('%-5s P1 %4.0f %02d %02d %02d %02d %05.02f %5.3f -999. 0.00 -999. 0.00\n'
|
||||||
% (key, pyear, pmonth, pday, phh, pmm, Pss, pstd))
|
% (key, pyear, pmonth, pday, phh, pmm, Pss, pstd))
|
||||||
# S onsets
|
# S onsets
|
||||||
if arrivals[key].has_key('S') and arrivals[key]['S']['mpp'] is not None:
|
if 'S' in arrivals[key] and arrivals[key]['S']['mpp'] is not None:
|
||||||
if arrivals[key]['S']['weight'] < 4:
|
if arrivals[key]['S']['weight'] < 4:
|
||||||
Sonset = arrivals[key]['S']['mpp']
|
Sonset = arrivals[key]['S']['mpp']
|
||||||
syear = Sonset.year
|
syear = Sonset.year
|
||||||
@ -768,7 +768,7 @@ def writephases(arrivals, fformat, filename, parameter=None, eventinfo=None):
|
|||||||
usedarrivals = chooseArrivals(arrivals)
|
usedarrivals = chooseArrivals(arrivals)
|
||||||
for key in usedarrivals:
|
for key in usedarrivals:
|
||||||
# P onsets
|
# P onsets
|
||||||
if usedarrivals[key].has_key('P'):
|
if 'P' in usedarrivals[key]:
|
||||||
if usedarrivals[key]['P']['weight'] < 4:
|
if usedarrivals[key]['P']['weight'] < 4:
|
||||||
n += 1
|
n += 1
|
||||||
stat = key
|
stat = key
|
||||||
@ -782,7 +782,7 @@ def writephases(arrivals, fformat, filename, parameter=None, eventinfo=None):
|
|||||||
else:
|
else:
|
||||||
fid.write('%-4sP%d%6.2f\n' % (stat, Pweight, Prt))
|
fid.write('%-4sP%d%6.2f\n' % (stat, Pweight, Prt))
|
||||||
# S onsets
|
# S onsets
|
||||||
if usedarrivals[key].has_key('S'):
|
if 'S' in usedarrivals[key]:
|
||||||
if usedarrivals[key]['S']['weight'] < 4:
|
if usedarrivals[key]['S']['weight'] < 4:
|
||||||
n += 1
|
n += 1
|
||||||
stat = key
|
stat = key
|
||||||
@ -828,13 +828,13 @@ def writephases(arrivals, fformat, filename, parameter=None, eventinfo=None):
|
|||||||
# prefer manual picks
|
# prefer manual picks
|
||||||
usedarrivals = chooseArrivals(arrivals)
|
usedarrivals = chooseArrivals(arrivals)
|
||||||
for key in usedarrivals:
|
for key in usedarrivals:
|
||||||
if usedarrivals[key].has_key('P'):
|
if 'P' in usedarrivals[key]:
|
||||||
# P onsets
|
# P onsets
|
||||||
if usedarrivals[key]['P']['weight'] < 4:
|
if usedarrivals[key]['P']['weight'] < 4:
|
||||||
Ponset = usedarrivals[key]['P']['mpp']
|
Ponset = usedarrivals[key]['P']['mpp']
|
||||||
Prt = Ponset - stime # onset time relative to source time
|
Prt = Ponset - stime # onset time relative to source time
|
||||||
fid.write('%s %6.3f 1 P\n' % (key, Prt))
|
fid.write('%s %6.3f 1 P\n' % (key, Prt))
|
||||||
if usedarrivals[key].has_key('S'):
|
if 'S' in usedarrivals[key]:
|
||||||
# S onsets
|
# S onsets
|
||||||
if usedarrivals[key]['S']['weight'] < 4:
|
if usedarrivals[key]['S']['weight'] < 4:
|
||||||
Sonset = usedarrivals[key]['S']['mpp']
|
Sonset = usedarrivals[key]['S']['mpp']
|
||||||
@ -879,7 +879,7 @@ def writephases(arrivals, fformat, filename, parameter=None, eventinfo=None):
|
|||||||
# prefer manual picks
|
# prefer manual picks
|
||||||
usedarrivals = chooseArrivals(arrivals)
|
usedarrivals = chooseArrivals(arrivals)
|
||||||
for key in usedarrivals:
|
for key in usedarrivals:
|
||||||
if usedarrivals[key].has_key('P'):
|
if 'P' in usedarrivals[key]:
|
||||||
if usedarrivals[key]['P']['weight'] < 4 and usedarrivals[key]['P']['fm'] is not None:
|
if usedarrivals[key]['P']['weight'] < 4 and usedarrivals[key]['P']['fm'] is not None:
|
||||||
stat = key
|
stat = key
|
||||||
for i in range(len(picks)):
|
for i in range(len(picks)):
|
||||||
@ -961,7 +961,7 @@ def writephases(arrivals, fformat, filename, parameter=None, eventinfo=None):
|
|||||||
arrivals = chooseArrivals(arrivals) # MP MP what is chooseArrivals? It is not defined anywhere
|
arrivals = chooseArrivals(arrivals) # MP MP what is chooseArrivals? It is not defined anywhere
|
||||||
# write phase lines
|
# write phase lines
|
||||||
for key in arrivals:
|
for key in arrivals:
|
||||||
if arrivals[key].has_key('P'):
|
if 'P' in arrivals[key]:
|
||||||
if arrivals[key]['P']['weight'] < 4 and arrivals[key]['P']['fm'] is not None:
|
if arrivals[key]['P']['weight'] < 4 and arrivals[key]['P']['fm'] is not None:
|
||||||
stat = key
|
stat = key
|
||||||
ccode = arrivals[key]['P']['channel']
|
ccode = arrivals[key]['P']['channel']
|
||||||
@ -1014,7 +1014,6 @@ def chooseArrivals(arrivals):
|
|||||||
:return: arrivals but with the manual picks prefered if possible
|
:return: arrivals but with the manual picks prefered if possible
|
||||||
"""
|
"""
|
||||||
# If len of arrivals is greater than 2 it comes from autopicking so only autopicks are available
|
# If len of arrivals is greater than 2 it comes from autopicking so only autopicks are available
|
||||||
print("=== CHOOSE ===")
|
|
||||||
if len(arrivals) > 2:
|
if len(arrivals) > 2:
|
||||||
return arrivals
|
return arrivals
|
||||||
if arrivals['auto'] and arrivals['manual']:
|
if arrivals['auto'] and arrivals['manual']:
|
||||||
|
@ -41,6 +41,7 @@ class Thread(QThread):
|
|||||||
exctype, value = sys.exc_info()[:2]
|
exctype, value = sys.exc_info()[:2]
|
||||||
self._executedErrorInfo = '{} {} {}'. \
|
self._executedErrorInfo = '{} {} {}'. \
|
||||||
format(exctype, value, traceback.format_exc())
|
format(exctype, value, traceback.format_exc())
|
||||||
|
if self.redirect_stdout:
|
||||||
sys.stdout = self.old_stdout
|
sys.stdout = self.old_stdout
|
||||||
|
|
||||||
def showProgressbar(self):
|
def showProgressbar(self):
|
||||||
|
@ -5663,9 +5663,23 @@ class ChooseWaveFormWindow(QWidget):
|
|||||||
def submit(self):
|
def submit(self):
|
||||||
matplotlib.pyplot.close(self.currentSpectro)
|
matplotlib.pyplot.close(self.currentSpectro)
|
||||||
t = self.chooseBoxTraces.currentText() + " " + self.chooseBoxComponent.currentText()
|
t = self.chooseBoxTraces.currentText() + " " + self.chooseBoxComponent.currentText()
|
||||||
self.currentSpectro = self.traces[
|
#self.currentSpectro = self.traces[
|
||||||
self.chooseBoxTraces.currentText()[3:]][self.chooseBoxComponent.currentText()].spectrogram(show=False, title=t)
|
# self.chooseBoxTraces.currentText()[3:]][self.chooseBoxComponent.currentText()].spectrogram(show=False, title=t)
|
||||||
self.currentSpectro.show()
|
#self.currentSpectro.show()
|
||||||
|
applyFFT()
|
||||||
|
|
||||||
|
def applyFFT(self, trace):
|
||||||
|
tra = self.traces[self.chooseBoxTraces.currentText()[3:]]['Z']
|
||||||
|
transformed = abs(np.fft.rfft(tra.data))
|
||||||
|
print ( transformed )
|
||||||
|
matplotlib.pyplot.plot ( transformed )
|
||||||
|
matplotlib.pyplot.show()
|
||||||
|
|
||||||
|
def applyFFTs(self, tra):
|
||||||
|
transformed = abs(np.fft.rfft(tra.data))
|
||||||
|
print ( transformed )
|
||||||
|
matplotlib.pyplot.plot ( transformed )
|
||||||
|
matplotlib.pyplot.show()
|
||||||
|
|
||||||
def submitN(self):
|
def submitN(self):
|
||||||
matplotlib.pyplot.close(self.currentSpectro)
|
matplotlib.pyplot.close(self.currentSpectro)
|
||||||
@ -5681,13 +5695,6 @@ class ChooseWaveFormWindow(QWidget):
|
|||||||
self.chooseBoxTraces.currentText()[3:]]['E'].spectrogram(show=False, title=t)
|
self.chooseBoxTraces.currentText()[3:]]['E'].spectrogram(show=False, title=t)
|
||||||
self.currentSpectro.show()
|
self.currentSpectro.show()
|
||||||
|
|
||||||
def submitZ(self):
|
|
||||||
matplotlib.pyplot.close(self.currentSpectro)
|
|
||||||
t = self.chooseBoxTraces.currentText() + " " + self.chooseBoxComponent.currentText()
|
|
||||||
self.currentSpectro = self.traces[
|
|
||||||
self.chooseBoxTraces.currentText()[3:]]['Z'].spectrogram(show=False, title=t)
|
|
||||||
self.currentSpectro.show()
|
|
||||||
|
|
||||||
# Creates a QComboBox and adds all traces provided
|
# Creates a QComboBox and adds all traces provided
|
||||||
def createComboBoxTraces(self):
|
def createComboBoxTraces(self):
|
||||||
if len(self.wFs) <= 0:
|
if len(self.wFs) <= 0:
|
||||||
@ -5714,6 +5721,86 @@ class ChooseWaveFormWindow(QWidget):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class SpectrogramTab(QWidget):
|
||||||
|
def __init__(self, traces, wfdata, parent=None):
|
||||||
|
super(SpectrogramTab, self).__init__(parent)
|
||||||
|
self.setupUi()
|
||||||
|
self.traces = traces
|
||||||
|
self.wfdata = wfdata
|
||||||
|
|
||||||
|
def setupUi(self):
|
||||||
|
pass
|
||||||
|
def makeSpecFig(self, direction = 'Z', height = 0, width = 0, parent = None):
|
||||||
|
|
||||||
|
i = 0
|
||||||
|
grams = []
|
||||||
|
figure, axis = matplotlib.pyplot.subplots(len(self.traces), sharex=True)
|
||||||
|
|
||||||
|
start, end = full_range(self.wfdata)
|
||||||
|
|
||||||
|
if height != 0 and width != 0:
|
||||||
|
figure.figsize = (width, height)
|
||||||
|
figure.set_figwidth = width
|
||||||
|
figure.set_figheight = height
|
||||||
|
|
||||||
|
#figure.tight_layout()
|
||||||
|
|
||||||
|
for t in self.traces:
|
||||||
|
tra = self.traces[t][direction]
|
||||||
|
#print(start, end)
|
||||||
|
|
||||||
|
# Set Title
|
||||||
|
if i == 0:
|
||||||
|
if direction == 'Z':
|
||||||
|
figure.suptitle("section: vertical components")
|
||||||
|
elif direction == 'E':
|
||||||
|
figure.suptitle("section: east-west components")
|
||||||
|
elif direction == 'N':
|
||||||
|
figure.suptitle("section: north-south components")
|
||||||
|
axis[i].vlines(0, axis[i].get_ylim()[0], axis[i].get_ylim()[1],
|
||||||
|
colors='m', linestyles='dashed',
|
||||||
|
linewidth=2)
|
||||||
|
|
||||||
|
# Different axis settings for visual improvements
|
||||||
|
# axis[i].set_xlim(left=0, right=end - start)
|
||||||
|
# axis[i].spines['top'].set_visible(False)
|
||||||
|
# axis[i].spines['right'].set_visible(False)
|
||||||
|
# # axis[i].spines['left'].set_visible(False)
|
||||||
|
|
||||||
|
# axis[i].tick_params(axis='x', which='both', bottom=False, top=False, labelbottom=False)
|
||||||
|
# if not (len(self.traces) == i - 1):
|
||||||
|
# axis[i].spines['bottom'].set_visible(False)
|
||||||
|
# axis[i].set_yticks([])
|
||||||
|
# axis[i].set_ylabel(t, loc='center', rotation='horizontal')
|
||||||
|
|
||||||
|
#ax.axhline(n, color="0.5", lw=0.5)
|
||||||
|
|
||||||
|
|
||||||
|
grams.append(tra.spectrogram(show=False, axes=axis[i]))
|
||||||
|
i+=1
|
||||||
|
|
||||||
|
#figure.setXLims([0, end - start])
|
||||||
|
figure.set_tight_layout(True)
|
||||||
|
fC = FigureCanvas(figure)
|
||||||
|
return fC
|
||||||
|
|
||||||
|
#for t in self.traces:
|
||||||
|
# tra = self.traces[t]['Z']
|
||||||
|
# transformed = abs(np.fft.rfft(tra.data))
|
||||||
|
# axis[i].plot(transformed, label=t)
|
||||||
|
# # axis[i].tick_params(labelbottom=False)
|
||||||
|
# axis[i].spines['top'].set_visible(False)
|
||||||
|
# axis[i].spines['right'].set_visible(False)
|
||||||
|
# axis[i].spines['left'].set_visible(False)
|
||||||
|
# if not (len(self.traces) == i - 1):
|
||||||
|
# axis[i].spines['bottom'].set_visible(False)
|
||||||
|
# axis[i].set_yticks([])
|
||||||
|
# axis[i].set_ylabel(t, loc='center', rotation='horizontal')
|
||||||
|
# # axis[i].axis('off')
|
||||||
|
# i += 1
|
||||||
|
# # self.applyFFTs(t)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import doctest
|
import doctest
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user