% Migration and Migration Velocity Lab
% Part 2: Time migration with a RMS Velocity Model

% Nonsmoothed and smoothed RMS Velocity Models
[vstk vstksmth]=vrmsmodel;

%Plot Stacking velocity 
figure;
imagesc(x,dt*[1:nt],vstk');
title('Nonsmoothed Stacking Velocity','FontSize',18);
xlabel('X (m)','FontSize',16);
ylabel('TWT (msec)','FontSize',16);
colorbar;
%Plot Smoothed Stacking velocity
figure;
imagesc(x,dt*[1:nt],vstksmth');
title('Smoothed Stacking Velocity','FontSize',18);
xlabel('X (m)','FontSize',16);
ylabel('TWT (msec)','FontSize',16);
colorbar;


% Time migration
[MIG_time]=timemigrate(stack,nx,nz,nt,dt,ap,dx,dz,vstk,TOTS,TOTE);
[MIG_timesmth]=timemigrate(stack,nx,nz,nt,dt,ap,dx,dz,vstksmth,TOTS,TOTE);

% Plot Migration Result 1
migtmax=0.2*max(MIG_time(:));
figure;
imagesc(x,t,MIG_time',[-migtmax migtmax]);
title('Migrated Section with Stacking Velocity','FontSize',18);
xlabel('X (m)','FontSize',16);
ylabel('TWT (msec)','FontSize',16);
colormap('gray');

% Plot Migration Result 2
figure;
imagesc(x,t,MIG_time',[-migtmax migtmax]);
title('Migrated Section with Smoothed Stacking Velocity','FontSize',18);
xlabel('X (m)','FontSize',16);
ylabel('TWT (msec)','FontSize',16);
colormap('gray');  
