Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Python numpy fft from data file
#1
Hello,
I'm new to Python and I'm not sure. trying to do a python fft with a data file.

It cans plot the data file in the time domain like the code above. set a start time and end time in data.trim to display a plot.

Error in numpy's fft function.

No friendly explanation found on Google or on any site, Noted similar code but got many errors.

Is code simple and is there a simple workaround?

data file type is miniseed(mseed) file.

from obspy import read, UTCDateTime
from numpy as np

def check_file(fname) :

    print("Check : ", fname)

    data = read(fname)
    myS = UTCDateTime("2020-01-06T00:30:00")
    myE = myS + 120
    data.trim(myS, myE)

    ### time domain plot
    data.plot()


    ### test1. frequency domain plot. It is error
    #y = np.fft(data)
    #y.plot()

    ### test2. frequency domain plot. error 2
    #fftdata = np.fft.fft(data)
    #frequ = np.fft.fftfreq(len(fftdata))
    #plt.plot(frequ,fftdata)
    #plt.show()


check_file('data file')
Quote
#2
(Feb-06-2020, 01:37 AM)magnet1 Wrote: Hello,
I'm new to Python and I'm not sure. trying to do a python fft with a data file.

It cans plot the data file in the time domain like the code above. set a start time and end time in data.trim to display a plot.

Error in numpy's fft function.

No friendly explanation found on Google or on any site, Noted similar code but got many errors.

Is code simple and is there a simple workaround?



from obspy import read, UTCDateTime
from numpy as np

def check_file(fname) :

    print("Check : ", fname)

    data = read(fname)
    myS = UTCDateTime("2020-01-06T00:30:00")
    myE = myS + 120
    data.trim(myS, myE)

    ### time domain plot
    data.plot()


    ### test1. frequency domain plot. It is error
    #y = np.fft(data)
    #y.plot()

    ### test2. frequency domain plot. error 2
    #fftdata = np.fft.fft(data)
    #frequ = np.fft.fftfreq(len(fftdata))
    #plt.plot(frequ,fftdata)
    #plt.show()


check_file('data file')
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  how to handling time series data file with Python? aupres 4 338 Aug-10-2020, 12:40 PM
Last Post: MattKahn13
  Adding data in 3D array from 2D numpy array asmasattar 0 321 Jul-23-2020, 10:55 AM
Last Post: asmasattar
  Corrupted numpy arrays when save to file. DreamingInsanity 2 635 Dec-14-2019, 12:12 PM
Last Post: DreamingInsanity
  numpy.copy / numpy.delete paul18fr 3 791 Jul-26-2019, 01:51 PM
Last Post: paul18fr
  "erlarge" a numpy-matrix to numpy-array PhysChem 2 823 Apr-09-2019, 04:54 PM
Last Post: PhysChem
  Extract data between two dates from a .csv file using Python 2.7 sujai_banerji 1 6,461 Nov-15-2017, 09:48 PM
Last Post: snippsat
  Problem of getting XLS file data into python klllmmm 3 10,786 Jan-19-2017, 08:59 AM
Last Post: klllmmm

Forum Jump:


Users browsing this thread: 1 Guest(s)