In [13]:
import numpy
import tensorflow as tf
import pylab

maxFreq = 120
minFreq = 80

tFft = 8192
stepFreq = 1/tFft
nFreqs = numpy.int((maxFreq-minFreq)/stepFreq)

sessione = tf.Session()

detector1 = tf.random_normal([nFreqs], dtype=tf.float32)

detector2 = tf.random_normal([nFreqs], dtype=tf.float32)

spettroProdTF = tf.constant(spettroProd,dtype=tf.float32)

frequenze = tf.range(minFreq,maxFreq, delta = stepFreq)

alpha = tf.range(-4,4, delta = 0.1)
nAlphas = tf.size(alpha)
alpha = tf.reshape(alpha, shape=[nAlphas,1] )
alpha = 0

spettroSegnale = tf.pow(frequenze, alpha-3)

#detector1 = detector1+spettroSegnale*10
#detector2 = detector2+spettroSegnale*10
#detector1NP = sessione.run(detector1)
#detector2NP = sessione.run(detector2)

funzione = spettroSegnale/(spettroProdTF)
funzNP = sessione.run(funzione)


prodotto = detector2*funzione

estimatoreSum = detector1*prodotto
#righe = tf.shape(inputConv)[0]
#colonne = tf.shape(inputConv)[1]

inputConv = prodotto
inputConv = tf.reshape(inputConv,(1,1,nFreqs,1))

kernel = tf.reshape(detector1, (1,nFreqs,1,1))
#kernel = tf.reshape(detector1, (tf.size(detector1),1,1,1))


estimatore = tf.nn.convolution(inputConv,kernel, padding = 'VALID')
#swipe = [0,0,0,0]
#estimatore = tf.nn.conv2d(inputConv,kernel,strides=swipe, padding = 'SAME') 

#inputConv = tf.reshape(detector1,(1,101,1))
#kernel = tf.reshape(detector2, (101,1,1))

#crosscorr = tf.nn.conv1d(inputConv,kernel,stride = 1,padding='VALID')/101

#cross = sessione.run(crosscorr)
print(estimatoreNP, autoestimatoreNP)
#inputConv = prodotto

#inputConv = tf.reshape(inputConv,(1,nFreqs,nAlphas,1))

#kernel = tf.reshape(detector1, (nFreqs,1,1,1))

#estimatore = tf.nn.convolution(inputConv,kernel, padding = 'VALID')
#estimatoreMulti = sessione.run(estimatore)
#print(estimatoreMulti.shape)
#alphaNP = numpy.arange(-4,4, 0.1)
freqNP = numpy.arange(80,120, 1/8192)
##estimatoreMulti = numpy.zeros(alphaNP.size)
##for i in numpy.arange(alphaNP.size-1):
	
	##inputConv = prodotto[0]

	##inputConv = tf.reshape(inputConv,(1,1,nFreqs,1))
	
	##estimatore = tf.nn.convolution(inputConv,kernel, padding = 'VALID')
 

	###start = time.time()
	##estimatoreMulti[i] = sessione.run(estimatore)
	###stop = time.time()
	###print(stop-start)


#spettroSegnale = sessione.run(spettroSegnale)
##%matplotlib notebook
#a = pyplot.scatter(alphaNP,estimatoreMulti, s = 5)

#pyplot.show()

 


%time estimatore = sessione.run(estimatore)
%time estimatoreSum = sessione.run(estimatoreSum)


CPU times: user 76 ms, sys: 0 ns, total: 76 ms
Wall time: 17.1 ms
CPU times: user 68 ms, sys: 0 ns, total: 68 ms
Wall time: 13.2 ms

In [14]:
print(estimatore)


[[[[ 0.0026062]]]]

In [40]:
%matplotlib notebook
pylab.plot(freqNP, funzNP)
#pylab.plot(L, 1e-8*F*L/c)
#pylab.tight_layout()
#pylab.loglog()
pylab.show()



In [24]:
vettore1 = tf.constant([1,2,3,4])
vettore2 = tf.constant([[2],[2],[2]])

matrice = tf.multiply(vettore1,vettore2)
print(sessione.run(matrice))


[[2 4 6 8]
 [2 4 6 8]
 [2 4 6 8]]

In [6]:
import numpy
han = numpy.loadtxt('/home/protoss/Documenti/TESI/DATI/strainsensib/2016-12-08_C01_H1_O2_Sensitivity_strain_asd.txt')
liv = numpy.loadtxt('/home/protoss/Documenti/TESI/DATI/strainsensib/2017-07-20_C01_L1_O2_Sensitivity_strain_asd.txt')

maxFreq = 120
minFreq = 80

tFft = 8192
stepFreq = 1/tFft
nFreqs = numpy.int((maxFreq-minFreq)/stepFreq)

filtrohan = numpy.where(han[:,0] > 80)
filtroliv = numpy.where(liv[:,0] > 80)
hansel = han[filtrohan]
livsel = liv[filtroliv]
filtrohan = numpy.where(hansel[:,0] < 120)
filtroliv = numpy.where(livsel[:,0] < 120)
hansel = hansel[filtrohan]
livsel = livsel[filtroliv]


spettroCoord = hansel[:,0]
spettroHan = hansel[:,1]
spettroLiv = livsel[:,1]


spettroHanExp = numpy.zeros(nFreqs)
spettroLivExp = numpy.zeros(nFreqs)
freqNP = numpy.arange(minFreq,maxFreq,stepFreq)
print(freqNP,spettroCoord.size)

filtro = numpy.where(freqNP<=spettroCoord[0])[0]
fine = filtro[filtro.size-1]
spettroHanExp[:fine] = spettroHan[0]
spettroLivExp[:fine] = spettroLiv[0]

for i in numpy.arange(spettroCoord.size-1):
    filtro1 = numpy.where(freqNP<=spettroCoord[i+1])[0]
    filtro2 = numpy.where(freqNP>spettroCoord[i])[0]
    
    inizio = filtro2[0]-1
    fine = filtro1[filtro1.size-1]
    #print(inizio,fine)
    spettroHanExp[inizio:fine] = spettroHan[i]
    spettroLivExp[inizio:fine] = spettroLiv[i]

filtro = numpy.where(freqNP>spettroCoord[-1])[0]
inizio = filtro[0]-1
spettroHanExp[inizio:] = spettroHan[-1]
spettroLivExp[inizio:] = spettroLiv[-1]
    
    
print(spettroHanExp, spettroLivExp)
spettroHanExp = spettroHanExp*1e23
spettroLivExp = spettroLivExp*1e23
print(spettroHanExp, spettroLivExp)
spettroProd = numpy.multiply(spettroHanExp,spettroLivExp)
print(spettroProd)


[  80.           80.00012207   80.00024414 ...,  119.99963379  119.99975586
  119.99987793] 319
[  1.04659180e-23   1.04659180e-23   1.04659180e-23 ...,   2.01345760e-23
   2.01345760e-23   2.01345760e-23] [  6.90864030e-24   6.90864030e-24   6.90864030e-24 ...,   1.02685990e-23
   1.02685990e-23   1.02685990e-23]
[ 1.0465918  1.0465918  1.0465918 ...,  2.0134576  2.0134576  2.0134576] [ 0.69086403  0.69086403  0.69086403 ...,  1.0268599   1.0268599   1.0268599 ]
[ 0.72305263  0.72305263  0.72305263 ...,  2.06753887  2.06753887
  2.06753887]

In [7]:
import numpy
import pylab
han = numpy.loadtxt('/home/protoss/Documenti/TESI/DATI/strainsensib/2016-12-08_C01_H1_O2_Sensitivity_strain_asd.txt')
liv = numpy.loadtxt('/home/protoss/Documenti/TESI/DATI/strainsensib/2017-07-20_C01_L1_O2_Sensitivity_strain_asd.txt')

%matplotlib qt
pylab.figure(figsize=(10,7.5))
pylab.loglog()
pylab.plot(han[:,0],han[:,1],label = "LIGO H",linewidth=1.0)
pylab.plot(liv[:,0],liv[:,1],label = "LIGO L",linewidth=1.0)
pylab.xlabel('Frequencies ($Hz$)')
pylab.ylabel('Strain amplitude ($1/\sqrt{Hz}$)')
pylab.title('Noise spectral amplitude')
pylab.legend()


Out[7]:
<matplotlib.legend.Legend at 0x7f2958ed7a58>

In [19]:
from matplotlib import pyplot
%matplotlib notebook
pyplot.figure(figsize=(10, 8))

#pyplot.loglog()

a = pyplot.scatter(freqNP,spettroHanExp, s = 0.5)
a = pyplot.scatter(freqNP,spettroLivExp, s = 0.5)
a = pyplot.scatter(freqNP,spettroProd, s = 0.5)



In [41]:
from matplotlib import pyplot
%matplotlib notebook
pyplot.figure(figsize=(10, 8))

pyplot.loglog()

a = pyplot.scatter(han[:,0],han[:,1], s = 0.5)
b = pyplot.scatter(liv[:,0],liv[:,1], s = 0.5)



In [45]:


In [62]:
print(livsel[:,0]- hansel[:,0])


[ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.
  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.
  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.
  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.
  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.
  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.
  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.
  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.
  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.
  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.
  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.
  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.
  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.
  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.
  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.
  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.
  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.
  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.]

In [90]:
from matplotlib import pyplot
%matplotlib notebook
pyplot.figure(figsize=(10, 8))

pyplot.loglog()

a = pyplot.scatter(hansel[:,0],hansel[:,1], s = 0.5)
b = pyplot.scatter(livsel[:,0],livsel[:,1], s = 0.5)



In [ ]:


In [47]:
import numpy
import tensorflow as tf
from matplotlib import pyplot
import time

maxFreq = 120
minFreq = 80

tFft = 8192
stepFreq = 1/tFft
nFreqs = numpy.int((maxFreq-minFreq)/stepFreq)


sessione = tf.Session()

detector1 = tf.random_normal([nFreqs], dtype=tf.float32)

detector2 = tf.random_normal([nFreqs], dtype=tf.float32)

#spettroProdTF = tf.constant(spettroProd,dtype=tf.float32)

frequenze = tf.range(minFreq,maxFreq, delta = stepFreq)

alpha = tf.range(0,3, delta = 0.01)
nAlphas = tf.size(alpha)
alpha = tf.reshape(alpha, shape=[nAlphas,1] )

espansoreFreq = tf.ones([nAlphas,1])
espansoreAlpha = tf.ones([1,nFreqs])

freqExp = tf.multiply(frequenze,espansoreFreq)
alphExp = tf.multiply(espansoreAlpha,alpha)

spettroSegnale = tf.pow(freqExp, alphExp-3)

#detector2 = detector2/spettroProdTF

prodotto = detector2*spettroSegnale

inputConv = prodotto#[0]

inputConv = tf.reshape(inputConv,(1,nAlphas,nFreqs,1))

kernel = tf.reshape(detector1, (1,nFreqs,1,1))

estimatore = tf.nn.convolution(inputConv,kernel, padding = 'VALID')
 

start = time.time()
estimatoreMulti = sessione.run(estimatore)
stop = time.time()
print(stop-start)

print(estimatoreMulti[0,:,0,0])

alphaNP = numpy.arange(0,3, 0.01)
%matplotlib notebook
#pyplot.loglog()
a = pyplot.scatter(alphaNP,estimatoreMulti[0,:,0,0], s = 5)
pyplot.show()


8.832739114761353
[  4.56042733e-04   4.77102818e-04   4.99134825e-04   5.22186048e-04
   5.46301715e-04   5.71530894e-04   5.97926497e-04   6.25540502e-04
   6.54430012e-04   6.84655271e-04   7.16276641e-04   7.49357394e-04
   7.83966854e-04   8.20175803e-04   8.58059269e-04   8.97690770e-04
   9.39153368e-04   9.82531579e-04   1.02791411e-03   1.07539457e-03
   1.12506526e-03   1.17703562e-03   1.23140402e-03   1.28828490e-03
   1.34779315e-03   1.41005102e-03   1.47518574e-03   1.54333015e-03
   1.61462394e-03   1.68921216e-03   1.76724605e-03   1.84888346e-03
   1.93429971e-03   2.02365406e-03   2.11714394e-03   2.21495377e-03
   2.31728191e-03   2.42433604e-03   2.53634225e-03   2.65352195e-03
   2.77610915e-03   2.90437345e-03   3.03856051e-03   3.17894481e-03
   3.32582067e-03   3.47948377e-03   3.64025100e-03   3.80844786e-03
   3.98441311e-03   4.16851230e-03   4.36111912e-03   4.56263404e-03
   4.77346359e-03   4.99401754e-03   5.22478810e-03   5.46621624e-03
   5.71879884e-03   5.98306302e-03   6.25952985e-03   6.54878467e-03
   6.85141282e-03   7.16803735e-03   7.49926455e-03   7.84583762e-03
   8.20841733e-03   8.58773664e-03   8.98461137e-03   9.39982384e-03
   9.83424392e-03   1.02887293e-02   1.07642291e-02   1.12617025e-02
   1.17821814e-02   1.23267155e-02   1.28964167e-02   1.34924771e-02
   1.41160954e-02   1.47685250e-02   1.54511193e-02   1.61652397e-02
   1.69124231e-02   1.76941231e-02   1.85119677e-02   1.93676129e-02
   2.02628355e-02   2.11994573e-02   2.21793838e-02   2.32045613e-02
   2.42772251e-02   2.53993757e-02   2.65735034e-02   2.78018918e-02
   2.90870853e-02   3.04316860e-02   3.18383910e-02   3.33102457e-02
   3.48501354e-02   3.64612304e-02   3.81467678e-02   3.99102867e-02
   4.17553075e-02   4.36857492e-02   4.57053520e-02   4.78183739e-02
   5.00291660e-02   5.23420572e-02   5.47620356e-02   5.72938584e-02
   5.99427931e-02   6.27142191e-02   6.56137541e-02   6.86473325e-02
   7.18214586e-02   7.51421824e-02   7.86163583e-02   8.22514370e-02
   8.60545412e-02   9.00334790e-02   9.41965580e-02   9.85521674e-02
   1.03109099e-01   1.07876763e-01   1.12865180e-01   1.18084028e-01
   1.23544432e-01   1.29257187e-01   1.35234565e-01   1.41488150e-01
   1.48030773e-01   1.54876515e-01   1.62038565e-01   1.69531837e-01
   1.77371785e-01   1.85574606e-01   1.94156542e-01   2.03135625e-01
   2.12529927e-01   2.22358793e-01   2.32642725e-01   2.43401691e-01
   2.54658908e-01   2.66436607e-01   2.78758913e-01   2.91651636e-01
   3.05140316e-01   3.19253385e-01   3.34019572e-01   3.49468291e-01
   3.65632296e-01   3.82543325e-01   4.00237024e-01   4.18749541e-01
   4.38118279e-01   4.58383203e-01   4.79586244e-01   5.01768351e-01
   5.24978876e-01   5.49262345e-01   5.74669361e-01   6.01251960e-01
   6.29063070e-01   6.58162355e-01   6.88608944e-01   7.20463574e-01
   7.53790796e-01   7.88661242e-01   8.25144470e-01   8.63314807e-01
   9.03253138e-01   9.45039630e-01   9.88759518e-01   1.03450179e+00
   1.08235979e+00   1.13243222e+00   1.18482399e+00   1.23963916e+00
   1.29698825e+00   1.35699379e+00   1.41977727e+00   1.48546255e+00
   1.55418909e+00   1.62609863e+00   1.70133007e+00   1.78004694e+00
   1.86240637e+00   1.94857585e+00   2.03873610e+00   2.13306546e+00
   2.23176265e+00   2.33502412e+00   2.44306993e+00   2.55611157e+00
   2.67438364e+00   2.79813409e+00   2.92760873e+00   3.06307840e+00
   3.20481300e+00   3.35311103e+00   3.50827217e+00   3.67061353e+00
   3.84047031e+00   4.01818752e+00   4.20413256e+00   4.39868164e+00
   4.60223436e+00   4.81521273e+00   5.03804779e+00   5.27119923e+00
   5.51513529e+00   5.77037621e+00   6.03741550e+00   6.31681204e+00
   6.60916138e+00   6.91502619e+00   7.23504972e+00   7.56991100e+00
   7.92023802e+00   8.28679943e+00   8.67033291e+00   9.07162094e+00
   9.49146652e+00   9.93076992e+00   1.03904104e+01   1.08713055e+01
   1.13744936e+01   1.19009361e+01   1.24517765e+01   1.30281191e+01
   1.36311502e+01   1.42620802e+01   1.49222279e+01   1.56129303e+01
   1.63356056e+01   1.70917702e+01   1.78829231e+01   1.87107086e+01
   1.95768013e+01   2.04829826e+01   2.14311352e+01   2.24231930e+01
   2.34611988e+01   2.45472202e+01   2.56835365e+01   2.68724937e+01
   2.81164818e+01   2.94180717e+01   3.07798843e+01   3.22048340e+01
   3.36957512e+01   3.52556000e+01   3.68877563e+01   3.85955048e+01
   4.03823090e+01   4.22517815e+01   4.42079010e+01   4.62545738e+01
   4.83960228e+01   5.06366539e+01   5.29809875e+01   5.54338989e+01
   5.80004196e+01   6.06857872e+01   6.34955673e+01   6.64353180e+01
   6.95112152e+01   7.27296143e+01   7.60970001e+01   7.96204605e+01
   8.33069916e+01   8.71642609e+01   9.12001877e+01   9.54229813e+01
   9.98412704e+01   1.04464348e+02   1.09301399e+02   1.14362488e+02
   1.19657921e+02   1.25198929e+02   1.30996170e+02   1.37061920e+02
   1.43408707e+02   1.50049530e+02   1.56997803e+02   1.64267761e+02
   1.71874588e+02   1.79833618e+02   1.88161652e+02   1.96874847e+02
   2.05991806e+02   2.15531235e+02   2.25512543e+02   2.35956207e+02
   2.46882660e+02   2.58316284e+02   2.70279419e+02   2.82796448e+02
   2.95892792e+02   3.09596558e+02   3.23934326e+02   3.38936584e+02]

In [ ]:


In [30]:
inputConv = detector2
inputConv = tf.reshape(inputConv,(1,1,nFreqs,1))

kernel = funzione[0]
kernel = tf.reshape(kernel, (1,nFreqs,1,1))

matchingfilter = tf.nn.convolution(inputConv,kernel, padding = 'SAME')

inputConv = detec1
inputConv = tf.reshape(inputConv,(1,1,nFreqs,1))

kernel = matchingfilter
kernel = tf.reshape(kernel, (1,nFreqs,1,1))

estimatore = tf.nn.convolution(inputConv,kernel, padding = 'SAME')


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-30-2bb8686957da> in <module>()
      7 matchingfilter = tf.nn.convolution(inputConv,kernel, padding = 'SAME')
      8 
----> 9 inputConv = detec1
     10 inputConv = tf.reshape(inputConv,(1,1,nFreqs,1))
     11 

NameError: name 'detec1' is not defined

In [67]:
import numpy
import tensorflow as tf
from matplotlib import pyplot
import time

maxFreq = 120
minFreq = 80

tFft = 8192
stepFreq = 1/tFft
nFreqs = numpy.int((maxFreq-minFreq)/stepFreq)
#nFreqs = 101

sessione = tf.Session()

def preparDati(N,sign):
    valori = tf.random_normal([N], dtype=tf.float32)
    ampiezza = tf.pow(tf.abs(valori),2)
    dati = ampiezza + sign
    return dati


frequenze = tf.range(minFreq,maxFreq, delta = stepFreq)

alpha = tf.range(-4,4, delta = 0.1)
nAlphas = tf.size(alpha)
alpha = tf.reshape(alpha, shape=[nAlphas,1] )
alpha = 3
refreq = minFreq

spettroSegnale = tf.pow(frequenze/refreq, alpha)

detector1 = preparDati(nFreqs,spettroSegnale)
detector2 = preparDati(nFreqs,spettroSegnale)

#detector1 = preparDati(nFreqs,0)
#detector2 = preparDati(nFreqs,0)

def crosscorrela(funz1,funz2, N):
    media1 = tf.reduce_mean(funz1)
    media2 = tf.reduce_mean(funz2)
    
    funz1=  funz1-media1
    funz2 = funz2-media2
    
    sigma1 = tf.sqrt(tf.reduce_sum(funz1*funz1)/N)
    sigma2 = tf.sqrt(tf.reduce_sum(funz2*funz2)/N)

    
    
    prodotto = funz1*funz2
    crosscorr = (tf.reduce_sum(prodotto)/N)/(sigma1*sigma2)
    return crosscorr
    
def matchedfiltra(funz,filtro, N):
    media = tf.reduce_mean(funz)
    funz= funz-media
    filtro = filtro-media
    sigma = tf.sqrt(tf.reduce_sum(funz*funz)/N)
    
    prodotto = filtro*funz/tf.pow(sigma,2)
    normalizzatore = tf.reduce_sum(tf.pow(filtro/sigma,2))
    filtraggio = tf.reduce_sum(prodotto)/normalizzatore
    return filtraggio

#def crossfiltra(funz1,funz2,sign,N)
    
filtrato1 = matchedfiltra(detector1,spettroSegnale,nFreqs)
filtrato2 = matchedfiltra(detector2,spettroSegnale,nFreqs)
    
estimatore = crosscorrela(detector1, detector2, nFreqs)
autoestimatore = crosscorrela(detector1,detector1, nFreqs)   

fil1NP = sessione.run(filtrato1)#detectorsNP[:,2]
fil2NP = sessione.run(filtrato2)#detectorsNP[:,3]
print(fil1NP,fil2NP)
detectorsNP = sessione.run(tf.stack([detector1,detector2],1))
det1NP = detectorsNP[:,0]
det2NP = detectorsNP[:,1]


estimatoreNP = sessione.run(estimatore)
autoestimatoreNP = sessione.run(autoestimatore)


0.319262 0.322849
0.189628 1.0

In [72]:
import numpy
from matplotlib import pyplot
import tensorflow as tf

spettroHan = numpy.load('/home/protoss/Documenti/Gravit_sper/dati/spettroHanMediato.npy')
spettroLiv = numpy.load('/home/protoss/Documenti/Gravit_sper/dati/spettroLivMediato.npy')

han = tf.constant(spettroHan)+spettroSegnale
liv = tf.constant(spettroLiv)+spettroSegnale

crossSpettri = sessione.run(crosscorrela(han,liv, nFreqs))
autoCorrHan = sessione.run(crosscorrela(han,han,nFreqs))
autoCorrLiv = sessione.run(crosscorrela(liv,liv,nFreqs))

filtroHan = sessione.run(matchedfiltra(han, spettroSegnale,nFreqs))
filtroLiv = sessione.run(matchedfiltra(liv, spettroSegnale,nFreqs))


print(crossSpettri, autoCorrHan, autoCorrLiv,filtroHan,filtroLiv)

freqNP = numpy.arange(80,120, 1/8192)

%matplotlib notebook
pyplot.loglog()
a = pyplot.scatter(freqNP,spettroHan, s = 5)
a = pyplot.scatter(freqNP,spettroLiv, s = 5)
#pyplot.show()


0.980257 1.0 1.0 0.729192 0.790313

In [52]:
spettroHan


Out[52]:
array([ 0.55258077,  0.44216788,  0.44126546, ...,  0.45012534,
        0.4422808 ,  0.43663269], dtype=float32)

In [ ]:


In [48]:
import numpy
import tensorflow as tf
from matplotlib import pyplot
import time

maxFreq = 120
minFreq = 80

samplerate = 16384
tFft = 192
sizetSeries = 16384*tFft
stepFreq = 1/tFft
nFreqs = numpy.int((maxFreq-minFreq)/stepFreq)


sessione = tf.Session()

def preparDati(N,sign=0):
    valori = tf.random_normal([N], dtype=tf.float32)
    mediaAmp = tf.reduce_mean(valori)
    dati = valori - mediaAmp
    dati = dati + sign
    return dati

timeseries1 = preparDati(sizetSeries)
#timeseries1 = tf.cast(timeseries1, dtype=tf.complex64)
timeseries2 = preparDati(sizetSeries)
#timeseries2 = tf.cast(timeseries2, dtype=tf.complex64)

#che succede se crosscorrelo sui tempi e faccio trasf di fourier 
#invece di fare media delle componenti di fourier come maggiore & romano?




#fft1 = tf.fft(timeseries1)
#fft2 = tf.fft(timeseries2)
#sizefft = tf.size(fft1)


times1NP = sessione.run(timeseries1)
times2NP = sessione.run(timeseries2)
#fftNP = sessione.run(fft1)
fft1NP = numpy.fft.fft(times1NP)


fft2NP = numpy.fft.fft(times2NP)

fft1 = tf.constant(fft1NP, dtype=tf.complex64)
fft2 = tf.constant(fft2NP, dtype=tf.complex64)
prod = tf.conj(fft1)*fft2
print(sessione.run(prod))

def crossfiltra(dati1,dati2,sign=1):
    prodComplesso = tf.conj(dati1)*dati2*sign
    estimatore = tf.reduce_sum(prodComplesso)
    return estimatore

estimatore = crossfiltra(fft1,fft2)
print(sessione.run(estimatore))

sizefft = tf.size(fft1)
frequenze = tf.range(sizefft)

alpha = tf.range(-4,4, delta = 0.1)
nAlphas = tf.size(alpha)
alpha = tf.reshape(alpha, shape=[nAlphas,1] )
alpha = 3
refreq = minFreq

spettroSegnale = tf.pow(frequenze/refreq, alpha)


[  7.12384004e-04      +0.j         6.46546100e+06+2460624.25j
  -1.31054938e+05 +218403.671875j ...,   3.71615781e+04-1219488.j
  -1.31054938e+05 -218403.671875j   6.46546100e+06-2460624.25j    ]
(-4.42663e+09+28672j)

In [43]:
#non ho capito come funziona ora il range di frequenza. che intervallo di frequenze copro con questo tfft
#e questo sampling rate?
#da 0 a 192 hz con 16384 valori per ogni hertz? ma se sensib dovrebbe essere 1/192, dovrei mediare i valori
#in mezzo?
fft1NP.size/192


Out[43]:
16384.0

In [26]:
a = numpy.array([1,2,3,4])
print(a)
numpy.flip(a,0)


[1 2 3 4]
Out[26]:
array([4, 3, 2, 1])

In [11]:
%matplotlib notebook
a = pyplot.scatter(numpy.arange(fft1NP.size),fft1NP, s = 5)

pyplot.imshow(a)
pyplot.show()


/home/protoss/.local/lib/python3.5/site-packages/numpy/core/numeric.py:583: ComplexWarning: Casting complex values to real discards the imaginary part
  return array(a, dtype, copy=False, order=order, subok=True)

In [ ]: