Metadata-Version: 2.4
Name: pymoku
Version: 4.8.0
Summary: Python interface to Moku devices
Author-email: Ben Coughlan <ben@liquidinstruments.com>
Maintainer-email: Ben Coughlan <ben@liquidinstruments.com>
License-Expression: MIT
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: click
Requires-Dist: pyzmq>=15.3.0
Requires-Dist: requests
Requires-Dist: tinydb
Requires-Dist: packaging
Requires-Dist: zeroconf
Requires-Dist: cryptography
Provides-Extra: gui
Requires-Dist: pymoku-applets[extras]>=1.1; extra == "gui"
Provides-Extra: sdk
Requires-Dist: pymoku-sdk>=0.6; extra == "sdk"
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Requires-Dist: pytest-cov; extra == "test"
Requires-Dist: pytest-mock; extra == "test"
Requires-Dist: numpy; extra == "test"
Requires-Dist: flake8; extra == "test"
Requires-Dist: flake8-pyproject; extra == "test"
Dynamic: license-file

# PyMoku

# Getting started

Install the core library with

    pip install pymoku

To include support for the GUI application install with

    pip install pymoku[gui]

Launch the GUI with

    pymoku

And if you have local barfiles you are developing, you can specify a folder to
load with

    pymoku --dev /path/to/dev_folder

# CLI

`pymoku` is also a CLI for managing devices and converting datalogs. Run
`pymoku --help` for the full list of subcommands. Common ones:

    pymoku list                          # discover Mokus on the network
    pymoku deploy 10.0.0.1 -i pymoku:oscilloscope -s 1
    pymoku upload 10.0.0.1 path/to/my.bar
    pymoku claim 10.0.0.1 -d 60          # claim ownership for 60s
    pymoku convert datalog.li -f csv     # convert .li to CSV/HDF5

# Scripting

Connect to a Moku by IP address, deploy instruments, and take measurements:

```python
import pymoku

m = pymoku.connect('10.0.0.1')

# A platform must be deployed before instruments are available
m.deploy_platform('pymoku:platform_8')

# Deploy a signal generator and oscilloscope
sg = m.deploy('pymoku:singen:1x', slot=0)
osc = m.deploy('pymoku:oscilloscope:1x', slot=1)

# Configure the signal generator
sg.ch[0].frequency = 1000   # 1 kHz
sg.ch[0].amplitude = 0.5    # 0.5 V peak
sg.ch[0].mute = False

# Route signal generator output to DAC and oscilloscope
m.output('Out 1').set_source(sg.output('ch0'))
osc.input('ch0').set_source(sg.output('ch0'))

# Set timebase and acquire data
osc.set_timebase(0, 2e-3)
data = osc.get_data(timeout=5.0, sync=False)
samples = data['ch0'].samples
print(f'{len(samples)} samples, peak-to-peak: {max(samples) - min(samples):.3f} V')

m.close()
```

Deploying the same instrument ID to the same slot returns the existing
instance. During development, use `force=True` to redeploy, or redeploy the
platform to clear all slots:

```python
slot = m.deploy('custom:myslot', slot=0, force=True)

# or redeploy the platform to start fresh
m.deploy_platform('pymoku:platform_8')
```

List available instruments for the connected device:

```python
m = pymoku.connect('10.0.0.1')
for fid in m.function_ids_for_platform(m.platform_sha):
    print(fid)
```
