def apply(self, tod): nmat.apply_window(tod, self.window) ft = fft.rfft(tod) self.nmat.apply_ft(ft, tod.shape[-1], tod.dtype) if self.filter is not None: ft *= self.filter fft.irfft(ft, tod, flags=['FFTW_ESTIMATE','FFTW_DESTROY_INPUT']) nmat.apply_window(tod, self.window) return tod
def calibrate_dark_fourier(data): """Fourier deconvolution of dark detectors. Can't do this completely, as we don't have time constants.""" require(data, ["dark_tod", "srate"]) if data.dark_tod.size == 0: return data ft = fft.rfft(data.dark_tod) freqs = np.linspace(0, data.srate/2, ft.shape[-1]) butter = filters.butterworth_filter(freqs) ft /= butter[None] fft.irfft(ft, data.dark_tod, normalize=True) return data
def calibrate_tod_fourier(data): """Deconvolve instrument filters and time constants from TOD""" require(data, ["tod", "tau", "srate", "speed", "mce_params"]) if data.tod.size == 0: return data ft = fft.rfft(data.tod) freqs = np.linspace(0, data.srate/2, ft.shape[-1]) # Deconvolve the butterworth filter butter = filters.mce_filter(freqs, data.mce_fsamp, data.mce_params) ft /= butter # And the time constants for di in range(len(ft)): ft[di] /= filters.tconst_filter(freqs, data.tau[di]) ## Optinally apply the beam aspect ratio correction #hbeam, vbeam = np.array(map(float,config.get("fix_beam_aspect").split(":")))*utils.arcmin*utils.fwhm #if vbeam != hbeam: # el = np.mean(data.boresight[2,::100]) # k = 2*np.pi*freqs # skyspeed = data.speed * np.cos(el) # tsigma = (vbeam**2-hbeam**2)**0.5/skyspeed # ft *= np.exp(-0.5*tsigma**2*k**2) fft.irfft(ft, data.tod, normalize=True) #np.savetxt("test_enki1/tod_detau.txt", data.tod[0]) del ft return data