forked from P-Rey/pysnid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnew_corr.py
36 lines (27 loc) · 871 Bytes
/
new_corr.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# -*- coding: utf-8 -*-
"""
Created on Mon May 28 11:33:55 2018
@author: Peter
"""
import numpy as np
from preprocessing import Hann
def DFT(ProcessedSig):
import scipy.fftpack as fft
dft=fft.fft(ProcessedSig)
for i in range(50,len(dft)):
dft[i]=0
sigma_squared= np.sqrt((1/len(dft))*np.sum((dft)**2))
return dft, sigma_squared
def Correlate(dftdata,dfttemp,sigma,sigmatemp):
dftdata=dftdata
dfttemp=dfttemp
Nd = int(len(dftdata))
Init_Correlate = dftdata[:int(len(dfttemp))]*np.conj(dfttemp)
import scipy.fftpack as fft
Trans_Corr=fft.ifft(Init_Correlate )
percent= 0.50
hanned_corr = Hann(Trans_Corr,percent)
rmsInput = np.std(dftdata)
rmsTemp = np.std(dfttemp)
hanned_corr= (1. / Nd * rmsInput * rmsTemp) * hanned_corr
return hanned_corr