# Cross Correlation analysis with two series of wavelets

#### MrSak87

##### New Member
Hey all,

This one will be a tough one to explain...

I essentially have 3 columns of data and 40000+ rows of it. Column A measures seconds from time 0 to say 10. Column B is a series of values creating on a graph wavelets from a source detected by receiver one and Column C is the same series of wavelets detected by receiver two. The two receivers are relatively closely spaced apart and therefore the profiles of these waves will be very similar although NOT identical. The spacing between the wavelets also changes due to the density of the soil/rock they travel throughThe aim is for excel to detect the peaks of each correlating wave and detect the lag time between the two series at each source. An example of a lag between two wavelets is shown

This lag time calculation (column 4!?) allows me to do all the statistical analysis for my job. The traditional way is to manually pick the peaks using ancient software but this simply isn't feasible with the amount of data I have.

My VB ability is marginally better than just recording but only slightly.

Sean

### Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

#### oldbrewer

##### Board Regular
show us the raw data that produces a wave - my first thought, if there is enough data, is to detect the max value and take the average of it and say 10 data values either side

#### MrSak87

##### New Member
Seconds x1 x2
 0 -5.87e-05 -0.0001 0.000417 -1.05e-05 -2.16e-05 0.000833 4.64e-07 -1.61e-05 0.00125 -5.53e-06 -2.32e-05 0.001667 -4.74e-06 -2.16e-05 0.002083 -6.32e-06 -2.21e-05 0.0025 2.38e-06 -9.34e-06 0.002917 2.43e-05 2.88e-05 0.003333 2.85e-05 4.73e-05 0.00375 2.64e-05 4.24e-05 0.004167 3.66e-05 5.96e-05 0.004583 3.98e-05 7.17e-05 0.005 4.37e-05 7.63e-05 0.005417 5.28e-05 8.52e-05 0.005833 5.39e-05 8.75e-05 0.00625 5.18e-05 8.56e-05 0.006667 5.28e-05 8.54e-05 0.007083 5.4e-05 9.17e-05 0.0075 5.9e-05 9.97e-05 0.007917 0.000108 0.00016 0.008333 0.000145 0.000199 0.00875 0.000139 0.000199 0.009167 0.000136 0.00018 0.009583 0.00013 0.00018 0.01 0.000116 0.000154 0.010417 6.84e-05 7.92e-05 0.010833 6.07e-05 6.89e-05 0.01125 6.62e-05 8.04e-05 0.011667 6.45e-05 7.6e-05 0.012083 6.16e-05 7.48e-05 0.0125 5.05e-05 5.67e-05 0.012917 2.93e-05 2.13e-05 0.013333 1.75e-05 -2.09e-06 0.01375 2.2e-05 2.43e-06 0.014167 8.96e-06 -1.58e-05 0.014583 1.1e-06 -3.22e-05 0.015 -1.89e-06 -4e-05 0.015417 -1.07e-05 -4.75e-05 0.015833 -1.69e-05 -4.91e-05 0.01625 -1.32e-05 -4.71e-05 0.016667 -1.58e-05 -4.91e-05 0.017083 -2.13e-05 -5.86e-05 0.0175 -2.92e-05 -6.76e-05 0.017917 -8.34e-05 -0.000138 0.018333 -0.000114 -0.000175 0.01875 -0.000112 -0.000126 0.019167 -6.75e-05 -0.000133 0.019583 -9.43e-05 -0.000121 0.02 -7.51e-05 -0.000101 0.020417 -4.83e-05 -4.7e-05 0.020833 -3.14e-05 -2.24e-05 0.02125 -4.12e-05 -3.68e-05 0.021667 -3.43e-05 -3.13e-05 0.022083 -3.65e-05 -3.23e-05 0.0225 -3.42e-05 -2.28e-05 0.022917 -1.72e-05 1.71e-06 0.023333 -1.95e-06 3.21e-05 0.02375 -5.21e-06 2.4e-05 0.024167 7.12e-06 3.62e-05 0.024583 1.91e-05 5.31e-05 0.025 2.52e-05 5.7e-05 0.025417 3.56e-05 6.15e-05 0.025833 3.97e-05 5.74e-05 0.02625 3.76e-05 5.69e-05 0.026667 4.27e-05 5.82e-05 0.027083 5.11e-05 6.8e-05 0.0275 5.87e-05 7.57e-05 0.027917 0.000105 0.000129 0.028333 0.000149 0.000181 0.02875 0.000141 0.00017 0.029167 0.00014 0.00017 0.029583 0.000141 0.000166 0.03 0.000127 0.000143 0.030417 9.39e-05 8.5e-05 0.030833 8.17e-05 7.44e-05 0.03125 8.67e-05 8.38e-05 0.031667 8.48e-05 8.61e-05 0.032083 8.74e-05 8.6e-05 0.0325 8.33e-05 7.9e-05 0.032917 7.5e-05 5.4e-05 0.033333 6.36e-05 2.61e-05 0.03375 6.23e-05 3e-05 0.034167 5.24e-05 1.5e-05 0.034583 4.81e-05 2.19e-06 0.035 3.7e-05 -2.96e-06 0.035417 3.02e-05 -5.15e-06 0.035833 2.32e-05 -3.19e-06 0.03625 2.56e-05 3.55e-07 0.036667 2.18e-05 1.55e-06 0.037083 1.8e-05 -2.66e-06 0.0375 1.01e-05 -1.41e-05 0.037917 -5.43e-05 -9.54e-05 0.038333 -6.99e-05 -0.000113 0.03875 -6.85e-05 -0.000107 0.039167 -6.75e-05 -0.000103 0.039583 -6.48e-05 -9.57e-05 0.04 -5.21e-05 -6.97e-05 0.040417 -1.66e-05 -8.3e-06 0.040833 -7.11e-06 1.1e-06 0.04125 -9.89e-06 -5.37e-06 0.041667 -1.06e-05 -7.34e-06 0.042083 -1.41e-05 -1.01e-05 0.0425 -6.71e-06 4.14e-06 0.042917 6.25e-08 2.92e-05 0.043333 7.3e-06 5.1e-05 0.04375 8.75e-06 4.48e-05 0.044167 1.7e-05 5.52e-05 0.044583 1.98e-05 6.75e-05 0.045 2.63e-05 7.14e-05 0.045417 3.58e-05 7.56e-05 0.045833 3.74e-05 6.91e-05 0.04625 3.74e-05 6.47e-05 0.046667 4.09e-05 6.02e-05 0.047083 5.32e-05 6.52e-05 0.0475 6.87e-05 7.24e-05 0.047917 0.000131 0.000135 0.048333 0.000176 0.000176 0.04875 0.000172 0.000163 0.049167 0.000168 0.000161 0.049583 0.000157 0.000152 0.05 0.000137 0.000133 0.050417 9.06e-05 7.19e-05 0.050833 6.81e-05 6.91e-05 0.05125 6.81e-05 9.16e-05 0.051667 6.27e-05 0.000104 0.052083 5.57e-05 0.00011 0.0525 3.63e-05 8.89e-05 0.052917 1.58e-05 4.87e-05 0.053333 8.46e-06 1.64e-05 0.05375 1.13e-05 1.98e-05 0.054167 1.13e-05 1.71e-06 0.054583 2.28e-05 -1.23e-05 0.055 2.99e-05 -1.81e-05 0.055417 3.27e-05 -2.28e-05 0.055833 3.74e-05 -2.92e-05 0.05625 4.59e-05 -3.58e-05 0.056667 5.21e-05 -3.75e-05 0.057083 5.88e-05 -4.37e-05 0.0575 6.03e-05 -4.56e-05 0.057917 1.3e-05 -9.69e-05 0.058333 -3.01e-05 -0.000125 0.05875 -3.79e-05 -0.000102 0.059167 -6.36e-05 -9.18e-05 0.059583 -8.66e-05 -7.56e-05 0.06 -0.000101 -4.96e-05 0.060417 -8.71e-05 2.29e-05 0.060833 -9.01e-05 4.24e-05 0.06125 -0.000103 3.17e-05 0.061667 -0.000112 2.52e-05 0.062083 -0.000121 8.89e-06 0.0625 -0.000124 -7e-06 0.062917 -0.000111 3.93e-06 0.063333 -0.000107 -4.31e-06 0.06375 -9.72e-05 -2.73e-05 0.064167 -7.35e-05 -2.44e-05 0.064583 -5.09e-05 -1.46e-05 0.065 -2.99e-05 -1.21e-05 0.065417 -1.64e-05 -1.5e-05 0.065833 -1.42e-05 -2.74e-05 0.06625 -1.62e-05 -3.41e-05 0.066667 -1.78e-05 -3.41e-05 0.067083 -9.77e-06 -1.65e-05 0.0675 2.99e-06 6.24e-06 0.067917 5.31e-05 8.11e-05 0.068333 0.000101 0.000145 0.06875 9.3e-05 0.000141 0.069167 9.13e-05 0.000142 0.069583 8.5e-05 0.000126 0.07 7.06e-05 0.000103 0.070417 3.97e-05 3.95e-05 0.070833 3.97e-05 3.43e-05 0.07125 5.8e-05 5.52e-05 0.071667 7.04e-05 5.92e-05 0.072083 7.43e-05 5.59e-05 0.0725 7.38e-05 3.49e-05 0.072917 5.84e-05 -8.99e-06 0.073333 6.91e-05 -2.55e-05 0.07375 8.75e-05 -1.27e-05 0.074167 9.86e-05 -1.9e-05 0.074583 0.000109 -2.13e-05 0.075 0.00012 -1.69e-05 0.075417 0.00012 -1.35e-05 0.075833 0.00012 -5.45e-06 0.07625 0.000127 3.02e-06 0.076667 0.00013 9.92e-06 0.077083 0.00013 1.34e-05 0.0775 0.000127 2.26e-05 0.077917 7.65e-05 -2.46e-05 0.078333 3.2e-05 -5.72e-05 0.07875 2.71e-05 -3.99e-05 0.079167 8.17e-06 -3.56e-05 0.079583 -1.37e-07 -2.47e-05 0.08 5.73e-06 4.25e-06 0.080417 4.17e-05 7.24e-05 0.080833 5.02e-05 8.53e-05 0.08125 3.78e-05 7.21e-05 0.081667 2.81e-05 6.8e-05 0.082083 1.36e-05 6.02e-05 0.0825 5.94e-06 6.35e-05 0.082917 9.02e-06 9.83e-05 0.083333 2.33e-06 0.000113 0.08375 -2.2e-06 9.83e-05 0.084167 3.62e-06 0.000108 0.084583 3.91e-06 0.000111 0.085 3.76e-06 0.000108 0.085417 1.52e-06 9.89e-05 0.085833 -7.79e-06 8.3e-05 0.08625 -2.08e-05 6.92e-05 0.086667 -2.47e-05 5.99e-05 0.087083 -3.02e-05 6.28e-05 0.0875 -2.91e-05 6.58e-05 0.087917 1.53e-05 0.000119 0.088333 5.31e-05 0.00016 0.08875 3.94e-05 0.000131 0.089167 3.74e-05 0.000121 0.089583 3.74e-05 9.89e-05 0.09 3.1e-05 6.9e-05 0.090417 1.12e-06 -6.51e-06 0.090833 7.02e-06 -1.85e-05 0.09125 2.86e-05 -3.42e-06 0.091667 4.07e-05 3.16e-07 0.092083 5.32e-05 7.17e-08 0.0925 5.77e-05 -1.32e-05 0.092917 4.67e-05 -4.77e-05 0.093333 5.19e-05 -5.85e-05 0.09375 6.39e-05 -4.37e-05 0.094167 6.5e-05 -4.44e-05 0.094583 6.47e-05 -4.77e-05 0.095 5.75e-05 -3.81e-05 0.095417 4.84e-05 -3.27e-05 0.095833 4.23e-05 -1.81e-05 0.09625 4.97e-05 -3.87e-06 0.096667 5.77e-05 1.04e-05 0.097083 6.76e-05 1.27e-05 0.0975 7.43e-05 1.14e-05 0.097917 3.52e-05 -4.99e-05 0.098333 1.42e-05 -9.43e-05 0.09875 3.72e-05 -8.13e-05 0.099167 5.16e-05 -8.16e-05 0.099583 6.85e-05 -6.28e-05 0.1 8.66e-05 -3.01e-05

<colgroup><col><col><col></colgroup><tbody>
</tbody>

#### oldbrewer

##### Board Regular
I plotted the data and the peak from the last column is higher, but both peak widths are the same. What info would you like. I do not think it is possible to detect any lag between the peaks hitting a maximum because there are very few data points maybe 5 that define the peak

#### MrSak87

##### New Member
Sorry my apologies, I pasted the top of the data then went home after work. The top of the data doesn't show anything really. This shows a bit more. Peak or trough is required. So in this data set the troughs would be appropriate

 3.495 0.003115 0.001985 3.49542 0.003294 0.001946 3.49583 0.003429 0.001883 3.49625 0.003548 0.001806 3.49667 0.003639 0.00173 3.49708 0.003709 0.001679 3.4975 0.00374 0.001686 3.49792 0.003703 0.001711 3.49833 0.003556 0.001727 3.49875 0.003412 0.00184 3.49917 0.003209 0.00191 3.49958 0.002988 0.00197 3.5 0.002736 0.002007 3.50042 0.002539 0.002056 3.50083 0.00238 0.002056 3.50125 0.002244 0.001977 3.50167 0.002132 0.001892 3.50208 0.002012 0.001765 3.5025 0.001865 0.001573 3.50292 0.001694 0.001352 3.50333 0.001466 0.00108 3.50375 0.001204 0.000792 3.50417 0.000926 0.000546 3.50458 0.000611 0.000363 3.505 0.000216 0.000193 3.50542 -0.00027 1.13e-05 3.50583 -0.00083 -0.0002 3.50625 -0.00146 -0.00044 3.50667 -0.0021 -0.0007 3.50708 -0.00272 -0.00093 3.5075 -0.0033 -0.00116 3.50792 -0.00379 -0.00136 3.50833 -0.00414 -0.00153 3.50875 -0.00447 -0.00182 3.50917 -0.0047 -0.00212 3.50958 -0.00487 -0.00245 3.51 -0.005 -0.00281 3.51042 -0.00507 -0.00321 3.51083 -0.00503 -0.00353 3.51125 -0.0049 -0.00374 3.51167 -0.00471 -0.00392 3.51208 -0.00446 -0.00408 3.5125 -0.00413 -0.00423 3.51292 -0.00377 -0.00436 3.51333 -0.00335 -0.00441 3.51375 -0.00291 -0.00437 3.51417 -0.00247 -0.00429 3.51458 -0.00203 -0.00419 3.515 -0.00159 -0.00403 3.51542 -0.00119 -0.00382 3.51583 -0.00081 -0.00354 3.51625 -0.00046 -0.00321 3.51667 -0.00015 -0.00284 3.51708 0.000113 -0.00245 3.5175 0.000305 -0.00205 3.51792 0.000438 -0.00168 3.51833 0.000519 -0.00134 3.51875 0.000652 -0.00089 3.51917 0.000708 -0.00047 3.51958 0.000729 -3.4e-05 3.52 0.000687 0.000389 3.52042 0.000608 0.000794 3.52083 0.000495 0.001104 3.52125 0.000324 0.001285 3.52167 9.63e-05 0.001408 3.52208 -0.00016 0.001494 3.5225 -0.00041 0.00155 3.52292 -0.00059 0.001613 3.52333 -0.00074 0.001605 3.52375 -0.0009 0.001497 3.52417 -0.00104 0.001325 3.52458 -0.00112 0.001144 3.525 -0.00117 0.000966 3.52542 -0.00117 0.000823 3.52583 -0.00108 0.000694 3.52625 -0.00091 0.000594 3.52667 -0.0007 0.000532 3.52708 -0.00048 0.000521 3.5275 -0.00025 0.000531 3.52792 7.3e-06 0.000578 3.52833 0.000349 0.000716 3.52875 0.00063 0.000816 3.52917 0.000928 0.001012 3.52958 0.0012 0.001246 3.53 0.001466 0.001472 3.53042 0.00167 0.001611 3.53083 0.001849 0.001731 3.53125 0.002003 0.001878 3.53167 0.002096 0.001979 3.53208 0.002182 0.002091 3.5325 0.002285 0.002206 3.53292 0.002406 0.002279 3.53333 0.002551 0.002348 3.53375 0.002706 0.002393 3.53417 0.002852 0.002379 3.53458 0.002982 0.002315 3.535 0.003103 0.002254 3.53542 0.003205 0.002189 3.53583 0.003291 0.002122 3.53625 0.003371 0.002048 3.53667 0.003442 0.00195 3.53708 0.003479 0.001838 3.5375 0.003489 0.001761 3.53792 0.003459 0.001702 3.53833 0.003374 0.001643 3.53875 0.003342 0.00171 3.53917 0.003263 0.001756 3.53958 0.003165 0.001798 3.54 0.003017 0.001825 3.54042 0.002874 0.001881 3.54083 0.002682 0.001888 3.54125 0.002449 0.001827 3.54167 0.00222 0.00178 3.54208 0.001999 0.001719 3.5425 0.001765 0.001628 3.54292 0.001566 0.001529 3.54333 0.00135 0.001367 3.54375 0.001121 0.001136 3.54417 0.00086 0.000885 3.54458 0.000536 0.000623 3.545 0.000138 0.000342 3.54542 -0.00029 6.72e-05 3.54583 -0.00077 -0.00019 3.54625 -0.00132 -0.00044 3.54667 -0.00191 -0.00068 3.54708 -0.00251 -0.00091 3.5475 -0.00311 -0.00115 3.54792 -0.00366 -0.00138 3.54833 -0.00412 -0.00158 3.54875 -0.00458 -0.00188 3.54917 -0.00492 -0.00215 3.54958 -0.00515 -0.00243 3.55 -0.00526 -0.00272 3.55042 -0.00531 -0.00307 3.55083 -0.00526 -0.00339 3.55125 -0.00508 -0.00366 3.55167 -0.00483 -0.00394 3.55208 -0.00451 -0.00418 3.5525 -0.00415 -0.00438 3.55292 -0.00378 -0.00454 3.55333 -0.00335 -0.00461 3.55375 -0.0029 -0.00459 3.55417 -0.00247 -0.00451 3.55458 -0.00208 -0.0044 3.555 -0.00173 -0.00422 3.55542 -0.00141 -0.004 3.55583 -0.00108 -0.00372 3.55625 -0.00077 -0.00338 3.55667 -0.00047 -0.00298 3.55708 -0.00019 -0.00257 3.5575 8.75e-05 -0.00215 3.55792 0.000319 -0.00176 3.55833 0.000493 -0.00143 3.55875 0.000688 -0.00102 3.55917 0.000791 -0.00064 3.55958 0.000846 -0.00024 3.56 0.000862 0.000145 3.56042 0.000833 0.000543 3.56083 0.000738 0.000879 3.56125 0.00056 0.001115 3.56167 0.000355 0.001324 3.56208 0.000147 0.001476 3.5625 -7.3e-05 0.001586 3.56292 -0.00027 0.001671 3.56333 -0.00046 0.001679 3.56375 -0.00065 0.0016 3.56417 -0.00079 0.001485 3.56458 -0.00087 0.00136 3.565 -0.00092 0.001206 3.56542 -0.00092 0.001057 3.56583 -0.00089 0.000903 3.56625 -0.00085 0.000769 3.56667 -0.00079 0.000657 3.56708 -0.00072 0.000595 3.5675 -0.00064 0.000576 3.56792 -0.00049 0.000638 3.56833 -0.00021 0.000808 3.56875 4.79e-05 0.000932 3.56917 0.000385 0.001122 3.56958 0.00077 0.001288 3.57 0.001197 0.001422 3.57042 0.001565 0.001463 3.57083 0.001884 0.001503 3.57125 0.002141 0.001604 3.57167 0.002322 0.001716 3.57208 0.002467 0.001869 3.5725 0.002583 0.002053 3.57292 0.00265 0.002205 3.57333 0.002726 0.002355 3.57375 0.002815 0.002467

<colgroup><col width="64" span="3" style="width:48pt"> </colgroup><tbody>
</tbody>

Is the kind of thing I'm looking for possible? Cheers for your reply

#### oldbrewer

##### Board Regular
I used conditional formatting to find all the minima in cols B and C using =and(b2<b1,b2<b3)

are you interested in the time difference between each pair of minima or the minimum value itself

PM me if you want to continue off line as I think there is nothing fundamental of interest to the general forum readers

#### shg

##### MrExcel MVP
Uisng formulas, you can see that the correlation of the first 150 samples of W1 peaks with a 5-sample delay to W2:

 Row\Col A​ B​ C​ D​ E​ F​ G​ 1​ T​ W1​ W2​ ​ Offset​ ​ ​ 2​ 3.4950​ 0.0031​ 0.0020​ 0​ 0.825​ F2: =CORREL(\$B\$2:\$B\$151, INDEX(\$C\$2:\$C\$191, E2 + 1):INDEX(\$C\$2:\$C\$191, E2 + 150)) 3​ 3.4954​ 0.0033​ 0.0019​ 1​ 0.856​ 4​ 3.4958​ 0.0034​ 0.0019​ 2​ 0.882​ 5​ 3.4963​ 0.0035​ 0.0018​ 3​ 0.902​ 6​ 3.4967​ 0.0036​ 0.0017​ 4​ 0.916​ 7​ 3.4971​ 0.0037​ 0.0017​ 5​ 0.923​ 8​ 3.4975​ 0.0037​ 0.0017​ 6​ 0.921​ 9​ 3.4979​ 0.0037​ 0.0017​ 7​ 0.910​ 10​ 3.4983​ 0.0036​ 0.0017​ 8​ 0.890​ 11​ 3.4988​ 0.0034​ 0.0018​ 9​ 0.859​ 12​ 3.4992​ 0.0032​ 0.0019​ 10​ 0.819​ 13​ 3.4996​ 0.0030​ 0.0020​ 11​ 0.769​ 14​ 3.5000​ 0.0027​ 0.0020​ 12​ 0.710​ 15​ 3.5004​ 0.0025​ 0.0021​ 13​ 0.644​ 16​ 3.5008​ 0.0024​ 0.0021​ 14​ 0.570​ 17​ 3.5013​ 0.0022​ 0.0020​ 15​ 0.490​ 18​ 3.5017​ 0.0021​ 0.0019​ 16​ 0.405​ 19​ 3.5021​ 0.0020​ 0.0018​ 17​ 0.317​ 20​ 3.5025​ 0.0019​ 0.0016​ 18​ 0.226​ 21​ 3.5029​ 0.0017​ 0.0014​ 19​ 0.135​ 22​ 3.5033​ 0.0015​ 0.0011​ 20​ 0.044​ 23​ 3.5038​ 0.0012​ 0.0008​ 21​ -0.045​ 24​ 3.5042​ 0.0009​ 0.0005​ 22​ -0.130​ 25​ 3.5046​ 0.0006​ 0.0004​ 26​ 3.5050​ 0.0002​ 0.0002​ 27​ 3.5054​ -0.0003​ 0.0000​ 28​ 3.5058​ -0.0008​ -0.0002​ 29​ 3.5063​ -0.0015​ -0.0004​ 30​ 3.5067​ -0.0021​ -0.0007​ 31​ 3.5071​ -0.0027​ -0.0009​ 32​ 3.5075​ -0.0033​ -0.0012​ 33​ 3.5079​ -0.0038​ -0.0014​

#### shg

##### MrExcel MVP
EDIT: For the first set of data, which has smaller time values, the correlation peak is at 0 offset. Maybe a better test is to see what time dilation of W1 is a best fit for W2. Does that make sense?

#### MrSak87

##### New Member
shg, I've not tried this yet but this is EXACTLY what I'm looking for!! Makes perfect sense I'll get back to you

#### MrSak87

##### New Member
Works perfectly! Thank you, you've no idea how much time I've spent trying to figure this out.

What do you mean by time dilation? Do you mean the amount of time change between the two waves as if one was stretched? If so how would I go about this?

1,101,946
Messages
5,483,831
Members
407,415
Latest member
Anton1999

### This Week's Hot Topics

• Finding issue in If elseif else with For each Loop
Finding issue in If elseif else with For each Loop I have tried this below code but i'm getting in Y column filled with W005. Colud you please...
• MsgBox Error
Hi Guys, I have the below error show up when i try and run my macro in File1 but works fine if i copy and paste the same code into file2. [ATTACH...
• CELL FORMAT - IF CONDITION
My Cell Format is [B]""0.00" Cr". [/B]But in the cell, it is showing 123.00 for editing. (123 is entry figure). (Data imported from other...
• Show numbers nearly the same
Is this possible. I have a number that can change very time eg 0.00001234 Then I have a lot of numbers 0.0000001, 0.0000002, 0.00000004...