Beispiel #1
0
    t0 = 0.
    tn = 3500.  # Simulation last 3.5 second (3500 ms)
    f0 = 0.025  # Source peak frequency is 25Hz (0.025 kHz)

#NBVAL_IGNORE_OUTPUT
from examples.seismic import plot_velocity, plot_perturbation
from scipy import ndimage

# Create true model from a preset
model = create_model()

# Create initial model and smooth the boundaries
model0 = create_model(grid=model.grid)
model0.vp = ndimage.gaussian_filter(model0.vp.data, sigma=filter_sigma, order=0)

plot_velocity(model)
plot_velocity(model0)
plot_perturbation(model0, model)


# ## Acquisition geometry
# 
# In this tutorial, we will use the easiest case for inversion, namely a transmission experiment. The sources are located on one side of the model and the receivers on the other side. This allows to record most of the information necessary for inversion, as reflections usually lead to poor inversion results.

# In[23]:


#NBVAL_IGNORE_OUTPUT
# Define acquisition geometry: source
from examples.seismic import AcquisitionGeometry
#NBVAL_IGNORE_OUTPUT
from examples.seismic import plot_velocity, plot_perturbation
from scipy import ndimage

# Create true model from a preset
model = create_model()

# Create initial model and smooth the boundaries
model0 = create_model(grid=model.grid)
model0.vp = ndimage.gaussian_filter(model0.vp.data,
                                    sigma=filter_sigma,
                                    order=0)

# Plot the true and initial model and the perturbation between them
plot_velocity(model)
plot_velocity(model0)
plot_perturbation(model0, model)

# ## Acquisition geometry
#
# Next we define the positioning and the wave signal of our source, as well as the location of our receivers. To generate the wavelet for our source we require the discretized values of time that we are going to use to model a single "shot",
# which again depends on the grid spacing used in our model. For consistency this initial setup will look exactly as in the previous modelling tutorial, although we will vary the position of our source later on during the actual imaging algorithm.

# In[4]:

#NBVAL_IGNORE_OUTPUT
# Define acquisition geometry: source
from examples.seismic import AcquisitionGeometry

# First, position source centrally in all dimensions, then set depth
Beispiel #3
0
rec = Receiver(name='rec',
               npoint=nreceivers,
               ntime=nt,
               grid=model.grid,
               coordinates=rec_coords)

# NOT FOR MANUSCRIPT
from examples.seismic import RickerSource

# At first, we want only a single shot.
# Src is 5% across model, at depth of 500 m.
z_locations = np.linspace(0, z_extent, num=nshots)
src_coords = np.array([(z_extent / 50, z) for z in z_locations])

# NOT FOR MANUSCRIPT
f0 = 0.010  # kHz, peak frequency.
src = RickerSource(name='src',
                   grid=model.grid,
                   f0=f0,
                   time=time,
                   coordinates=src_coords[nshots // 2])
# NOT FOR MANUSCRIPT
plt.plot(src.time, src.data)
plt.xlabel("Time (ms)")
plt.ylabel("Amplitude")
plt.show()

from examples.seismic import plot_velocity

plot_velocity(model)
plot_velocity(model0)
Beispiel #4
0
shape = (101, 101)  # Number of grid point (nx, nz)
spacing = (10., 10.)  # Grid spacing in m. The domain size is now 1km by 1km
origin = (0., 0.)  # What is the location of the top left corner. This is necessary to define
# the absolute location of the source and receivers

# Define a velocity profile. The velocity is in km/s
v = np.empty(shape, dtype=np.float32)
v[:, :51] = 1.5
v[:, 51:] = 2.5

# With the velocity and model size defined, we can create the seismic model that
# encapsulates this properties. We also define the size of the absorbing layer as 10 grid points
model = Model(vp=v, origin=origin, shape=shape, spacing=spacing,
              space_order=2, nbpml=10)

plot_velocity(model)

############################################################################################

from examples.seismic import TimeAxis

t0 = 0.  # Simulation starts a t=0
tn = 1000.  # Simulation last 1 second (1000 ms)
dt = model.critical_dt  # Time step from model grid spacing

time_range = TimeAxis(start=t0, stop=tn, step=dt)

##############################################################################################

#NBVAL_IGNORE_OUTPUT
from examples.seismic import RickerSource
Beispiel #5
0
def demo_fwi(preset, **kwargs):
    # Method to return preset-setups for a fwi aplication
    
    shape = kwargs.pop('shape', (101, 101))                       # Number of grid point (nx, nz)
    spacing = kwargs.pop('spacing', tuple([10. for _ in shape]))  # Grid spacing in m
    origin = kwargs.pop('origin', tuple([0. for _ in shape]))     # Defines relative source and receiver locations   
    nshots = kwargs.pop('nshots', int(shape[0]/2))                # One every two grid points
    nreceivers = kwargs.pop('nreceivers', int(shape[0]))          # One recevier every grid point
    t0 = kwargs.pop('t0', 0.)                                     # Simulation starts at t=0
    tn = kwargs.pop('tn', 3500.)                                  # Simulation last 3.5 seconds (3500 ms)
    f0 = kwargs.pop('f0', 0.025)                                  # Source peak frequency is 25Hz (0.025 kHz)
    
    if preset.lower() in ['marmousi2d-isotropic', 'm2d']:
        shape = (1601, 401)
        spacing = (7.5, 7.5)
        origin = (0., 0.)
        nshots = 301
        nreceivers = 601
        nbl = kwargs.pop('nbl', 20)
        resolution_scale = kwargs.pop('resolution_scale', 3.0)    # Scale to which the shape is rescaled
        filter_sigma = kwargs.pop('filter_sigma', 2.0)            # Sigma to which the data is smoothened  
        
        # Build the model based on the preset data
        if resolution_scale != 1:
            true_model = low_res_marmousi(resolution_scale)
        else:
            true_model = demo_model('marmousi2d-isotropic', data_path='data/', grid=None, nbpml=20)
        
        # Create initial model by smooth the boundaries
        fwi_model0 = smoothen_model(true_model, filter_sigma)
        
        # Position source
        src_coordinates = np.empty((1, 2))
        src_coordinates[0, :] = np.array(true_model.domain_size) * .5
        src_coordinates[0, 1] = 20.  # Depth is 20m
        
        # Initialize receivers for synthetic and imaging data
        rec_coordinates = np.empty((nreceivers, 2))
        rec_coordinates[:, 0] = np.linspace(0, true_model.domain_size[0], num=nreceivers)
        rec_coordinates[:, 1] = 20. # Depth(m)
        
        # Prepare the varying source locations sources
        source_locations = np.empty((nshots, 2), dtype=np.float32)
        source_locations[:, 1] = 30.
        source_locations[:, 0] = np.linspace(0., 7500, num=nshots)
        
        # Ready up the Geometry
        geometry = AcquisitionGeometry(true_model, rec_coordinates, src_coordinates,
                                       t0, tn, f0=f0, src_type='Ricker')
        
        # Construct the Solver
        solver = AcousticWaveSolver(true_model, geometry, space_order=4)
        
        # Attribute the number of fwi iterations
        fwi_iterations = 20
        
    elif preset.lower() in ['circle-isotropic', 'c2d']:
        nshots = 9
        tn = 1000.
        f0 = 0.010
        
        # Build the model based on the preset data
        true_model = demo_model('circle-isotropic', vp_circle=3.0, vp_background=2.5,
                         origin=origin, shape=shape, spacing=spacing, nbl=40)
        
        # Create initial model by smooth the boundaries
        fwi_model0 = demo_model('circle-isotropic', vp_circle=2.5, vp_background=2.5,
                         origin=origin, shape=shape, spacing=spacing, nbl=40,
                         grid = true_model.grid)
        
        # Position source
        src_coordinates = np.empty((1, 2))
        src_coordinates[0, :] = np.array(true_model.domain_size) * .5
        src_coordinates[0, 0] = 20.  # Depth is 20m
        
        # Initialize receivers for synthetic and imaging data
        rec_coordinates = np.empty((nreceivers, 2))
        rec_coordinates[:, 1] = np.linspace(0, true_model.domain_size[0], num=nreceivers)
        rec_coordinates[:, 0] = 980.
        
        # Prepare the varying source locations sources
        source_locations = np.empty((nshots, 2), dtype=np.float32)
        source_locations[:, 0] = 30.
        source_locations[:, 1] = np.linspace(0., 1000, num=nshots)
        
        # Ready up the Geometry
        geometry = AcquisitionGeometry(true_model, rec_coordinates, src_coordinates,
                                       t0, tn, f0=f0, src_type='Ricker')
        
        # Construct the Solver
        solver = AcousticWaveSolver(true_model, geometry, space_order=4)
        
        # Attribute the number of fwi iterations
        fwi_iterations = 5
        
    
    # Show the plots
    if kwargs.pop('show_plots', False):
        print("True Model:")
        plot_velocity(true_model)
        print("FWI Model 0:")
        plot_velocity(fwi_model0)
        #print("True Model ad FWI Model 0 difference:")
        #plot_perturbation(fwi_model0, true_model)
        print("Sources and receivers positions:")
        plot_velocity(true_model, source=geometry.src_positions, receiver=geometry.rec_positions[::4, :])
        print("Sources locations:")
        plot_velocity(true_model, source=source_locations)
        print("Geometry:")
        geometry.src.show()
        
    return true_model, fwi_model0, nshots, nreceivers, src_coordinates, rec_coordinates,\
           source_locations, geometry, solver, fwi_iterations
Beispiel #6
0
def plot_model_to_file(model, filename, cmap="jet"):
    plt.clf()
    plot_velocity(model, cmap=cmap)
    plt.savefig(filename)