faitdivers / pyao

PyAO - Adaptive Optics simulation package
6 stars 0 forks source link

[WFS] Redundant parameters in main.py #62

Closed faitdivers closed 10 years ago

faitdivers commented 10 years ago

The parameters Nx and Ny are the same as numPupilx and numPupily.

(Note: it is usually assumed that the pupil-plane is sampled the same way as the focal-plane)

NKant13 commented 10 years ago

Ill remove Nx and Ny and keep the initial names. On your note, its hard to get the same sampling in the focal plane because of the use of the FFT, should we then down sample or interpolate to match the sampling in the pupil plane?

faitdivers commented 10 years ago

Perfect, Nick.

But why do you say it's difficult? With an FFT you get as an output a vector with the same size as the input, right?

By the way, work on the branch issue66. There were some problems with some of the compatibility (namely in #65). When all the problems are fixed, we'll try to merge it again.

NKant13 commented 10 years ago

The way I do it I get a sample spacing in the pupil plane of dxo = lx/Nx and in the focal plane of dxi = lambda*f/lx.

Im waiting on some input about issue 66 because I can only find the problem to be that i didnt specify the lensCentx/y to be arrays, when that is in place the mainWFS work in the test script i made.

faitdivers commented 10 years ago

1 function[u2,L2]=propFF(u1,L1,lambda,z); 2 % propagation - Fraunhofer pattern 3 % assumes uniform sampling 4 % u1 - source plane field 5 % L1 - source plane side length 6 % lambda - wavelength 7 % z - propagation distance 8 % L2 - observation plane side length 9 % u2 - observation plane field 10 % 11 [M,N]=size(u1); 12 dx1=L1/M 13 k=2_pi/lambda; 14 % 15 L2=lambda_z/dx1; 16 dx2=lambda_z/L1; 17 x2=-L2/2:dx2:L2/2-dx2; 18 [X2,Y2]=meshgrid(x2,x2); 19 % 20 c=1/(j_lambda_z)_exp(j_k/(2z)(X2.^2+Y2.^2)); 21 u2=c._ifftshift(fft2(fftshift(u1)))*dx1^2; 22 end

I usually use this function for Fraunhofer propagation (see the book by Voelz). In his case he uses the same sampling as you and gets the same number of samples as an output.

On 7 June 2014 22:17, Nick Kant notifications@github.com wrote:

The way I do it I get a sample spacing in the pupil plane of dxo = lx/Nx and in the focal plane of dxi = lambda*f/lx.

Im waiting on some input about issue 66 because I can only find the problem to be that i didnt specify the lensCentx/y to be arrays, when that is in place the mainWFS work in the test script i made.

— Reply to this email directly or view it on GitHub https://github.com/faitdivers/pyao/issues/62#issuecomment-45420106.

NKant13 commented 10 years ago

Thx! Ill look into this and apply it to our code.

NKant13 commented 10 years ago

This is actually almost exactly as how I do it. Also in this case dx1 =! dx2 and then you get the same problem I got that the amount of samples over the spatial grid in the pupil plane are not the same as in the focal plane, because N1 = l/dx1 =! N2 = l/dx2. Or am I missing something?

faitdivers commented 10 years ago

So, according to the code that I posted we have the following:

dx1 = L1/N1 (1) L2 = lambda_f/dx1 (2) dx2 = lambda_f/L1 (3)

Please see if you agree with these premises.

Now, we want to see how many samples are in the detector plane, which is given by (where I used (2) and (3), and then (1) )

L2/dx2 = (lambda_f/dx1) / (lambda_f/L1) = L1 / dx1 = N1.

Hence, the number of samples in the detector plane are the same as in the pupil plane.

On 7 June 2014 22:48, Nick Kant notifications@github.com wrote:

This is actually almost exactly as how I do it. Also in this case dx1 =! dx2 and then you get the same problem I got that the amount of samples over the spatial grid in the pupil plane are not the same as in the focal plane, because N1 = l/dx1 =! N2 = l/dx2. Or am I missing something?

— Reply to this email directly or view it on GitHub https://github.com/faitdivers/pyao/issues/62#issuecomment-45420798.

NKant13 commented 10 years ago

I agree with this, the problem start when your spatial size of the pupil plane is the same as the detector plane, then L1 = L2. This problem only arises with the calculation of several lenses which you then place into a spatial grid of the detector plane which has the same size as the lenslet array.

faitdivers commented 10 years ago

Yes, you're correct. But is that a problem?

I think you can safely assume that they are the same length, or is there a problem that I am not seeing?

On 7 June 2014 23:26, Nick Kant notifications@github.com wrote:

I agree with this, the problem start when your spatial size of the pupil plane is the same as the detector plane, then L1 = L2. This problem only arises with the calculation of several lenses which you then place into a spatial grid of the detector plane which has the same size as the lenslet array.

— Reply to this email directly or view it on GitHub https://github.com/faitdivers/pyao/issues/62#issuecomment-45421642.

NKant13 commented 10 years ago

Well if you want the amount of samples to be the same, yes. The airy disks with a sampling of dx2 are placed in a grid with the spatial dimension the same as the lenslet array, thus lx and ly. Hence the amount of samples in the detector plane are Nxo = lx/dx2 .... This is different from the amount of samples in the pupil plane which are Nxi = lx/dx1 ....

faitdivers commented 10 years ago

I misread your previous comment. Hence, the confusion.

Well, in the end, you choose what you want to do.

I think its more intelligible and simpler to have the same number of samples. So, L2 should not be fixed a priori, but be variable so as to accommodate as many samples as you have defined in the pupil plane.

On 8 June 2014 10:24, Nick Kant notifications@github.com wrote:

Well if you want the amount of samples to be the same, yes. The airy disks with a sampling of dx2 are placed in a grid with the spatial dimension the same as the lenslet array, thus lx and ly. Hence the amount of samples in the detector plane are Nxo = lx/dx2 .... This is different from the amount of samples in the pupil plane which are Nxi = lx/dx1 ....

— Reply to this email directly or view it on GitHub https://github.com/faitdivers/pyao/issues/62#issuecomment-45431375.

NKant13 commented 10 years ago

Agreed, but its not solved that simply, because L2 is set by dx1. Think its the best way to interpolate to the right amount of samples for now.

faitdivers commented 10 years ago

Ok.

On 8 June 2014 11:51, Nick Kant notifications@github.com wrote:

Agreed, but its not solved that simply, because L2 is set by dx1. Think its the best way to interpolate to the right amount of samples for now.

— Reply to this email directly or view it on GitHub https://github.com/faitdivers/pyao/issues/62#issuecomment-45432868.

NKant13 commented 10 years ago

Must numPupilx/y and numImagx/y always be the same? Because then I suggest we throw one of them away. Also noApertx/y are also redundant because these parameters can be collected form centLensx/y.

faitdivers commented 10 years ago

Must numPupilx/y and numImagx/y always be the same?

Yes. You can throw one away.

Also noApertx/y are also redundant because these parameters can be collected form centLensx/y.

True. But centLensx/y is difficult to set. I would suggest that two options are provided to the user: (1) creation of a square symmetric mesh given noApertx/y (basically a systematic way to create lensCent without having to change each and every element) (2) user-defined centers using centLens or lensCent.

On 9 June 2014 13:37, Nick Kant notifications@github.com wrote:

Must numPupilx/y and numImagx/y always be the same? Because then I suggest we throw one of them away. Also noApertx/y are also redundant because these parameters can be collected form centLensx/y.

— Reply to this email directly or view it on GitHub https://github.com/faitdivers/pyao/issues/62#issuecomment-45482651.

NKant13 commented 10 years ago

Oke noted. To keep the nomenclature clean I will use Nx/y instead of numPupilx/y and numImagx/y.

NKant13 commented 10 years ago

Some other function are dependent on numPupilx/y, what is the procedure if we want to change variables names or even completely throw them out?

faitdivers commented 10 years ago

Create an issue for that.

On 9 June 2014 14:46, Nick Kant notifications@github.com wrote:

Some other function are dependent on numPupilx/y, what is the procedure if we want to change variables names or even completely throw them out?

— Reply to this email directly or view it on GitHub https://github.com/faitdivers/pyao/issues/62#issuecomment-45486893.

NKant13 commented 10 years ago

Issues #73 and #69 come forth out of this discussion and the main issue is solved. So this issue can be closed.

forcaeluz commented 10 years ago

Seems good.