Demo entry 4069684

python

   

Submitted by anonymous on Mar 16, 2016 at 11:24
Language: Python. Code size: 3.2 kB.

#------------------------Modules needed for the work--------------------------
#This is for dissertation project,here attempting to plot spectrum results
#vs frequency(measure of speed)
from gCR import gC#getcolumn function under the name of gC.py
import numpy as np
import scipy.fftpack
from my_sin import my_sin#sin func that i made maybe wont use it here
import matplotlib.pyplot as plt
from enveloper import getEnvelope#get Envelope from enveloper.py again i made
from scipy.interpolate import spline
from scipy.signal import hilbert, chirp
from scipy.interpolate import UnivariateSpline as uspl
from scipy.interpolate import InterpolatedUnivariateSpline as intuspl
from scipy.signal import savgol_filter as savitzky_golay
import numpy.fft as fft
from pitch import Pitch as ptch
import scipy.fftpack
from wR import wR
#---------------------------Variable and data preparation---------------------
val=0
for i in range(75,81):
    print i
    csvfile="ANTA_%d.csv" % i
    while True:
        
        
        
        try:
            
            stringtime=np.array(gC(csvfile,0,val))#this  get the values as string
            
            time = stringtime.astype(np.float)#get back float from string

            break
            val=0
        except ValueError:
            val+=1
    timeinterval=(time[1]-time[0])#time interval
    sampFreq=1/timeinterval#sample frequency set for oscilloscope
    t=np.linspace(0,len(time)*timeinterval,len(time))#time axis
    while True:
        
        try:
            dbstring=np.array(gC(csvfile,1,val))# and the values for the db
            db=dbstring.astype(np.float)
            break
        except ValueError:
            val+=1
    
    ##env=abs(hilbert(volt))
    ##insphase = np.unwrap(np.angle(env))
    ##insfreq= np.diff(insphase) / (2.0*np.pi) * sampFreq
    #-------------------------------Savitzky and Hilbert--------------------------


    ##yhat = savitzky_golay(volt, 51, 2)# window size 51, polynomial order 3
    ##hil=hilbert(yhat)
    ##abshil=np.abs(yhat)
    ##instantaneous_phase = np.unwrap(np.angle(hil))
    ##instantaneous_frequency = np.diff(instantaneous_phase) / (2.0*np.pi) * sampFreq
    ##
    ##freqsin=(1.5*np.sin(4.1*t+(np.pi)/2)+3.5)
    #------------------------------Fourier transform-------------------------------
    ##N=len(time)
    ##ft=scipy.fftpack.fft(volt)
    ##xf=np.linspace(0.0,1.0/(2.0*timeinterval),N/2)
    ##Y    = np.fft.fft(yhat)
    ##freq = np.fft.fftfreq(len(yhat), t[1] - t[0])
    ##
    ##
    ##plt.plot( freq, np.abs(Y) )
    ##plt.plot(freq, np.angle(Y) )
    ##plt.show()


    #-------------------------------Plotting---------------------------------------
    ##fig=plt.figure()
    ##ax0=fig.add_subplot(211)
    wR('90degangle.csv',10**(db.max()/10)/1000)
    plt.xlim(10.305*10**9,10.329*10**9)
    plt.plot(time, db, label='fft')

    ##ax0.set_xlabel("time in s")
    ##ax1=fig.add_subplot(212)
    ##ax1.plot(t[1:],1.5*abs(instantaneous_frequency))
    ##ax1.plot(t,np.sin((freqsin)*t)+3.5)
    ##ax1.plot(t,abshil, color='red')
plt.savefig('total90.png')
plt.close()

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).