astro-informatics / s2let

Fast wavelet transforms on the sphere.
http://astro-informatics.github.io/s2let
GNU General Public License v3.0
11 stars 2 forks source link

Appearance of artifacts (Convergence problem?) #40

Closed GasperJu closed 2 years ago

GasperJu commented 2 years ago

I have used S2let code applying it in component separation analysis and saw that it behaved strangely when I used your python version with healpy (Healpix extension for python). My collegue has done a jupyter notebook with an example in which it ran the same map with s2let multiple times, using the axisymmetric wavelet transformation. There were very, very strange transformations (is it possible that it's a convergence problem?). @marinscosmo

Could you, or any of your collaborators, help me with this possible problem? I already got in touch with Jason McEwen and Boris Leistedt, they have pointed out that @mdavezac could know why these artifacts are being created.

mdavezac commented 2 years ago

I'm not sure I understand what exactly you are doing or what the problem is. Do you think you could provide the notebook you mentioned and define what you mean by "strange transformations"? thanks.

GasperJu commented 2 years ago

Hi, so I have uploaded the file of my colleague (@marinscosmo) on https://github.com/GasperJu/ComponentSeparation/blob/main/s2let_test.ipynb. The notebook and the file that we have used in it, it's shared on https://drive.google.com/drive/u/0/folders/0AFNotcRqnF-vUk9PVA. This is the same notebook that I have send to Jason and Boris. I hope that it can explain better what is the problem. If you would prefer to discuss this issue in details, maybe you can getting touch with our group project thought our emails: julialeite.carvalho@usp.br (my email), filipe.abdalla@gmail.com (supervisor's email) and alessandro.marins@usp.br (my colleague's email that have created this notebook).

jasonmcewen commented 2 years ago

Thanks @GasperJu. There is a lot going on in that notebook so it is difficult for us to get to the bottom of the issue.

Are you sure you are using ssht/s2let data structures rather than those of healpy?

Could you please produce a minimal working example illustrating this issue, i.e. avoiding the use of healpy, pandas, astropy etc. and avoiding complicated data wrangling (since it's possible these could be the source of the problem).

I'm going to close this issue for now since it's difficult to proceed at present but please reopen if you can produce a minimal working example of the issue.

GasperJu commented 2 years ago

Dear, Jason, I understand that you're concerned about the use of other libraries such as healpy, however, your own example online on git hub uses this library in the example script https://github.com/astro-informatics/s2let/blob/main/src/test/python/mw.py . Can I please insist that you or one of your collaborates have a look at this issue? If you can provide an example script without healpy, we are happy to use it. Do you have an example script without healpy for us to use? By the way, we tried to use another function, which was not the healpy version of map2alm and this did not work either, so an example script would be very welcome indeed.

GasperJu commented 2 years ago

Dear Jason, can I ask if you had time to take a look at my message? @jasonmcewen

GasperJu commented 2 years ago

Dear, Jason, I'm very sorry to insist, but did you glance at what we have discussed? Sorry for being stubborn, but we really need and would appreciate very much your help. @jasonmcewen

GasperJu commented 2 years ago

Dear, Jason, we have developed a minimal working example of the issue: https://drive.google.com/drive/folders/1oS2_OK7PoXWtZJ8uscM21p92JI2xXOuN?usp=sharing. Here, you will find the main script, an auxiliary code, the map used and a directory with the coefficients of each transform. I hope that this message finds you well and we appreciate very much your help. Thank you. @jasonmcewen

jasonmcewen commented 2 years ago

Thanks @GasperJu. I've only had a quick look so far but I see you are using the older analysis_axisym_lm_wav method. Could you please try to use the analysis_lm2wav function (see here). If you set N=1 you should get axisymmetric wavelets. You might also want to try going through the MW map representation just to get something working. In which case you would want to use the analysis_px2wav routine (see here). We've used this in a looping setting similar to yours with no problems, e.g.

    for i_channel, f_channel in enumerate(f):
            L = _get_L(f_channel)
            f_contig = np.ascontiguousarray(f_channel.reshape((-1)))
            f_wav, f_scal = pys2let.analysis_px2wav(
                f_contig,
                B,
                L,
                J_min,
                N=1,
                spin=0,
                upsample=False,
            )
GasperJu commented 2 years ago

Hi @jasonmcewen , where can I find the _get_L(f_channel) function? I couldn't find it.

jasonmcewen commented 2 years ago

@GasperJu I copied this example out of some other code. That is just getting the L (bandlimit) within the class of that code. So you can ignore that and just replace with an L value.

GasperJu commented 2 years ago

Dear @jasonmcewen, can I ask you a technical help here: analysis_axisym_lm_wav returns f_wav of shape (295296, 3) and f_scal of shape (295296,). However, when I successfully used the function you suggested, i.e. analysis_lm2wav with N=1 and spin = 0, we received a f_wav of shape (2377660,) and f_scal of shape (190,). We tried to interpret the shapes of these arrays and we discussed internally with Filipe, however we are having trouble identify how why these shapes are different. Can you confirm to us what file formats are being returned by this function? We did not find this in any documentation and found it hard to see in the code.

GasperJu commented 2 years ago

Dear @jasonmcewen , this is a gentle reminder of my previous message. Thank you again!