def test_spectrum(random_samples):
    from wwb_scanner.scan_objects import Spectrum

    rs = 2.048e6
    fc = 600e6

    spectrum = Spectrum()
    freqs, sig, ff = random_samples(rs=rs, fc=fc)

    for freq, val in zip(freqs, ff):
        spectrum.add_sample(frequency=freq, iq=val)

    assert np.array_equal(spectrum.sample_data['frequency'], freqs)
    assert np.array_equal(spectrum.sample_data['iq'], ff)
    assert np.array_equal(spectrum.sample_data['magnitude'], np.abs(ff))
    assert np.array_equal(spectrum.sample_data['dbFS'], 10 * np.log10(np.abs(ff)))
def test_spectrum(random_samples):
    from wwb_scanner.scan_objects import Spectrum

    rs = 2.048e6
    fc = 600e6

    spectrum = Spectrum()
    freqs, sig, ff = random_samples(rs=rs, fc=fc)

    for freq, val in zip(freqs, ff):
        spectrum.add_sample(frequency=freq, iq=val)

    assert np.array_equal(spectrum.sample_data['frequency'], freqs)
    assert np.array_equal(spectrum.sample_data['iq'], ff)
    assert np.array_equal(spectrum.sample_data['magnitude'], np.abs(ff))
    assert np.array_equal(spectrum.sample_data['dbFS'], 10 * np.log10(np.abs(ff)))
Ejemplo n.º 3
0
 def on_sweep_processed(self, **kwargs):
     freqs = kwargs.get('frequencies')
     powers = kwargs.get('powers')
     fc = kwargs.get('sample_set').center_frequency / 1e6
     fc = float(fc)
     spectrum = self.current_spectrum
     new_spectrum = False
     if spectrum is None or fc != self.scan_controls.current_freq:
         spectrum = Spectrum()
         new_spectrum = True
     try:
         self.scan_controls.current_freq = fc
     except:
         print type(fc), repr(fc)
         self.cancel_scan()
         raise
     for f, val in zip(freqs, powers):
         spectrum.add_sample(frequency=f, dbFS=val, force_magnitude=True)
     if new_spectrum:
         self.current_spectrum = spectrum
     elif self.scan_controls.live_view_visible:
         sg = self.scan_controls.live_spectrum_graph
         plot = sg.spectrum_plot_container.children[0]
         plot.update_data()