Compare commits
2 Commits
962cf4edac
...
d879aa1a8b
Author | SHA1 | Date | |
---|---|---|---|
d879aa1a8b | |||
445f1da5ac |
10
PyLoT.py
10
PyLoT.py
@ -254,7 +254,7 @@ class MainWindow(QMainWindow):
|
|||||||
self._inputs.export2File(infile)
|
self._inputs.export2File(infile)
|
||||||
self.infile = infile
|
self.infile = infile
|
||||||
|
|
||||||
def setupUi(self):
|
def setupUi(self, use_logwidget=True):
|
||||||
try:
|
try:
|
||||||
self.startTime = min(
|
self.startTime = min(
|
||||||
[tr.stats.starttime for tr in self.data.wfdata])
|
[tr.stats.starttime for tr in self.data.wfdata])
|
||||||
@ -731,10 +731,14 @@ class MainWindow(QMainWindow):
|
|||||||
_widget.setLayout(self._main_layout)
|
_widget.setLayout(self._main_layout)
|
||||||
_widget.showFullScreen()
|
_widget.showFullScreen()
|
||||||
|
|
||||||
|
if use_logwidget:
|
||||||
self.logwidget = LogWidget(parent=None)
|
self.logwidget = LogWidget(parent=None)
|
||||||
self.logwidget.show()
|
self.logwidget.show()
|
||||||
sys.stdout = self.logwidget.stdout
|
self.stdout = self.logwidget.stdout
|
||||||
sys.stderr = self.logwidget.stderr
|
self.stderr = self.logwidget.stderr
|
||||||
|
|
||||||
|
sys.stdout = self.stdout
|
||||||
|
sys.stderr = self.stderr
|
||||||
|
|
||||||
self.setCentralWidget(_widget)
|
self.setCentralWidget(_widget)
|
||||||
|
|
||||||
|
@ -1103,14 +1103,14 @@ def getQualitiesfromxml(xmlnames, ErrorsP, ErrorsS, plotflag=1):
|
|||||||
if phase == 'P':
|
if phase == 'P':
|
||||||
if ((mpick.waveform_id.station_code == mstation) or
|
if ((mpick.waveform_id.station_code == mstation) or
|
||||||
(mpick.waveform_id.station_code == mstation_ext)) and \
|
(mpick.waveform_id.station_code == mstation_ext)) and \
|
||||||
(mpick.method_id.split('/')[1] == 'auto') and \
|
(mpick.method_id.id.split('/')[1] == 'auto') and \
|
||||||
(mpick.time_errors['uncertainty'] <= ErrorsP[3]):
|
(mpick.time_errors['uncertainty'] <= ErrorsP[3]):
|
||||||
del mpick
|
del mpick
|
||||||
break
|
break
|
||||||
elif phase == 'S':
|
elif phase == 'S':
|
||||||
if ((mpick.waveform_id.station_code == mstation) or
|
if ((mpick.waveform_id.station_code == mstation) or
|
||||||
(mpick.waveform_id.station_code == mstation_ext)) and \
|
(mpick.waveform_id.station_code == mstation_ext)) and \
|
||||||
(mpick.method_id.split('/')[1] == 'auto') and \
|
(mpick.method_id.id.split('/')[1] == 'auto') and \
|
||||||
(mpick.time_errors['uncertainty'] <= ErrorsS[3]):
|
(mpick.time_errors['uncertainty'] <= ErrorsS[3]):
|
||||||
del mpick
|
del mpick
|
||||||
break
|
break
|
||||||
@ -1208,3 +1208,5 @@ def getQualitiesfromxml(xmlnames, ErrorsP, ErrorsS, plotflag=1):
|
|||||||
plt.xlabel('Qualities')
|
plt.xlabel('Qualities')
|
||||||
plt.title('{0} P-Qualities, {1} S-Qualities'.format(numPweights, numSweights))
|
plt.title('{0} P-Qualities, {1} S-Qualities'.format(numPweights, numSweights))
|
||||||
plt.show()
|
plt.show()
|
||||||
|
|
||||||
|
return [P0perc, P1perc, P2perc, P3perc, P4perc], [S0perc, S1perc, S2perc, S3perc, S4perc]
|
||||||
|
@ -22,9 +22,11 @@ class Thread(QThread):
|
|||||||
self.abortButton = abortButton
|
self.abortButton = abortButton
|
||||||
self.finished.connect(self.hideProgressbar)
|
self.finished.connect(self.hideProgressbar)
|
||||||
self.showProgressbar()
|
self.showProgressbar()
|
||||||
|
self.old_stdout = None
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
if self.redirect_stdout:
|
if self.redirect_stdout:
|
||||||
|
self.old_stdout = sys.stdout
|
||||||
sys.stdout = self
|
sys.stdout = self
|
||||||
try:
|
try:
|
||||||
if self.arg is not None:
|
if self.arg is not None:
|
||||||
@ -39,7 +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())
|
||||||
sys.stdout = sys.__stdout__
|
sys.stdout = self.old_stdout
|
||||||
|
|
||||||
def showProgressbar(self):
|
def showProgressbar(self):
|
||||||
if self.progressText:
|
if self.progressText:
|
||||||
@ -96,10 +98,12 @@ class Worker(QRunnable):
|
|||||||
self.progressText = progressText
|
self.progressText = progressText
|
||||||
self.pb_widget = pb_widget
|
self.pb_widget = pb_widget
|
||||||
self.redirect_stdout = redirect_stdout
|
self.redirect_stdout = redirect_stdout
|
||||||
|
self.old_stdout = None
|
||||||
|
|
||||||
@Slot()
|
@Slot()
|
||||||
def run(self):
|
def run(self):
|
||||||
if self.redirect_stdout:
|
if self.redirect_stdout:
|
||||||
|
self.old_stdout = sys.stdout
|
||||||
sys.stdout = self
|
sys.stdout = self
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -112,7 +116,7 @@ class Worker(QRunnable):
|
|||||||
self.signals.result.emit(result)
|
self.signals.result.emit(result)
|
||||||
finally:
|
finally:
|
||||||
self.signals.finished.emit('Done')
|
self.signals.finished.emit('Done')
|
||||||
sys.stdout = sys.__stdout__
|
sys.stdout = self.old_stdout
|
||||||
|
|
||||||
def write(self, text):
|
def write(self, text):
|
||||||
self.signals.message.emit(text)
|
self.signals.message.emit(text)
|
||||||
@ -144,11 +148,13 @@ class MultiThread(QThread):
|
|||||||
self.progressText = progressText
|
self.progressText = progressText
|
||||||
self.pb_widget = pb_widget
|
self.pb_widget = pb_widget
|
||||||
self.redirect_stdout = redirect_stdout
|
self.redirect_stdout = redirect_stdout
|
||||||
|
self.old_stdout = None
|
||||||
self.finished.connect(self.hideProgressbar)
|
self.finished.connect(self.hideProgressbar)
|
||||||
self.showProgressbar()
|
self.showProgressbar()
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
if self.redirect_stdout:
|
if self.redirect_stdout:
|
||||||
|
self.old_stdout = sys.stdout
|
||||||
sys.stdout = self
|
sys.stdout = self
|
||||||
try:
|
try:
|
||||||
if not self.ncores:
|
if not self.ncores:
|
||||||
@ -164,7 +170,7 @@ class MultiThread(QThread):
|
|||||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||||
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
||||||
print('Exception: {}, file: {}, line: {}'.format(exc_type, fname, exc_tb.tb_lineno))
|
print('Exception: {}, file: {}, line: {}'.format(exc_type, fname, exc_tb.tb_lineno))
|
||||||
sys.stdout = sys.__stdout__
|
sys.stdout = self.old_stdout
|
||||||
|
|
||||||
def showProgressbar(self):
|
def showProgressbar(self):
|
||||||
if self.progressText:
|
if self.progressText:
|
||||||
|
33
tests/test_get_qualities_from_xml.py
Normal file
33
tests/test_get_qualities_from_xml.py
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
import unittest
|
||||||
|
|
||||||
|
from pylot.core.io.phases import getQualitiesfromxml
|
||||||
|
|
||||||
|
|
||||||
|
class TestQualityFromXML(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
self.xmlpaths = ['PyLoT_e0019.048.13.xml']
|
||||||
|
self.ErrorsP = [0.02, 0.04, 0.08, 0.16]
|
||||||
|
self.ErrorsS = [0.04, 0.08, 0.16, 0.32]
|
||||||
|
self.test0_result = [[0.0136956521739, 0.0126, 0.0101612903226, 0.00734848484849, 0.0135069444444,
|
||||||
|
0.00649659863946, 0.0129513888889, 0.0122747747748, 0.0119252873563, 0.0103947368421,
|
||||||
|
0.0092380952381, 0.00916666666667, 0.0104444444444, 0.0125333333333, 0.00904761904762,
|
||||||
|
0.00885714285714, 0.00911616161616, 0.0164166666667, 0.0128787878788, 0.0122756410256,
|
||||||
|
0.013653253667966917], [0.0239333333333, 0.0223791578953, 0.0217974304255],
|
||||||
|
[0.0504861111111, 0.0610833333333], [], [0.171029411765]], [
|
||||||
|
[0.0195, 0.0203623188406, 0.0212121212121, 0.0345833333333, 0.0196180555556,
|
||||||
|
0.0202536231884, 0.0200347222222, 0.0189, 0.0210763888889, 0.018275862069,
|
||||||
|
0.0213888888889, 0.0319791666667, 0.0205303030303, 0.0156388888889, 0.0192,
|
||||||
|
0.0231349206349, 0.023625, 0.02875, 0.0195512820513, 0.0239393939394, 0.0234166666667,
|
||||||
|
0.0174702380952, 0.0204151307995], [0.040314343081226646], [0.148555555556], [], []]
|
||||||
|
self.test1_result = [77.77777777777777, 11.11111111111111, 7.407407407407407, 0, 3.7037037037037037],\
|
||||||
|
[92.0, 4.0, 4.0, 0, 0]
|
||||||
|
|
||||||
|
def test_result_plotflag0(self):
|
||||||
|
self.assertEqual(getQualitiesfromxml(self.xmlpaths, self.ErrorsP, self.ErrorsS, 0), self.test0_result)
|
||||||
|
|
||||||
|
def test_result_plotflag1(self):
|
||||||
|
self.assertEqual(getQualitiesfromxml(self.xmlpaths, self.ErrorsP, self.ErrorsS, 1), self.test1_result)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
Loading…
Reference in New Issue
Block a user