[change] changed some functions to work with Python 3 and Windows
This commit is contained in:
parent
ac25f9cacb
commit
f57aa37d99
@ -2575,7 +2575,7 @@ class Project(object):
|
||||
self.setDirty()
|
||||
else:
|
||||
print('Skipping event with path {}. Already part of project.'.format(event.path))
|
||||
self.search_eventfile_info()
|
||||
#self.search_eventfile_info()
|
||||
|
||||
def read_eventfile_info(self, filename, separator=','):
|
||||
'''
|
||||
|
24
autoPyLoT.py
24
autoPyLoT.py
@ -369,18 +369,18 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, even
|
||||
# HYPOSAT
|
||||
hyposatfile = '%s/PyLoT_%s_HYPOSAT_phases' % (event, evID)
|
||||
hyposat.export(picks, hyposatfile, parameter)
|
||||
# VELEST
|
||||
velestfile = '%s/PyLoT_%s_VELEST_phases.cnv' % (event, evID)
|
||||
velest.export(picks, velestfile, parameter, evt)
|
||||
# hypoDD
|
||||
hypoddfile = '%s/PyLoT_%s_hypoDD_phases.pha' % (event, evID)
|
||||
hypodd.export(picks, hypoddfile, parameter, evt)
|
||||
# FOCMEC
|
||||
focmecfile = '%s/PyLoT_%s_FOCMEC.in' % (event, evID)
|
||||
focmec.export(picks, focmecfile, parameter, evt)
|
||||
# HASH
|
||||
hashfile = '%s/PyLoT_%s_HASH' % (event, evID)
|
||||
hash.export(picks, hashfile, parameter, evt)
|
||||
# VELEST
|
||||
velestfile = '%s/PyLoT_%s_VELEST_phases.cnv' % (event, evID)
|
||||
velest.export(picks, velestfile, parameter, evt)
|
||||
# hypoDD
|
||||
hypoddfile = '%s/PyLoT_%s_hypoDD_phases.pha' % (event, evID)
|
||||
hypodd.export(picks, hypoddfile, parameter, evt)
|
||||
# FOCMEC
|
||||
focmecfile = '%s/PyLoT_%s_FOCMEC.in' % (event, evID)
|
||||
focmec.export(picks, focmecfile, parameter, evt)
|
||||
# HASH
|
||||
hashfile = '%s/PyLoT_%s_HASH' % (event, evID)
|
||||
hash.export(picks, hashfile, parameter, evt)
|
||||
|
||||
endsplash = '''------------------------------------------\n'
|
||||
-----Finished event %s!-----\n'
|
||||
|
@ -6,9 +6,9 @@
|
||||
#
|
||||
# WARNING! All changes made in this file will be lost!
|
||||
|
||||
from PySide import QtCore
|
||||
from PyQt4 import QtCore
|
||||
|
||||
qt_resource_data = "\
|
||||
qt_resource_data = b"\
|
||||
\x00\x00\x9e\x04\
|
||||
\x89\
|
||||
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
|
||||
@ -97831,7 +97831,7 @@ qt_resource_data = "\
|
||||
\x3c\x2f\x68\x74\x6d\x6c\x3e\x0a\
|
||||
"
|
||||
|
||||
qt_resource_name = "\
|
||||
qt_resource_name = b"\
|
||||
\x00\x04\
|
||||
\x00\x06\xec\x30\
|
||||
\x00\x68\
|
||||
@ -98033,7 +98033,7 @@ qt_resource_name = "\
|
||||
\x00\x6e\x00\x64\x00\x65\x00\x78\x00\x2e\x00\x68\x00\x74\x00\x6d\x00\x6c\
|
||||
"
|
||||
|
||||
qt_resource_struct = "\
|
||||
qt_resource_struct = b"\
|
||||
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x03\x00\x00\x00\x01\
|
||||
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x32\
|
||||
\x00\x00\x00\x0e\x00\x02\x00\x00\x00\x2d\x00\x00\x00\x05\
|
||||
|
@ -39,7 +39,7 @@ class Data(object):
|
||||
elif isinstance(evtdata, dict):
|
||||
evt = readPILOTEvent(**evtdata)
|
||||
evtdata = evt
|
||||
elif isinstance(evtdata, basestring):
|
||||
elif isinstance(evtdata, str):
|
||||
try:
|
||||
cat = read_events(evtdata)
|
||||
if len(cat) is not 1:
|
||||
|
@ -2,7 +2,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from pylot.core.util.errors import ParameterError
|
||||
import default_parameters
|
||||
from pylot.core.io import default_parameters
|
||||
|
||||
class PylotParameter(object):
|
||||
'''
|
||||
|
@ -307,7 +307,7 @@ class HOScf(CharacteristicFunction):
|
||||
class ARZcf(CharacteristicFunction):
|
||||
def calcCF(self, data):
|
||||
|
||||
print 'Calculating AR-prediction error from single trace ...'
|
||||
print('Calculating AR-prediction error from single trace ...')
|
||||
x = self.getDataArray(self.getCut())
|
||||
xnp = x[0].data
|
||||
nn = np.isnan(xnp)
|
||||
@ -430,7 +430,7 @@ class ARZcf(CharacteristicFunction):
|
||||
class ARHcf(CharacteristicFunction):
|
||||
def calcCF(self, data):
|
||||
|
||||
print 'Calculating AR-prediction error from both horizontal traces ...'
|
||||
print('Calculating AR-prediction error from both horizontal traces ...')
|
||||
|
||||
xnp = self.getDataArray(self.getCut())
|
||||
n0 = np.isnan(xnp[0].data)
|
||||
@ -567,7 +567,7 @@ class ARHcf(CharacteristicFunction):
|
||||
class AR3Ccf(CharacteristicFunction):
|
||||
def calcCF(self, data):
|
||||
|
||||
print 'Calculating AR-prediction error from all 3 components ...'
|
||||
print('Calculating AR-prediction error from all 3 components ...')
|
||||
|
||||
xnp = self.getDataArray(self.getCut())
|
||||
n0 = np.isnan(xnp[0].data)
|
||||
|
@ -480,7 +480,7 @@ def main():
|
||||
Insheim = PDFstatistics(root_dir)
|
||||
Insheim.curphase = 'p'
|
||||
qdlist = Insheim.get('qdf', 0.2)
|
||||
print qdlist
|
||||
print(qdlist)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -1,13 +1,16 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import urllib2
|
||||
try:
|
||||
from urllib2 import urlopen
|
||||
except:
|
||||
from urllib.request import urlopen
|
||||
|
||||
|
||||
def checkurl(url='https://ariadne.geophysik.rub.de/trac/PyLoT'):
|
||||
try:
|
||||
urllib2.urlopen(url, timeout=1)
|
||||
urlopen(url, timeout=1)
|
||||
return True
|
||||
except urllib2.URLError:
|
||||
except:
|
||||
pass
|
||||
return False
|
||||
|
@ -59,7 +59,7 @@ def exp_parameter(te, tm, tl, eta):
|
||||
return tm, sig1, sig2, a
|
||||
|
||||
|
||||
def gauss_branches(k, (mu, sig1, sig2, a1, a2)):
|
||||
def gauss_branches(k, param_tuple):
|
||||
'''
|
||||
function gauss_branches takes an axes x, a center value mu, two sigma
|
||||
values sig1 and sig2 and two scaling factors a1 and a2 and return a
|
||||
@ -79,6 +79,9 @@ def gauss_branches(k, (mu, sig1, sig2, a1, a2)):
|
||||
:returns fun_vals: list with function values along axes x
|
||||
'''
|
||||
|
||||
#python 3 workaround
|
||||
mu, sig1, sig2, a1, a2 = param_tuple
|
||||
|
||||
def _func(k, mu, sig1, sig2, a1, a2):
|
||||
if k < mu:
|
||||
rval = a1 * 1 / (np.sqrt(2 * np.pi) * sig1) * np.exp(-((k - mu) / sig1) ** 2 / 2)
|
||||
@ -93,7 +96,7 @@ def gauss_branches(k, (mu, sig1, sig2, a1, a2)):
|
||||
return _func(k, mu, sig1, sig2, a1, a2)
|
||||
|
||||
|
||||
def exp_branches(k, (mu, sig1, sig2, a)):
|
||||
def exp_branches(k, param_tuple):
|
||||
'''
|
||||
function exp_branches takes an axes x, a center value mu, two sigma
|
||||
values sig1 and sig2 and a scaling factor a and return a
|
||||
@ -107,6 +110,9 @@ def exp_branches(k, (mu, sig1, sig2, a)):
|
||||
:returns fun_vals: list with function values along axes x:
|
||||
'''
|
||||
|
||||
#python 3 workaround
|
||||
mu, sig1, sig2, a = param_tuple
|
||||
|
||||
def _func(k, mu, sig1, sig2, a):
|
||||
mu = float(mu)
|
||||
if k < mu:
|
||||
|
@ -5,7 +5,10 @@ import hashlib
|
||||
import numpy as np
|
||||
from scipy.interpolate import splrep, splev
|
||||
import os
|
||||
import pwd
|
||||
try:
|
||||
import pwd
|
||||
except:
|
||||
print('Warning: Could not import module pwd')
|
||||
import re
|
||||
import warnings
|
||||
import subprocess
|
||||
@ -258,7 +261,7 @@ def getLogin():
|
||||
returns the actual user's login ID
|
||||
:return: login ID
|
||||
'''
|
||||
return pwd.getpwuid(os.getuid())[0]
|
||||
return os.getlogin()
|
||||
|
||||
|
||||
def getOwner(fn):
|
||||
|
@ -70,9 +70,9 @@ def plot_pdf(_axes, x, y, annotation, bbox_props, xlabel=None, ylabel=None,
|
||||
title=None):
|
||||
# try method or data
|
||||
try:
|
||||
_axes.plot(x, y()) # y provided as method
|
||||
_axes.plot(x, y()) # y provided as method
|
||||
except:
|
||||
_axes.plot(x, y) # y provided as data
|
||||
_axes.plot(x, y) # y provided as data
|
||||
|
||||
if title:
|
||||
_axes.set_title(title)
|
||||
@ -513,7 +513,7 @@ class WaveformWidgetPG(QtGui.QWidget):
|
||||
stime = trace.stats.starttime - wfstart
|
||||
time_ax = prepTimeAxis(stime, trace)
|
||||
if time_ax is not None:
|
||||
if not scaleddata:
|
||||
if not scaleddata:
|
||||
trace.detrend('constant')
|
||||
trace.normalize(np.max(np.abs(trace.data)) * 2)
|
||||
times = [time for index, time in enumerate(time_ax) if not index%nth_sample]
|
||||
@ -653,7 +653,7 @@ class WaveformWidget(FigureCanvas):
|
||||
stime = trace.stats.starttime - wfstart
|
||||
time_ax = prepTimeAxis(stime, trace)
|
||||
if time_ax is not None:
|
||||
if not scaleddata:
|
||||
if not scaleddata:
|
||||
trace.detrend('constant')
|
||||
trace.normalize(np.max(np.abs(trace.data)) * 2)
|
||||
times = [time for index, time in enumerate(time_ax) if not index%nth_sample]
|
||||
@ -865,7 +865,7 @@ class PickDlg(QDialog):
|
||||
tip='Delete current picks.')
|
||||
|
||||
# create other widget elements
|
||||
phaseitems = [None] + FILTERDEFAULTS.keys()
|
||||
phaseitems = [None] + list(FILTERDEFAULTS.keys())
|
||||
|
||||
# create buttons for P and S filter and picking
|
||||
self.p_button = QPushButton('P', self)
|
||||
|
Loading…
Reference in New Issue
Block a user