Python FFT help, non linear scaling

In summary, the conversation discusses using Python to simulate the propagation of a gaussian beam through a thick lens and reaching the focal point using Fourier optics. The speaker mentions needing a lot of data points for a high resolution at the focus, and to speed up the process they rescaled their axis to have more points in the center. However, this caused issues with the scipy.fft function, which requires a linear distribution of points. The speaker is unsure if this can be done or if they should try another method to increase precision at the center. They also mention the possibility of using numpy.fft.fftfreq(...) as a solution.
  • #1
Hypochondriac
35
0
Im writing a program in python to simulate the propagation of a gaussian beam through a thick lens and to the focussing point using Fourier optics.

Due to the strength of the focussing I need a lot of data points so that I have a decent resolution at the focus. To speed things up and to reduce the number of data points I need, I rescaled my axis so that instead of the points being linear in space, (i.e. each data point is the same delta x from the next) I scaled it so that it was more cubic than linear. This gives me many more points in the centre of my axis (where I need them) and a lot less for the outer regions where not a lot is happening.
Thats the best I can explain it sorry.

However the fft function in scipy.fft (I assume) requires a linear distribution of points.
Because when I start multiplying my E-field and angular distribution by phase factors to focus it, the results are not what I expect. (If it doesn't require linear spacing, how can I put tell it my real space values as well as the E-field values at them points?)

Either I'm wrong and my code is wrong, or it cannot be done because I've been ripping my code to pieces for days now trying to solve this.

So, can I do a FFT with a non-linear scaling? and should I persevere with my code to make it work?
Or should I give up and try another method of increasing the precision in the centre?
 
Technology news on Phys.org
  • #2
can you use numpy.fft.fftfreq(...)?
 

Related to Python FFT help, non linear scaling

1. What is Python FFT?

Python FFT (Fast Fourier Transform) is a mathematical algorithm used for analyzing and transforming signals in a time domain to their frequency domain representations. This allows for easier analysis and manipulation of signals in areas such as signal processing, data compression, and image processing.

2. How does FFT work in Python?

In Python, FFT is implemented through the use of the numpy.fft module. This module provides functions and methods for performing FFT on arrays of data. The algorithm works by breaking down a signal into smaller components, taking the Discrete Fourier Transform (DFT) of these components, and then combining them to reconstruct the original signal.

3. What is non-linear scaling in Python FFT?

Non-linear scaling in Python FFT refers to the process of transforming the amplitude of a signal from linear to logarithmic scale. This is often used to better visualize signals with a wide range of amplitudes. This can be achieved by using the numpy.log() function on the FFT output.

4. How can I use Python FFT for non-linear scaling?

To use Python FFT for non-linear scaling, you can first perform FFT on your signal using the numpy.fft module. Then, use the numpy.log() function to transform the amplitude to a logarithmic scale. This will result in a more evenly distributed visualization of your signal's frequency components.

5. What are some applications of Python FFT with non-linear scaling?

Python FFT with non-linear scaling has various applications in fields such as audio and image processing, data compression, and signal analysis. It can be used to visualize and analyze signals in a more meaningful way, identify frequency components in a signal, and even remove unwanted noise from a signal.

Similar threads

  • Programming and Computer Science
Replies
3
Views
1K
  • Programming and Computer Science
Replies
10
Views
2K
  • Programming and Computer Science
Replies
15
Views
1K
  • Programming and Computer Science
Replies
3
Views
2K
  • Programming and Computer Science
Replies
8
Views
1K
  • Programming and Computer Science
Replies
2
Views
924
  • Programming and Computer Science
Replies
5
Views
3K
  • Programming and Computer Science
Replies
3
Views
1K
  • Programming and Computer Science
Replies
24
Views
1K
  • Programming and Computer Science
Replies
8
Views
1K
Back
Top