Skip to content

Question about Huygens PSF #55

Open
@hemkumarsrinivas

Description

@hemkumarsrinivas

Hi,
I was recently trying to write my own function for the Huygens PSF. I have tried a very simplistic approach so far, where I have a spot diagram and assume each spot in the diagram to be a spherical emitter. A coherent sum over the emitters then gives the PSF.

I have tried the following implementation, with a dummy 'spot diagram', where I just generate a grid of uniformly distributed points.

# function to calculate Huygens contribution
def huygens_contribution(x_spot, y_spot, x_obs, y_obs):
    r = np.sqrt((x_obs - x_spot)**2 + (y_obs - y_spot)**2)
    amplitude = np.exp(1j * (2 * np.pi / wavelength) * r)  # Example phase term
    return amplitude

x_spots = [...]  # List of x coordinates of the spots
y_spots = [...]  # List of y coordinates of the spots
X_obs, Y_obs = np.meshgrid(np.linspace(-5, 5, 100), np.linspace(-5, 5, 100))  # Observation grid
wavelength = 500e-9  # Example wavelength in meters

# Initialize a complex array for coherent summation
amplitude_sum = np.zeros(X_obs.shape, dtype=np.complex128)

# Loop over the spots
for x_spot, y_spot in zip(x_spots, y_spots):
    # Calculate contribution  for each observation point
    for i in range(X_obs.shape[0]):
        for j in range(X_obs.shape[1]):
            amplitude_sum[i, j] += huygens_contribution(x_spot, y_spot, X_obs[i, j], Y_obs[i, j])

# Calculate the intensity from  coherent sum
psf = np.abs(amplitude_sum)**2 

At the end of it, I am able to generate a Huygens PSF. Here's an example for it:

Image

One main challenge I face is its speed. I wanted to ask, if there are any ideas, suggestions to improve this ? Moreover, how can I extract the coordinates of the spots from the spot diagram to use with such an implementation ?

It would be great if you could share some ideas on this. I will be happy to work further on this and contribute to the package.

Edited by Kramer on Feb. 1st, 2025 to format code as Python

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions