https://github.com/scientifichackers/oscilloscope
An oscilloscope for python that just works™
https://github.com/scientifichackers/oscilloscope
Last synced: about 1 year ago
JSON representation
An oscilloscope for python that just works™
- Host: GitHub
- URL: https://github.com/scientifichackers/oscilloscope
- Owner: scientifichackers
- License: mit
- Created: 2018-08-11T19:51:21.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2022-12-08T01:14:32.000Z (over 3 years ago)
- Last Synced: 2025-04-17T19:56:55.741Z (about 1 year ago)
- Language: Python
- Size: 39.1 KB
- Stars: 27
- Watchers: 2
- Forks: 6
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Oscilloscope
**An oscilloscope for python that just works™**
## Features
### Simple to use
[*This*](examples/simple_signal.py)
```python3
import random
from time import sleep
from oscilloscope import Osc
osc = Osc()
@osc.signal
def simple_random_signal(state):
while True:
state.draw(random.random())
sleep(0.1)
osc.start()
```
*Gives you this*

### Parallel compute
Each `osc.signal` gets it's own process.
[*This*](examples/parallel_signals.py)
```python3
import random
from time import sleep
from oscilloscope import Osc
osc = Osc(nrows=2, ncols=3)
@osc.signal
def signal1(state):
while True:
state.draw((random.random())
sleep(0.1)
@osc.signal
def signal2(state):
while True:
state.draw(random.random(), row=1, col=2)
sleep(0.1)
osc.start()
```
*Gives you this*

P.S. Don't worry about race conditions, `state.draw()` is atomic. (See [zproc](https://github.com/pycampers/zproc))
### Dynamic axis scale
The Y-axis's scale is dynamic, meaning that the graph's y axis scales with your signal.
[*This*](examples/increasing.py)
```python3
import random
from time import sleep
from oscilloscope import Osc
# adjust window_sec and intensity to improve visibility
osc = Osc(window_sec=10, intensity=1)
@osc.signal
def increasing_signal(state):
delta = 1
while True:
state.draw(random.randint(-delta, delta))
delta += 5
sleep(0.01)
osc.start()
```
*Gives you this*

### Automatic normalization
[*This*](examples/normalized.py)
```python3
import random
from time import sleep
from oscilloscope import Osc
# turn on normalization
osc = Osc(normalize=True)
@osc.signal
def increasing_signal(state):
delta = 1
while True:
state.draw(random.randint(-delta, delta))
delta += 5
sleep(0.01)
osc.start()
```
*Gives you this*

This was the same signal as the [earlier](#Automatic normalization) one,
but it looks a lot like the simple example, because we turned on normalization!
The Y-axis will now show, % max-amplitude encountered at the time, not the raw value.
## Install
[](https://pypi.org/project/oscilloscope/)
`pip install oscilloscope`
MIT Licence
Python 3.6+ only.
---
[🐍🏕️](http://www.pycampers.com/)