ACTCollaboration / actsims

Simulations of the microwave sky as seen by ACT and Planck.
9 stars 4 forks source link

Apply a small apodization window when applying pixel window function #37

Open dwhan89 opened 5 years ago

dwhan89 commented 5 years ago

The issue was brought up by Mat. Should be a very tiny correction to signal simulations.

    def __signal_postprocessing__(self, patch, signal_idx, alm_patch, save_map, oshape, owcs, apply_window=True):
        signal = self.get_template(patch,shape=oshape,wcs=owcs)
        signal = signal if len(alm_patch.shape) > 1 else signal[0,...]
        curvedsky.alm2map(alm_patch, signal, spin = [0,2], verbose=True)

        if apply_window:
            print('apply window')
            axes = [-2, -1]
            for idx in range(signal.shape[0]):
                kmap   = pfft.fft(signal[idx], axes=axes)
                wy, wx = enmap.calc_window(kmap.shape)
                wind   = wy[:,None]**1 * wx[None,:]**1
                kmap   *= wind

                signal[idx] = (pfft.ifft(kmap, axes=axes, normalize=True)).real
                del kmap

        if save_map: 
            self.signals[signal_idx] = signal.copy()
            self.manage_cache(self.signals, self.max_cached)
        return signal