def display(input, agc=1):
	
	def update(val):
		vmax = smax.val
		vmin = smin.val
		im.set_clim(vmax=vmax, vmin=vmin)
		fig.canvas.draw_idle()
	
	fig = pylab.figure()
	'''displays a gather using imshow'''
	dataset = toolbox.read(input)
	vmax = np.amax(dataset['trace'])
	vmin = np.amin(dataset['trace'])
	if agc:
		dataset = toolbox.agc(dataset)
	im = pylab.imshow(dataset['trace'].T, aspect='auto', cmap='spectral', vmax =vmax, vmin=vmin)
	pylab.colorbar()
	axcolor = 'lightgoldenrodyellow'
	axmax = pylab.axes([0.08, 0.06, 0.65, 0.01], axisbg=axcolor) #rect = [left, bottom, width, height] in normalized (0, 1) units
	smax = Slider(axmax, 'vmax', vmin, vmax, valinit=vmax)
	smax.on_changed(update)
	axmin = pylab.axes([0.08, 0.03, 0.65, 0.01], axisbg=axcolor) #rect = [left, bottom, width, height] in normalized (0, 1) units
	smin = Slider(axmin, 'vmin', vmin, vmax, valinit=vmin)
	smin.on_changed(update)	
	smin.on_changed(update)
	
	pylab.show()
def display(input, agc=1):
    def update(val):
        vmax = smax.val
        vmin = smin.val
        im.set_clim(vmax=vmax, vmin=vmin)
        fig.canvas.draw_idle()

    fig = pylab.figure()
    '''displays a gather using imshow'''
    dataset = toolbox.read(input)
    vmax = np.amax(dataset['trace'])
    vmin = np.amin(dataset['trace'])
    if agc:
        dataset = toolbox.agc(dataset)
    im = pylab.imshow(dataset['trace'].T,
                      aspect='auto',
                      cmap='spectral',
                      vmax=vmax,
                      vmin=vmin)
    pylab.colorbar()
    axcolor = 'lightgoldenrodyellow'
    axmax = pylab.axes(
        [0.08, 0.06, 0.65, 0.01], axisbg=axcolor
    )  #rect = [left, bottom, width, height] in normalized (0, 1) units
    smax = Slider(axmax, 'vmax', vmin, vmax, valinit=vmax)
    smax.on_changed(update)
    axmin = pylab.axes(
        [0.08, 0.03, 0.65, 0.01], axisbg=axcolor
    )  #rect = [left, bottom, width, height] in normalized (0, 1) units
    smin = Slider(axmin, 'vmin', vmin, vmax, valinit=vmin)
    smin.on_changed(update)
    smin.on_changed(update)

    pylab.show()
def semb(input, vels):
	dataset = toolbox.read(input)
	nvels = vels.size
	ns = dataset['ns'][0]
	result = np.zeros((nvels,ns),'f')
	for v in range(nvels):
		gather = nmo(input, None, [vels[v]], [0],  20)
		gather = toolbox.agc(gather)
		result[v,:] += np.abs(_stack_gather(gather)['trace'])
		
		
	pylab.imshow(result.T, aspect='auto', extent=(800.,4400.,1.,0.), cmap='spectral', vmin=0, vmax=0.6)
	pylab.colorbar()
	pylab.show()
def semb(input, vels):
    dataset = toolbox.read(input)
    nvels = vels.size
    ns = dataset['ns'][0]
    result = np.zeros((nvels, ns), 'f')
    for v in range(nvels):
        gather = nmo(input, None, [vels[v]], [0], 20)
        gather = toolbox.agc(gather)
        result[v, :] += np.abs(_stack_gather(gather)['trace'])

    pylab.imshow(result.T,
                 aspect='auto',
                 extent=(800., 4400., 1., 0.),
                 cmap='spectral',
                 vmin=0,
                 vmax=0.6)
    pylab.colorbar()
    pylab.show()
Exemple #5
0
    x = ((panel["trace"] * scalar) + trace_centers).ravel()
    xlines = np.split(x, 284)
    ylines = np.split(y, 284)
    lines = [zip(xlines[a], ylines[a]) for a in range(len(xlines))]
    fig, ax = pylab.subplots()
    ax.fill_betweenx(y, offsets, x, where=(x > offsets), color="k")
    col1 = collections.LineCollection(lines)
    col1.set_color("k")
    ax.add_collection(col1, autolim=True)
    pylab.xlim([0, 284])
    pylab.ylim([0, 1500])
    ax.set_ylim(ax.get_ylim()[::-1])
    pylab.tight_layout()
    pylab.show()


file = "/home/sfletcher/Downloads/2d_land_data/2D_Land_data_2ms/Line_001.su"
data, params = toolbox.initialise(file)
dmap = np.memmap(file, dtype=toolbox.typeSU(1501), mode="r")
eps = np.unique(dmap["ep"])
for ep in eps[:1]:
    params["window"] = 500
    panel = dmap[dmap["ep"] == ep].copy()
    panel = toolbox.agc(panel, None, **params)
    func(panel)
    # t = Timer("""func(panel)""", setup="from __main__ import func; from __main__ import panel")
    # print t.timeit(100)


# 777.01802206
Exemple #6
0
import toolbox
import numpy as np
import pylab

#~ for mute in range(110,200, 10):
#initialise
data, params = toolbox.initialise('prepro.su')

#load vels
params['vels'] = np.fromfile('vels_full.bin').reshape(-1, params['ns'])

params['smute'] = 150  #mute

#normal moveout correction
toolbox.nmo(data, None, **params)

#AGC
toolbox.agc(data, None, **params)
#stack
stack = toolbox.stack(data, None, **params)
params['gamma'] = -1
toolbox.tar(stack, None, **params)
data['tstat'] /= 2
toolbox.apply_statics(stack, None, **params)
#~ stack.tofile("smute_%d.su" %mute)
stack.tofile("1st_vels_stack_elev.su")
# i think I like 150
Exemple #7
0
        ax.fill(x,y, 'k', aa=True) 
        ax.set_xlim([0,nt])
        ax.set_ylim([ns,0])
        pylab.tight_layout()
        pylab.show()
        
        
if __name__ == "__main__":
        file = "/home/stewart/su/2d_land_data/2D_Land_data_2ms/su/Line_001.su"
        #file = "/home/sfletcher/Downloads/2d_land_data/2D_Land_data_2ms/Line_001.su"
        data, params = toolbox.initialise(file)
        eps = np.unique(data['ep'])
        for ep in eps[:1]:
                frame = data[data['ep'] == ep]
                params['window'] = 500
                toolbox.agc(frame, None, **params)
                wiggle(frame, scale=2)

    
    
    #~ trace_centers = np.linspace(1,284, panel.size).reshape(-1,1)
    #~ scalar = 284/(panel.size*0.1)
        
    #~ panel['trace'][:,-1] = np.nan
    #~ x = panel['trace'].ravel()
    #~ y = np.arange(x.size)
     
    #~ dx = np.signbit(x)
    #~ before = np.where(np.diff(np.signbit(x)))[0]
    #~ after = before + 1
Exemple #8
0
	
	data = su.readSU('record.su')
	
	cdp_gathers = 
	cdp300 = cdp_gathers[cdp_gathers['cdp'] == 300]
	#~ toolbox.display(cdp300)
	
	#~ velrange = np.arange(800.0, 4500.0, 100.0)
	#~ result = semb(toolbox.agc(cdp300), velrange)
	
	velx = [0.91,0.23,0.38]
	vely = [1531,1630, 1919]
	
	vector = build_vel_trace(velx, vely)
	stack = stack_volume(cdp_gathers, vector)
	stack = toolbox.agc(stack)
	#~ toolbox.display(stack)
	pylab.imshow(stack['trace'].T, aspect='auto', extent=(1,stack.size,1.,0.), cmap='spectral' , vmin=-8, vmax=8)
	pylab.colorbar()
	pylab.show()
	
	
	#~ offsets = np.unique(data['offset'])
	#~ aoffsets = sorted(np.abs(offsets))
	#~ print aoffsets
	#~ supergathers = toolbox.build_supergather(10, 3, aoffsets[::2], data)

	#~ inds = supergathers['ns1']
	
	#~ print inds
	
#-----------------------------------------------------------------------
#              useful functions
#-----------------------------------------------------------------------

None

#-----------------------------------------------------------------------
#              main functions
#-----------------------------------------------------------------------

if __name__ == "__main__":
    #intialise workspace and parameter dictionary
    print 'initialising'
    workspace, params = toolbox.initialise('../../../../foybrook.su')
    cdp400 = workspace[workspace['cdp'] == 480]
    toolbox.agc(cdp400, None, **params)

    params['velocities'] = np.arange(2000, 7000, 50)
    toolbox.semb(cdp400, **params)

    #set our TAR
    #~ print "applying tar"
    #~ params['gamma'] = 3
    #~ tar(workspace, None, **params)

    #apply LMO
    #~ print "applying lmo"
    #~ params['lmo'] =1000.0
    #~ lmo(workspace, None, **params)
    #~ workspace['trace'][:,:30] *= 0
    #~ workspace['trace'][:,1850:] *= 0
displays multiple stacks
'''
import toolbox
import pylab
import numpy as np

filelist = ["1st_vels_stack.su", 
#"1st_vels_stack_elev.su", 
"fk_stack.su", 
#"model.su", 
"model_filtered.su", 
#"trim_stack.su",
"trim_stack2.su",
]

dataset, params = toolbox.initialise(filelist[0])
dataset['fldr'] = 0
for index, file in enumerate(filelist[1:]):
	data, junk = toolbox.initialise(file)
	data['fldr'] = index + 1
	dataset = np.column_stack([dataset, data])

params['window'] = 1000
toolbox.agc(dataset, None, **params)
params['primary'] = 'fldr'
params['secondary'] = 'cdp'
params['clip'] = 0.02
toolbox.display(dataset, **params)
pylab.show()
	
Exemple #11
0
import toolbox
import numpy as np
import pylab

#extract shot record
data, params = toolbox.initialise("prepro.su")
mask = data['fldr'] == 221
shot = data[mask].copy()

#agc
toolbox.agc(shot, None, **params)
params['primary'] = 'fldr'
params['secondary'] = 'tracf'
params['wiggle'] = True
toolbox.display(shot, **params)

#fk plot
params['dx'] = 33.5 #m
#~ toolbox.fk_view(shot,  **params)


#~ #fk filter design
params['fkVelocity'] = 2000
params['fkSmooth'] = 20
params['fkFilter'] = toolbox.fk_design(shot, **params) 
shot = toolbox.fk_filter(shot, None, **params)
toolbox.display(shot, **params)

##############end of testing
#~ data, nparams = toolbox.initialise("prepro.su")
def agc(input, output, window=100):
    dataset = toolbox.read(input)
    dataset = toolbox.agc(dataset, window=window)
    toolbox.write(dataset, output)
#              useful functions
#-----------------------------------------------------------------------

None
	
	
#-----------------------------------------------------------------------
#              main functions
#-----------------------------------------------------------------------

if __name__ == "__main__":
	#intialise workspace and parameter dictionary
	print 'initialising'
	workspace, params = toolbox.initialise('../../../../foybrook.su')
	cdp400 = workspace[workspace['cdp'] ==480]
	toolbox.agc(cdp400, None, **params)
	
	params['velocities'] = np.arange(2000,7000,50)
	toolbox.semb(cdp400,  **params)

	#set our TAR
	#~ print "applying tar"
	#~ params['gamma'] = 3
	#~ tar(workspace, None, **params)
	

	#apply LMO
	#~ print "applying lmo"
	#~ params['lmo'] =1000.0
	#~ lmo(workspace, None, **params)
	#~ workspace['trace'][:,:30] *= 0
Exemple #14
0
    ax.fill(x, y, 'k', aa=True)
    ax.set_xlim([0, nt])
    ax.set_ylim([ns, 0])
    pylab.tight_layout()
    pylab.show()


if __name__ == "__main__":
    file = "/home/stewart/su/2d_land_data/2D_Land_data_2ms/su/Line_001.su"
    #file = "/home/sfletcher/Downloads/2d_land_data/2D_Land_data_2ms/Line_001.su"
    data, params = toolbox.initialise(file)
    eps = np.unique(data['ep'])
    for ep in eps[:1]:
        frame = data[data['ep'] == ep]
        params['window'] = 500
        toolbox.agc(frame, None, **params)
        wiggle(frame, scale=2)

#~ trace_centers = np.linspace(1,284, panel.size).reshape(-1,1)
#~ scalar = 284/(panel.size*0.1)

#~ panel['trace'][:,-1] = np.nan
#~ x = panel['trace'].ravel()
#~ y = np.arange(x.size)

#~ dx = np.signbit(x)
#~ before = np.where(np.diff(np.signbit(x)))[0]
#~ after = before + 1

#~ #y = mx + c.
#~ x1=  x[before].astype(np.float)
def agc(input, output, window=100):
	dataset = toolbox.read(input)
	dataset = toolbox.agc(dataset, window=window)
	toolbox.write(dataset, output)
        for index, cdp in enumerate(cdps):
                gather = dataset[dataset['cdp'] == cdp]
                trace = _stack_gather(gather)
                result[index] = trace
        return result
        
if __name__ == '__main__':
        #initialise your test cdp first

        
        #first do the true amplitude recovery

        
        #set nmo parameters	
        params['smute'] = 0
        params['vels'] = toolbox.build_vels([0.5], [1], ns=params['ns'])
        #then apply NMO
        
        #we will apply a pre-stack agc
        toolbox.agc(workspace, None, None)
        
        #stack it
        section = stack(workspace, None, **params)
        
        #display it
        #params['clip'] = 1e-5
        toolbox.display(section, None, **params)
        
        pylab.show()
        
        
Exemple #17
0
        #apply tar
        params['gamma'] = 5
        toolbox.tar(workspace, None, **params)

      
        #copy vels from previous exercise
        vels = {}
        vels[225] =  (0.06, 1537.38) , (0.28, 2876.21) , (0.87, 4608.10)
        vels[270] =  (0.05, 1525.09) , (0.18, 2483.16) , (0.36, 3171.00) , (0.66, 4079.93) , (0.98, 4816.90)
        vels[315] =  (0.04, 1365.42) , (0.14, 2728.82) , (0.22, 3134.15) , (0.57, 4116.78) , (0.74, 4571.25) , (0.97, 5013.43)
        vels[360] =  (0.04, 1697.05) , (0.10, 2520.01) , (0.21, 2937.62) , (0.43, 3244.70) , (0.64, 3981.67) , (0.98, 4239.61)
        vels[405] =  (0.06, 1439.11) , (0.27, 2753.38) , (0.49, 3957.10) , (0.97, 5381.92)
        vels[450] =  (0.06, 1340.85) , (0.41, 2741.10) , (0.52, 3625.47) , (0.02, 1144.32) , (0.29, 3060.45) , (0.54, 3711.45) , (0.97, 4313.31)
        vels[495] =  (0.04, 1611.07) , (0.11, 3072.74) , (0.23, 3318.39) , (0.35, 3772.86) , (0.48, 3981.67) , (0.94, 5099.41)
        vels[539] =  (0.04, 2028.69) , (0.11, 3072.74) , (0.32, 3883.41) , (0.51, 4485.27) , (0.96, 5222.24)
        vels[584] =  (0.06, 1623.36) , (0.20, 2495.44) , (0.32, 3121.87) , (0.95, 4411.57)
        
        #build vels
        vels = toolbox.build_vels(vels, **params)
        
        params['primary'] = None
        params['smute'] = 30
        
        params['vels'] = vels
        v100 = toolbox.co_nmo(workspace, None, **params)
        toolbox.agc(v100, None, **params)
        section100 = toolbox.stack(v100, None, **params)
        toolbox.cp(section100, 'stack100.su', None)
        toolbox.display(section100, None, **params)
        
        pylab.show()
Exemple #18
0
    sutype = np.result_type(dataset)
    result = np.zeros(cdps.size, dtype=sutype)
    for index, cdp in enumerate(cdps):
        gather = dataset[dataset['cdp'] == cdp]
        trace = _stack_gather(gather)
        result[index] = trace
    return result


if __name__ == '__main__':
    #initialise your test cdp first

    #first do the true amplitude recovery

    #set nmo parameters
    params['smute'] = 0
    params['vels'] = toolbox.build_vels([0.5], [1], ns=params['ns'])
    #then apply NMO

    #we will apply a pre-stack agc
    toolbox.agc(workspace, None, None)

    #stack it
    section = stack(workspace, None, **params)

    #display it
    #params['clip'] = 1e-5
    toolbox.display(section, None, **params)

    pylab.show()
Exemple #19
0
        #~ lmo(workspace, None, **params)
        #~ workspace['trace'][:,:30] *= 0
        #~ workspace['trace'][:,1850:] *= 0
        #~ params['lmo'] = -1000.0
        #~ lmo(workspace, None, **params)
        
        #apply our NMO
        print "applying nmo"
        params['smute'] = 30
        v = [3000]
        t = [0.5]
        params['vels'] = toolbox.build_vels(t, v, ns=params['ns'])
        nmo(workspace, None, **params)
        
        #~ #apply AGC
        toolbox.agc(workspace, None, **params)
        #~ #stack
        print "stacking"
        stack(workspace, 'stack1.su', **params)
        
        #view
        params['primary'] = None
        toolbox.display('stack1.su', None, **params)
        
        pylab.show()
        
        

        
        
Exemple #20
0
        vels[539] =  (0.04, 2028.69) , (0.11, 3072.74) , (0.32, 3883.41) , (0.51, 4485.27) , (0.96, 5222.24)
        vels[584] =  (0.06, 1623.36) , (0.20, 2495.44) , (0.32, 3121.87) , (0.95, 4411.57)
        
        #build vels
        vels = toolbox.build_vels(vels, **params)
        
        params['primary'] = None
        params['highcut'] = 100
        params['lowcut'] = 30
        params['smute'] = 30
        
        
        
        params['vels'] = vels
        v100 = toolbox.co_nmo(workspace, None, **params)
        toolbox.agc(v100, None, **params)
        section100 = toolbox.stack(v100, None, **params)
        toolbox.bandpass(section100, None, **params)
        toolbox.display(section100, None, **params)
        

        params['vels'] = vels * .9
        v90 = toolbox.co_nmo(workspace, None, **params)
        toolbox.agc(v90, None, **params)
        section90 = toolbox.stack(v90, None, **params)
        toolbox.bandpass(section90, None, **params)
        toolbox.display(section90, None, **params)
        
        params['vels'] = vels *1.1
        v110 = toolbox.co_nmo(workspace, None, **params)
        toolbox.agc(v110, None, **params)
Exemple #21
0
@io
def add_noise(dataset, **kwargs):
    noise = np.random.normal(0.0, 1e-8, size=(dataset.shape))
    dataset += noise
    return dataset


@io
def convolve_wavelet(dataset, **kwargs):
    wavelet = toolbox.ricker(60)
    dataset = toolbox.conv(dataset, wavelet)
    return dataset


if __name__ == '__main__':
    #initialise
    workspace, params = initialise()

    #build record
    build_combined(workspace, None, **params)

    #add wavelet
    workspace = convolve_wavelet(workspace, None, **params)

    #add noise
    workspace = add_noise(workspace, None, **params)

    #display
    toolbox.agc(workspace, None, **params)
    toolbox.display(workspace, None, **params)
Exemple #22
0
import toolbox
import numpy as np
import pylab

#initialise
data, params = toolbox.initialise('prepro.su')

#load vels
params['vels'] = np.fromfile('vels_full.bin').reshape(-1, params['ns'])
params['smute'] = 200

#normal moveout correction
nmo = toolbox.nmo(data, None, **params)

#AGC
toolbox.agc(nmo, None, **params)
#stack
stack = toolbox.stack(nmo, None, **params)
params['gamma'] = -1
toolbox.tar(stack, None, **params)
stack.tofile("field_stack2.su")

params['primary'] = None
params['secondary'] = 'cdp'
toolbox.display(stack, **params)
pylab.show()