Skip to main content
deleted 4 characters in body
Source Link
Sjoerd C. de Vries
  • 66.1k
  • 15
  • 189
  • 327

A simple and fast method for finding the phase difference would be to do it manually. Let's plot the the two data sets in a Manipulate and let one have a manually determined offset. Since the time bases in both lists are the same I discard them for the moment so that the x-axis depicts sample number:

Manipulate[
    ListLinePlot[{24.7 lists[[1, All, 2]], lists[[2, offset ;; -1, 2]]}, ImageSize -> 600], 
    {offset, 1, 400, 1}
]

Mathematica graphics

Note that I scaled one of the plots by 24.7 for reasons that will be made clear later on.

If you play with that you find that a 38 sample shift is about optimal.

How to do this with fourier analysis?

The amplitude spectra:

af1 = Abs@Fourier[lists[[1, All, 2]]];
af2 = Abs@Fourier[lists[[2, All, 2]]];

The phases:

pf1 = Arg@Fourier[lists[[1, All, 2]]];
pf2 = Arg@Fourier[lists[[2, All, 2]]];

A plot of the amplitude spectrum of the first sample:

ListLinePlot[af1, PlotRange -> All]

Mathematica graphics

The two peaks are at:

Ordering[af1, -2]

{14, 2488}

The same for the second sample. At position 14 the ratio of the amplitudes is:

af2[[14]]/af1[[14]]

24.70345393

So, here we have our amplitude scaling factor.

The phase difference for this peak is:

pf2[[14]] - pf1[[14]]

1.240647232

or in terms of sample positions:

(pf2[[14]] - pf1[[14]])/(2 \[Pi]) 1/((14.-1)/Length[af1])

37.97214223

Yes, the same value we found manually.

A simple and fast method for finding the phase difference would be to do it manually. Let's plot the the two data sets in a Manipulate and let one have a manually determined offset. Since the time bases in both lists are the same I discard them for the moment so that the x-axis depicts sample number:

Manipulate[
    ListLinePlot[{24.7 lists[[1, All, 2]], lists[[2, offset ;; -1, 2]]}, ImageSize -> 600], 
    {offset, 1, 400, 1}
]

Mathematica graphics

Note that I scaled one of the plots by 24.7 for reasons that will be made clear later on.

If you play with that you find that a 38 sample shift is about optimal.

How to do this with fourier analysis?

The amplitude spectra:

af1 = Abs@Fourier[lists[[1, All, 2]]];
af2 = Abs@Fourier[lists[[2, All, 2]]];

The phases:

pf1 = Arg@Fourier[lists[[1, All, 2]]];
pf2 = Arg@Fourier[lists[[2, All, 2]]];

A plot of the amplitude spectrum of the first sample:

ListLinePlot[af1, PlotRange -> All]

Mathematica graphics

The two peaks are at:

Ordering[af1, -2]

{14, 2488}

The same for the second sample. At position 14 the ratio of the amplitudes is:

af2[[14]]/af1[[14]]

24.70345393

So, here we have our amplitude scaling factor.

The phase difference for this peak is:

pf2[[14]] - pf1[[14]]

1.240647232

or in terms of sample positions:

(pf2[[14]] - pf1[[14]])/(2 \[Pi]) 1/((14.-1)/Length[af1])

37.97214223

Yes, the same value we found manually.

A simple and fast method for finding the phase difference would be to do it manually. Let's plot the two data sets in a Manipulate and let one have a manually determined offset. Since the time bases in both lists are the same I discard them for the moment so that the x-axis depicts sample number:

Manipulate[
    ListLinePlot[{24.7 lists[[1, All, 2]], lists[[2, offset ;; -1, 2]]}, ImageSize -> 600], 
    {offset, 1, 400, 1}
]

Mathematica graphics

Note that I scaled one of the plots by 24.7 for reasons that will be made clear later on.

If you play with that you find that a 38 sample shift is about optimal.

How to do this with fourier analysis?

The amplitude spectra:

af1 = Abs@Fourier[lists[[1, All, 2]]];
af2 = Abs@Fourier[lists[[2, All, 2]]];

The phases:

pf1 = Arg@Fourier[lists[[1, All, 2]]];
pf2 = Arg@Fourier[lists[[2, All, 2]]];

A plot of the amplitude spectrum of the first sample:

ListLinePlot[af1, PlotRange -> All]

Mathematica graphics

The two peaks are at:

Ordering[af1, -2]

{14, 2488}

The same for the second sample. At position 14 the ratio of the amplitudes is:

af2[[14]]/af1[[14]]

24.70345393

So, here we have our amplitude scaling factor.

The phase difference for this peak is:

pf2[[14]] - pf1[[14]]

1.240647232

or in terms of sample positions:

(pf2[[14]] - pf1[[14]])/(2 \[Pi]) 1/((14.-1)/Length[af1])

37.97214223

Yes, the same value we found manually.

Source Link
Sjoerd C. de Vries
  • 66.1k
  • 15
  • 189
  • 327

A simple and fast method for finding the phase difference would be to do it manually. Let's plot the the two data sets in a Manipulate and let one have a manually determined offset. Since the time bases in both lists are the same I discard them for the moment so that the x-axis depicts sample number:

Manipulate[
    ListLinePlot[{24.7 lists[[1, All, 2]], lists[[2, offset ;; -1, 2]]}, ImageSize -> 600], 
    {offset, 1, 400, 1}
]

Mathematica graphics

Note that I scaled one of the plots by 24.7 for reasons that will be made clear later on.

If you play with that you find that a 38 sample shift is about optimal.

How to do this with fourier analysis?

The amplitude spectra:

af1 = Abs@Fourier[lists[[1, All, 2]]];
af2 = Abs@Fourier[lists[[2, All, 2]]];

The phases:

pf1 = Arg@Fourier[lists[[1, All, 2]]];
pf2 = Arg@Fourier[lists[[2, All, 2]]];

A plot of the amplitude spectrum of the first sample:

ListLinePlot[af1, PlotRange -> All]

Mathematica graphics

The two peaks are at:

Ordering[af1, -2]

{14, 2488}

The same for the second sample. At position 14 the ratio of the amplitudes is:

af2[[14]]/af1[[14]]

24.70345393

So, here we have our amplitude scaling factor.

The phase difference for this peak is:

pf2[[14]] - pf1[[14]]

1.240647232

or in terms of sample positions:

(pf2[[14]] - pf1[[14]])/(2 \[Pi]) 1/((14.-1)/Length[af1])

37.97214223

Yes, the same value we found manually.