.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/ex_02_probe_2d_probe_3d.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_ex_02_probe_2d_probe_3d.py: 2d and 3d Probes ---------------- This example shows how to manipulate a probe in 2d or 3d. .. GENERATED FROM PYTHON SOURCE LINES 9-10 Import .. GENERATED FROM PYTHON SOURCE LINES 10-17 .. code-block:: Python import numpy as np import matplotlib.pyplot as plt from probeinterface import Probe from probeinterface.plotting import plot_probe .. GENERATED FROM PYTHON SOURCE LINES 18-19 First, let's create one 2d probe with 24 contacts: .. GENERATED FROM PYTHON SOURCE LINES 19-33 .. code-block:: Python n = 24 positions = np.zeros((n, 2)) for i in range(n): x = i // 8 y = i % 8 positions[i] = x, y positions *= 20 positions[8:16, 1] -= 10 probe_2d = Probe(ndim=2, si_units='um') probe_2d.set_contacts(positions=positions, shapes='circle', shape_params={'radius': 5}) probe_2d.create_auto_shape(probe_type='tip') .. GENERATED FROM PYTHON SOURCE LINES 34-38 Let's transform it into a 3d probe. Here the axes are 'xz' so y will be 0 for all contacts. The shape of probe_3d.contact_positions is now (n_elec, 3) .. GENERATED FROM PYTHON SOURCE LINES 38-43 .. code-block:: Python probe_3d = probe_2d.to_3d(axes='xz') print(probe_2d.contact_positions.shape) print(probe_3d.contact_positions.shape) .. rst-class:: sphx-glr-script-out .. code-block:: none (24, 2) (24, 3) .. GENERATED FROM PYTHON SOURCE LINES 44-45 Note that all **"y"** coordinates are 0 .. GENERATED FROM PYTHON SOURCE LINES 45-49 .. code-block:: Python df = probe_3d.to_dataframe() df[['x', 'y', 'z']].head() .. raw:: html
x y z
0 0.0 0.0 0.0
1 0.0 0.0 20.0
2 0.0 0.0 40.0
3 0.0 0.0 60.0
4 0.0 0.0 80.0


.. GENERATED FROM PYTHON SOURCE LINES 50-51 The plotting function automatically displays the `Probe` in 3d: .. GENERATED FROM PYTHON SOURCE LINES 51-54 .. code-block:: Python plot_probe(probe_3d) .. image-sg:: /examples/images/sphx_glr_ex_02_probe_2d_probe_3d_001.png :alt: Probe - 24ch :srcset: /examples/images/sphx_glr_ex_02_probe_2d_probe_3d_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none (, ) .. GENERATED FROM PYTHON SOURCE LINES 55-56 We can create another probe lying on another plane: .. GENERATED FROM PYTHON SOURCE LINES 56-61 .. code-block:: Python other_3d = probe_2d.to_3d(axes='yz') plot_probe(other_3d) .. image-sg:: /examples/images/sphx_glr_ex_02_probe_2d_probe_3d_002.png :alt: Probe - 24ch :srcset: /examples/images/sphx_glr_ex_02_probe_2d_probe_3d_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none (, ) .. GENERATED FROM PYTHON SOURCE LINES 62-63 `Probe` can be moved and rotated in 3d: .. GENERATED FROM PYTHON SOURCE LINES 63-70 .. code-block:: Python probe_3d.move([0, 30, -50]) probe_3d.rotate(theta=35, center=[0, 0, 0], axis=[0, 1, 1]) plot_probe(probe_3d) plt.show() .. image-sg:: /examples/images/sphx_glr_ex_02_probe_2d_probe_3d_003.png :alt: Probe - 24ch :srcset: /examples/images/sphx_glr_ex_02_probe_2d_probe_3d_003.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.295 seconds) .. _sphx_glr_download_examples_ex_02_probe_2d_probe_3d.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: ex_02_probe_2d_probe_3d.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: ex_02_probe_2d_probe_3d.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: ex_02_probe_2d_probe_3d.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_