Created
May 28, 2024 14:28
-
-
Save sp5wwp/5c6a1123b50dd7dc1bd45daaf545292b to your computer and use it in GitHub Desktop.
AM/AM poly DPD python block for GNU Radio
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Embedded Python Blocks: | |
| Each time this file is saved, GRC will instantiate the first class it finds | |
| to get ports and parameters of your block. The arguments to __init__ will | |
| be the parameters. All of them are required to have default values! | |
| """ | |
| import numpy as np | |
| from gnuradio import gr | |
| class blk(gr.sync_block): | |
| """Embedded Python Block - a simple quadratic polynomial DPD model.\nout = a1*in + a2*in*abs(in) + a3*in*abs(in^2)""" | |
| def __init__(self, a1=1.0, a2=0.0, a3=0.0): | |
| """arguments to this function show up as parameters in GRC""" | |
| gr.sync_block.__init__( | |
| self, | |
| name='AM/AM poly DPD', # will show up in GRC | |
| in_sig=[np.complex64], | |
| out_sig=[np.complex64] | |
| ) | |
| self.a1 = a1 | |
| self.a2 = a2 | |
| self.a3 = a3 | |
| def work(self, input_items, output_items): | |
| """apply predistortion to samples""" | |
| output_items[0][:] = self.a1 * input_items[0] + self.a2 * input_items[0] * np.absolute(input_items[0]) + self.a3 * input_items[0] * np.absolute(np.power(input_items[0], 2.0)) | |
| return len(output_items[0]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment