1

I have function of two variables which was calculated numerically for grid {x,y}. Then I calculate numerical Fourier trasform of my function and obtain array of Fourier transform values. How can I find the array {u,v,f[u,v]}, where u and v Fourier coordinates and f[u,v] is obtained values of Fourier transform, i.e. how can I create frequency array {u,v}?

Artem Alexandrov
  • 803
  • 4
  • 11

1 Answers1

3

You need your data in a 2D array form, but I've also shown how to convert a flat list to this form. You can use ImagePeriodogram to get the image, or use Fourier directly, or use ImagePeriodogramArray to get the image 2D array data:

(* make up some fake data in 2D grid form *)
f[x_, y_] := Sin[4 π x y^2] - y*Cos[6 π x]
data = Table[f[x, y], {y, 0, 1, .01}, {x, 0, 1, 0.01}];

ArrayPlot[data]

ft = Fourier[data]; (* note you may want to look into FourierParameters ) ( to get ft in a flat list of {u,v,ft} where u,v are integers we can do: *) ftflat = Flatten[MapIndexed[Append[#2,#1],ft,{2}],1];

(* see also ImagePeriodogramArray *) ImagePeriodogram[Image@data]

(* if your data are in a flat list of the form {{x,y,f[x,y]}, {x,y,f[x,y]}, ... } ) ( make up some fake data first ) dataFlat = Flatten[Table[{x, y, f[x, y]}, {y, 0, 1, .01}, {x, 0, 1, 0.01}], 1]; ( convert dataFlat to the appropriate 2D array form *) dataConverted = Map[Last, GatherBy[dataFlat, #[[2]] &], {2}]; ArrayPlot[dataConverted] ImagePeriodogram[Image@dataConverted]

fourier image

See also FourierDCT if you want a discrete cosine transform:

MatrixPlot[FourierDCT[data], ImageSize -> Medium]
flinty
  • 25,147
  • 2
  • 20
  • 86