galsci / pysm

PySM 3: Sky emission simulations for Cosmic Microwave Background experiments
https://pysm3.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
36 stars 23 forks source link

Final Dust and Synchrotron models w/ Pol. Tens. Small scales #148

Closed giuspugl closed 1 year ago

giuspugl commented 1 year ago

As agreed, i am posting two notebooks encoding a version of models for both dust and synchrotron that have been thoroughly validated. These models employ a unified approach in injecting small angular scales:

employed Validations

Maps w/ small scales

Notebooks

giuspugl commented 1 year ago

Also i've implemented the bug fix as recommended in #147. thanks @YJHelloWorld for catching that!

zonca commented 1 year ago

thanks, for testing purposes, can you please also provide the output templates at 353 GHz? So I can compare the outputs I get with yours. They are going to be different because I need to run at 8192, but at least I can compare the spectra.

giuspugl commented 1 year ago

i've updated the first posting w/ map location as well

zonca commented 1 year ago

ok, I am executing the notebook at 2048 for documentation purposes, comparison of the modulation maps looks good:

https://gist.github.com/e9245bb5170362d01a8fde2f40f5a786

image image

zonca commented 1 year ago

In the notebook the seed was fixed after synalm, so cannot reproduce the same realization, even at 2048. Anyway, the difference in the maps seems compatible with a different realization, it has a noise-like feature, spectra are compatible. See notebook https://gist.github.com/aba4a81fe93a8eb98e8a66e6b4f81b8c

giuspugl commented 1 year ago

In the notebook the seed was fixed after synalm, so cannot reproduce the same realization, even at 2048.

ah sorry about that! If you think is worth to implement this fix can rerun and reproduce the files to compare with.

in the notebook https://gist.github.com/aba4a81fe93a8eb98e8a66e6b4f81b8c, we notice some difference in the modulation maps ( as blobs ), that is totally expected as it might be due to different amplitude in the spectra wrt what i've gotten. Although this doesn't seem to affect neither the small scale maps nor the power spectra, could you check the relative difference between the two modulation maps ?

zonca commented 1 year ago

it is really strange, the first time I ran the notebook, I got the maps at https://github.com/galsci/pysm/issues/148#issuecomment-1423412240, which are very similar to yours, without blobs. Now instead I get the blobs, which while in temperature I could ignore, in polarization a single blob is at the 20% level. Here is the relative difference:

image image

zonca commented 1 year ago

the discrepancy in modulation is fixed. I have not understood the source, possibly activating threading, it seems hardly plausible, I will investigate later.

Now relative difference is at 1e-8:

image image

zonca commented 1 year ago

https://gist.github.com/c3695988a4c99fa185357e7a7a5ed05c

giuspugl commented 1 year ago

Thanks @zonca, i 'd say that a difference of 1e-8 is acceptable, but i leave the other speak. I can't wrap my head around the previous source of discrepancy, though.

zonca commented 1 year ago

@giuspugl I have completed the implementation of the templates.

Now for beta and Td, currently we are adding small scales only outside of the GAL080 mask. However, this technique, that was previously used for the templates, is not used anymore.

So I think the best way to be consistent with the templates is to also apply the "Galactic plane fix" the same way it is done for the templates and add the small scales everywhere else. I will start to implement this, if you have any feedback please let me know asap.

zonca commented 1 year ago

completed the update for dust in #150

yaojian95 commented 1 year ago

Hello, I think the latest implementation of the two pivot scales should be 100 and 2000, right? The numbers in the notebook (see following two places)(https://pysm3.readthedocs.io/en/latest/preprocess-templates/small_scale_dust_pysm3.html) seem to be the old ones.

image image

giuspugl commented 1 year ago

Hello, thanks! @yaojian95 yes the pivotal scales are ell=100 and 2000. Here the documentation didn't get updated! but ell=2000 is actually employed in the notebook.

zonca commented 1 year ago

finalized implementation in #150 and #152