Climate Data Toolbox: how can i calculate correctly a trend with trend function?
17 views (last 30 days)
Show older comments
Alessandro De Lorenzis
on 24 Mar 2021
Commented: Chad Greene
on 25 Mar 2021
Hi! I'm trying to apply the trend function presents in the Climate Data Toolbox for calculating sea level anomaly for the interval 1993-2020. The data matrix has dimension 720x1440x366 (lat,lon,time), where 336 are the months in the studied period. The matrix contains a lot of Nans in the third colmun, especially in the higher latitudes. Is it correct to apply the trend function as follows in order to correctly calculate the trend taking into account in the proper manner the Nans?
[matrix_trend,p] = trend (matrix, 336, 'omitnan');
Is this the way to calculate trend for a 3-D matrix along the time dimension, whose values are stored in the third column?
Moreover, is it ok to use the detrend3 function as follows to subtract the trend to the original data?
detrend = detrend3 (matrix, 'omitnan');
Or, otherwise, does exist a more efficient manner to obtain such a result, i.e.e the subtraction the trend from the reference data?
Thank you in advance.
0 Comments
Accepted Answer
Chad Greene
on 25 Mar 2021
Edited: Chad Greene
on 25 Mar 2021
Hi Alessandro,
I think you've mostly got it. One key point to note is your sampling frequency is monthly, so 12 times per year. If you want the trend in units of sea level height per year, then the correct way to calculate it is:
[matrix_trend,p] = trend(matrix, 12, 'omitnan');
If you're trying to detrend the data, you've got it right, except I wouldn't use detrend as a variable name, because that might get confused with a function called detrend. It's probably better to do:
ssh_detrend = detrend3(ssh, 'omitnan');
Just one more note regarding your nans: I assume you have a lot of nans up north due to presence of sea ice and perhaps due to the orbital limit of whatever altimeters you're using. The 'omitnan' option should work properly, but when interpreting results, know that the results will represent the trend of the available data. So if a given grid cell only has data for the last ten years of the record, then the trend function will only tell you about the trend over the past ten years in that grid cell. This could potentially paint a picture of more extreme trends at the poles, in comparison to low-latitudes where data are available for the full record. But again, if the data span the full timespan of record but are just spotty due to perhaps an intermittent presence of sea ice, that should be alright.
2 Comments
Chad Greene
on 25 Mar 2021
Ah, sorry, I forgot to change your 366 to 12 when I posted it above. I've just now edited my answer to say 12 instead of 366.
The trend function gives you the slope of a least-squares fit to the change. The slope represents the average change in ssh over a given time period. So if your ssh values are in units of meters and you have monthly data, then trend(ssh,12) will give you units of meters per year. Multiply that by ten to get meters per decade.
If, however, you want the change in ssh over the entire record, then all you need is simple subtration, like this:
ssh_change = ssh(:,:,end) - ssh(:,:,1);
More Answers (0)
See Also
Categories
Find more on Climate Science and Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!