Jashcraf / poke

Poke (pronounced poh-keh) is a Polarization Ray Tracing and Gaussian Beamlet module for Python
BSD 3-Clause "New" or "Revised" License
33 stars 7 forks source link

Debugging Inconsistent field on translation #54

Closed Jashcraf closed 1 year ago

Jashcraf commented 1 year ago

r_ray and k_ray look good to me, let's try the ray transfer matrices.

A matrix

image

B Matrix

image

C matrix

image

D matrix

image

Jashcraf commented 1 year ago

top is new algo, bottom is old

overall the new one looks less regular, maybe an operation got broadcast over an unintended dimesnion

Jashcraf commented 1 year ago

Delta calculation image

These actually just look like the right values in perhaps different places. Specifically - the middle two columns are switched

Jashcraf commented 1 year ago

K rays before delta calculation are the same, but different order

image

Jashcraf commented 1 year ago

Oh my god lData and mData were flipped in the function inputs

Jashcraf commented 1 year ago

Delta is good (left gbd, right beamlets) image

Jashcraf commented 1 year ago

After orthogonal transformation

k_rays on both == np.array([0,0,1]), which is good! r_rays look a little different at first glance, can we use fewer beamlets without breaking?

image

Jashcraf commented 1 year ago

4x4 beamlets traces few enough to peruse. Seems like the comparison might be approaching numerical precision limits, this might be a thing with using numexpr for calculations? image

Jashcraf commented 1 year ago

Gonna look at the +X differential ray, r_rays should basically all be at x,y = 0 here. They are different and transposed! image

Jashcraf commented 1 year ago

Ah I think I might have been looking at the wrong coordinate here is the x,y,z position for each ray at a given pixel - which it is constant across image consistency!

Jashcraf commented 1 year ago

plotting after the delta propagation, the beamlets array is entirely black? image

Jashcraf commented 1 year ago

Oh it's because I'm passing it weird data, the rayset index is now in the first when it should be in the zeroth. consistency! image

Jashcraf commented 1 year ago

Checking after orthogonal transformation. Might have some nan vals in the old method. Viridis is r_data and magma is k_data image image

Both look good (save the nans)

Jashcraf commented 1 year ago

Axx

image

Cxx - looks wrong

image

Bxx - looks wrong, values of near 50 are about what we'd expect given the HST focal length

image

Dxx - also doesn't look spectacular

image

Jashcraf commented 1 year ago

Ah I forgot to normalize the l vector in the orthogonal transfer matrix

Axx - looking good!

image

Cxx - looking good!

image

Bxx - looking good!

image

Dxx - tell me why im so excited

image

Jashcraf commented 1 year ago

WE WIN image

time to try the misaligned case

Jashcraf commented 1 year ago

Breaks during misalignment and focus - I suspect that this has to do with where the ray positions are image

Jashcraf commented 1 year ago

image

Nah the ray positions are identical

Jashcraf commented 1 year ago

Let's check the final ingredients for the matrix, starting with Amplitude

|Amplitude|

image Looks slightly different, don't know what this could be from (other than the complex beam parameter computation)

Angle{Phase}

This is very different! image

(The vertical lines are the new algorithm)

Jashcraf commented 1 year ago

For the misaligned case the ray transfer matrices are different!

Axx (left is beamlets right is gbd)

image

on-axis case for comparison

image

Jashcraf commented 1 year ago

Works for the defocused case image

Jashcraf commented 1 year ago

The orthogonal transformation matrix is looking good, each image is a row in the matrix image image image

Jashcraf commented 1 year ago

image The detector coords are wrong!

Jashcraf commented 1 year ago

image turns out you need to provide the offset to the rays, not detector

trentjbrendel commented 1 year ago

This is fascinating. Thanks for sharing, Jaren!