Open crystalskim opened 4 weeks ago
I had the same issue. I'm not sure why the function was marked as broken because the function works fine for a single image instead of list of images.
I instead just copy/pasted the source code and made a new function in my code. The math in that function is correct so it's basically identical. You do need to make your own aperture mask (i.e. a boolean mask that covers the four pupils), however.
def estimate_pwfs_slopes(img, aperture_mask):
image = img.shaped
sub_shape = image.grid.shape // 2
I_a = image[:sub_shape[0], :sub_shape[1]]
I_b = image[sub_shape[0]:2 * sub_shape[0], :sub_shape[1]]
I_c = image[sub_shape[0]:2 * sub_shape[0], sub_shape[1]:2 * sub_shape[1]]
I_d = image[:sub_shape[0], sub_shape[1]:2 * sub_shape[1]]
norm = I_a + I_b + I_c + I_d
inv_norm = np.zeros_like(norm)
inv_norm[norm != 0] = 1 / norm[norm != 0]
I_x = (I_a + I_b - I_c - I_d) * inv_norm
I_y = (I_a - I_b - I_c + I_d) * inv_norm
# I_a bottom left
# I_b top left
# I_c top right
# I_d bottom right
reshaped_aperture = aperture_mask.shaped[:sub_shape[0], :sub_shape[1]]
I_x = I_x[reshaped_aperture > 0]
I_y = I_y[reshaped_aperture > 0]
return np.array([I_x, I_y])
Thanks, that got me past the error!
I am attempting to output dynamic AO images like in this tutorial except using a pyramid WFS. At the last step when outputting the animation video, I keep getting the following error while calculating the image slopes. I see there is a warning message already, but I saw it was added six years ago. Are these issues related? Does the PWFS need a different approach to work?