astronomy-laboratory / pyoof

pyoof is a Python package which performs out-of-focus (OOF) holography on astronomical beam maps for single-dish radio telescopes.
BSD 3-Clause "New" or "Revised" License
0 stars 1 forks source link

Implement multi-frequency fit #2

Closed tcassanelli closed 1 year ago

tcassanelli commented 1 year ago

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.

VicentePenaLet commented 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

tcassanelli commented 1 year ago

@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$.

VicentePenaLet commented 1 year ago

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.

download (1) download

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.

tcassanelli commented 1 year ago

Some things that you can try:

VicentePenaLet commented 1 year ago

I ran test using different frequencies, then plotted the correlation matrix

wavelength = 9 um corr_n5_0 009000000000000001

wavelength = 7, 9 um corr_n5_0 009000000000000001

wavelength = 7, 9, 11 um corr_n5_0 009000000000000001

Visually it seems like the correlations are generally lower when we add more wavelengths.

tcassanelli commented 1 year ago

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.

tcassanelli commented 1 year ago

@VicentePenaLet can you plot the two phases and the residual difference?

VicentePenaLet commented 1 year ago

This is the original Simulated Phase Map

download

This are the Phase map and phase error for simulated observation with a single 9 um wavelength fitphase_n5_0 009000000000000001

9

This are the Phase map and phase error for simulated observation with a 7 and 9 um wavelength

fitphase_n5_0 009000000000000001

79
VicentePenaLet commented 1 year ago

phase difference wavelenght= 7,9,11

download (1)

phase wavelenght= 7,9,11 fitphase_n5_0 009000000000000001

tcassanelli commented 1 year ago

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.

tcassanelli commented 1 year ago

Also when doing the fit are you using the same width in degrees for the beam maps?

VicentePenaLet commented 1 year ago

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.

tcassanelli commented 1 year ago

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?

tcassanelli commented 1 year ago

phase difference wavelenght= 7,9,11

download (1)

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.

VicentePenaLet commented 1 year ago

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.

tcassanelli commented 1 year ago

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.

VicentePenaLet commented 1 year ago

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.

99 download (3)
tcassanelli commented 1 year ago

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.

tcassanelli commented 1 year ago

We have converged in a good solution.