From d093349b50c3091aeb072e01bcb69371f79e033f Mon Sep 17 00:00:00 2001 From: Marcel Paffrath Date: Wed, 28 Sep 2016 14:38:16 +0200 Subject: [PATCH] changed function position --- pylot/RELEASE-VERSION | 2 +- pylot/core/active/seismicArrayPreparation.py | 70 ++++++++++---------- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/pylot/RELEASE-VERSION b/pylot/RELEASE-VERSION index 30ada269..4c41ac0c 100644 --- a/pylot/RELEASE-VERSION +++ b/pylot/RELEASE-VERSION @@ -1 +1 @@ -55a58-dirty +5f92-dirty diff --git a/pylot/core/active/seismicArrayPreparation.py b/pylot/core/active/seismicArrayPreparation.py index 976c37f3..907e9161 100644 --- a/pylot/core/active/seismicArrayPreparation.py +++ b/pylot/core/active/seismicArrayPreparation.py @@ -3,6 +3,41 @@ import sys import numpy as np from scipy.interpolate import griddata +def readMygridNlayers(filename): + infile = open(filename, 'r') + nlayers = len(infile.readlines()) / 2 + infile.close() + + return nlayers + +def readMygrid(filename): + ztop = []; + zbot = []; + vtop = []; + vbot = [] + infile = open(filename, 'r') + nlayers = readMygridNlayers(filename) + + print('\nreadMygrid: Reading file %s.' % filename) + for index in range(nlayers): + line1 = infile.readline() + line2 = infile.readline() + ztop.append(float(line1.split()[0])) + vtop.append(float(line1.split()[1])) + zbot.append(float(line2.split()[0])) + vbot.append(float(line2.split()[1])) + print('Layer %s:\n[Top: v = %s [km/s], z = %s [m]]' + '\n[Bot: v = %s [km/s], z = %s [m]]' + % (index + 1, vtop[index], ztop[index], + vbot[index], zbot[index])) + + if not ztop[0] == 0: + print('ERROR: there must be a velocity set for z = 0 in the file %s' % filename) + print('e.g.:\n0 0.33\n-5 1.0\netc.') + + infile.close() + return ztop, zbot, vtop, vbot + class SeisArray(object): ''' @@ -714,41 +749,6 @@ class SeisArray(object): # rad = angle / 180 * PI # return rad - def readMygridNlayers(filename): - infile = open(filename, 'r') - nlayers = len(infile.readlines()) / 2 - infile.close() - - return nlayers - - def readMygrid(filename): - ztop = []; - zbot = []; - vtop = []; - vbot = [] - infile = open(filename, 'r') - nlayers = readMygridNlayers(filename) - - print('\nreadMygrid: Reading file %s.' % filename) - for index in range(nlayers): - line1 = infile.readline() - line2 = infile.readline() - ztop.append(float(line1.split()[0])) - vtop.append(float(line1.split()[1])) - zbot.append(float(line2.split()[0])) - vbot.append(float(line2.split()[1])) - print('Layer %s:\n[Top: v = %s [km/s], z = %s [m]]' - '\n[Bot: v = %s [km/s], z = %s [m]]' - % (index + 1, vtop[index], ztop[index], - vbot[index], zbot[index])) - - if not ztop[0] == 0: - print('ERROR: there must be a velocity set for z = 0 in the file %s' % filename) - print('e.g.:\n0 0.33\n-5 1.0\netc.') - - infile.close() - return ztop, zbot, vtop, vbot - R = 6371. vmin = 0.34 decm = 0.3 # diagonal elements of the covariance matrix (grid3dg's default value is 0.3)