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

Simulate bandpass mismatch with PySM for numerous arrays #75

Open zonca opened 3 years ago

zonca commented 3 years ago

Current sky models at high resolution are very expensive to run, especially memory-wise.

A complete sky model with CMB, foregrounds and extragalactic can have 8-9 components, each needs to load a number of high resolution maps, generally 2 or 3, but sometimes 5 or 6.

Running PySM on the fly for time domain simulations is very expensive. Some pre-computation is most probably needed. The simplest model would be to only simulate the impact of shifting the center of the bandpass, keeping bandwidth and shape the same for all detectors.

My proposal for this is:

Next level:

zonca commented 3 years ago

@keskitalo based on today's discussion I thought about an approach for simulating bandpass mismatch, do you think this would work?

keskitalo commented 3 years ago

Different spectral indices imply different shifts in central frequency for the same bandpass. I don't see how this model would work for more than one foreground component at the time. And not even then if the component has varying spectral index across the sky.

In the NPIPE analysis we took each foreground component and evaluated the component and its frequency derivative at the nominal center frequency. Then we constructed the bandpassed sky as a sum of the center frequency maps and their derivatives, allowing for different prefactors for each foreground derivative. Perhaps something like this would work?

zonca commented 3 years ago

Different spectral indices imply different shifts in central frequency for the same bandpass. I don't see how this model would work for more than one foreground component at the time. And not even then if the component has varying spectral index across the sky.

I don't follow you here. I am not simulating the sky at the center frequency, I am integrating the whole bandpass just shifted by the center frequency shift. So I capture both the different spectral indices of the components and also if a component has varying spectral index across the sky.

In the NPIPE analysis we took each foreground component and evaluated the component and its frequency derivative at the nominal center frequency. Then we constructed the bandpassed sky as a sum of the center frequency maps and their derivatives, allowing for different prefactors for each foreground derivative. Perhaps something like this would work?

Yes I think this also works, but it is more complicated, how do you properly estimate the derivatives?

keskitalo commented 3 years ago

I must have misunderstood. Yes, if you are convolving the sky model with the shifted bandpasses, that obviously works. The only trouble is that it locks you into a particular shape and mismatch of bandpass.

The NPIPE formalism can accommodate various bandpass shapes. Different shapes map to different prefactors on the derivatives. As for evaluating the derivatives themselves, that just requires two evaluations of the sky model near the nominal center frequency.

zonca commented 3 years ago

Precompute sum of components at delta frequencies

With similar memory usage of the 2 approaches above, we could also precompute the sky emission with all the components summed at 10 or 20 points in frequency (delta-frequency), possibly distributed more densely in the center of the band and more sparsely at the sides. Then integrate the bandpasses with trapz or something similar for each channel. Is discretizing bandpass response in 10 or 20 points enough to capture its impact? I think in any case it would be useful to have some expected bandpasses and some details about their variability across an array, so we could do some tests of these methods.

zonca commented 3 years ago

@smsimon in https://github.com/simonsobs/instrument_model/tree/master/instrument_hardware/modeled_bandpasses we have some expected average bandpasses. Do we have any idea on how do bandpasses vary from detector to detector?

smsimon commented 3 years ago

This depends on each individual fab. Do you want detector to detector on a given wafer or between wafers? The second is usually larger

zonca commented 3 years ago

thanks @smsimon it would be nice to have both, even if they are approximate, they would still help understand how to better do the integration.

smsimon commented 3 years ago

I think we can just assume a ~2% uncertainty for now (there's also systematic effects in measuring the bands, but those are more difficult to parameterize)

jdborrill commented 3 years ago

Assuming that the band doesn't change over the course of the mission, this cost is massively subdominant to the time-domain processing unless we cut the timestream into many small, independent, jobs.

giuspugl commented 2 years ago

Hi all, i've worked on a module to simulate realistic bandpasses with several levels of complexity. You can sample from a top-hat , a top-hat with two apodization profile (e.g. cosine and exponential) and from a Chebyshev polynomial . image Once the sampler of your bandpass is constructed it can easily apply to multiple detector arrays for a given freq. channel , e.g. : image please lemme know if it can be of any use!