expected[i] = 1.0/_numpy.abs(a) * _numpy.sinc(f/a)
if TEST_PLOTS :
- pylab.figure()
- pylab.subplot(211)
- pylab.plot(_numpy.arange(0, dt*samples, dt), x)
- pylab.title('time series')
- pylab.subplot(212)
- pylab.plot(freq_axis, X.real, 'r.')
- pylab.plot(freq_axis, X.imag, 'g.')
- pylab.plot(freq_axis, expected, 'b-')
- pylab.title('freq series')
+ figure = _pyplot.figure()
+ time_axes = figure.add_subplot(2, 1, 1)
+ time_axes.plot(_numpy.arange(0, dt*samples, dt), x)
+ time_axes.set_title('time series')
+ freq_axes = figure.add_subplot(2, 1, 2)
+ freq_axes.plot(freq_axis, X.real, 'r.')
+ freq_axes.plot(freq_axis, X.imag, 'g.')
+ freq_axes.plot(freq_axis, expected, 'b-')
+ freq_axes.set_title('freq series')
def _test_unitary_rfft_rect_suite() :
print('Test unitary FFTs on variously shaped rectangular functions')
1.0/a, _numpy.pi*f)
if TEST_PLOTS :
- pylab.figure()
- pylab.subplot(211)
- pylab.plot(_numpy.arange(0, dt*samples, dt), x)
- pylab.title('time series')
- pylab.subplot(212)
- pylab.plot(freq_axis, X.real, 'r.')
- pylab.plot(freq_axis, X.imag, 'g.')
- pylab.plot(freq_axis, expected, 'b-')
- pylab.title('freq series')
+ figure = _pyplot.figure()
+ time_axes = figure.add_subplot(2, 1, 1)
+ time_axes.plot(_numpy.arange(0, dt*samples, dt), x)
+ time_axes.set_title('time series')
+ freq_axes = figure.add_subplot(2, 1, 2)
+ freq_axes.plot(freq_axis, X.real, 'r.')
+ freq_axes.plot(freq_axis, X.imag, 'g.')
+ freq_axes.plot(freq_axis, expected, 'b-')
+ freq_axes.set_title('freq series')
def _test_unitary_rfft_gaussian_suite() :
print("Test unitary FFTs on variously shaped gaussian functions")
print('The total power should be {} ({})'.format(Pexp, P))
if TEST_PLOTS :
- pylab.figure()
- pylab.subplot(211)
- pylab.plot(_numpy.arange(0, samples/samp_freq, 1.0/samp_freq), x, 'b-')
- pylab.title('time series')
- pylab.subplot(212)
- pylab.plot(freq_axis, power, 'r.')
- pylab.plot(freq_axis, expected, 'b-')
- pylab.title('{} samples of sin at {} Hz'.format(samples, sin_freq))
+ figure = _pyplot.figure()
+ time_axes = figure.add_subplot(2, 1, 1)
+ time_axes.plot(
+ _numpy.arange(0, samples/samp_freq, 1.0/samp_freq), x, 'b-')
+ time_axes.set_title('time series')
+ freq_axes = figure.add_subplot(2, 1, 2)
+ freq_axes.plot(freq_axis, power, 'r.')
+ freq_axes.plot(freq_axis, expected, 'b-')
+ freq_axes.set_title(
+ '{} samples of sin at {} Hz'.format(samples, sin_freq))
def _test_unitary_power_spectrum_sin_suite() :
print('Test unitary power spectrums on variously shaped sin functions')
expected_amp, power[0]))
if TEST_PLOTS :
- pylab.figure()
- pylab.subplot(211)
- pylab.plot(_numpy.arange(0, samples/samp_freq, 1.0/samp_freq), x, 'b-')
- pylab.title('time series')
- pylab.subplot(212)
- pylab.plot(freq_axis, power, 'r.')
- pylab.plot(freq_axis, expected, 'b-')
- pylab.title('{} samples of delta amp {}'.format(samples, amp))
+ figure = _pyplot.figure()
+ time_axes = figure.add_subplot(2, 1, 1)
+ time_axes.plot(
+ _numpy.arange(0, samples/samp_freq, 1.0/samp_freq), x, 'b-')
+ time_axes.set_title('time series')
+ freq_axes = figure.add_subplot(2, 1, 2)
+ freq_axes.plot(freq_axis, power, 'r.')
+ freq_axes.plot(freq_axis, expected, 'b-')
+ freq_axes.set_title('{} samples of delta amp {}'.format(samples, amp))
def _test_unitary_power_spectrum_delta_suite() :
print('Test unitary power spectrums on various delta functions')
expected[0], power[0]))
if TEST_PLOTS :
- pylab.figure()
- pylab.subplot(211)
- pylab.plot(_numpy.arange(0, samples/samp_freq, 1.0/samp_freq), x, 'b-')
- pylab.title('time series')
- pylab.subplot(212)
- pylab.plot(freq_axis, power, 'r.')
- pylab.plot(freq_axis, expected, 'b-')
- pylab.title('freq series')
+ figure = _pyplot.figure()
+ time_axes = figure.add_subplot(2, 1, 1)
+ time_axes.plot(
+ _numpy.arange(0, samples/samp_freq, 1.0/samp_freq), x, 'b-')
+ time_axes.set_title('time series')
+ freq_axes = figure.add_subplot(2, 1, 2)
+ freq_axes.plot(freq_axis, power, 'r.')
+ freq_axes.plot(freq_axis, expected, 'b-')
+ freq_axes.set_title('freq series')
def _test_unitary_power_spectrum_gaussian_suite() :
print('Test unitary power spectrums on various gaussian functions')
print('The total power should be {} ({})'.format(Pexp, P))
if TEST_PLOTS :
- pylab.figure()
- pylab.subplot(211)
- pylab.plot(_numpy.arange(0, samples/samp_freq, 1.0/samp_freq), x, 'b-')
- pylab.title('time series')
- pylab.subplot(212)
- pylab.plot(freq_axis, power, 'r.')
- pylab.plot(freq_axis, expected, 'b-')
- pylab.title('{} samples of sin at {} Hz'.format(samples, sin_freq))
+ figure = _pyplot.figure()
+ time_axes = figure.add_subplot(2, 1, 1)
+ time_axes.plot(
+ _numpy.arange(0, samples/samp_freq, 1.0/samp_freq), x, 'b-')
+ time_axes.set_title('time series')
+ freq_axes = figure.add_subplot(2, 1, 2)
+ freq_axes.plot(freq_axis, power, 'r.')
+ freq_axes.plot(freq_axis, expected, 'b-')
+ freq_axes.set_title(
+ '{} samples of sin at {} Hz'.format(samples, sin_freq))
def _test_unitary_avg_power_spectrum_sin_suite() :
print('Test unitary avg power spectrums on variously shaped sin functions')
options,args = p.parse_args()
if options.plot:
- import pylab
+ import matplotlib.pyplot as _pyplot
TEST_PLOTS = True
test()
if options.plot:
- pylab.show()
+ _pyplot.show()