Example #1
0
def add_raysum_seis_to_plot(subplot,filename,scale_factor,zoff=0.,wavelet=[1.]):
	import matplotlib as mpl
	mpl.use('PS')
	import pylab as plt
	from rotate import readxy
	from scipy.signal import convolve

	plt.subplot(subplot)

	t,u=readxy(filename)
	
	u2 = convolve(u,wavelet,mode='same')

	u3=u2*scale_factor + zoff

	plt.plot(t,u3,'--',color='red')

	return
Example #2
0
def main():
    import os, sys
    sys.path.append('src/')
    import rotate
    from numpy import argmax

    rotate.main()

    os.system('ls OUTPUT_FILES/AA*BXS.semd > filelist')
    fin = open('filelist', 'r')
    fout = open('_station_info.txt', 'w')
    for line_raw in fin.readlines():
        line = line_raw.strip('\n')
        t, u = rotate.readxy(line)
        dt = t[1] - t[0]
        tS = t[argmax(u)]

        str = line[16:21] + '   %5.2f\n' % (tS)
        fout.write(str)

    fin.close()
    fout.close()
Example #3
0
def CalculateRelativeAmp(filename):
    from moveout import calculateMoveout
    from rotate import readxy
    from numpy import max, array, pi, sin

    def window(ts, xs, tmin, tmax):
        tnew, xnew = [], []
        for ii in range(len(ts)):
            t = ts[ii]
            x = xs[ii]
            if t >= tmin and t <= tmax:
                tnew.append(t)
                xnew.append(x)

        tnew = array(tnew)
        xnew = array(xnew)
        return tnew, xnew

    def getXforStation(StationNumber):
        fin = open('%s/OUTPUT_FILES/STATIONS' % (filename))
        lines = fin.readlines()
        nfo = lines[StationNumber - 1].strip('\n').split()
        x = float(nfo[2]) / 1000. - 1000.
        return x

    RelativeAmplitudes = []

    Stations = range(1, 150)

    for StationNumber in Stations:
        FullFileName = '%s/OUTPUT_FILES/AA.S%04d.BXZ.semd' % (filename,
                                                              StationNumber)

        try:
            t, uz = readxy(FullFileName)
        except:
            print '***Warning: Problem reading %s' % (FullFileName)
            return float('nan')

        tscat = 90.0
        t = t - MP.tscat

        xorig, torig = 0., 0.
        xSta = getXforStation(StationNumber)
        dtwin = 30.
        PhaseAmps = {}
        Windows = {}

        for Phase in ['Main', 'Ra']:
            if Phase == 'Main':
                vapp = MP.vapp_main
            elif Phase == 'Ra':
                vapp = 0.89 * MP.vs_crust
            ttarg = calculateMoveout(vapp, xorig, torig, xSta)
            tsWin, xsWin = window(t, uz, ttarg, ttarg + dtwin)

            PhaseAmps[Phase] = max(abs(xsWin))
            Windows[Phase] = [tsWin, xsWin]

        tmp = PhaseAmps['Ra'] / PhaseAmps['Main']
        RelativeAmplitudes.append(tmp)

    import matplotlib as mpl
    mpl.use('PS')
    import pylab as plt
    plt.subplot(2, 1, 1)
    plt.plot(Stations, RelativeAmplitudes)
    plt.subplot(2, 1, 2)
    plt.plot(t, uz, 'black')
    for Phase in ['Main', 'Ra']:
        plt.plot(Windows[Phase][0], Windows[Phase][1], 'red')
    plt.savefig('debug.eps')

    from numpy import mean, median

    avg1 = mean(RelativeAmplitudes)
    avg2 = median(RelativeAmplitudes)

    print avg1, avg2, min(RelativeAmplitudes), max(RelativeAmplitudes)

    return avg1