commlab 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
commlab-0.2.0/PKG-INFO ADDED
@@ -0,0 +1,16 @@
1
+ Metadata-Version: 2.1
2
+ Name: commlab
3
+ Version: 0.2.0
4
+ Summary: Communication Lab utilities for signal processing and noise addition
5
+ Author: Padmapriya C J
6
+ Author-email: padmapriyacj06@gmail.com
7
+ Classifier: Development Status :: 3 - Alpha
8
+ Classifier: Intended Audience :: Science/Research
9
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.7
12
+ Classifier: Programming Language :: Python :: 3.8
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Requires-Python: >=3.7
@@ -0,0 +1,101 @@
1
+ # CommLab - Communication Laboratory Utilities
2
+
3
+ A Python package providing utility functions for communication systems experiments and simulations.
4
+
5
+ ## Features
6
+
7
+ - **AWGN Noise Addition**: Add Additive White Gaussian Noise to signals with specified SNR
8
+ - Supports both real and complex-valued signals
9
+ - Works with multi-dimensional arrays
10
+ - Easy to use and extend
11
+
12
+ ## Installation
13
+
14
+ ### From source (Development mode)
15
+
16
+ 1. Clone or download this repository
17
+ 2. Navigate to the package directory
18
+ 3. Install in editable mode:
19
+
20
+ ```bash
21
+ pip install -e .
22
+ ```
23
+
24
+ This allows you to modify the source code and see changes immediately without reinstalling.
25
+
26
+ ## Usage
27
+
28
+ ### Basic Example
29
+
30
+ ```python
31
+ import numpy as np
32
+ from commlab import awgn
33
+
34
+ # Create a simple BPSK signal
35
+ signal = np.array([1, -1, 1, -1, 1, -1])
36
+
37
+ # Add AWGN with SNR = 10 dB
38
+ noisy_signal = awgn(signal, SNRdb=10)
39
+ ```
40
+
41
+ ### QPSK Example
42
+
43
+ ```python
44
+ import numpy as np
45
+ from commlab import awgn
46
+
47
+ # Create QPSK symbols
48
+ qpsk_symbols = np.array([1+1j, -1+1j, -1-1j, 1-1j]) / np.sqrt(2)
49
+
50
+ # Add noise with 15 dB SNR
51
+ noisy_qpsk = awgn(qpsk_symbols, SNRdb=15)
52
+ ```
53
+
54
+ ### With Oversampling
55
+
56
+ ```python
57
+ import numpy as np
58
+ from commlab import awgn
59
+
60
+ # Oversampled signal (4 samples per symbol)
61
+ oversampled_signal = np.repeat([1, -1, 1, -1], 4)
62
+
63
+ # Add noise (L=4 for 4 samples per symbol)
64
+ noisy_signal = awgn(oversampled_signal, SNRdb=10, L=4)
65
+ ```
66
+
67
+ ## Function Reference
68
+
69
+ ### `awgn(s, SNRdb, L=1)`
70
+
71
+ Add Additive White Gaussian Noise to a signal.
72
+
73
+ **Parameters:**
74
+ - `s` (array_like): Input signal (real or complex)
75
+ - `SNRdb` (float): Signal-to-Noise Ratio in dB
76
+ - `L` (int, optional): Samples per symbol (default=1)
77
+
78
+ **Returns:**
79
+ - `r` (ndarray): Noisy signal
80
+
81
+ ## Requirements
82
+
83
+ - Python >= 3.7
84
+ - NumPy >= 1.20.0
85
+
86
+ ## Future Extensions
87
+
88
+ This package is designed to be easily extensible. Future versions may include:
89
+ - Modulation schemes (BPSK, QPSK, QAM)
90
+ - Demodulation functions
91
+ - BER calculation utilities
92
+ - Eye diagram plotting
93
+ - Channel models
94
+
95
+ ## License
96
+
97
+ MIT License
98
+
99
+ ## Contributing
100
+
101
+ Feel free to add more functions as needed for your communication lab experiments!
@@ -0,0 +1,24 @@
1
+ """
2
+ CommLab - Communication Laboratory Utilities
3
+ =============================================
4
+
5
+ A Python package providing utility functions for communication systems
6
+ experiments and simulations.
7
+
8
+ Available functions
9
+ -------------------
10
+ awgn : Add Additive White Gaussian Noise to signals
11
+
12
+ Example usage
13
+ -------------
14
+ >>> from commlab import awgn
15
+ >>> import numpy as np
16
+ >>>
17
+ >>> signal = np.array([1, -1, 1, -1])
18
+ >>> noisy_signal = awgn(signal, SNRdb=10)
19
+ """
20
+
21
+ from .main import awgn
22
+
23
+ __version__ = '0.1.0'
24
+ __all__ = ['awgn']
@@ -0,0 +1,76 @@
1
+ """
2
+ Noise generation functions for communication systems.
3
+ """
4
+
5
+ import numpy as np
6
+
7
+
8
+ def awgn(s, SNRdb, L=1):
9
+ """
10
+ Add Additive White Gaussian Noise (AWGN) to a signal.
11
+
12
+ This function adds AWGN to the input signal based on the specified
13
+ Signal-to-Noise Ratio (SNR) in dB. It works with both real and
14
+ complex-valued signals of any dimension.
15
+
16
+ Parameters
17
+ ----------
18
+ s : array_like
19
+ Input signal (real or complex-valued). Can be 1D or multi-dimensional.
20
+ SNRdb : float
21
+ Signal-to-Noise Ratio in decibels (dB).
22
+ L : int, optional
23
+ Samples per symbol for oversampled signals (default=1).
24
+ Used to normalize the signal power calculation.
25
+
26
+ Returns
27
+ -------
28
+ r : ndarray
29
+ Noisy signal with the same shape as input signal s.
30
+ r = s + n, where n is the generated AWGN.
31
+
32
+ Examples
33
+ --------
34
+ >>> import numpy as np
35
+ >>> from commlab import awgn
36
+ >>>
37
+ >>> # Real signal
38
+ >>> signal = np.array([1, -1, 1, -1])
39
+ >>> noisy_signal = awgn(signal, SNRdb=10)
40
+ >>>
41
+ >>> # Complex signal (QPSK)
42
+ >>> qpsk_signal = np.array([1+1j, -1+1j, -1-1j, 1-1j]) / np.sqrt(2)
43
+ >>> noisy_qpsk = awgn(qpsk_signal, SNRdb=15)
44
+
45
+ Notes
46
+ -----
47
+ The noise power is calculated as N0 = P/gamma, where:
48
+ - P is the average signal power
49
+ - gamma is the SNR in linear scale (10^(SNRdb/10))
50
+
51
+ For complex signals, the noise is generated with equal power in
52
+ both I and Q components.
53
+ """
54
+ # Convert SNR from dB to linear scale
55
+ gamma = 10**(SNRdb / 10.0)
56
+
57
+ # Calculate average signal power
58
+ P = L * np.sum(np.abs(s)**2) / s.size
59
+
60
+ # Calculate noise power spectral density
61
+ N0 = P / gamma
62
+
63
+ # Generate AWGN based on signal type
64
+ if np.isrealobj(s):
65
+ # Real-valued signal: generate real Gaussian noise
66
+ n = np.sqrt(N0 / 2) * np.random.standard_normal(s.shape)
67
+ else:
68
+ # Complex-valued signal: generate complex Gaussian noise
69
+ # with equal power in real and imaginary components
70
+ n = np.sqrt(N0 / 2) * (
71
+ np.random.standard_normal(s.shape) +
72
+ 1j * np.random.standard_normal(s.shape)
73
+ )
74
+
75
+ # Return noisy signal
76
+ return s + n
@@ -0,0 +1,16 @@
1
+ Metadata-Version: 2.1
2
+ Name: commlab
3
+ Version: 0.2.0
4
+ Summary: Communication Lab utilities for signal processing and noise addition
5
+ Author: Padmapriya C J
6
+ Author-email: padmapriyacj06@gmail.com
7
+ Classifier: Development Status :: 3 - Alpha
8
+ Classifier: Intended Audience :: Science/Research
9
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.7
12
+ Classifier: Programming Language :: Python :: 3.8
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Requires-Python: >=3.7
@@ -0,0 +1,9 @@
1
+ README.md
2
+ setup.py
3
+ commlab/__init__.py
4
+ commlab/main.py
5
+ commlab.egg-info/PKG-INFO
6
+ commlab.egg-info/SOURCES.txt
7
+ commlab.egg-info/dependency_links.txt
8
+ commlab.egg-info/requires.txt
9
+ commlab.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ numpy>=1.20.0
@@ -0,0 +1 @@
1
+ commlab
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
commlab-0.2.0/setup.py ADDED
@@ -0,0 +1,30 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ with open("README.md","r") as f:
4
+ description = f.read()
5
+
6
+ setup(
7
+ name='commlab',
8
+ version='0.2.0',
9
+ description='Communication Lab utilities for signal processing and noise addition',
10
+ author='Padmapriya C J',
11
+ author_email='padmapriyacj06@gmail.com',
12
+ packages=find_packages(),
13
+ install_requires=[
14
+ 'numpy>=1.20.0',
15
+ ],
16
+ python_requires='>=3.7',
17
+ classifiers=[
18
+ 'Development Status :: 3 - Alpha',
19
+ 'Intended Audience :: Science/Research',
20
+ 'Topic :: Scientific/Engineering :: Information Analysis',
21
+ 'Programming Language :: Python :: 3',
22
+ 'Programming Language :: Python :: 3.7',
23
+ 'Programming Language :: Python :: 3.8',
24
+ 'Programming Language :: Python :: 3.9',
25
+ 'Programming Language :: Python :: 3.10',
26
+ 'Programming Language :: Python :: 3.11',
27
+ ],
28
+ )
29
+ long_description=open("README.md").read(),
30
+ long_description_content_type="text/markdown",