def _create_controls(self): self._freq_ax = plt.axes([0.2, 0.19, 0.2, 0.03]) self._freq_slider = Slider(self._freq_ax, 'Frequency', 0, self.samplerate / 2.0, valinit = self.frequency) self._freq_slider.on_changed(self.set_signal_frequency) self._ampl_ax = plt.axes([0.2, 0.1, 0.2, 0.03]) self._ampl_slider = Slider(self._ampl_ax, 'Amplitude', -100, 0, valinit = dcv.lin2db(self.amplitude)) self._ampl_slider.on_changed(self.set_signal_amplitude) self._signaltype_ax = plt.axes([0.5, 0.05, 0.15, 0.20]) self._signaltype_radio = RadioButtons(self._signaltype_ax, ('Sine', 'Square', 'Sawtooth', 'Triangle', 'Noise', 'Constant')) self._signaltype_radio.on_clicked(self.set_signal_type) self._windowtype_ax = plt.axes([0.7, 0.05, 0.15, 0.20]) self._windowtype_radio = RadioButtons(self._windowtype_ax, ('Flat', 'Hanning', 'Hamming', 'Blackman')) self._windowtype_radio.on_clicked(self.set_window_type)
def amplitude_response(spec_real, spec_imag, db=True): size = len(spec_real) amp = [0] * size for i in range(0, size): amp[i] = dcx.modulus(spec_real[i], spec_imag[i]) / (size/2) if db: amp[i] = dcv.lin2db(amp[i]) return amp
def test_one(self): self.assertEqual(dc.lin2db(1.0), 0.0)
def test_min_limit(self): self.assertEqual(dc.lin2db(1e-5), -100.0)
def test_minus_inf(self): self.assertEqual(dc.lin2db(1e-10), -100.0)