From ba3dfa4c1484336ba7441bd4ce65cf88916c9cbb Mon Sep 17 00:00:00 2001 From: accessbox777 <84122321+accessbox777@users.noreply.github.com> Date: Wed, 27 Mar 2024 15:56:26 +0800 Subject: [PATCH 1/3] Update iq_files.rst is this more realistic that x_symbols also a complex number, when we do r = x_symbols +n? --- content/iq_files.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/iq_files.rst b/content/iq_files.rst index 89a919c..60293f7 100644 --- a/content/iq_files.rst +++ b/content/iq_files.rst @@ -39,7 +39,7 @@ In Python, and numpy specifically, we use the :code:`tofile()` function to store num_symbols = 10000 - x_symbols = np.random.randint(0, 2, num_symbols)*2-1 # -1 and 1's + x_symbols = (np.random.randint(0, 2, num_symbols)*2-1)*(1+1j) # -1 and 1's n = (np.random.randn(num_symbols) + 1j*np.random.randn(num_symbols))/np.sqrt(2) # AWGN with unity power r = x_symbols + n * np.sqrt(0.01) # noise power of 0.01 print(r) From 16d6436a3ae5a85ef33a401ea934d1ad2f58b933 Mon Sep 17 00:00:00 2001 From: accessbox777 <84122321+accessbox777@users.noreply.github.com> Date: Sun, 31 Mar 2024 12:36:50 +0800 Subject: [PATCH 2/3] Update iq_files.rst # Changed one word in the description from BPSK to QPSK # Added one line of description for how x_symbols consists # Added your code for generating QPSK symbols (it's clear and easy to understand, so I don't think you need to make it shorter). --- content/iq_files.rst | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/content/iq_files.rst b/content/iq_files.rst index 60293f7..c9f42fc 100644 --- a/content/iq_files.rst +++ b/content/iq_files.rst @@ -30,7 +30,7 @@ In Python, the default complex type is np.complex128, which uses two 64-bit floa Python Examples ************************* -In Python, and numpy specifically, we use the :code:`tofile()` function to store a numpy array to a file. Here is a short example of creating a simple BPSK signal plus noise and saving it to a file in the same directory we ran our script from: +In Python, and numpy specifically, we use the :code:`tofile()` function to store a numpy array to a file. Here is a short example of creating a simple QPSK signal plus noise and saving it to a file in the same directory we ran our script from: .. code-block:: python @@ -39,7 +39,11 @@ In Python, and numpy specifically, we use the :code:`tofile()` function to store num_symbols = 10000 - x_symbols = (np.random.randint(0, 2, num_symbols)*2-1)*(1+1j) # -1 and 1's + # x_symbols array will contain complex numbers representing the QPSK symbols. Each symbol will be a complex number with a magnitude of 1 and a phase angle corresponding to one of the four QPSK constellation points (45, 135, 225, or 315 degrees) + x_int = np.random.randint(0, 4, num_symbols) # 0 to 3 + x_degrees = x_int*360/4.0 + 45 # 45, 135, 225, 315 degrees + x_radians = x_degrees*np.pi/180.0 # sin() and cos() takes in radians + x_symbols = np.cos(x_radians) + 1j*np.sin(x_radians) # this produces our QPSK complex symbols n = (np.random.randn(num_symbols) + 1j*np.random.randn(num_symbols))/np.sqrt(2) # AWGN with unity power r = x_symbols + n * np.sqrt(0.01) # noise power of 0.01 print(r) From 7a20af3f97d99f4e6880c52a1ddbec7a2697d865 Mon Sep 17 00:00:00 2001 From: accessbox777 <84122321+accessbox777@users.noreply.github.com> Date: Sun, 31 Mar 2024 12:40:37 +0800 Subject: [PATCH 3/3] Update iq_files.rst --- content/iq_files.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/content/iq_files.rst b/content/iq_files.rst index c9f42fc..55693aa 100644 --- a/content/iq_files.rst +++ b/content/iq_files.rst @@ -39,11 +39,11 @@ In Python, and numpy specifically, we use the :code:`tofile()` function to store num_symbols = 10000 - # x_symbols array will contain complex numbers representing the QPSK symbols. Each symbol will be a complex number with a magnitude of 1 and a phase angle corresponding to one of the four QPSK constellation points (45, 135, 225, or 315 degrees) + # x_symbols array will contain complex numbers representing the QPSK symbols. Each symbol will be a complex number with a magnitude of 1 and a phase angle corresponding to one of the four QPSK constellation points (45, 135, 225, or 315 degrees) x_int = np.random.randint(0, 4, num_symbols) # 0 to 3 - x_degrees = x_int*360/4.0 + 45 # 45, 135, 225, 315 degrees - x_radians = x_degrees*np.pi/180.0 # sin() and cos() takes in radians - x_symbols = np.cos(x_radians) + 1j*np.sin(x_radians) # this produces our QPSK complex symbols + x_degrees = x_int*360/4.0 + 45 # 45, 135, 225, 315 degrees + x_radians = x_degrees*np.pi/180.0 # sin() and cos() takes in radians + x_symbols = np.cos(x_radians) + 1j*np.sin(x_radians) # this produces our QPSK complex symbols n = (np.random.randn(num_symbols) + 1j*np.random.randn(num_symbols))/np.sqrt(2) # AWGN with unity power r = x_symbols + n * np.sqrt(0.01) # noise power of 0.01 print(r)