manoharan-lab / holopy

Hologram processing and light scattering in python
GNU General Public License v3.0
131 stars 50 forks source link

Issue with ps_propagate function #441

Open lorenzol90 opened 3 months ago

lorenzol90 commented 3 months ago

Dear all,

I'm trying to build some synthethic diverging-beam holograms and to back propagate them using the ps_propagate function, but I'm obtaining incorrect results. I'm assuming that the physical problem that the ps_propagate function is addressing is the one described in the following picture, where a point source located at position (Sx, Sy, Sz) generates a spherical wave with wavelength $\lambda$ . I'm considering a point scatterer located at (Px,Py,Pz) that is illuminated by the source radiation, producing a second spherical wave with the same wavelength. The origin of the spatial reference system is located at the center of the screen. Constructive or destructive interference occurs at the screen depending on the relative phase $\frac{2 \pi} { \lambda}*(D-d)$ of the two spherical waves at the screen location,

PS

The interference pattern on the screen defines the hologram that I would like to back propagate using the ps_propagate function.

Below is my code:

import numpy as np
import holopy as hp

import matplotlib.pyplot as plt

%matplotlib inline

L = 6

Px, Py, Pz = 0, 0, 2   #scatterer position
Sx, Sy, Sz = 0, 0, L  #point source position

W = 2     #screen size
Nx = 128  #number of pixel on the screen
dx = L/Nx #pixel size

wl = dx/0.5 #wavelength

x_bins = np.arange(-(Nx/2)*dx, (Nx/2)*dx, dx)

holo = np.zeros((Nx, Nx),dtype=float)  #initialize the hologram

for i, x0 in enumerate(x_bins):
    for j, y0 in enumerate(x_bins):

        d = np.sqrt((Px-x0)**2 + (Py-y0)**2 + (Pz-0)**2)  #distance from scatterer to point (x0, y0) on the screen
        D = np.sqrt((Sx-x0)**2 + (Sy-y0)**2 + (Sz-0)**2)  #distance from point source to point (x0, y0) on the screen

        holo[i,j] =  np.cos(2*np.pi/wl * (D-d)) #phase difference between point source and scatterer spherical waves

plt.matshow(holo, cmap = "gray")          
holo = hp.core.metadata.data_grid(holo, spacing=dx, medium_index=1, illum_wavelen=wl)

Below the interefrence pattern of the two waves:

image

However, when I backpropagate the hologram using the ps_propagate function, I find that the backpropagation focuses at z = 7.0 instead than at z= 2.0 as i expected.

zstack = np.arange(0.1, 7, 0.1) 
out_schema = hp.core.detector_grid(shape=128, spacing=dx) 

rec_vol = hp.propagation.ps_propagate(holo, zstack, L, (64,64), out_schema)

%matplotlib qt
hp.show(rec_vol)

image

What is wrong with my interpretation of the ps_propagate function behaviour?