Beispiel #1
0
def demo_fft(sum_waves):
    num_samples, spacing, t = utils.get_wave_timing()

    y_fft = scipy.fftpack.fft(sum_waves)
    # y_fft = None  # test
    x_fft = np.linspace(0.0, 1.0/spacing, num_samples)
    return x_fft, y_fft
Beispiel #2
0
def demo_fft(sum_waves):
    num_samples, spacing, _ = utils.get_wave_timing()

    # TODO create a Fast Fourier Transform of the waveform using scipy.fftpack.fft
    # named 'y_fft'
    y_fft = scipy.fftpack.fft(sum_waves)
    # end TODO

    x_fft = np.linspace(0.0, 1.0 / spacing, num_samples)
    return x_fft, y_fft
Beispiel #3
0
def add_the_waves(freqs):
    """
    create three sinusoidal waves and one wave that is the sum of the three
    :param freqs: [int, int, int]
    :return: [np.array, np.array, np.array, np.array]
        representing wave1, wave2, wave3, sum of waves
        each array contains 500(by default) discrete values for plotting a sinusoidal
    """
    _, _, t = utils.get_wave_timing()
    w1, w2, w3 = utils.make_waves(t, freqs)

    # TODO sum the waves together to form sum_waves
    sum_waves = w1 + w2 + w3
    # end TODO

    return [w1, w2, w3, sum_waves]
Beispiel #4
0
#
#
# plt.show = show
#
# # start of this quiz
import fft_quiz.function as function
import fft_quiz.utils as utils
import fft_quiz.dutils as dutils
# runs when student click "test"
# *****
import matplotlib.pyplot as plt
import numpy as np
import scipy.fftpack

# internal dev only end
num_samples, spacing, t = utils.get_wave_timing()

# test choose_frequencies()
freqs = function.choose_frequencies()
assert None not in freqs, 'choose_frequencies ERROR: Please replace the "None" values with values from 1 to 50.'
assert len(freqs) == 3 and max(freqs) <= 50 and min(
    freqs
) >= 1, 'choose_frequencies ERROR: Expected three in a range between 1 and 50, but the result was {}.'.format(
    freqs)
print('Frequencies look good!')

# test add_the_waves
waves = function.add_the_waves(freqs)
assert waves[
    3] is not None, 'add_the_waves ERROR: Please replace the "None" value with a sum of the waves'
testsum = waves[0] + waves[1] + waves[2]
Beispiel #5
0
def add_the_waves(freqs):
    _, _, t = utils.get_wave_timing()
    w1, w2, w3 = utils.make_waves(t, freqs)
    sum_waves = w1 + w2 + w3
    # sum_waves = None #test
    return [w1, w2, w3, sum_waves]