MATLAB: How to remove the seasonal signals from the monthly sea level data

sea leveltime series

I have computed monthly averaged sea level anomalies from altimetry data. I have to remove the seasonal signal from these data. How should I do?

Best Answer

Another way to do it is to remove the means for each month. That is, figure out the average sea level for January and subtract it from all January data. Here's an example:
% Months 1-12 corresponding to 10 years of data:
month = repmat(1:12,1,10);
% Some constant + seasonal signal + longterm trend + noise:
data = 10 + 5*sin(month*pi/6) + 0.05*(1:length(month)) + 2*rand(size(month));
plot(data)
xlabel 'ten years of monthly data'
We can figure out the average value for each month like this:
for k=1:12
monthlymeans(k) = mean(data(month==k));
end
plot(1:12,monthlymean)
xlabel 'month of year'
ylabel 'normal data value for each month'
And we can subtract the monthly means from the corresponding months like this:
for k = 1:12
deseasoned_data(month==k) = data(month==k) - monthlymeans(k);
end
figure
plot(deseasoned_data)
title 'deseasoned data'
The deseasoned data now has only the long-term trend and the noise components.