{"id":18951735,"url":"https://github.com/kawai-senpai/wiggles","last_synced_at":"2025-04-16T00:32:06.157Z","repository":{"id":212331491,"uuid":"554016850","full_name":"Kawai-Senpai/Wiggles","owner":"Kawai-Senpai","description":"Beautiful, Efficient \u0026 Easy Signal Processing \u0026 Plotting in Python","archived":false,"fork":false,"pushed_at":"2024-08-08T07:33:52.000Z","size":1768,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-14T18:06:47.311Z","etag":null,"topics":["library","plotting","plotting-in-python","python","python3","signal","signal-analysis","signal-processing"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/wiggles/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Kawai-Senpai.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-10-19T05:44:57.000Z","updated_at":"2024-12-05T17:40:09.000Z","dependencies_parsed_at":"2023-12-13T18:59:21.408Z","dependency_job_id":null,"html_url":"https://github.com/Kawai-Senpai/Wiggles","commit_stats":null,"previous_names":["kawai-senpai/wiggles"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kawai-Senpai%2FWiggles","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kawai-Senpai%2FWiggles/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kawai-Senpai%2FWiggles/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kawai-Senpai%2FWiggles/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Kawai-Senpai","download_url":"https://codeload.github.com/Kawai-Senpai/Wiggles/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248933339,"owners_count":21185460,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["library","plotting","plotting-in-python","python","python3","signal","signal-analysis","signal-processing"],"created_at":"2024-11-08T13:29:15.050Z","updated_at":"2025-04-16T00:32:05.754Z","avatar_url":"https://github.com/Kawai-Senpai.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Wiggles\n\n![Wiggles Cover](https://github.com/Kawai-Senpai/Wiggles/blob/d4d0f21e78641af6dd0ebce17b165801f1b827d6/Assets/Wiggles%20Cover%20Image.png)\n\n[Wiggles](https://pypi.org/project/wiggles/) is a powerful and flexible Python library for generating, manipulating, and visualizing signals developed by [*Ranit Bhowmick*](https://www.linkedin.com/in/ranitbhowmick/) \u0026 [*Sayanti Chatterjee*](https://www.linkedin.com/in/sayantichatterjee/). Whether you're working with continuous or discrete signals, Wiggles provides a wide range of functionalities to make signal processing straightforward and intuitive. It supports operations in both the time domain and frequency domain, including Fast Fourier Transform (FFT) and inverse FFT, and allows for easy conversion between different representations.\n\nWiggles is designed to be easy to use and integrate into your existing Python workflows, making it a valuable tool for engineers, researchers, and anyone interested in signal processing.\n\n- [Download Wiggles](https://pypi.org/project/wiggles/)\n- [Wiggles Documentation (With Images \u0026 Outputs)](https://github.com/Kawai-Senpai/wiggles/tree/8d3cb835b1c2561db5d24dbe7295803c8b1f879a/Documentation)\n- [Example Codes](https://github.com/Kawai-Senpai/wiggles/tree/8d3cb835b1c2561db5d24dbe7295803c8b1f879a/Examples)\n\n## Features\n- Generation of continuous and discrete signals\n- Conversion between time domain and frequency domain\n- Support for common signal types like sine waves, square waves, and more\n- Visualization of signals\n- Export and import of signals to various formats\n- Playback of signals as audio\n\n## Installation\nEnsure Python 3.10 is installed in the system and added to the system variables. Install the library through pip with the command:\n```sh\npip install wiggles\n```\n\n## Getting Started\nHere are examples of generating and visualizing basic signals using Wiggles.\n\n---\n\n## Generation of Basic Signals (Continuous and Discrete) in Python using the Custom Library Wiggles\n\n### Sin Wave\n\n#### Theory\nA sine wave, sinusoidal wave, or just sinusoid is a mathematical curve defined in terms of the sine trigonometric function, of which it is the graph. It is a type of continuous wave and also a smooth periodic function. It occurs often in mathematics, as well as in physics, engineering, signal processing, and many other fields.\n\n#### Expression\n$$\ny(t) = A \\sin(\\omega t + \\phi) = A \\sin(2 \\pi f t + \\phi)\n$$\n\nwhere:\n- $A$ represents the amplitude, which is the peak deviation of the function from zero.\n- $f$ represents the ordinary frequency, which is the number of oscillations (cycles) that occur each second of time.\n- $\\omega = 2 \\pi f$ represents the angular frequency, which is the rate of change of the function argument in units of radians per second.\n- $\\phi$ represents the phase, which specifies (in radians) where in its cycle the oscillation is at $t = 0$. When $\\phi$ is non-zero, the entire waveform appears to be shifted in time by the amount $\\frac{\\phi}{\\omega}$ seconds. A negative value represents a delay, and a positive value represents an advance.\n\n### Getting the Environment Ready\n- Ensure Python 3.10 is installed in the system and added to the system variables.\n- Install the library through pip with the command:\n  ```sh\n  pip install wiggles\n  ```\n- Use VS Code to code and test out the results.\n- The code is written to find the best solution to the given problem and then is evaluated and displayed using the inbuilt `show()` or `compare()` function in Wiggles.\n\n### Problem\nGenerate sine waves in Python and plot them using Wiggles.\n\n### Program Code\n\n```python\nimport math\nfrom wiggles import signals as sp\n\n# Adjust using these variables\nA = 2\nf = 5\nw = 2 * f * math.pi\nQ = 0\n\n# The sin function\ndef sin(t):\n    return A * math.sin((w * t) + Q)\n\n# Building the continuous signal\ny = sp.continuous(sin)\n\n# Adjusting properties and displaying the continuous signal\ny.name = \"sin(t)\"\ny.show() \n\n# Building the discrete signal\ny2 = sp.continuous(sin, step=0.01)\ny2.is_descrete = True\n\n# Adjusting properties and displaying the discrete signal\ny2.name = \"sin[t]\"\ny2.show()\n```\n\n---\n\n### COS WAVE\n\n#### Theory\nA cosine wave is a mathematical curve defined in terms of the cosine trigonometric function, of which it is the graph. It is a type of continuous wave and also a smooth periodic function. It occurs often in mathematics, as well as in physics, engineering, signal processing, and many other fields.\n\n#### Expression\n$$\ny(t) = A \\cos(\\omega t + \\phi) = A \\cos(2 \\pi f t + \\phi)\n$$\n\nwhere:\n- $A$: Amplitude, the peak deviation of the function from zero.\n- $f$: Ordinary frequency, the number of oscillations (cycles) that occur each second of time.\n- $\\omega = 2 \\pi f$: Angular frequency, the rate of change of the function argument in units of radians per second.\n- $\\phi$: Phase, specifies (in radians) where in its cycle the oscillation is at $t = 0$. When $\\phi$ is non-zero, the entire waveform appears to be shifted in time by the amount $\\phi / \\omega$ seconds. A negative value represents a delay, and a positive value represents an advance.\n\n### Problem\nGenerate cosine waves in Python and plot them using Wiggles.\n\n### Program Code\n\n```python\nimport math\nfrom wiggles import signals as sp\n\n# Adjust using these variables\nA = 2\nf = 5\nw = 2 * f * math.pi\nQ = 0\n\n# The cos function\ndef cos(t):\n    return A * math.cos((w * t) + Q)\n\n# Building the continuous signal\ny = sp.continuous(cos)\n\n# Adjusting properties and displaying the continuous signal\ny.name = \"cos(t)\"\ny.show() \n\n# Building the discrete signal\ny2 = sp.continuous(cos, step=0.01)\ny2.is_descrete = True\n\n# Adjusting properties and displaying the discrete signal\ny2.name = \"cos[t]\"\ny2.show()\n```\n\n---\n\n### EXPONENTIAL CURVE\n\n#### Theory\nThe exponential function is a mathematical function denoted by $f(x) = \\exp(x)$ or $e^x$ (where the argument $x$ is) written as an exponent). Unless otherwise specified, the term generally refers to the positive-valued function of a real variable, although it can be extended to the complex numbers or generalized to other mathematical objects like matrices or Lie algebras. The exponential function originated from the notion of exponentiation (repeated multiplication), but modern definitions (there are several equivalent characterizations) allow it to be rigorously extended to all real arguments, including irrational numbers.\n\n#### Expression\n$$\ny(t) = A e^{-t}\n$$\n    \nwhere:\n- $A$: Amplitude, the peak deviation of the function from zero.\n- $\\omega$: Angular frequency, the rate of change of the function argument in units of radians per second.\n\n### Problem\nGenerate exponentially growing and exponentially decaying waves in Python and plot them using Wiggles.\n\n### Program Code\n\n#### Exponentially Growing\n\n```python\nimport math\nfrom wiggles import signals as sp\n\n# Adjust using these variables\nA = 2\na = -4\n\n# The exp function\ndef exp(t):\n    return A * math.exp(-1 * a * t)\n\n# Building the signal\ny = sp.continuous(exp)\n\n# Adjusting properties and displaying the signal\ny.name = \"Exponentially Growing\"\ny.show()\n```\n\n#### Exponentially Decaying\n\n```python\nfrom wiggles import signals as sp\n\n# Adjust using these variables\nA = 2\na = 4\n\n# The exp function\ndef exp(t):\n    return A * math.exp(-1 * a * t)\n\n# Building the signal\ny = sp.continuous(exp)\n\n# Adjusting properties and displaying the signal\ny.name = \"Exponentially Decaying\"\ny.show()\n```\n\n---\n\n## Generation of Exponentially Growing and Decaying Sinusoidal Curves in Python using the Custom Library Wiggles\n\n### Theory\nThe exponential function is a mathematical function denoted by $f(x) = \\exp(x)$ or $e^x$ (where the argument $x$ is written as an exponent). A sinusoidal wave, or just sinusoid, is a mathematical curve defined in terms of the sine trigonometric function.\n\n#### Expressions\n- Exponential: $y(t) = A e^{-t}$\n- Sinusoidal:\n  - Sine: $y(t) = A \\sin(\\omega t + \\phi) = A \\sin(2 \\pi f t + \\phi)$\n  - Cosine: $y(t) = A \\cos(\\omega t + \\phi) = A \\cos(2 \\pi f t + \\phi)$\n\nWhere:\n- $A$: Amplitude, the peak deviation of the function from zero.\n- $f$: Ordinary frequency, the number of oscillations (cycles) that occur each second of time.\n- $\\omega = 2 \\pi f$: Angular frequency, the rate of change of the function argument in units of radians per second.\n- $\\phi$: Phase, specifies (in radians) where in its cycle the oscillation is at $t = 0$.\n\n### Problem\nGenerate exponentially growing and exponentially decaying sine and cosine waves in Python and plot them using Wiggles.\n\n### Program Code\n\n#### Exponentially Growing Sin\n\n```python\nimport math\nfrom wiggles import signals as sp\n\n# Adjust using these variables\nA = 1\na = -5\nf = 7\nw = 2 * f * math.pi\nQ = 0\n\n# The exp function\ndef exp(t):\n    return A * math.exp(-1 * a * t)\n\n# The sin function\ndef sin(t):\n    return A * math.sin((w * t) + Q)\n\n# Building and operating on the signal\nexpwave = sp.continuous(exp)\nsinwave = sp.continuous(sin)\nexpsin = expwave * sinwave\n\n# Adjusting properties and displaying the signal\nexpwave.name = \"Exponentially Growing Wave\"\nsinwave.name = \"Sin Wave\"\nexpsin.name = \"Exponentially Growing Sin\"\n\nexpwave.compare(sinwave, expsin, spacing=0.407)\n```\n\n#### Exponentially Decaying Sin\n\n```python\nimport math\nfrom wiggles import signals as sp\n\n# Adjust using these variables\nA = 1\na = 5\nf = 7\nw = 2 * f * math.pi\nQ = 0\n\n# The exp function\ndef exp(t):\n    return A * math.exp(-1 * a * t)\n\n# The sin function\ndef sin(t):\n    return A * math.sin((w * t) + Q)\n\n# Building and operating on the signal\nexpwave = sp.continuous(exp)\nsinwave = sp.continuous(sin)\nexpsin = expwave * sinwave\n\n# Adjusting properties and displaying the signal\nexpwave.name = \"Exponentially Decaying Wave\"\nsinwave.name = \"Sin Wave\"\nexpsin.name = \"Exponentially Decaying Sin\"\n\nexpwave.compare(sinwave, expsin, spacing=0.407)\n```\n\n#### Exponentially Growing Cos\n\n```python\nimport math\nfrom wiggles import signals as sp\n\n# Adjust using these variables\nA = 1\na = -5\nf = 7\nw = 2 * f * math.pi\nQ = 0\n\n# The exp function\ndef exp(t):\n    return A * math.exp(-1 * a * t)\n\n# The cos function\ndef cos(t):\n    return A * math.cos((w * t) + Q)\n\n# Building and operating on the signal\nexpwave = sp.continuous(exp)\ncoswave = sp.continuous(cos)\nexpsin = expwave * coswave\n\n# Adjusting properties and displaying the signal\nexpwave.name = \"Exponentially Growing Wave\"\ncoswave.name = \"Cos Wave\"\nexpsin.name = \"Exponentially Growing Cos\"\n\nexpwave.compare(coswave, expsin, spacing=0.407)\n```\n\n#### Exponentially Decaying Cos\n\n```python\nimport math\nfrom wiggles import signals as sp\n\n# Adjust using these variables\nA = 1\na = 5\nf = 7\nw = 2 * f * math.pi\nQ = 0\n\n# The exp function\ndef exp(t):\n    return A * math.exp(-1 * a * t)\n\n# The cos function\ndef cos(t):\n    return A * math.cos((w * t) + Q)\n\n# Building and operating on the signal\nexpwave = sp.continuous(exp)\ncoswave = sp.continuous(cos)\nexpsin = expwave * coswave\n\n# Adjusting properties and displaying the signal\nexpwave.name = \"Decaying Growing Wave\"\ncoswave.name = \"Cos Wave\"\nexpsin.name = \"Decaying Growing Cos\"\n\nexpwave.compare(coswave, expsin, spacing=0.407)\n```\n---\n\n### UNIT IMPULSE WITHOUT FUNCTION\n\n**Theory**\n\nAn ideal impulse signal is a signal that is zero everywhere but at the origin ($t = 0$), where it is infinitely high. Although, the area of the impulse is finite. The unit impulse signal is the most widely used standard signal in the analysis of signals and systems.\n\n**Expression**\n\n$$\n\\delta(t) = \n\\begin{cases} \n1 \u0026 \\text{for } t = 0 \\\\\n0 \u0026 \\text{else} \n\\end{cases}\n$$\n\n**PROBLEM**\n\nGenerate unit impulse signal in Python and plot it using the same.\n\n**PROGRAM CODE**\n\n```python\nfrom wiggles import signals as sp\n\n# Building amplitude data for unit impulse\nlength = 20\ny = ([0] * length) + [1] + ([0] * length)\n\n# Making signal using the amplitude data 'y' using wiggles and displaying\nunitimpulse = sp.discrete(y, -length)\nunitimpulse.name = \"Unit Impulse\"\nunitimpulse.show()\n```\n\n---\n\n### UNIT STEP WITHOUT FUNCTION\n\n**Theory**\n\nThe step signal or step function is a standard signal that exists only for positive time and is zero for negative time. In other words, a signal $x(t)$ is said to be a step signal if and only if it exists for $t \u003e 0$ and is zero for $t \u003c 0$. The step signal is an important signal used for the analysis of many systems. The step signal is equivalent to applying a signal to a system whose magnitude suddenly changes and remains constant forever after application. To obtain a signal that starts at $t = 0$, multiply the given signal with the unit step signal $u(t)$.\n\n**Expression**\n\n$$\nu(t) = \n\\begin{cases} \n1 \u0026 \\text{for } t \\ge 0 \\\\\n0 \u0026 \\text{for } t \u003c 0 \n\\end{cases}\n$$\n\n**PROBLEM**\n\nGenerate unit step signals in Python and plot them using the same.\n\n**PROGRAM CODE**\n\n```python\nfrom wiggles import signals as sp\n\n# Building amplitude data for unit Step\nlength = 20\ny = ([0] * length) + ([1] * length)\n\n# Making signal using the amplitude data 'y' using wiggles\nunitimpulse = sp.discrete(y, -length)\n\n# Naming and displaying the signal\nunitimpulse.name = \"Unit Step\"\nunitimpulse.show()\n```\n\n---\n\n### RAMP WITHOUT FUNCTION\n\n**Theory**\n\nA ramp function or ramp signal is a standard signal that starts at $t = 0$ and increases linearly with time. The unit ramp function has unit slope. The unit ramp signal can be obtained by integrating the unit step signal with respect to time. In other words, a unit step signal can be obtained by differentiating the unit ramp signal.\n\n**Expression**\n\n$$\nr(t) = \n\\begin{cases} \nt \u0026 \\text{for } t \\ge 0 \\\\\n0 \u0026 \\text{for } t \u003c 0 \n\\end{cases}\n$$\n\n**PROBLEM**\n\nGenerate a ramp signal in Python and plot it using the same.\n\n**PROGRAM CODE**\n\n```python\nfrom wiggles import signals as sp\n\n# Building amplitude data for Ramp\nlength = 20\ny = [i for i in range(length)]\n\n# Making signal using the amplitude data 'y' using wiggles\nunitimpulse = sp.discrete(y)\n\n# Naming and displaying the signal\nunitimpulse.name = \"Ramp\"\nunitimpulse.show()\n```\n\n---\n\n### UNIT IMPULSE WITH FUNCTION\n\n**Theory**\n\nAn ideal impulse signal is a signal that is zero everywhere but at the origin ($t = 0$), where it is infinitely high. Although the area of the impulse is finite, the unit impulse signal is widely used in the analysis of signals and systems.\n\n**Expression**\n\n$$\n\\delta(t) = \n\\begin{cases} \n1 \u0026 \\text{for } t = 0 \\\\\n0 \u0026 \\text{else} \n\\end{cases}\n$$\n\n**PROBLEM**\n\nGenerate unit impulse signals using user-defined functions in Python and plot them.\n\n**PROGRAM CODE**\n\n```python\nfrom wiggles import signals as sp\n\n# Making signal using the abstracted user-defined function\nunitimpulse = sp.unit_impulse(-20, 20)\nunitimpulse.name = \"Unit Impulse\"\nunitimpulse.show()\n```\n\n---\n\n### UNIT STEP WITH FUNCTION\n\n**Theory**\n\nThe step signal or step function is a standard signal that exists only for positive time and is zero for negative time. In other words, a signal $x(t)$ is a step signal if and only if it exists for $t \u003e 0$ and is zero for $t \u003c 0$. The step signal is crucial for analyzing many systems. To obtain a signal that starts at $t = 0$, multiply the given signal with the unit step signal $u(t)$.\n\n**Expression**\n\n$$\nu(t) = \n\\begin{cases} \n1 \u0026 \\text{for } t \\ge 0 \\\\\n0 \u0026 \\text{for } t \u003c 0 \n\\end{cases}\n$$\n\n**PROBLEM**\n\nGenerate unit step signals in Python using user-defined functions and plot and display the signal.\n\n**PROGRAM CODE**\n\n```python\nfrom wiggles import signals as sp\n\n# Making signal using the inbuilt function we developed in wiggles and displaying it\nunitstep = sp.unit_step(-20, 20)\nunitstep.name = \"Unit Step\"\nunitstep.show()\n```\n\n---\n\n## Basic Operations on Signals in Python\n\n### SIGNAL SHIFTING\n\n**Theory**\n\nShifting means moving a signal either in the time domain or in the amplitude domain. This can be categorized into:\n\n- **Time Shifting**: Movement in the time domain. If $k$ is positive, the signal shifts left; if $k$ is negative, the signal shifts right.\n\n**Expression**\n\n$$\nx(t) \\rightarrow y(t + k)\n$$\n\n**PROBLEM**\n\nTime shift a test signal by a specific value and display it in a subplot to study the change and compare.\n\n**PROGRAM CODE**\n\n```python\nfrom wiggles import signals as sp\n\n# Test signal y; Making discrete signal using wiggles\ny = sp.discrete([2, -2, 3, -3, 4], -3)\ny.name = \"y\"\n\n# Shifting the signal 'y' by 1\ny1 = y.TimeShift(1)\n\n# Comparing two signals\ny.compare(y1)\n```\n\n---\n\n### SIGNAL SCALING\n\n**Theory**\n\nTime scaling involves multiplying the time axis of a signal by a constant. This process can result in:\n\n- **Time Compression**: If $\\alpha \u003e 1$, the signal is compressed in time by a factor of $\\alpha$.\n- **Time Expansion**: If $\\alpha \u003c 1$, the signal is expanded in time by a factor of $\\alpha$.\n\n**Expression**\n\n$$\nx(t) \\rightarrow y(t) = x(\\alpha t)\n$$\n\n**PROBLEM**\n\nTime scale a test signal by a specific value and display it in a subplot to study the change and compare.\n\n**PROGRAM CODE**\n\n```python\nfrom wiggles import signals as sp\n\n# Test signal y; Making discrete signal using wiggles\ny = sp.discrete([2, -2, 3, -3, 4], -3)\ny.name = \"y\"\n\n# Scaling the signal 'y' by 2\ny1 = y.TimeScale(2)\n\n# Comparing two signals\ny.compare(y1)\n```\n\n---\n\n### SIGNAL REVERSAL\n\n**Theory**\n\nTime reversal involves multiplying the time variable by -1, which produces a mirror image of the signal about the Y-axis.\n\n**Expression**\n\n$$\nx(t) \\rightarrow y(t) = x(-t)\n$$\n\n**PROBLEM**\n\nTime reverse a test signal by a specific value and display it in a subplot to study the change and compare.\n\n**PROGRAM CODE**\n\n```python\nfrom wiggles import signals as sp\n\n# Test signal y; Making discrete signal using wiggles\ny = sp.discrete([2, -2, 3, -3, 4], -3)\ny.name = \"y\"\n\n# Reversing the signal 'y'\ny1 = y.reverse()\n\n# Comparing two signals\ny.compare(y1)\n```\n\n---\n\n## Implementing and performing convolution\n\n### CONVOLUTION SAME INDEX\n\n**Theory**\n\nConvolution is a mathematical tool for combining two signals to produce a third signal. It is crucial in signal processing as it relates the input signal and the impulse response of the system to generate the output signal. For continuous signals, convolution involves integrating the product of the signals over time.\n\n**Expression**\n\n$$\ny(t) = x(t) * h(t) \\equiv \\int_{-\\infty}^{\\infty} x(\\tau) h(t - \\tau) \\, d\\tau\n$$\n\n**PROBLEM**\n\nPerform convolution between two signals starting from the same index and display the results.\n\n**PROGRAM CODE**\n\n```python\nfrom wiggles import signals as sp\n\n# Creating two test signals (Starting from the same index)\nx1 = sp.discrete([-1, 2, -3, 1], -1)\nx1.name = \"x1\"\nx2 = sp.discrete([3, 0, 1, -4], -1)\nx2.name = \"x2\"\n\n# Performing convolution and displaying the result\nresult = x1.convolve(x2)\nx1.compare(x2, result)\n```\n\n---\n\n### CONVOLUTION DIFFERENT INDEX\n\n**Theory**\n\nConvolution combines two signals to produce a third signal, relating the input signal and the impulse response to generate the output signal. For continuous signals, it involves integrating the product of the signals over time.\n\n**Expression**\n\n$$\ny(t) = x(t) * h(t) \\equiv \\int_{-\\infty}^{\\infty} x(\\tau) h(t - \\tau) \\, d\\tau\n$$\n\n**PROBLEM**\n\nPerform convolution between two signals starting from different indices and display the results.\n\n**PROGRAM CODE**\n\n```python\nfrom wiggles import signals as sp\n\n# Creating two test signals (Starting from different index)\nx1 = sp.discrete([-1, 2, -3, 1], -1)\nx1.name = \"x1\"\nx2 = sp.discrete([3, 0, 1, -4], -3)\nx2.name = \"x2\"\n\n# Performing convolution and displaying the result\nresult = x1.convolve(x2)\nx1.compare(x2, result)\n```\n\n---\n\n## Implementing and verifying different properties of convolution\n\n### COMMUTATIVE PROPERTY\n\n**Theory**\n\nThe commutative property of convolution states that the order in which two signals are convolved does not affect the result. This means:\n\n**Expression**\n\n$$\nx_1(t) * x_2(t) = x_2(t) * x_1(t)\n$$\n\n**PROBLEM**\n\nImplement and verify the commutative property of convolution.\n\n**PROGRAM CODE**\n\n```python\nfrom wiggles import signals as sp\n\n# Creating two test signals\nx1 = sp.discrete([-1, 2, -3, 1], -1)\nx1.name = \"x1\"\nx2 = sp.discrete([3, 0, 1, -4], -3)\nx2.name = \"x2\"\n\n'''\nCommutative Property of Convolution:\nThe commutative property of convolution states that the order in which\nwe convolve two signals does not change the result,\ni.e.,\nx1(t) * x2(t) = x2(t) * x1(t)\n'''\n\n# Calculating LHS:\nlhs = x1.convolve(x2)\n\n# Calculating RHS:\nrhs = x2.convolve(x1)\n\n# Displaying both results\nlhs.compare(rhs)\n```\n\n---\n\n### DISTRIBUTIVE PROPERTY\n\n**Theory**\n\nThe distributive property of convolution states that convolution distributes over addition. For three signals \\(x_1(t)\\), \\(x_2(t)\\), and \\(x_3(t)\\), this means:\n\n**Expression**\n\n$$\nx_1(t) * [x_2(t) + x_3(t)] = [x_1(t) * x_2(t)] + [x_1(t) * x_3(t)]\n$$\n\n**PROBLEM**\n\nImplement and verify the distributive property of convolution.\n\n**PROGRAM CODE**\n\n```python\nfrom wiggles import signals as sp\n\n# Creating three test signals\nx1 = sp.discrete([-1, 2, -3, 1], -1)\nx1.name = \"x1\"\nx2 = sp.discrete([3, 0, 1, -4], -3)\nx2.name = \"x2\"\nx3 = sp.discrete([5, 6, 7, 8], -2)\nx3.name = \"x3\"\n\n'''\nDistributive Property of Convolution:\nThe distributive property of convolution states that\nif there are three signals x1(t), x2(t), and x3(t),\nthen the convolution of x1(t) is distributive over the addition,\ni.e.,\nx1(t) * [x2(t) + x3(t)] = [x1(t) * x2(t)] + [x1(t) * x3(t)]\n'''\n\n# Calculating LHS:\nlhs = x1.convolve(x2 + x3)\n\n# Calculating RHS:\nrhs = (x1.convolve(x2)) + (x1.convolve(x3))\n\n# Displaying both results\nlhs.compare(rhs)\n```\n\n---\n\n### ASSOCIATIVE PROPERTY\n\n**Theory**\n\nThe associative property of convolution states that the grouping of signals in convolution does not affect the result. This means:\n\n**Expression**\n\n$$\nx_1(t) * [x_2(t) * x_3(t)] = [x_1(t) * x_2(t)] * x_3(t)\n$$\n\n**PROBLEM**\n\nImplement and verify the associative property of convolution.\n\n**PROGRAM CODE**\n\n```python\nfrom wiggles import signals as sp\n\n# Creating three test signals\nx1 = sp.discrete([-1, 2, -3, 1], -1)\nx1.name = \"x1\"\nx2 = sp.discrete([3, 0, 1, -4], -3)\nx2.name = \"x2\"\nx3 = sp.discrete([5, 6, 7, 8], -2)\nx3.name = \"x3\"\n\n'''\nAssociative Property of Convolution:\nThe associative property of convolution states that the way in which\nthe signals are grouped in a convolution does not change the result,\ni.e.,\nx1(t) * [x2(t) * x3(t)] = [x1(t) * x2(t)] * x3(t)\n'''\n\n# Calculating LHS:\nlhs = x1.convolve(x2.convolve(x3))\n\n# Calculating RHS:\nrhs = (x1.convolve(x2)).convolve(x3)\n\n# Displaying both results\nlhs.compare(rhs)\n```\n\n---\n\n## Performing Operations Like Addition, Subtraction and Multiplication on Signals\n\n### ADDITION\n\n**Theory**\n\nThe sum of two discrete time signals \\(x_1[n]\\) and \\(x_2[n]\\) can be obtained by adding their values at every instant of time.\n\n**PROBLEM**\n\nImplement and verify the result after adding two discrete signals.\n\n**PROGRAM CODE**\n\n```python\nfrom wiggles import signals as sp\n\n# Creating two test signals\nx = sp.discrete([-1, 2, -3, 1], -1)\nx.name = \"x\"\ny = sp.discrete([3, 0, 1, -4], -3)\ny.name = \"y\"\n\n# Performing operation and displaying the result\nresult = x + y\nx.compare(y, result)\n```\n\n---\n\n### SUBTRACTION\n\n**Theory**\n\nThe difference of two discrete time signals \\(x_1[n]\\) and \\(x_2[n]\\) can be obtained by subtracting their values at every instant of time.\n\n**PROBLEM**\n\nImplement and verify the result after subtracting two discrete signals.\n\n**PROGRAM CODE**\n\n```python\nfrom wiggles import signals as sp\n\n# Creating two test signals\nx = sp.discrete([-1, 2, -3, 1], -1)\nx.name = \"x\"\ny = sp.discrete([3, 0, 1, -4], -3)\ny.name = \"y\"\n\n# Performing operation and displaying the result\nresult = x - y\nx.compare(y, result)\n```\n\n---\n\n### MULTIPLICATION\n\n**Theory**\n\nThe multiplication of two discrete time signals \\(x_1[n]\\) and \\(x_2[n]\\) can be obtained by multiplying their values at every instant of time.\n\n**PROBLEM**\n\nImplement and verify the result after multiplying two discrete signals.\n\n**PROGRAM CODE**\n\n```python\nfrom wiggles import signals as sp\n\n# Creating two test signals\nx = sp.discrete([-1, 2, -3, 1], -1)\nx.name = \"x\"\ny = sp.discrete([3, 0, 1, -4], -3)\ny.name = \"y\"\n\n# Performing operation and displaying the result\nresult = x * y\nx.compare(y, result)\n```\n\n---\n\n### DIVISION\n\n**Theory**\n\nThe division of two discrete time signals \\(x_1[n]\\) and \\(x_2[n]\\) can be obtained by dividing their values at every instant of time.\n\n**PROBLEM**\n\nImplement and verify the result after dividing two discrete signals.\n\n**PROGRAM CODE**\n\n```python\nfrom wiggles import signals as sp\n\n# Creating two test signals\nx = sp.discrete([-1, 2, -3, 1], 0)\nx.name = \"x\"\ny = sp.discrete([3, 1, 1, -4], 0)\ny.name = \"y\"\n\n# Performing operation and displaying the result\nresult = x / y\nx.compare(y, result)\n```\n\n---\n\n## Computing and displaying even and odd components of a signal\n\n### EVEN COMPONENT\n\n**Theory**\n\nA signal is said to be an even signal if it is symmetrical about the vertical axis or time origin. Every signal need not be purely even or purely odd; instead, it can be expressed as the sum of even and odd components. The even component of any signal can be calculated by:\n\n$$\nx_e(t) = \\frac{1}{2} \\left[ x(t) + x(-t) \\right]\n$$\n\n**PROBLEM**\n\nImplement and verify the calculation of the even component of a signal.\n\n**PROGRAM CODE**\n\n```python\nfrom wiggles import signals as sp\n\n# Creating a test signal\nx = sp.discrete([-1, 8, -3, 4], 0)\nx.name = \"x\"\n\n# Finding the even component and displaying the result\ncomponent = x.even_component()\ncomponent.name = \"Even Component\"\nx.compare(component)\n```\n\n---\n\n### ODD COMPONENT\n\n**Theory**\n\nA signal is said to be an odd signal if it is anti-symmetrical about the vertical axis. Every signal need not be purely even or purely odd; instead, it can be expressed as the sum of even and odd components. The odd component of any signal can be calculated by:\n\n$$\nx_o(t) = \\frac{1}{2} \\left[ x(t) - x(-t) \\right]\n$$\n\n**PROBLEM**\n\nImplement and verify the calculation of the odd component of a signal.\n\n**PROGRAM CODE**\n\n```python\nfrom wiggles import signals as sp\n\n# Creating a test signal\nx = sp.discrete([-1, 8, -3, 4], 0)\nx.name = \"x\"\n\n# Finding the odd component and displaying the result\ncomponent = x.odd_component()\ncomponent.name = \"Odd Component\"\nx.compare(component)\n```\n\n---\n\n### VERIFICATION\n\n**Theory**\n\nEvery signal need not be purely even or purely odd; instead, it can be expressed as the sum of even and odd components:\n\n$$\nx(t) = x_e(t) + x_o(t)\n$$\n\nWhere:\n- \\(x_e(t)\\) is the even component of the signal\n- \\(x_o(t)\\) is the odd component of the signal\n\n**PROBLEM**\n\nVerify by adding the even and odd components of the signal to retrieve the original signal.\n\n**PROGRAM CODE**\n\n```python\nfrom wiggles import signals as sp\n\n# Creating a test signal\nx = sp.discrete([-1, 8, -3, 4], 0)\nx.name = \"x\"\n\n# Finding the even component\neven = x.even_component()\neven.name = \"Even Component\"\n\n# Finding the odd component\nodd = x.odd_component()\nodd.name = \"Odd Component\"\n\n# Adding the two components\n'''\nSince:\nEvery signal need not be either purely even or purely odd,\nbut it can be expressed as the sum of even and odd components.\nx(t) = x_e(t) + x_o(t)\nWhere:\n  x_e(t) is the even component of the signal,\n  x_o(t) is the odd component of the signal.\n'''\nverify = even + odd\nverify.trim()\n\n# Displaying the results\nx.compare(even, odd, verify)\n```\n\n---\n\n## Generation of different types of signals, using basic operations\n\n### USING UNIT IMPULSE\n\n**PROBLEM**\n\nGeneration of different types of signals using operations involving unit impulse signals. Given:\n\n$$\nx[n] = 2 \\cdot \\delta[n + 2] - \\delta[n - 4]\n$$\n\nWhere \\( -5 \u003c n \u003c 5 \\).\n\n**Getting the environment ready**\n\nPython 3.10 is installed in the system and added to the system variables. The library is installed through pip with the command `pip install wiggles`. VS Code is used for coding and testing. The code is evaluated and displayed using the `show()` or `compare()` function in Wiggles.\n\n**PROGRAM CODE**\n\n```python\nfrom wiggles import signals as sp\n\n# Generating unit impulse signal\nus = sp.unit_impulse()\nus.name = \"unit impulse\"\n\n# Performing operation\nx = (2 * us.TimeShift(2)) - us.TimeShift(-4)\nx.name = \"result\"\n\n# Trimming and displaying result\nx.trim()\nus.compare(x)\n```\n\n---\n\n### USING UNIT STEP\n\n**PROBLEM**\n\nGeneration of different types of signals using operations involving unit step signals. Given:\n\n$$\nx[n] = n \\cdot [u[n] - u[n - 10]] + 10 \\cdot e^{-0.3[n - 10]} \\cdot [u[n - 10] - u[n - 20]]\n$$\n\nWhere \\( 0 \\leq n \\leq 20 \\).\n\n**Getting the environment ready**\n\nPython 3.10 is installed in the system and added to the system variables. The library is installed through pip with the command `pip install wiggles`. VS Code is used for coding and testing. The code is evaluated and displayed using the `show()` or `compare()` function in Wiggles.\n\n**PROGRAM CODE**\n\n```python\nfrom wiggles import signals as sp\nimport numpy as np\nimport math\n\n# Generating unit step signal\nu = sp.unit_step(21)\nu.name = \"unit step\"\n\n# Generating array as desired\nn = sp.array(np.arange(0, 21, 1))\nn.name = \"array\"\n\n# Performing operation\nx = (n * (u - u.TimeShift(-10))) + (10 * (math.e ** (-0.3 * (n - 10)))) * (u.TimeShift(-10) - u.TimeShift(-20))\nx.trim()\nx.name = \"result\"\n\n# Trimming and displaying result\nu.compare(n, x)\n```\n\n---\n\n### USING ANOTHER SIGNAL\n\n**PROBLEM**\n\nGeneration of different types of signals using operations involving other signals. Given:\n\n$$\nx[n] = [1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1]\n$$\n\nStarting index = -2\n\nDetermine and plot the following sequences:\n\n1. $$ x_1[n] = 2 \\cdot x[n - 5] - 3 \\cdot x[n + 4] $$\n2. $$ x_2[n] = x[3 - n] + x[n] \\cdot x[n - 2] $$\n\n**Getting the environment ready**\n\nPython 3.10 is installed in the system and added to the system variables. The library is installed through pip with the command `pip install wiggles`. VS Code is used for coding and testing. The code is evaluated and displayed using the `show()` or `compare()` function in Wiggles.\n\n**PROGRAM CODE**\n\n```python\nfrom wiggles import signals as sp\n\n# Generating wiggles wave using the given amplitude data\nx = sp.discrete([1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1], -2)\nx.name = \"x\"\n\n# Operation 1 (a)\nx1 = (2 * x.TimeShift(-5)) - (3 * x.TimeShift(4))\nx1.name = \"operation 1\"\n\n# Operation 2 (b)\nx2 = x.operate(-1, 3) + (x * x.TimeShift(-2))\nx2.name = \"operation 2\"\n\n# Displaying the result\nx.compare(x1, x2)\n```\n\n---\n\n## Finding the laplace transform and inverse laplace transform\n\n### LAPLACE TRANSFORM\n\n**Theory**\n\nA function is said to be a piecewise continuous function if it has a finite number of breaks and it does not blow up to infinity anywhere. The Laplace transform of a function \\( f(t) \\), represented as \\( L\\{f(t)\\} \\) or \\( F(s) \\), is defined by the integral transform:\n\n$$\nF(s) = \\int_{0}^{\\infty} f(t) \\cdot e^{-st} \\, dt\n$$\n\nwhere \\( s = \\sigma + j\\omega \\) is a complex variable.\n\n**Getting the environment ready**\n\nPython 3.10 is installed in the system and added to the system variables. The library is installed through pip with the command `pip install wiggles`. VS Code is used for coding and testing. The code is evaluated and displayed using the `show()` or `compare()` function in Wiggles.\n\n**PROBLEM**\n\nFind the Laplace transform of the following signals:\n\n1. \\( x(t) = 2 \\cdot \\delta(t) + e^{-3t} \\)\n2. \\( x(t) = u(t-1) - 2e^{-t} \\)\n\n**PROGRAM CODE 1**\n\n```python\nfrom wiggles import symbols as sy\n\n# Given Expression\ndef x(t):\n    return sy.unit_impulse(t) + sy.exp(-3 * t)\n\n# Making time domain object\nexpression = sy.time_domain(x)\nprint(\"The Expression in time Domain: \", expression)\n\n# Laplace transformation\ny = expression.laplace_transform()\nprint(\"The Expression in frequency Domain is: \", y)\n```\n\n**PROGRAM CODE 2**\n\n```python\nfrom wiggles import symbols as sy\n\n# Given Expression\ndef x(t):\n    return sy.unit_step(t - 1) - sy.exp(-2 * (-t))\n\n# Making time domain object\nexpression = sy.time_domain(x)\nprint(\"The Expression in time Domain: \", expression)\n\n# Laplace transformation\ny = expression.laplace_transform()\nprint(\"The Expression in frequency Domain is: \", y)\n```\n\n---\n\n### INVERSE LAPLACE TRANSFORM\n\n**Theory**\n\nThe inverse Laplace transform of a function \\( F(s) \\) is given by:\n\n$$\nf(t) = \\frac{1}{2\\pi i} \\int_{T - i\\infty}^{T + i\\infty} F(s) \\cdot e^{st} \\, ds\n$$\n\nwhere the integration is along the vertical line \\( \\text{Re}(s) = \\gamma \\) in the complex plane, with \\( \\gamma \\) being greater than the real part of all singularities of \\( F(s) \\).\n\n**Getting the environment ready**\n\nPython 3.10 is installed in the system and added to the system variables. The library is installed through pip with the command `pip install wiggles`. VS Code is used for coding and testing. The code is evaluated and displayed using the `show()` or `compare()` function in Wiggles.\n\n**PROBLEM A**\n\nFind the inverse Laplace transform of the following signals:\n\n1. \\( X(s) = \\frac{10s^2 + 4}{s(s + 1)(s + 2)^2} \\)\n2. \\( X(s) = \\frac{s^3 + 2s + 6}{s(s + 3)(s + 1)^2} \\)\n\n**PROGRAM CODE 1**\n\n```python\nfrom wiggles import symbols as sy\n\n# Given Expression\ndef x(s):\n    return (10 * s**2 + 4) / (s * (s + 1) * (s + 2)**2)\n\n# Making frequency domain object\nexpression = sy.frequency_domain(x)\nexpression.name = \"X(s)\"\nprint(\"The Expression in frequency Domain: \", expression)\n\n# Inverse Laplace transformation\ny = expression.inverse_laplace_transform()\ny.name = \"x(t)\"\nprint(\"The Expression in Time Domain is: \", y)\n```\n\n**PROGRAM CODE 2**\n\n```python\nfrom wiggles import symbols as sy\n\n# Given Expression\ndef x(s):\n    return (s**3 + 2 * s + 6) / (s * (s + 3) * (s + 1)**2)\n\n# Making frequency domain object\nexpression = sy.frequency_domain(x)\nexpression.name = \"X(s)\"\nprint(\"The Expression in frequency Domain: \", expression)\n\n# Inverse Laplace transformation\ny = expression.inverse_laplace_transform()\ny.name = \"x(t)\"\nprint(\"The Expression in Time Domain is: \", y)\n```\n\n**PROBLEM B**\n\nUse commands to fragment the expression and find the inverse Laplace transform:\n\nGiven:\n\n$$\nX(s) = \\frac{4s^5 + 20s^4 + 11s^3 + 10s^2 - 12}{s^4 + 5s^3 + 8s^2 + 4s}\n$$\n\n**PROGRAM CODE 1**\n\n```python\nfrom wiggles import symbols as sy\n\n# Given Expression\ndef x(s):\n    return (4 * s**5 + 20 * s**4 + 11 * s**3 + 10 * s**2 - 12) / (s**4 + 5 * s**3 + 8 * s**2 + 4 * s)\n\n# Making frequency domain object\nexpression = sy.frequency_domain(x)\nexpression.name = \"X(s)\"\nprint(\"The Expression in frequency Domain: \\n\", expression)\n\n# Expanding and fragmenting the expression\nexpression.apart()\nprint(\"The Expanded and processed expression: \\n\", expression)\n\n# Inverse Laplace transformation\ny = expression.inverse_laplace_transform()\ny.name = \"x(t)\"\nprint(\"The Expression in Time Domain is: \\n\", y)\n```\n\n---\n\n### POLES AND ZEROS\n\n**Theory**\n\nThe zeros are the roots of the numerator, and the poles are the roots of the denominator of a transfer function.\n\n**Getting the environment ready**\n\nPython 3.10 is installed in the system and added to the system variables. The library is installed through pip with the command `pip install wiggles`. VS Code is used for coding and testing. The code is evaluated and displayed using the `show()` or `compare()` function in Wiggles.\n\n**PROBLEM**\n\nFind the roots of the numerator and the denominator to compute the poles and the zeros of the expression:\n\nGiven:\n\n$$\nX(s) = \\frac{s^2 + 3s + 1}{s^3 + 4s^2 + 3s}\n$$\n\n**PROGRAM CODE**\n\n```python\nfrom wiggles import symbols as sy\n\n# Given Expression\ndef x(s):\n    return (s**2 + 3 * s + 1) / (s**3 + 4 * s**2 + 3 * s)\n\n# Creating frequency domain object\nexpression = sy.frequency_domain(x)\nexpression.name = \"X(s)\"\nprint(\"The Expression in frequency Domain: \\n\", expression)\n\n# Finding out poles and zeros and displaying\npolezero = expression.roots()\nprint(\"Poles of the expression:\", polezero['poles'])\nprint(\"Zeros of the expression:\", polezero['zeros'])\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkawai-senpai%2Fwiggles","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkawai-senpai%2Fwiggles","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkawai-senpai%2Fwiggles/lists"}