Closed tcassanelli closed 1 year ago
I was able to make the multifrequency fit work, I made modified function in order for the simulation to accept a list of frequencies, and modified the data extraction and data plotting in order to be consistent with the changes. I also modified the data extraction function so they return a dictionary instead of list so the data flow is easier to follow. There is an example notebook of the multifrequency fit in my development repo. I still have to fix some issues regarding the saving of plots, and I have to make sure I didn't break the normal fit function in the process.
The example can be found here, I used 3 wave lengths close to the original wave length of 9, the algorithm is able to plot all 3 of the original wavelengths with the estimated Zernike model.
https://github.com/VicentePenaLet/pyoofDevelopment/blob/master/notebooks/multifrequency_fit.ipynb
Currently my solution expect all wavelengths to have the same defocus, next step is to extend it so we can give a different defocus to each of the wavelengths. this relates to #3
@VicentePenaLet great job! A couple thoughts here:
I would focus first in the different wavelength, make it work and study properly the result, i.e., check with noise, what is the tolerance, review the correlation between parameters. Another test would be to give many more $\lambda$ when does the problem become super constraint? There are many more things to test first with multiple $\lambda$.
Ok, I will commit to this repository then.
in the notebook I'm just plotting the beam corresponding to the 15 um, here is a clearer comparison, the simulated beam is shown on top and the result from the model is shown below.
The phase errors in the notebook, are not the correct ones, I still need to tweak the phase error plotting function a bit, so ignore them for now.
Some things that you can try:
I ran test using different frequencies, then plotted the correlation matrix
wavelength = 9 um
wavelength = 7, 9 um
wavelength = 7, 9, 11 um
Visually it seems like the correlations are generally lower when we add more wavelengths.
ah right, ok I see that it has decreased a bit, but I was expecting to give a better constraint since we're using way more data ... my questions would be now how do we properly normalize different data sets with different wavelengths.
@VicentePenaLet can you plot the two phases and the residual difference?
This is the original Simulated Phase Map
This are the Phase map and phase error for simulated observation with a single 9 um wavelength
This are the Phase map and phase error for simulated observation with a 7 and 9 um wavelength
phase difference wavelenght= 7,9,11
phase wavelenght= 7,9,11
I am not following all these phase maps. I want the simulated phase map (which I believe it is the first one), and side by side, I want to see the one that you obtained after using the fit method of the three wavelengths, that is only two phase maps ... not several (the rest of them are not interesting). Then I want the difference from the simulated and the obtained from the fit. So only three.
Also when doing the fit are you using the same width in degrees for the beam maps?
That's what the graph are, as you say, the first one is the original phase map, fixing the Zernike coefficients to be a random choice. Then using that same Maps I made 3 fits, one using 1 frequency of 9 um, one using 2 frequencies of 7 and 9 um, and one using 3 frequencies, of 7,9 and um, this with the goal of comparing how the errors relate to the number of frequencies chosen. For each fit I'm plotting the phase map and the difference between the real Phase error, and the simulated one.
Ah ok I understand now ... yeah seems like it works but I was maybe being too hopeful that you have worked better? Can you plot side by side the simulated phase and then the phase of the obtained with the 3 frequency test?
phase difference wavelenght= 7,9,11
Seems to me that all values within the center region are below 1? or am I wrong here. If that is the case then it may not be as bad.
One reason why it may have not worked so well is that I used low resolution for the FFT so the fit would be faster. I'm repeating the same test with a better resolution and it seems like is working better. I will post the images after the algorithm finishes.
Yeah the FFT number (#7) of point will be better for a beam map that is smaller, i.e., at high frequencies you'll need a larger FFT window, something that we should at some point, be able to return the optimum number of points for a beam map and frequency.
Here are the phase differences with a higher resolution FFT. The scale of the error is a lot lower than with low resolution. reaching only 0.150 and 0.125 for the fit with one frequency and the fit with three frequencies respectively. The error also looks way flatter, with more frequencies. I think this are promising results. Adding more frequencies does in fact improve the accuracy of the fit.
Interesting. When doing so, did you also increase the number of data points in the simulation? i.e., did you increase the FFT size or resolution
in the simulation and in the least-squares minimization? If that is the case then I would always expect a good result. The case that we are interested in is to set the simulation fixed and then increase the resolution
only in the least squares minimization.
We have converged in a good solution.
This is the particular case when given a set of OOF holography maps, another set is also recorded but at a different centred frequency, extra information that we may be able to use to constraint the fit. A multi-frequency fit will, most certainly, increase the computation time.
I think this is a good time to explore a proper normalization of the power pattern, something that should, in principle, include the noise level. I believe that one of the two (or more frequencies) will have a higher noise level that should be tone down before combining it in a multi-fit nonlinear least-squares minimization.