litebird / litebirdXS4

1 stars 6 forks source link

Change CMB-S4 LAT map default NSIDE to 2048 #13

Closed 1cosmologist closed 4 months ago

1cosmologist commented 8 months ago

Currently maps.get_s4_map fetches CMB-S4 LAT CMB-only maps at NSIDE=4096. The noise maps are at NSIDE=2048, while the lensed CMB is computed till lmax=4096. So we do not need to fetch the CMB-only LAT maps at NSIDE=4096 and increase compute time for each iteration to produce coadded maps. Can we switch to a default of NSIDE=2048 for the LATs?

zonca commented 8 months ago

@carronj what do you think? As we are discussing this, why don't we generate the noise maps on the fly?

carronj commented 8 months ago

The nside of the CMB maps now comes as given from the s4 instrument model. But there is no problem at all to adapt the code to request any different nside and I can do that soon. For some unclear reason I did not do that for the noise maps. Yes in principle could be built on the fly. I guess I will sweat a lot handling the generator state because of potential issues with reproducibilty , but you probably point me to a super safe way to do that ? If so, I could produce as default to 4096 (not clear we will ever need that) as specified and ud_grade to anything else.

1cosmologist commented 8 months ago

@carronj If our lensed CMB has lmax of 4096, I do not think if need to go higher than NSIDE=2048.

Correct me if I am wrong but the random numbers for chwide noise maps are being seeded by SeedSequence state entropy and not seeded from a key. Since the different frequency bands share the same rng, the order in which the maps are generated would matter. For on-the-fly noise generation, the order in which maps are queried would matter. I usually spawn child sequences one for each frequency to avoid this. The lmax or npix change can also change the results.

carronj commented 8 months ago

Let's keep nside 2048 then. I cant see the need for higher as of now since this should easily capture all the lensing signal.

Looks like to me that if we want the user to be able to ask for any sim we must set the seed for each and every sim beforehand in a deterministic fashion ?

1cosmologist commented 8 months ago

Or we need a deterministic way of producing the seeds for each sim for each channel. If we constrain ourselves to only generate sims starting from Monte Carlo index 0 and not query a particular mc index, we can spawn child streams from one initial seed passed to SeedSequence.

There is no well defined prescription to incorporate the MC index other than say adding the MC index to the child seed sequence. JAX random has a method to do this deterministically (jax.random.fold_in). But numpy random doesn't seem to have any such feature.

zonca commented 4 months ago

@carronj @1cosmologist what happened with this issue?

1cosmologist commented 4 months ago

The original issue of having maps at NISDE=2048 has been fixed. But the question that @carronj asked in https://github.com/litebird/litebirdXS4/issues/13#issuecomment-1969834156 has not been resolved, I think.

zonca commented 4 months ago

Okay, if either of you thinks that the question is still relevant, please open a separate issue

going to close this one