Skip to content

Commit

Permalink
example
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobTh98 committed Nov 14, 2024
1 parent 1c86057 commit 0cafc0b
Show file tree
Hide file tree
Showing 2 changed files with 220 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ dist/
.eggs/
sciopy.egg-info/
.ipynb_checkpoints
*.ipynb

developing.ipynb
update_package.sh
update_test_pypi.sh
Expand Down
219 changes: 219 additions & 0 deletions examples/example_notebook.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "1e1715cc-c123-45e2-b767-e6412faeebe3",
"metadata": {},
"source": [
"# Example code for connecting a Sciospec device"
]
},
{
"cell_type": "markdown",
"id": "8a5423a4-f8da-4cdb-8163-1d50d12e6e23",
"metadata": {},
"source": [
"## EIT device\n",
"\n",
"**USB-HS**"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f49a2bed-51db-4627-b5e6-21831a620644",
"metadata": {},
"outputs": [],
"source": [
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"from sciopy import EIT_16_32_64_128, EitMeasurementSetup"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f8c7590a-9aea-4b22-91ad-b953b540362b",
"metadata": {},
"outputs": [],
"source": [
"# create a 'sciospec' class which represents the sciospec EIT device\n",
"n_el = 64\n",
"sciospec = EIT_16_32_64_128(n_el)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "aebcee3a-f3f0-4709-88d3-525eec9b6bb8",
"metadata": {},
"outputs": [],
"source": [
"# connect device via USB-HS port\n",
"sciospec.connect_device_HS()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "de7aaeb5-afb9-4c0d-a3ad-1a8bcf804d6a",
"metadata": {},
"outputs": [],
"source": [
"# read system message buffer\n",
"sciospec.SystemMessageCallback()\n",
"# should be empty"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e8609e39-a7bd-4aaf-8f02-56d7c3c527d7",
"metadata": {},
"outputs": [],
"source": [
"# get device info\n",
"sciospec.GetDeviceInfo()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "10d15631-d005-4929-9f4e-38716f0fdfb2",
"metadata": {},
"outputs": [],
"source": [
"# create a measurement setup\n",
"setup = EitMeasurementSetup(\n",
" burst_count=1,\n",
" n_el=n_el,\n",
" exc_freq=125_000,\n",
" framerate=3,\n",
" amplitude=0.01,\n",
" inj_skip=n_el // 2,\n",
" gain=1,\n",
" adc_range=1,\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9a80f291-4722-497d-9f16-672b6b50af86",
"metadata": {},
"outputs": [],
"source": [
"sciospec.SetMeasurementSetup(setup)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4ca492ed-b55d-429c-b1a3-996691918529",
"metadata": {},
"outputs": [],
"source": [
"# look inside the docstring of the function and manual\n",
"sciospec.GetMeasurementSetup(2)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7607a215-8bb9-429a-885d-e96707d957b5",
"metadata": {},
"outputs": [],
"source": [
"# get data\n",
"data = sciospec.StartStopMeasurement(return_as=\"pot_mat\") # or \"hex\"\n",
"# data.shape = (burst_count, n_el, n_el)\n",
"# check if data shape equals setup\n",
"assert data.shape[0] == setup.burst_count"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2c4c8ac0-4a41-4d85-836d-b17b0a8b81aa",
"metadata": {},
"outputs": [],
"source": [
"for pot in data:\n",
" plt.imshow(np.abs(pot))\n",
" plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c057f22c-949c-4f86-9fb0-bf88a9028ef2",
"metadata": {},
"outputs": [],
"source": [
"# reset the device software (may take a while ~5s, have a look at the LEDs)\n",
"sciospec.SoftwareReset()"
]
},
{
"cell_type": "markdown",
"id": "2d6fd515-c283-4f34-850a-a00e6326def3",
"metadata": {},
"source": [
"## EIT device\n",
"\n",
"**USB-FS**"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6a05b7d3-1b6c-45a9-8670-c49685b369be",
"metadata": {},
"outputs": [],
"source": [
"# TBD"
]
},
{
"cell_type": "markdown",
"id": "a526b930-1c20-4f6f-a500-602451eca9d7",
"metadata": {},
"source": [
"## EIS device\n",
"\n",
"**USB-HS**"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c6c247dd-a41c-4ebd-9c65-867c1b995dcf",
"metadata": {},
"outputs": [],
"source": [
"# TBD"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.2"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

0 comments on commit 0cafc0b

Please sign in to comment.