Hello,(adsbygoogle = window.adsbygoogle || []).push({});

My name is Thibaut. I am looking to improve my code in python in order to have a better look a my fourier transform. as you can see on the image, we barely see any detail of the peaks on the image. Also it's not centred. the zero order peak in on the corner, not in the centre.

Any idea how to fix it?

Thibaut

image: click here

Code (Python):

import numpy as np

import matplotlib.pyplot as plt

x = np.linspace(-100, 100.0, 201.0, endpoint = True)

y = np.linspace(-100, 100.0, 201.0, endpoint = True)

xx, yy = np.meshgrid(x, y, sparse=True)

def f1(a,b):

return np.piecewise(a, [abs(a) < 2, abs(a) >= 2], [1, 0]) * np.piecewise(b, [abs(b) < 2, abs(b) >= 2], [1, 0])

def f2(r,c):

spacing=10

a=np.zeros([r,c])

for ii in range (r):

for jj in range(c):

if (ii%spacing)==0 and (jj%spacing)==0 and abs(ii-100)<55 and abs(jj-100)<55:

a[ii,jj]=1

else:

a[ii,jj]=0

return a

h = np.fft.fft2(f1(xx,yy))

g = np.fft.fft2(f2(201,201))

k=abs(h)*abs(g)

plt.imshow(np.abs(k),interpolation='nearest')

#plt.imshow(f1(xx,yy),interpolation='nearest')

#plt.imshow(f2(200,200),interpolation='nearest')

plt.show()

**Physics Forums - The Fusion of Science and Community**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Fourier transform with Python

Loading...

Similar Threads - Fourier transform Python | Date |
---|---|

Discrete Fast Fourier transform with FFTW in FORTRAN77 | Aug 27, 2017 |

Question about Fourier transformation in Matlab | Dec 23, 2016 |

How Signals Are Sampled and Stored As A Fourier Transform? | Mar 28, 2016 |

[Fortran MKL] FFT quick questions | Jul 13, 2015 |

ND Fourier Transform in Python | Aug 26, 2014 |

**Physics Forums - The Fusion of Science and Community**