コード例 #1
0
    def setUp(self):
        """Create a time-domain signal comprised of two frequencies.
        """
        # Setup a 11kHz 1V signal in time domain
        # Signals are sampled at 96 kHz (common for LX-10) for 10 seconds
        sampling_rate = 96000
        num_samples = 960000
        time_array = (1.0 / sampling_rate) * np.arange(num_samples)
        signal_1_frequency = 11000
        self.signal_1_amplitude = 1
        signal_1 = self.signal_1_amplitude * np.sin(
            2 * np.pi * signal_1_frequency * time_array)
        test_signal = signal_1

        # Setup variables needed for the STFT
        frame_size_sec = 1
        hop_size_sec = 0.5
        use_hamming_window = False
        self.data_stft, self.time_array_stft, self.freq_array_stft, \
            freq_bin_size = \
            siganalysis.stft(test_signal,
                             sampling_rate,
                             frame_size_sec,
                             hop_size_sec,
                             use_hamming_window)
コード例 #2
0
 def test_stft_freq_bin_size(self):
     data_stft, time_array_stft, freq_array_stft, freq_bin_size = \
         siganalysis.stft(self.test_signal,
                          self.sampling_rate,
                          self.frame_size_sec,
                          self.hop_size_sec,
                          self.use_hamming_window)
     self.assertEqual(freq_bin_size, 1 / self.frame_size_sec)
コード例 #3
0
 def test_stft_another_freq_bin_size(self):
     frame_size_sec = 0.5
     correct_freq_per_bin = 1 / frame_size_sec
     data_stft, time_array_stft, freq_array_stft, freq_bin_size = \
         siganalysis.stft(self.test_signal,
                          self.sampling_rate,
                          frame_size_sec,
                          self.hop_size_sec,
                          self.use_hamming_window)
     self.assertEqual(freq_bin_size, correct_freq_per_bin)
コード例 #4
0
 def test_stft_shape_size(self):
     data_stft, time_array_stft, freq_array_stft, freq_bin_size = \
         siganalysis.stft(self.test_signal,
                          self.sampling_rate,
                          self.frame_size_sec,
                          self.hop_size_sec,
                          self.use_hamming_window)
     known_freq_size = int(self.frame_size_sec * self.sampling_rate / 2)
     self.assertEqual(data_stft.shape[1], known_freq_size)
     self.assertEqual(data_stft.shape[1], freq_array_stft.size)
     self.assertEqual(data_stft.shape[0], time_array_stft.size)