% Migration and Migration Velocity Lab
% Part 3: Depth Migration with Straight Ray Assumption

% Create non-smoothed and smoothed average velocities
[vave vaves]=vavemod(dz,nz);

%Plot Average Velocity Model
figure;
imagesc(x,dz*[1:nz],vave',[1500 2500]);
title('Nonsmoothed Average Velocity Model','FontSize',18);
xlabel('X (m)','FontSize',16);
ylabel('Depth (m)','FontSize',16);
colorbar;
%Plot Smoothed Average Velocity Model
figure;
imagesc(x,dz*[1:nz],vaves',[1500 2500]);
title('Smoothed Average Velocity Model','FontSize',18);
xlabel('X (m)','FontSize',16);
ylabel('Depth (m)','FontSize',16);
colorbar;

% Depth Migrations with Non-smoothed and Smoothed Velocities.
[MIG_depth1]=migrate_vave(stack,nx,nz,nt,dt,ap,dx,dz,vave,TOZS,TOZE);
[MIG_depth1s]=migrate_vave(stack,nx,nz,nt,dt,ap,dx,dz,vaves,TOZS,TOZE);

% Plot Migration Result
migdmax=0.2*max(MIG_depth1(:));
figure;
imagesc(x,z,MIG_depth1',[-migdmax migdmax]);
title('Migrated Section with a Nonsmoothed Velocity Model','FontSize',18);
xlabel('X (m)','FontSize',16);
ylabel('Depth (m)','FontSize',16);
colormap('gray');

% Plot Migration Result
figure;
imagesc(x,z,MIG_depth1s',[-migdmax migdmax]);
title('Migrated Section with Smoothed Velocity Model','FontSize',18);
xlabel('X (m)','FontSize',16);
ylabel('Depth (m)','FontSize',16);
colormap('gray');  