Skip to content

Commit

Permalink
Merge pull request scikit-rf#1187 from mxxmxn/doc_tutorials
Browse files Browse the repository at this point in the history
Improve tutorial for virtual instruments
  • Loading branch information
jhillairet authored Oct 18, 2024
2 parents 834d672 + 01ce7f8 commit 452ee10
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 42 deletions.
102 changes: 64 additions & 38 deletions doc/source/tutorials/VirtualInstruments.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -90,20 +90,44 @@
]
},
{
"cell_type": "markdown",
"metadata": {},
"cell_type": "raw",
"metadata": {
"raw_mimetype": "text/restructuredtext"
},
"source": [
"### Connecting to an instrument over an ethernet connection"
".. note::\n",
"\n",
" You can download this Jupyter notebook and run it directly on your PC:\n",
" :download:`VirtualInstruments.ipynb`\n",
"\n",
" Make sure to comment out any code that is not needed for your instrument."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": "### Connecting to an instrument"
},
{
"metadata": {},
"cell_type": "code",
"outputs": [],
"execution_count": null,
"source": [
" from skrf.vi.vna.keysight import PNA\n",
"from skrf import Frequency\n",
"from skrf.vi.vna.keysight import PNA\n",
"from skrf.vi.vna.nanovna import NanoVNAv2\n",
"\n",
"# Keysight PNA over ethernet\n",
"instr = PNA(address=\"TCPIP0::10.0.0.5::INSTR\")\n",
"ch1 = instr.ch1\n",
"\n",
" instr = PNA(address=\"TCPIP0::10.0.0.5::INSTR\")\n",
" print(instr.id)"
"# NanoVNA V2 over USB\n",
"instr = NanoVNAv2(\"ASRL/dev/ttyACM0::INSTR\") # Linux\n",
"instr = NanoVNAv2(\"ASRL1::INSTR\") # Windows\n",
"ch1 = instr # the NanoVNA does not support channels\n",
"\n",
"print(instr.id)"
]
},
{
Expand All @@ -114,61 +138,60 @@
]
},
{
"cell_type": "markdown",
"metadata": {},
"cell_type": "code",
"outputs": [],
"execution_count": null,
"source": [
" from skrf.vi.vna.keysight import PNA\n",
" from skrf import Frequency\n",
"\n",
" instr = PNA(address=\"TCPIP0::10.0.0.5::INSTR\")\n",
" freq = Frequency(start=\"2.3 GHz\", stop=\"2.6 GHz\", npoints = 451, unit='hz')\n",
"\n",
" instr.ch1.frequency = freq"
"freq = Frequency(start=1, stop=2, npoints = 101, unit=\"GHz\") # create frequency object\n",
"ch1.frequency = freq # apply frequency"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Creating an S21 measurement on the instrument"
]
"source": "### Creating measurements on the instrument"
},
{
"cell_type": "markdown",
"metadata": {},
"cell_type": "code",
"outputs": [],
"execution_count": null,
"source": [
" from skrf.vi.vna.keysight import PNA\n",
"\n",
" instr = PNA(address=\"TCPIP0::10.0.0.5::INSTR\")\n",
" instr.ch1.create_measurement(name=\"SKRF S21\", parameter=\"S21\")"
"# not supported on NanoVNA\n",
"ch1.create_measurement(name=\"Temp S11\", parameter=\"S11\")\n",
"ch1.create_measurement(name=\"Temp S22\", parameter=\"S22\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": "### Getting a 2-port network and plotting"
},
{
"metadata": {},
"cell_type": "code",
"outputs": [],
"execution_count": null,
"source": [
"### Getting a full 2-port network and plotting"
"ntwk = ch1.get_snp_network(ports=(1,2))\n",
"ntwk.plot_s_db()"
]
},
{
"metadata": {},
"cell_type": "markdown",
"source": "### Deleting measurements on the instrument"
},
{
"metadata": {},
"cell_type": "code",
"outputs": [],
"execution_count": null,
"source": [
" from skrf.vi.vna.keysight import PNA\n",
"\n",
" instr = PNA(address=\"TCPIP0::10.0.0.5::INSTR\")\n",
"\n",
" # Here we create temporary S11 and S22 to make sure ports 1 and 2 are driven\n",
" # This might change at some point to having get_snp_network do this \n",
" # automatically in the background\n",
" instr.ch1.create_measurement(name=\"Temp S11\", parameter=\"S11\")\n",
" instr.ch1.create_measurement(name=\"Temp S22\", parameter=\"S22\")\n",
"\n",
" ntwk = instr.ch1.get_snp_network(ports=(1,2))\n",
" ntwk.plot_s_db()\n",
"\n",
" instr.ch1.delete_measurement(name=\"Temp S11\")\n",
" instr.ch1.delete_measurement(name=\"Temp S22\")"
"# not supported on NanoVNA\n",
"ch1.delete_measurement(name=\"Temp S11\")\n",
"ch1.delete_measurement(name=\"Temp S22\")"
]
}
],
Expand All @@ -195,6 +218,9 @@
"interpreter": {
"hash": "6e9ab46c0308d25f8ecf2297d605bcf30c0184a06f23fc8ad30aef47f26c08c0"
}
},
"nbsphinx": {
"execute": "never"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ testpaths = [
"doc/source/examples",
"doc/source/tutorials"
]
addopts = "--cov=skrf --ignore-glob='*.ipynb_checkpoints'"
addopts = "--cov=skrf --ignore-glob='*.ipynb_checkpoints' --ignore=doc/source/tutorials/VirtualInstruments.ipynb"
norecursedirs = [
"skrf/src",
"doc/source/examples/instrumentcontrol"
Expand Down
2 changes: 0 additions & 2 deletions skrf/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
one_port_2_two_port
n_oneports_2_nport
four_oneports_2_twoport
three_twoports_2_threeport
n_twoports_2_nport
concat_ports
Expand Down Expand Up @@ -6016,7 +6015,6 @@ def four_oneports_2_twoport(s11: Network, s12: Network, s21: Network, s22: Netwo
See Also
--------
n_oneports_2_nport
three_twoports_2_threeport
"""
return n_oneports_2_nport([s11, s12, s21, s22], *args, **kwargs)

Expand Down
1 change: 0 additions & 1 deletion skrf/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
plot_minmax_bounds_s_time_db
plot_uncertainty_bounds_component
plot_uncertainty_bounds_s
plot_uncertainty_bounds_s_db
plot_uncertainty_bounds_s_time_db
Expand Down

0 comments on commit 452ee10

Please sign in to comment.