.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/tutorials/tuto_plot_basic.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_tutorials_tuto_plot_basic.py: Getting started: 5 minutes tutorial for `tofu` ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This is a tutorial that aims to get a new user a little familiar with tofu's structure. .. GENERATED FROM PYTHON SOURCE LINES 8-13 .. code-block:: default # The following imports matplotlib, preferably using a # backend that allows the plots to be interactive (Qt5Agg). import numpy as np .. GENERATED FROM PYTHON SOURCE LINES 14-17 We start by loading `tofu`. You might see some warnings at this stage since optional modules for `tofu` could be missing on the machine you are working on. This can be ignored safely. .. GENERATED FROM PYTHON SOURCE LINES 17-21 .. code-block:: default import tofu as tf .. GENERATED FROM PYTHON SOURCE LINES 22-26 We can now create our first configuration. In `tofu` speak, a configuration is the geometry of the device and its structures. `tofu` provides pre-defined ones for your to try, so we're going to do just that: .. GENERATED FROM PYTHON SOURCE LINES 26-29 .. code-block:: default configB2 = tf.load_config("B2") .. GENERATED FROM PYTHON SOURCE LINES 30-31 The configuration can easily be visualized using the `.plot()` method: .. GENERATED FROM PYTHON SOURCE LINES 31-34 .. code-block:: default configB2.plot() .. image-sg:: /auto_examples/tutorials/images/sphx_glr_tuto_plot_basic_001.png :alt: WEST-V3 :srcset: /auto_examples/tutorials/images/sphx_glr_tuto_plot_basic_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none /home/lasofivec/tofu/tofu/geom/_def.py:127: MatplotlibDeprecationWarning: The set_window_title function was deprecated in Matplotlib 3.4 and will be removed two minor releases later. Use manager.set_window_title or GUI-specific methods instead. f.canvas.set_window_title(wintit) [, ] .. GENERATED FROM PYTHON SOURCE LINES 35-37 Since `tofu` is all about tomography, let's create a 1D camera and plot its output. .. GENERATED FROM PYTHON SOURCE LINES 37-53 .. code-block:: default cam1d = tf.geom.utils.create_CamLOS1D( config=configB2, pinhole=[3.4, 0, 0], sensor_nb=100, focal=0.1, sensor_size=0.1, orientation=[np.pi, 0, 0], Name="", Exp="", Diag="", ) # interactive plot cam1d.plot_touch() .. image-sg:: /auto_examples/tutorials/images/sphx_glr_tuto_plot_basic_002.png :alt: - - :srcset: /auto_examples/tutorials/images/sphx_glr_tuto_plot_basic_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none /home/lasofivec/miniconda3/envs/newtofu3/lib/python3.9/site-packages/numpy/core/fromnumeric.py:3208: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray. return asarray(a).size /home/lasofivec/tofu/tofu/geom/_plot.py:1412: MatplotlibDeprecationWarning: The set_window_title function was deprecated in Matplotlib 3.4 and will be removed two minor releases later. Use manager.set_window_title or GUI-specific methods instead. fig.canvas.set_window_title(wintit) /home/lasofivec/tofu/tofu/utils.py:3476: UserWarning: Not interactive backend!: - backend : agg (prefer Qt5Agg) - canvas : FigureCanvasAgg warnings.warn(msg) .. GENERATED FROM PYTHON SOURCE LINES 54-55 The principle is similar for 2D cameras. .. GENERATED FROM PYTHON SOURCE LINES 55-69 .. code-block:: default cam2d = tf.geom.utils.create_CamLOS2D( config=configB2, pinhole=[3.4, 0, 0], sensor_nb=100, focal=0.1, sensor_size=0.1, orientation=[np.pi, 0, 0], Name="", Exp="", Diag="", ) cam2d.plot_touch() .. image-sg:: /auto_examples/tutorials/images/sphx_glr_tuto_plot_basic_003.png :alt: - - :srcset: /auto_examples/tutorials/images/sphx_glr_tuto_plot_basic_003.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none /home/lasofivec/miniconda3/envs/newtofu3/lib/python3.9/site-packages/numpy/core/fromnumeric.py:3208: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray. return asarray(a).size /home/lasofivec/tofu/tofu/geom/_plot.py:1412: MatplotlibDeprecationWarning: The set_window_title function was deprecated in Matplotlib 3.4 and will be removed two minor releases later. Use manager.set_window_title or GUI-specific methods instead. fig.canvas.set_window_title(wintit) /home/lasofivec/tofu/tofu/utils.py:3476: UserWarning: Not interactive backend!: - backend : agg (prefer Qt5Agg) - canvas : FigureCanvasAgg warnings.warn(msg) .. GENERATED FROM PYTHON SOURCE LINES 70-75 What comes next is up to you! You could now play with the function parameters (change the cameras direction, refinement, aperture), with the plots (many are interactive) or create you own tomographic configuration. .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 6.412 seconds) .. _sphx_glr_download_auto_examples_tutorials_tuto_plot_basic.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: tuto_plot_basic.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: tuto_plot_basic.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_