# Set the parameters of the finite difference grid velocity = np.zeros(shape)+6000. velocity[100:,100:] = 0. fc = 15. sources = [wavefd.GaussSource(125*ds, 75*ds, area, shape, 1., fc)] dt = wavefd.scalar_maxdt(area, shape, np.max(velocity)) duration = 2.5 maxit = int(duration/dt) stations = [[75*ds, 125*ds]] # x, z coordinate of the seismometer snapshots = 3 # every 3 iterations plots one simulation = wavefd.scalar(velocity, area, dt, maxit, sources, stations, snapshots) # This part makes an animation using matplotlibs animation API background = (velocity-4000)*10**-1 fig = mpl.figure(figsize=(8, 6)) mpl.subplots_adjust(right=0.98, left=0.11, hspace=0.5, top=0.93) mpl.subplot2grid((4, 3), (0,0), colspan=3,rowspan=3) wavefield = mpl.imshow(np.zeros_like(velocity), extent=area, cmap=mpl.cm.gray_r, vmin=-1000, vmax=1000) mpl.points(stations, '^b', size=8) mpl.ylim(area[2:][::-1]) mpl.xlabel('x (km)') mpl.ylabel('z (km)') mpl.m2km() mpl.subplot2grid((4,3), (3,0), colspan=3) seismogram1, = mpl.plot([],[],'-k') mpl.xlim(0, duration) mpl.ylim(-200, 200) mpl.ylabel('Amplitude') times = np.linspace(0, dt*maxit, maxit) # This function updates the plot every few timesteps
shape = (100,100) xp, yp, zp = gridder.regular((-5000, 5000, -5000, 5000), shape, z=-150) fields = [prism.potential(xp, yp, zp, model), prism.gx(xp, yp, zp, model), prism.gy(xp, yp, zp, model), prism.gz(xp, yp, zp, model), prism.gxx(xp, yp, zp, model), prism.gxy(xp, yp, zp, model), prism.gxz(xp, yp, zp, model), prism.gyy(xp, yp, zp, model), prism.gyz(xp, yp, zp, model), prism.gzz(xp, yp, zp, model)] titles = ['potential', 'gx', 'gy', 'gz', 'gxx', 'gxy', 'gxz', 'gyy', 'gyz', 'gzz'] mpl.figure(figsize=(8, 9)) mpl.subplots_adjust(left=0.03, right=0.95, bottom=0.05, top=0.92, hspace=0.3) mpl.suptitle("Potential fields produced by a 3 prism model") for i, field in enumerate(fields): mpl.subplot(4, 3, i + 3) mpl.axis('scaled') mpl.title(titles[i]) levels = mpl.contourf(yp*0.001, xp*0.001, field, shape, 15) cb = mpl.colorbar() mpl.contour(yp*0.001, xp*0.001, field, shape, levels, clabel=False, linewidth=0.1) mpl.show() myv.figure() myv.prisms(model, prop='density') axes = myv.axes(myv.outline()) myv.wall_bottom(axes.axes.bounds, opacity=0.2) myv.wall_north(axes.axes.bounds)
mu, density, area, dt, maxit, sources, stations, snapshots, padding=70, taper=0.005, xz2ps=True) # This part makes an animation using matplotlibs animation API background = 10**-5 * ((density - density.min()) / density.max()) fig = mpl.figure(figsize=(10, 8)) mpl.subplots_adjust(right=0.98, left=0.11, hspace=0.3, top=0.93) mpl.subplot(3, 1, 1) mpl.title('x seismogram') xseismogram, = mpl.plot([], [], '-k') mpl.xlim(0, duration) mpl.ylim(-0.05, 0.05) mpl.ylabel('Amplitude') mpl.subplot(3, 1, 2) mpl.title('z seismogram') zseismogram, = mpl.plot([], [], '-k') mpl.xlim(0, duration) mpl.ylim(-0.05, 0.05) mpl.ylabel('Amplitude') ax = mpl.subplot(3, 1, 3) mpl.title('time: 0.0 s') wavefield = mpl.imshow(background,
gravmag.prism.potential(xp, yp, zp, prisms), gravmag.prism.gx(xp, yp, zp, prisms), gravmag.prism.gy(xp, yp, zp, prisms), gravmag.prism.gz(xp, yp, zp, prisms), gravmag.prism.gxx(xp, yp, zp, prisms), gravmag.prism.gxy(xp, yp, zp, prisms), gravmag.prism.gxz(xp, yp, zp, prisms), gravmag.prism.gyy(xp, yp, zp, prisms), gravmag.prism.gyz(xp, yp, zp, prisms), gravmag.prism.gzz(xp, yp, zp, prisms) ] titles = [ 'potential', 'gx', 'gy', 'gz', 'gxx', 'gxy', 'gxz', 'gyy', 'gyz', 'gzz' ] mpl.figure(figsize=(8, 9)) mpl.subplots_adjust(left=0.03, right=0.95, bottom=0.05, top=0.92, hspace=0.3) mpl.suptitle("Potential fields produced by a 3 prism model") for i, field in enumerate(fields): mpl.subplot(4, 3, i + 3) mpl.axis('scaled') mpl.title(titles[i]) levels = mpl.contourf(yp * 0.001, xp * 0.001, field, shape, 15) cb = mpl.colorbar() mpl.contour(yp * 0.001, xp * 0.001, field, shape, levels, clabel=False, linewidth=0.1) mpl.show()
shp = (70, 560) nz, nx = shp # bellow load geologic model velociy model vmodel = utils.fromimage('pinchout.bmp', ranges=[2500., 3500.], shape=shp) twti = np.cumsum(ds / vmodel, axis=0) * 2 # calculate irregular sampled twt times twt = np.arange(0, np.max(twti) + 0.10, dt) # new twt times re-sampled to 4 ms dnx = int(nx / disc) twtvmodel = np.zeros((len(twt), dnx)) # velocity model in time and discretized for i in xrange(0, nx, disc): # set the time re-sample velocity model twtvmodel[:, int(i / disc)] = np.interp(twt, twti[:, i], vmodel[:, i]) zimp = np.ones( twtvmodel.shape) * 1000. * twtvmodel # create impedance z = rho*v rc = (zimp[1:] - zimp[:-1]) / (zimp[1:] + zimp[:-1] ) # calculate reflection coefs fig = mpl.figure(figsize=(11, 7)) # plottings mpl.subplots_adjust(right=0.98, left=0.11, hspace=0.4, top=0.93, bottom=0.13) mpl.subplot2grid((3, 4), (0, 0), colspan=4) # plot rc model mpl.title("Zero-offset section reflection coefficients", fontsize=13, family='sans-serif', weight='bold') rcs = utils.matrix2stream(rc.transpose(), header={'delta': dt}) mpl.seismic_wiggle(rcs, normalize=True, scale=1.5, ranges=[0, nx]) # rc model wavelet = signal.ricker(255, 1 / (2 * f * dt)) # create wavelet samples = signal.filtfilt(wavelet, np.ones(len(wavelet)), rc, axis=0, padlen=len(twt) - 2) # convolve rc*wavelet mpl.ylabel('twt (s)') mpl.subplot2grid((3, 4), (1, 0), colspan=4) # plot zero-offset traces
gyz = utils.si2eotvos(transform.derivy(xp, yp, utils.mgal2si(gz), shape)) gzz = utils.si2eotvos(transform.derivz(xp, yp, utils.mgal2si(gz), shape)) gxz_true = prism.gxz(xp, yp, zp, model) gyz_true = prism.gyz(xp, yp, zp, model) gzz_true = prism.gzz(xp, yp, zp, model) mpl.figure() mpl.title("Original gravity anomaly") mpl.axis('scaled') mpl.contourf(xp, yp, gz, shape, 15) mpl.colorbar(shrink=0.7) mpl.m2km() mpl.figure(figsize=(14, 10)) mpl.subplots_adjust(top=0.95, left=0.05, right=0.95) mpl.subplot(2, 3, 1) mpl.title("x deriv (contour) + true (color map)") mpl.axis('scaled') levels = mpl.contourf(yp, xp, gxz_true, shape, 12) mpl.colorbar(shrink=0.7) mpl.contour(yp, xp, gxz, shape, 12, color='k') mpl.m2km() mpl.subplot(2, 3, 2) mpl.title("y deriv (contour) + true (color map)") mpl.axis('scaled') levels = mpl.contourf(yp, xp, gyz_true, shape, 12) mpl.colorbar(shrink=0.7) mpl.contour(yp, xp, gyz, shape, 12, color='k') mpl.m2km() mpl.subplot(2, 3, 3)
ds = 10. # depth increment f = 30. # approximated frequency ricker wavelet (scipy a=1/(2.f.dt)) disc = 10 # space discretization shp = (70, 560) nz, nx = shp # bellow load geologic model velociy model vmodel = utils.fromimage('pinchout.bmp', ranges=[2500., 3500.], shape=shp) twti = np.cumsum(ds/vmodel, axis=0)*2 # calculate irregular sampled twt times twt = np.arange(0, np.max(twti)+0.10, dt) # new twt times re-sampled to 4 ms dnx = int(nx/disc) twtvmodel = np.zeros((len(twt), dnx)) # velocity model in time and discretized for i in xrange(0, nx, disc): # set the time re-sample velocity model twtvmodel[:, int(i/disc)] = np.interp(twt, twti[:, i], vmodel[:, i]) zimp = np.ones(twtvmodel.shape)*1000.*twtvmodel # create impedance z = rho*v rc = (zimp[1:]-zimp[:-1])/(zimp[1:]+zimp[:-1]) # calculate reflection coefs fig = mpl.figure(figsize=(11, 7)) # plottings mpl.subplots_adjust(right=0.98, left=0.11, hspace=0.4, top=0.93, bottom=0.13) mpl.subplot2grid((3, 4), (0, 0), colspan=4) # plot rc model mpl.title("Zero-offset section reflection coefficients", fontsize=13, family='sans-serif', weight='bold') rcs = utils.matrix2stream(rc.transpose(), header={'delta': dt}) mpl.seismic_wiggle(rcs, normalize=True, scale=1.5, ranges=[0, nx]) # rc model wavelet = signal.ricker(255, 1/(2*f*dt)) # create wavelet samples = signal.filtfilt(wavelet, np.ones(len(wavelet)), rc, axis=0, padlen=len(twt)-2) # convolve rc*wavelet mpl.ylabel('twt (s)') mpl.subplot2grid((3, 4), (1, 0), colspan=4) # plot zero-offset traces traces = utils.matrix2stream(samples.transpose(), header={'delta': dt}) mpl.seismic_image(traces, cmap=mpl.pyplot.cm.jet, aspect='auto', ranges=[0, nx]) mpl.seismic_wiggle(traces, ranges=[0, nx], normalize=True) mpl.ylabel('twt (s)') mpl.title("Zero-offset section amplitude",