MATLAB Code for MASW Shot Alignment and Analysis
Below is a comprehensive MATLAB code for processing active MASW (Multichannel Analysis of Surface Waves) data, including shot alignment, frequency analysis, and visualization.
%% MASW Data Processing with Shot Alignment
% Senior Geophysicist - MATLAB Implementation
clear; close all; clc;
%% 1. Generate Synthetic MASW Data (or load real data)
% Parameters for synthetic data generation
num_shots = 5; % Number of shots
num_receivers = 24; % Number of receivers
fs = 1000; % Sampling frequency (Hz)
t = 0:1/fs:1; % Time vector (1 second duration)
freq = 10; % Dominant frequency (Hz)
% Create synthetic shot gathers with random time shifts
shot_gathers = zeros(num_receivers, length(t), num_shots);
for i = 1:num_shots
% Create a synthetic surface wave
wave = sin(2*pi*freq*t) .* exp(-t*2);
% Add some random noise
wave = wave + 0.1*randn(size(t));
% Apply distance attenuation
for j = 1:num_receivers
distance = j; % Receiver spacing (meters)
attenuation = exp(-0.01*distance);
shot_gathers(j,:,i) = wave * attenuation;
end
% Apply random time shift to simulate unsynchronized shots
shift = randi([-50 50]); % Random shift in samples
shot_gathers(:,:,i) = circshift(shot_gathers(:,:,i), shift, 2);
end
%% 2. Plot Common Receiver Gather (Before Alignment)
figure;
for i = 1:num_receivers
subplot(6,4,i);
plot(t, squeeze(shot_gathers(i,:,:)));
title(['Receiver ' num2str(i)]);
xlabel('Time (s)');
ylabel('Amplitude');
grid on;
end
sgtitle('Common Receiver Gather - Before Alignment');
%% 3. Calculate Average Frequency Response
% Compute FFT for each shot
fft_length = 2^nextpow2(length(t));
f = fs*(0:(fft_length/2))/fft_length;
% Initialize frequency response matrix
freq_response = zeros(num_receivers, length(f), num_shots);
for i = 1:num_shots
for j = 1:num_receivers
signal = squeeze(shot_gathers(j,:,i));
fft_signal = abs(fft(signal, fft_length));
freq_response(j,:,i) = fft_signal(1:fft_length/2+1);
end
end
% Average across all shots and receivers
avg_freq_response = mean(freq_response, [1 3]);
% Plot average frequency response
figure;
plot(f, avg_freq_response);
title('Average Frequency Response Across All Shots');
xlabel('Frequency (Hz)');
ylabel('Amplitude');
grid on;
xlim([0 50]); % Focus on typical MASW frequency range
%% 4. Auto Alignment of Shot Gathers
% Method: Cross-correlation based alignment
% Choose a reference shot (usually the one with highest energy)
reference_shot = squeeze(shot_gathers(:,:,1));
% Initialize aligned gathers
aligned_gathers = zeros(size(shot_gathers));
for i = 1:num_shots
current_shot = squeeze(shot_gathers(:,:,i));
% Calculate cross-correlation for each receiver
for j = 1:num_receivers
[corr, lag] = xcorr(reference_shot(j,:), current_shot(j,:));
[~, idx] = max(abs(corr));
time_shift = lag(idx);
% Apply the shift to align the traces
aligned_gathers(j,:,i) = circshift(current_shot(j,:), -time_shift, 2);
end
end
%% 5. Plot Common Receiver Gather (After Alignment)
figure;
for i = 1:num_receivers
subplot(6,4,i);
plot(t, squeeze(aligned_gathers(i,:,:)));
title(['Receiver ' num2str(i)]);
xlabel('Time (s)');
ylabel('Amplitude');
grid on;
end
sgtitle('Common Receiver Gather - After Alignment');
%% 6. Compare Before and After Alignment for One Receiver
figure;
subplot(2,1,1);
plot(t, squeeze(shot_gathers(12,:,:))); % Middle receiver
title('Before Alignment');
xlabel('Time (s)');
ylabel('Amplitude');
grid on;
subplot(2,1,2);
plot(t, squeeze(aligned_gathers(12,:,:))); % Middle receiver
title('After Alignment');
xlabel('Time (s)');
ylabel('Amplitude');
grid on;
Explanation of Shot Alignment Importance
Why Shot Alignment is Important in MASW:
-
Phase Coherence: Proper alignment ensures that surface wave phases are coherent across different shots, which is crucial for accurate dispersion analysis.
-
Signal Enhancement: Alignment allows for constructive stacking of signals, improving the signal-to-noise ratio.
-
Accurate Velocity Analysis: Misaligned shots can lead to incorrect phase velocity estimates, which are fundamental to MASW processing.
-
Consistent Waveform Analysis: Aligned shots provide consistent waveforms across the survey, making it easier to identify and track surface wave arrivals.
When Shot Alignment is Particularly Important:
-
Field Conditions: When using unsynchronized sources or when trigger timing is unreliable.
-
Long Offsets: For surveys with large source-receiver offsets where timing errors become more significant.
-
Low Signal Conditions: In noisy environments where signal enhancement through stacking is crucial.
-
High-Resolution Studies: When detailed dispersion analysis is required for shallow subsurface characterization.
Is MASW Possible Without Shot Alignment?
Yes, MASW can be performed without explicit shot alignment, but with limitations:
-
Single Shot Analysis: If each shot is processed individually, alignment isn't strictly necessary, but this approach may have lower signal quality.
-
Manual Picking: Experienced interpreters can manually pick dispersion curves from unaligned data, though this is time-consuming and less accurate.
-
Modern Processing: Some advanced processing techniques can compensate for minor timing inconsistencies.
However, for optimal results and reliable subsurface characterization, shot alignment is highly recommended as it significantly improves data quality and interpretation confidence.
The provided MATLAB code demonstrates a complete workflow from raw data visualization to alignment and frequency analysis, which forms the foundation for subsequent MASW processing steps like dispersion analysis and inversion.