def test_ricker(self): x = array([0.88273185, 0.90950743, 0.9330604 , 0.95324475, 0.96993473, 0.9830259 , 0.99243608, 0.99810603, 1. , 0.99810603, 0.99243608, 0.9830259 , 0.96993473, 0.95324475, 0.9330604 , 0.90950743]) y = ricker(0.064, 0.004, np.arange(1, 10))[1] self.assertTrue(np.allclose(x, y))
def test_do_convolve( self ): # Make a spike dataset [samp, trace, theta] data = np.zeros( (1000,100,10) ) data[500,50,:] = 1.0 dt = 0.001 duration = .2 f = (20,40,60) wavelets = ricker( duration, dt, f ) con = do_convolve( wavelets, data ) truth = np.zeros( (1000,100,10,3) ) for i in range(10): truth[:wavelets.shape[0], 50, i, :] += wavelets truth = np.roll( truth, 401, axis=0 ) self.assertTrue( np.allclose( truth, con ) )
def test_ricker(self): x = array([ 0.88273185, 0.90950743, 0.9330604, 0.95324475, 0.96993473, 0.9830259, 0.99243608, 0.99810603, 1., 0.99810603, 0.99243608, 0.9830259, 0.96993473, 0.95324475, 0.9330604, 0.90950743 ]) y = ricker(0.064, 0.004, np.arange(1, 10))[1] self.assertTrue(np.allclose(x, y))
def _make_synthetic(size=256, top=0.4, base=0.6, value=1, freq=25, phase=0): """Make a synthetic. Return the wavelet, the model, the RC, and the synthetic. """ v = np.ones(size) - value v[int(top*size):int(base*size)] = value rc = np.diff(v) w = ricker(0.256, 0.001, freq) if phase != 0: w = rotate_phase(w, phase, degrees=True) syn = np.convolve(rc, w, mode='same') return w, v, rc, syn
def test_wavelet(self): # Make a dipping reflectivity field data = np.zeros((150, 100)) data[0, :] = np.arange(100) / 10.0 dips = np.arange(0, 100, 2) dips = np.concatenate([dips, dips[::-1]]) window_size = 10 freq = 20.0 duration = 1 wavelet = ricker(window_size, duration, freq) for i in range(dips.size): data[:, i] = np.convolve(wavelet, np.roll(data[:, i], dips[i]), mode='same') stepout = 1 maxlag = 2 dip = dipsteer(data, window_size, stepout=stepout, maxlag=maxlag, overlap=0.5) undipped = np.zeros(dips.shape) for i in range(dips.size): undipped[i] = (dip[dips[i], i]) check = undipped[maxlag * stepout:-maxlag * stepout] test = np.zeros(check.shape) test[0:test.size // 2 - 1] = -2.0 test[(test.size // 2) - 1] = -1 test[(test.size // 2)] = 1 test[(test.size // 2) + 1:] = 2 self.assertTrue(np.allclose(test, check))
def test_do_convolve(self): # Make a spike dataset [samp, trace, theta] data = np.zeros((1000, 100, 10)) data[500, 50, :] = 1.0 dt = 0.001 duration = .2 f = (20, 40, 60) wavelets = ricker(duration, dt, f) con = do_convolve(wavelets, data) truth = np.zeros((1000, 100, 10, 3)) for i in range(10): truth[:wavelets.shape[0], 50, i, :] += wavelets truth = np.roll(truth, 401, axis=0) self.assertTrue(np.allclose(truth, con))
def test_wavelet(self): # Make a dipping reflectivity field data = np.zeros((150, 100)) data[0, :] = np.arange(100) / 10.0 dips = np.arange(0, 100, 2) dips = np.concatenate([dips, dips[::-1]]) window_size = 10 freq = 20.0 duration = 1 wavelet = ricker(window_size, duration, freq) for i in range(dips.size): data[:, i] = np.convolve(wavelet, np.roll(data[:, i], dips[i]), mode='same') stepout = 1 maxlag = 2 dip = dipsteer(data, window_size, stepout=stepout, maxlag=maxlag, overlap=0.5) undipped = np.zeros(dips.shape) for i in range(dips.size): undipped[i] = (dip[dips[i], i]) check = undipped[maxlag*stepout:-maxlag*stepout] test = np.zeros(check.shape) test[0: test.size//2 - 1] = -2.0 test[(test.size//2) - 1] = -1 test[(test.size//2)] = 1 test[(test.size//2)+1:] = 2 self.assertTrue(np.allclose(test, check))
# the properties of the upper layer are an average from # the shale points in the well vp0, vs0, rho0 = L[['VP', 'VS', 'RHO']][sh].mean().values # the properties of the lower layer come from RPM phi, vsh = .15, .8 _, _, K0 = vrh(vsh, K_qz, K_sh) _, _, MU0 = vrh(vsh, MU_qz, MU_sh) RHO0 = vsh * RHO_qz + (1 - vsh) * RHO_sh Kdry, MUdry = softsand(K0, MU0, phi, phic=.5, Cn=12, P=45, f=.3) vp1, vs1, rho1, _ = vels(Kdry, MUdry, K0, RHO0, K_g, RHO_g, phi) n_samples = 500 interface = int(n_samples / 2) ang = np.arange(31) wavelet = ricker(.25, 0.001, 25) model_ip, model_vpvs, rc0, rc1 = (np.zeros(n_samples) for _ in range(4)) model_z = np.arange(n_samples) model_ip[:interface] = vp0 * rho0 model_ip[interface:] = vp1 * rho1 model_vpvs[:interface] = np.true_divide(vp0, vs0) model_vpvs[interface:] = np.true_divide(vp1, vs1) avo = shuey2(vp0, vs0, rho0, vp1, vs1, rho1, ang) rc0[interface] = avo[0] rc1[interface] = avo[-1] synt0 = np.convolve(rc0, wavelet, mode='same') synt1 = np.convolve(rc1, wavelet, mode='same') clip = np.max(np.abs([synt0, synt1])) clip += clip * .2
def twolayer(vp0,vs0,rho0,vp1,vs1,rho1): from bruges.reflection import shuey2 # TODO: install bruges.reflection from bruges.filters import ricker # TODO: install bruges.filters n_samples = 500 interface=int(n_samples/2) ang=np.arange(31) wavelet=ricker(.25, 0.001, 25) model_ip,model_vpvs,rc0,rc1 = ( np.zeros(n_samples) for _ in range(4) ) model_z = np.arange(n_samples) model_ip[:interface]=vp0*rho0 model_ip[interface:]=vp1*rho1 model_vpvs[:interface]=np.true_divide(vp0,vs0) model_vpvs[interface:]=np.true_divide(vp1,vs1) avo=shuey2(vp0,vs0,rho0,vp1,vs1,rho1,ang) rc0[interface]=avo[0] rc1[interface]=avo[-1] synt0=np.convolve(rc0,wavelet,mode='same') synt1=np.convolve(rc1,wavelet,mode='same') clip=np.max(np.abs([synt0, synt1])) clip += clip*.2 opz0={'color':'b', 'linewidth':4} opz1={'color':'k', 'linewidth':2} opz2={'linewidth':0, 'alpha':0.5} f = plt.subplots(figsize=(10, 4)) ax0 = plt.subplot2grid((1,16), (0,0), colspan=2) # ip ax1 = plt.subplot2grid((1,16), (0,2), colspan=2) # vp/vs ax2 = plt.subplot2grid((1,16), (0,4), colspan=2) # synthetic @ 0 deg ax3 = plt.subplot2grid((1,16), (0,6), colspan=2) # synthetic @ 30 deg ax4 = plt.subplot2grid((1,16), (0,9), colspan=7) # avo curve ax0.plot(model_ip, model_z, **opz0) ax0.set_xlabel('IP') ax0.locator_params(axis='x', nbins=2) ax1.plot(model_vpvs, model_z, **opz0) ax1.set_xlabel('VP/VS') ax1.locator_params(axis='x', nbins=2) ax2.plot(synt0, model_z, **opz1) ax2.fill_betweenx(model_z, 0, synt0, where=synt0>0, facecolor='black', **opz2) ax2.set_xlim(-clip,clip) ax2.set_xlabel('angle={:.0f}'.format(ang[0])) ax2.locator_params(axis='x', nbins=2) ax3.plot(synt1, model_z, **opz1) ax3.fill_betweenx(model_z, 0, synt1, where=synt1>0, facecolor='black', **opz2) ax3.set_xlim(-clip,clip) ax3.set_xlabel('angle={:.0f}'.format(ang[-1])) ax3.locator_params(axis='x', nbins=2) ax4.plot(ang, avo, **opz0) ax4.axhline(0, color='k', lw=2) ax4.set_xlabel('angle of incidence') ax4.tick_params(which='major', labelsize=8) for aa in [ax0,ax1,ax2,ax3]: aa.set_ylim(350,150) aa.tick_params(which='major', labelsize=8) aa.set_yticklabels([]) plt.subplots_adjust(wspace=.8,left=0.05,right=0.95)
# QC the calculation - pass test0 = model_AI[0, 0, 0] - model_den[0, 0, 0] * model_Vp[0, 0, 0] test1 = model_SI[0, 0, 0] - model_den[0, 0, 0] * model_Vs[0, 0, 0] # Test data save/load model_path = r'C:\Users\N.Srisutthiyakorn\OneDrive - Shell\Documents\GitHub\ShellHackathon\SampleInputs\IntermediateSteps' model_fn_out = os.path.join(model_path, 'density_output_test.npy') np.save(model_fn_out, model_den) model_den_qc = np.load(model_fn_out) # ============================================================================= # Test wavelet from bruges.filters import ricker delta_t = 0.001 # sample rate of the data wavelet, tw = ricker(0.128, delta_t, 25.0, return_t=True) plt.plot(wavelet, '.') # ============================================================================= # Test synthetic models from bruges.reflection import reflectivity theta = np.arange(46) model_Vp_trace = model_Vp[:, 0, 0] model_Vs_trace = model_Vs[:, 0, 0] model_den_trace = model_den[:, 0, 0] rc_theta = reflectivity(model_Vp_trace, model_Vs_trace, model_den_trace, theta).T plt.imshow(rc_theta.real, aspect='auto')
tick.label.set_fontsize(fs) for tick in axarr[1,p].yaxis.get_major_ticks(): tick.label.set_fontsize(fs) #plot horizontal green line on model image, and steady state axarr[0,p].axhline(y=t, alpha=0.5, lw=2, color = 'g') fig.tight_layout() return get_figure_data() if __name__ == '__main__': dt =0.001 gain = 1 temp = ricker(0.256,dt,25) ntraces=50 data =np.zeros((temp.shape[0],ntraces)) for i in range(ntraces): temp = ricker(0.256,dt,25+10*i) data[:,i] = temp wiggle(data,dt,skipt=1,gain=gain)
axarr[1, p].set_ylabel('amplitude', fs) axarr[1, p].grid() axarr[1, p].set_xlim(xax[0], xax[-1]) for tick in axarr[1, p].xaxis.get_major_ticks(): tick.label.set_fontsize(fs) for tick in axarr[1, p].yaxis.get_major_ticks(): tick.label.set_fontsize(fs) #plot horizontal green line on model image, and steady state axarr[0, p].axhline(y=t, alpha=0.5, lw=2, color='g') fig.tight_layout() return get_figure_data() if __name__ == '__main__': dt = 0.001 gain = 1 temp = ricker(0.256, dt, 25) ntraces = 50 data = np.zeros((temp.shape[0], ntraces)) for i in range(ntraces): temp = ricker(0.256, dt, 25 + 10 * i) data[:, i] = temp wiggle(data, dt, skipt=1, gain=gain)
# the properties of the upper layer are an average from # the shale points in the well vp0, vs0, rho0 = L[['VP', 'VS', 'RHO']][sh].mean().values # the properties of the lower layer come from RPM phi, vsh = .15, .8 _, _, K0 = vrh(vsh, K_qz, K_sh) _, _, MU0 = vrh(vsh, MU_qz, MU_sh) RHO0 = vsh*RHO_qz+(1-vsh)*RHO_sh Kdry, MUdry = softsand(K0, MU0, phi, phic=.5, Cn=12, P=45, f=.3) vp1, vs1, rho1, _ = vels(Kdry, MUdry, K0, RHO0, K_g, RHO_g, phi) n_samples = 500 interface = int(n_samples/2) ang = np.arange(31) wavelet = ricker(.25, 0.001, 25) model_ip, model_vpvs, rc0, rc1 = (np.zeros(n_samples) for _ in range(4)) model_z = np.arange(n_samples) model_ip[:interface] = vp0*rho0 model_ip[interface:] = vp1*rho1 model_vpvs[:interface] = np.true_divide(vp0, vs0) model_vpvs[interface:] = np.true_divide(vp1, vs1) avo = shuey2(vp0, vs0, rho0, vp1, vs1, rho1, ang) rc0[interface] = avo[0] rc1[interface] = avo[-1] synt0 = np.convolve(rc0, wavelet, mode='same') synt1 = np.convolve(rc1, wavelet, mode='same') clip = np.max(np.abs([synt0, synt1])) clip += clip*.2