Exemple #1
0
y = y * 1
t = training_sets

y_mp = np.reshape(y, (t, y_freq))
g = np.shape(y_mp)[1]
#Phi_designer_k_svd(Phi_test, y_mp,maxiter = max_iter)
ksvd = ApproximateKSVD(n_components=dict_component,
                       transform_n_nonzero_coefs=sparsity)
y_cur = np.reshape(y_mp, (t * num_samples, sample_len))
y_cur = y_cur.T
Phi_test = ksvd.fit(y_cur).components_

Phi = Phi_test

#for super large y signals
'''
print Phi_init
print Phi
'''
#m,n = np.shape(Phi)
#print m, n, len(Phi)
m, n = np.shape(Phi)
print m, n
'''
for x in Phi:
    print x
    print '######'
'''
#sys.exit(0)
file_create(f_name, Phi, m, n)
    y_mp = np.reshape(y[i], (t,y_freq))
    g = np.shape(y_mp)[1]
    #Phi_designer_k_svd(Phi_test, y_mp,maxiter = max_iter)
    ksvd = ApproximateKSVD(n_components = dict_component, transform_n_nonzero_coefs=sparsity)
    y_cur = np.reshape(y_mp, (t * k,m))
    y_cur =  y_cur.T
    Phi[j] = ksvd.fit(y_cur).components_

print "Done reading in incoming signal/components"
#Phi = Phi_test

#note to self: try taking dictionary of the the normal vibrating spindle at point #350000, idle at 0


chan = 1
count = 0

for k in range(0, channels):
	a, b = np.shape(Phi[k])
	write_name = f_name + "/" + f_name + "_" + str(chan) + "_" + str(count) + ".h5"
	file_create(write_name, Phi[k], a, b)
	if ((k+1) % 4 == 0):
		count = 0
		chan += 1
	else:
		count +=1
	#count += 1
print "Done creating dictionaries for all channels"

sys.exit(0)
#file_create(f_name, Phi, a, b)