Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # ------------------------------------------------------------------------------
- # Name: Maninder Dhaliwal (1496691)
- # Assignment Four - Fourier Spectrums
- # This takes a data set and trys to clean it using fourier spectrums.
- # ------------------------------------------------------------------------------
- import numpy as np
- import matplotlib.pyplot as plt
- def main():
- Data = np.genfromtxt("362HW4data.csv", delimiter = ",")
- fig = plt.figure()
- ax1 = fig.add_subplot(3, 1, 1)
- ax2 = fig.add_subplot(3, 1, 2)
- ax3 = fig.add_subplot(3, 1, 3)
- GivenDataPlot(Data, ax1)
- FourierAmpSpec(Data, ax2)
- FourierPhaSpec(Data, ax3)
- plt.show()
- return()
- def GivenDataPlot(Input, canvas):
- FRow = Input[:, 0] ; SRow = Input[:, 1]
- canvas.plot(FRow, SRow)
- canvas.set_xlabel("time")
- canvas.set_ylabel("signal")
- canvas.set_title("Funk")
- return()
- def FourierAmpSpec(Input, canvas):
- fA_Data = abs(np.fft.rfftn(Input))
- canvas.plot(fA_Data)
- canvas.set_xlabel("frequency")
- canvas.set_ylabel("power")
- canvas.set_title("Da Noize")
- return()
- def FourierPhaSpec(Input, canvas):
- fP_Data = np.angle((np.fft.rfftn(Input)))
- canvas.plot(fP_Data)
- canvas.set_xlabel("frequency")
- canvas.set_ylabel("phase")
- canvas.set_title("faze")
- return()
- main()
- '''
- Idk what to do with this at this point ... in class Dr. Meldrum told us about
- slicing off the right half of the amplitude spectrum and then using that data
- for a cleaner function ... not sure how to do that whatsoever. My phase graph
- looks like a tide pod and I really have no clue how to fix it. I took the real
- fourier spectrum in 'n' dimensions throughout; a) because it just seems to
- match the data set I have so it didn't matter if I put an 'n' after the 'fft'
- or a '2' b) I did the real fourier transform because we are after a discrete
- fourier series.
- I will comment this all up when I come back to this post Wednesday and clean
- everything up.
- '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement