SO503 Honors Modern Methods
Spring 2017
Lab 5: Cross Correlation
Resample a series.
Perform a cross correlation, understanding the concept of lag.
Divide a vector into x and y components.
Use a loop to find the maximum value and where it occurs in the series.
Do a double loop
There is a Matlab m file xcorr_lab.m and a data set time_tide_weather.csv which show you how to resample a series and perform a cross correlation. There is a function linear_reinterpolate.m if you do not like what is built into Matlab. There is also a function to deal with NaN in your input files.
Take an 8-10 day subset of the data you used in the previous lab. You want a time period with a good storm.
Reinterpolate the storm surge (6 minute data) and continuous wind (10 minute data) from the data sources from Lab 4 to a common sampling interval. This has several subtasks:
Get the same start and stop time for the two sets of data. Do not try to put them into the same worksheet in Excel.
Deal with any missing data. This will be a NaN in Matlab, but a blank cell in Excel. If you have a choice, avoid this data through careful selection of the time period you will analyze.
Have them both progress in the same order. Look up fliplr or flipud to deal with this is Matlab. NOAA might now have fixed this, but you should still know what the two flips do.
You can do any required manipulations of the data file in either Matlab or Excel , but the requirements listed below must be done in Matlab and your code must show how they were done. This data set is relatively short, but your program should be prepared to handle a much larger data set.
General Matlab tips and resources.
Due in the Blackboard dropbox, in a single Word Document, with your last name as the first element:
A scatter plot showing the relationship between the tide residual and the wind speed.
Compute the cross correlation coefficient between wind speed and tide residual, and determine the lag at which the highest correlation occurs , and include a correlogram.
Compute the cross correlation coefficient between the north component of wind speed and tide residual, and determine the lag at which the highest correlation (absolute value) occurs. Note that this is one of the results for the next requirement, but it might be much easier to do this first, and then decide how to extend it. Once you have the next part of the assignment done, this code should disappear from your m file.
Compute the cross correlation coefficient between the component of wind speed at every 10 degrees between 270 and 90 and tide residual, and determine the lag at which the highest correlation (absolute value) occurs for each, and overall. Put this into a table. This includes the north component you previously computed. Insure that you have a double loop doing this.
A plotyy showing the wind component with the best correlation and the tide residual, with the time shifted by the optimal lag for one of the series, so you can see the best relationship.
Discussion of the following points:
What the correlogram means, and how can we use it to predict storm surge from wind data.
Why using just the north component of the wind (or another angle) changes the correlogram, and which you think is more relevant, total speed or a component.
Which interpolation routine you liked best, and why. Insure that you look closely at the interpolated results.
Acknowledgements of any assistance received.
An appendix with your Matlab code, with enough comments for someone to understand you (like you if you have to come back to this kind of problem next fall). If you use a function from a friend, insure it is commented to explain how it works.
An appendix detailing what you have to do to the data you got from the web, before you can put it into your Matlab code.