Python Forum
Python numpy fft from data file
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')
Reply


Messages In This Thread
Python numpy fft from data file - by magnet1 - Feb-06-2020, 01:37 AM
RE: Python numpy fft from data file - by magnet1 - Feb-06-2020, 07:30 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Numpy] How to store different data type in one numpy array? water 7 527 Mar-26-2024, 02:18 PM
Last Post: snippsat
  Add data to CSV file via Python Anaconda23 0 717 Dec-30-2022, 02:31 AM
Last Post: Anaconda23
  Numpy returns "TypeError: unsupported operand type(s) for *: 'numpy.ufunc' and 'int'" kalle 2 2,594 Jul-19-2022, 06:31 AM
Last Post: paul18fr
  how to handling time series data file with Python? aupres 4 2,976 Aug-10-2020, 12:40 PM
Last Post: MattKahn13
  Corrupted numpy arrays when save to file. DreamingInsanity 2 3,220 Dec-14-2019, 12:12 PM
Last Post: DreamingInsanity
  "erlarge" a numpy-matrix to numpy-array PhysChem 2 2,973 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 10,350 Nov-15-2017, 09:48 PM
Last Post: snippsat
  Problem of getting XLS file data into python klllmmm 3 15,207 Jan-19-2017, 08:59 AM
Last Post: klllmmm

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020