https://github.com/jmwilson/lti-arithmetic
Arithmetic manipulation for scipy.signal.lti TransferFunction
https://github.com/jmwilson/lti-arithmetic
scipy signal-processing
Last synced: 19 days ago
JSON representation
Arithmetic manipulation for scipy.signal.lti TransferFunction
- Host: GitHub
- URL: https://github.com/jmwilson/lti-arithmetic
- Owner: jmwilson
- License: mit
- Created: 2019-02-03T02:49:34.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2021-06-10T04:46:50.000Z (almost 4 years ago)
- Last Synced: 2025-04-12T01:14:31.349Z (19 days ago)
- Topics: scipy, signal-processing
- Language: Python
- Homepage:
- Size: 4.88 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# lti-arithmetic
Arithmetic manipulation for scipy.signal.lti TransferFunctionLTI system representations in scipy do not offer built-in composability.
Given two instances of `scipy.signal.lti`, for example, `H` and `G`,
you cannot directly write `H * G`.This package defines a `scipy.signal.lti`-compatible `TransferFunction`
that permits standard arithmetical combination: `H + G`, `H - G`, `H * G`,
`H / G`, and `H**n`. In addition, the parallel combination
(reciprocal of reciprocal sums) of systems is available by writing `H | G`.The package also defines functions `Z_R`, `Z_C`, and `Z_L` that represent
the impedance of a resistance, capacitance, and inductance, respectively,
as LTI systems that can be composed to represent the transfer function
of a larger network.For convenience, the package also defines `s` so that transfer functions
can be written as rational expressions in `s`.## Examples
```
>>> from ltiarithmetic import TransferFunction, Z_R, Z_C, Z_L, s
```Compute the product of two LTI systems:
```
>>> H = TransferFunction([1,2,3],[1])
>>> G = TransferFunction[[1],[2,3,4])
>>> H * G
TransferFunction(
array([0.5, 1. , 1.5]),
array([1. , 1.5, 2. ]),
dt: None
)
```Compute the transfer function of a RC lowpass filter:
```
Z_1 = Z_R(1000.)
Z_2 = Z_C(1e-9)
H = Z_2 / (Z_1 + Z_2)
```Construct LTI systems from rational expressions in `s`:
```
import math
w0 = 2 * math.pi * 1000.
Q = 2.
H = 1/(1 + s / (Q * w0) + (s / w0)**2)
```