[change] changed some functions to work with Python 3 and Windows

This commit is contained in:
Marcel Paffrath 2017-07-13 17:27:48 +02:00
parent ac25f9cacb
commit f57aa37d99
11 changed files with 47 additions and 35 deletions

View File

@ -2575,7 +2575,7 @@ class Project(object):
self.setDirty() self.setDirty()
else: else:
print('Skipping event with path {}. Already part of project.'.format(event.path)) 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=','): def read_eventfile_info(self, filename, separator=','):
''' '''

View File

@ -6,9 +6,9 @@
# #
# WARNING! All changes made in this file will be lost! # 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\ \x00\x00\x9e\x04\
\x89\ \x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\ \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\ \x3c\x2f\x68\x74\x6d\x6c\x3e\x0a\
" "
qt_resource_name = "\ qt_resource_name = b"\
\x00\x04\ \x00\x04\
\x00\x06\xec\x30\ \x00\x06\xec\x30\
\x00\x68\ \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\ \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\x03\x00\x00\x00\x01\
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x32\ \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\ \x00\x00\x00\x0e\x00\x02\x00\x00\x00\x2d\x00\x00\x00\x05\

View File

@ -39,7 +39,7 @@ class Data(object):
elif isinstance(evtdata, dict): elif isinstance(evtdata, dict):
evt = readPILOTEvent(**evtdata) evt = readPILOTEvent(**evtdata)
evtdata = evt evtdata = evt
elif isinstance(evtdata, basestring): elif isinstance(evtdata, str):
try: try:
cat = read_events(evtdata) cat = read_events(evtdata)
if len(cat) is not 1: if len(cat) is not 1:

View File

@ -2,7 +2,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from pylot.core.util.errors import ParameterError from pylot.core.util.errors import ParameterError
import default_parameters from pylot.core.io import default_parameters
class PylotParameter(object): class PylotParameter(object):
''' '''

View File

@ -307,7 +307,7 @@ class HOScf(CharacteristicFunction):
class ARZcf(CharacteristicFunction): class ARZcf(CharacteristicFunction):
def calcCF(self, data): 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()) x = self.getDataArray(self.getCut())
xnp = x[0].data xnp = x[0].data
nn = np.isnan(xnp) nn = np.isnan(xnp)
@ -430,7 +430,7 @@ class ARZcf(CharacteristicFunction):
class ARHcf(CharacteristicFunction): class ARHcf(CharacteristicFunction):
def calcCF(self, data): 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()) xnp = self.getDataArray(self.getCut())
n0 = np.isnan(xnp[0].data) n0 = np.isnan(xnp[0].data)
@ -567,7 +567,7 @@ class ARHcf(CharacteristicFunction):
class AR3Ccf(CharacteristicFunction): class AR3Ccf(CharacteristicFunction):
def calcCF(self, data): 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()) xnp = self.getDataArray(self.getCut())
n0 = np.isnan(xnp[0].data) n0 = np.isnan(xnp[0].data)

View File

@ -480,7 +480,7 @@ def main():
Insheim = PDFstatistics(root_dir) Insheim = PDFstatistics(root_dir)
Insheim.curphase = 'p' Insheim.curphase = 'p'
qdlist = Insheim.get('qdf', 0.2) qdlist = Insheim.get('qdf', 0.2)
print qdlist print(qdlist)
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -1,13 +1,16 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- 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'): def checkurl(url='https://ariadne.geophysik.rub.de/trac/PyLoT'):
try: try:
urllib2.urlopen(url, timeout=1) urlopen(url, timeout=1)
return True return True
except urllib2.URLError: except:
pass pass
return False return False

View File

@ -59,7 +59,7 @@ def exp_parameter(te, tm, tl, eta):
return tm, sig1, sig2, a 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 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 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 :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): def _func(k, mu, sig1, sig2, a1, a2):
if k < mu: if k < mu:
rval = a1 * 1 / (np.sqrt(2 * np.pi) * sig1) * np.exp(-((k - mu) / sig1) ** 2 / 2) 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) 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 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 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: :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): def _func(k, mu, sig1, sig2, a):
mu = float(mu) mu = float(mu)
if k < mu: if k < mu:

View File

@ -5,7 +5,10 @@ import hashlib
import numpy as np import numpy as np
from scipy.interpolate import splrep, splev from scipy.interpolate import splrep, splev
import os import os
import pwd try:
import pwd
except:
print('Warning: Could not import module pwd')
import re import re
import warnings import warnings
import subprocess import subprocess
@ -258,7 +261,7 @@ def getLogin():
returns the actual user's login ID returns the actual user's login ID
:return: login ID :return: login ID
''' '''
return pwd.getpwuid(os.getuid())[0] return os.getlogin()
def getOwner(fn): def getOwner(fn):

View File

@ -865,7 +865,7 @@ class PickDlg(QDialog):
tip='Delete current picks.') tip='Delete current picks.')
# create other widget elements # create other widget elements
phaseitems = [None] + FILTERDEFAULTS.keys() phaseitems = [None] + list(FILTERDEFAULTS.keys())
# create buttons for P and S filter and picking # create buttons for P and S filter and picking
self.p_button = QPushButton('P', self) self.p_button = QPushButton('P', self)