|
From: | Chad R |
Subject: | Re: [Discuss-gnuradio] Python block with vector input and vector output |
Date: | Thu, 29 Oct 2015 14:27:07 +0200 |
import numpy from gnuradio import gr from yall1 import * class yall1_reconstruction_cc(gr.sync_block): """ Yall1_reconstruction_block """ def __init__(self,n,m): self.N = n self.M = m phi = np.load("/home/chad/Desktop/PROJECT/Python/Matrices/phi_mtx%(M)dx%(N)d.npy" %{"M":self.M,"N":self.N}) psi = np.load("/home/chad/Desktop/PROJECT/Python/Matrices/psi_mtx%(N)dx%(N)d.npy" %{"N":self.N}) self.alpha = np.dot(phi,psi) gr.sync_block.__init__(self, name="yall1_reconstruction", in_sig=[(np.complex64,self.M)], out_sig=[(np.complex64,self.N)]) def work(self, input_items, output_items): in0 = input_items[0] size = np.shape(in0)[0] out = np.zeros((size,self.N),dtype = np.complex64) #out = yall1(self.alpha,in0[0]).reshape(self.N,) for i in range(0,size): recon = yall1(self.alpha, in0[i].reshape(self.M,1))*4.6 out[i] = recon.reshape(self.N,) output_items[0][:] = out return len(output_items[0])
Hi Chad,
there's something wrong with the indention of the lines between "def __init__" and "g.sync_block", and the same goes for your work function; so that's my first stab at explaining misbehaviour.
Best regards,
Marcus
On 29.10.2015 13:01, Chad R wrote:
Chad RichsThank you in advance for your helpHave I implemented it right? or is my issue with my implementation? I read through the tutorials but I feel some aspects are quiet hard to follow.The code for my block is shown below:Good day every oneI have implemented a Python block but I am not getting the results I expected. I get the results I expect at any frequency=samp_rate/2^n where n is any integer. My block makes use of a yall1 reconstruction algorithm to reconstruct a signal from M=100 to N=1024 vector.
class yall1_reconstruction_cc(gr.sync_block):
"""
Yall1_reconstruction_block
"""
def __init__(self,n,m):
self.N = n
self.M = m
phi = np.load("/home/chad/Desktop/PROJECT/Python/Matrices/phi_mtx%(M)dx%(N)d.npy" %{"M":self.M,"N":self.N})
psi = np.load("/home/chad/Desktop/PROJECT/Python/Matrices/psi_mtx%(N)dx%(N)d.npy" %{"N":self.N})
self.alpha = np.dot(phi,psi)
gr.sync_block.__init__(self,
name="yall1_reconstruction",
in_sig=[(np.complex64,self.M)],
out_sig=[(np.complex64,self.N)])
def work(self, input_items, output_items):
in0 = input_items[0]
size = np.shape(in0)[0]
out = np.zeros((size,self.N),dtype = np.complex64)
#out = yall1(self.alpha,in0[0]).reshape(self.N,)
for i in range(0,size):
recon = yall1(self.alpha, in0[i].reshape(self.M,1))*4.7
out[i] = recon.reshape(self.N,)
output_items[0][:] = out
return len(output_items[0])
_______________________________________________ Discuss-gnuradio mailing list address@hidden https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
_______________________________________________
Discuss-gnuradio mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
[Prev in Thread] | Current Thread | [Next in Thread] |