def demodulate(self, data, tone_bin, tone_num_samples, tone_phase, fft_bin, nchan, seq_nos=None): phi0 = tone_phase nfft = self.nfft ns = tone_num_samples offset_frequency = tone_offset_frequency(tone_bin, tone_num_samples, fft_bin, nfft) wc = self.compute_pfb_response(offset_frequency) t = np.arange(data.shape[0]) demod = wc * np.exp(-1j * (2 * np.pi * offset_frequency * t + phi0)) * data if type(seq_nos) is np.ndarray: pphase = np.exp(1j * packet_phase(seq_nos[0], offset_frequency, nchan, ns / nfft, nfft)) demod *= pphase if self.hardware_delay_samples != 0: demod *= np.exp(2j * np.pi * self.hardware_delay_samples * tone_bin / tone_num_samples) return demod
def create_demodulation_waveform(self, data_shape, seq_nos): # Handles dropped packets if they are included as NaNs. # If do not want to use NaNs then need to calculate phase from seq_nos... pphase = np.exp(1j * packet_phase(seq_nos[0], self.offset_frequencies, self.num_channels, self.tone_nsamp // self.nfft, self.nfft)) hardware_delay = -self.hardware_delay_samples * self.tone_bins / float(self.tone_nsamp) t = np.arange(data_shape[0]) # wave_period) wave = (self.pfb_response_correction * np.exp(-1j * (2 * np.pi * (np.outer(t, self.offset_frequencies) + hardware_delay) + self.phases)) * pphase) # wave_mat = np.lib.stride_tricks.as_strided(wave, shape=data_shape, strides=(0,wave.strides[1])) wave_mat = wave return wave_mat
def create_demodulation_waveform(self, data_shape, seq_nos): # Handles dropped packets if they are included as NaNs. # If do not want to use NaNs then need to calculate phase from seq_nos... pphase = np.exp(1j * packet_phase( seq_nos[0], self.offset_frequencies, self.num_channels, self.tone_nsamp // self.nfft, self.nfft)) hardware_delay = -self.hardware_delay_samples * self.tone_bins / float( self.tone_nsamp) t = np.arange(data_shape[0]) # wave_period) wave = (self.pfb_response_correction * np.exp( -1j * (2 * np.pi * (np.outer(t, self.offset_frequencies) + hardware_delay) + self.phases)) * pphase) # wave_mat = np.lib.stride_tricks.as_strided(wave, shape=data_shape, strides=(0,wave.strides[1])) wave_mat = wave return wave_mat