Getting back into NumPy, Day 5

less than 1 minute read

A couple of days of travelling have messed up the schedule. I’m just going to continue on with my journey, even though the numbers are off :-)

Today’s post is a short one. I’m still preparing some small stuff before starting with the algorithm. I have to admit: I need to read up a bit on the details of the alternating projections. I don’t quite know how the projections are formulated, and until I have had time to do that, I’m going to prepare as much as I can.

Today’s code creates a random start guess. It’s nothing more than a matrix filled with normal distributed random numbers. This matrix is then element wise multiplied with the aperture matrix (the circle from Day 4, remember?).

The scattered image is then computed by taking the FFT of the random start guess and plotting its amplitude.

The code is short, but the images are beautiful! Enjoy!

Element wise product of random start guess and aperture

The scatter pattern of the random start guess. Isn’t it beautiful?

And the code that generated these pictures are:

## Start guess
start_guess = np.multiply(np.random.randn(n, n), aperture)
## Start guess FFT
start_guess_fft = np.fft.fftshift(np.fft.fft2(start_guess))