diff --git a/.gitignore b/.gitignore index b6b2f1fd8..a94e3bed3 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,8 @@ *.c *.cpp *.nfs* + +# annotated files tofu/geom/*.html # No images @@ -38,22 +40,19 @@ dist/ tofu.egg-info/ build/ -#Notes_Upgrades/ - # Tex files *.aux *.log -# .gitignore -1 -Introduction -computing -Details +# coverage output .coverage # Include travis !.travis.yml +# no precommit configurations +.pre-commit-config.yaml + # installation dir usr/ diff --git a/doc/Makefile b/doc/Makefile index d4d543162..2327611a5 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -5,7 +5,7 @@ SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = -BUILDDIR = build +BUILDDIR = ../../test_doc/tofu # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 @@ -39,12 +39,12 @@ help: @echo " doctest to run all doctests embedded in the documentation (if enabled)" clean: - -rm -rf $(BUILDDIR)/* - + rm -rf $(BUILDDIR)/* + rm -rf source/auto_examples/ html: - $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR) @echo - @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." + @echo "Build finished. The HTML pages are in $(BUILDDIR)." dirhtml: $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml diff --git a/doc/source/Auto_tofu.geom.rst b/doc/source/Auto_tofu.geom.rst deleted file mode 100644 index 39547abef..000000000 --- a/doc/source/Auto_tofu.geom.rst +++ /dev/null @@ -1,28 +0,0 @@ -.. role:: envvar(literal) -.. role:: command(literal) -.. role:: file(literal) -.. role:: ref(title-reference) -.. _overview: - -**tofu.geom** -============== - -.. automodule:: tofu.geom - :members: - - -Indices and tables ------------------- -* Homepage_ -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` - -.. _Homepage: index.html - - - -.. Local Variables: -.. mode: rst -.. End: - diff --git a/doc/source/Auto_tofu.pathfile.rst b/doc/source/Auto_tofu.pathfile.rst deleted file mode 100644 index 08fb4fd31..000000000 --- a/doc/source/Auto_tofu.pathfile.rst +++ /dev/null @@ -1,28 +0,0 @@ -.. role:: envvar(literal) -.. role:: command(literal) -.. role:: file(literal) -.. role:: ref(title-reference) -.. _overview: - -**tofu.pathfile** -================= - -.. automodule:: tofu.pathfile - :members: - - -Indices and tables ------------------- -* Homepage_ -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` - -.. _Homepage: index.html - - - -.. Local Variables: -.. mode: rst -.. End: - diff --git a/doc/source/Auto_tofu.plugins.AUG.rst b/doc/source/Auto_tofu.plugins.AUG.rst deleted file mode 100644 index fbbe47ba9..000000000 --- a/doc/source/Auto_tofu.plugins.AUG.rst +++ /dev/null @@ -1,43 +0,0 @@ -.. role:: envvar(literal) -.. role:: command(literal) -.. role:: file(literal) -.. role:: ref(title-reference) -.. _overview: - -**AUG** -======= - - -**AUG.Ves** ------------ - -.. automodule:: tofu.plugins.AUG.Ves - :members: - - -**AUG.SXR.geom** ----------------- - -.. automodule:: tofu.plugins.AUG.SXR.geom - :members: - - -**AUG.SXR.data** ----------------- -.. automodule:: tofu.plugins.AUG.SXR.data - :members: - - -Indices and tables ------------------- -* Homepage_ -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` - -.. _Homepage: index.html - - -.. Local Variables: -.. mode: rst -.. End: diff --git a/doc/source/Auto_tofu.plugins.ITER.rst b/doc/source/Auto_tofu.plugins.ITER.rst deleted file mode 100644 index 2a3ce8669..000000000 --- a/doc/source/Auto_tofu.plugins.ITER.rst +++ /dev/null @@ -1,44 +0,0 @@ -.. role:: envvar(literal) -.. role:: command(literal) -.. role:: file(literal) -.. role:: ref(title-reference) -.. _overview: - -**ITER** -=============================== - - -**ITER.Ves** ------------- - -.. automodule:: tofu.plugins.ITER.Ves - :members: - -**ITER.Struct** ---------------- - -.. automodule:: tofu.plugins.ITER.Struct - :members: - - -**ITER.Bolo.geom** ------------------- - -.. automodule:: tofu.plugins.ITER.Bolo.geom - :members: - - - -Indices and tables ------------------- -* Homepage_ -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` - -.. _Homepage: index.html - - -.. Local Variables: -.. mode: rst -.. End: diff --git a/doc/source/Auto_tofu.plugins.rst b/doc/source/Auto_tofu.plugins.rst deleted file mode 100644 index 3bca24afa..000000000 --- a/doc/source/Auto_tofu.plugins.rst +++ /dev/null @@ -1,48 +0,0 @@ -.. role:: envvar(literal) -.. role:: command(literal) -.. role:: file(literal) -.. role:: ref(title-reference) -.. _overview: - -**tofu.plugins** -================ - - -In an effort to adapt ToFu to several experiments and ensure a smooth use for non-specialists users, plugins can be developped to adapt ToFu to the local specificities of each laboratory or environment (local computer systems and networks, local geometry and nomenclature, local data storing systems...). - -While ToFu in itself is open-source, the plugins, which concentrate everything that is machine-specific, are writen on demand and customized for the local needs, they remain on the local servers and are not provided on the GitHub page of ToFu. It is via the laboratories that you may have access to them. - -The following plugins have been / are being developped: - -Machine-oriented plugins ------------------------- - -.. toctree:: - :maxdepth: 1 - - Auto_tofu.plugins.AUG - Auto_tofu.plugins.ITER - - -Code-oriented plugins ---------------------- - -1. CAID_ - -.. _CAID: https://www.qwant.com/web - - - -Indices and tables ------------------- -* Homepage_ -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` - -.. _Homepage: index.html - - -.. Local Variables: -.. mode: rst -.. End: diff --git a/doc/source/Auto_tofu.treat.rst b/doc/source/Auto_tofu.treat.rst deleted file mode 100644 index d8536b49d..000000000 --- a/doc/source/Auto_tofu.treat.rst +++ /dev/null @@ -1,28 +0,0 @@ -.. role:: envvar(literal) -.. role:: command(literal) -.. role:: file(literal) -.. role:: ref(title-reference) -.. _overview: - -**tofu.treat** -============== - -.. automodule:: tofu.treat - :members: - - -Indices and tables ------------------- -* Homepage_ -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` - -.. _Homepage: index.html - - - -.. Local Variables: -.. mode: rst -.. End: - diff --git a/doc/source/Dependencies.rst b/doc/source/Dependencies.rst deleted file mode 100644 index 135664f6e..000000000 --- a/doc/source/Dependencies.rst +++ /dev/null @@ -1,64 +0,0 @@ -.. role:: envvar(literal) -.. role:: command(literal) -.. role:: file(literal) -.. role:: ref(title-reference) - -Dependencies -============ - -ToFu uses the following generic packages: - -- python/2.7.3 -- ipython/1.1.0 -- dateutil/2.4.0 -- docutils/0.12.0 -- distribute/0.6.34 - - -Scientific computing and plotting: - -- numpy/1.9.1 -- scipy/0.15.1 -- matplotlib/1.2.1 -- polygon2 -- datetime - - -Some part of ToFu are coded using Cython, which requires Cython and a compiler: - -- cython/0.19.1 -- gcc/4.8 -- intel/14.0 - - -Testing: - -- nose/1.3.4 - - -Documentation: - -- pygments/1.5 - - -To be determined: - -- pyzmq/13.0.2 -- tornado/2.4.1 -- setuptools -- mdsplus/5.0_11 -- pip -- git/1.8.4 - - - - -Indices and tables ------------------- -* Homepage_ -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` - -.. _Homepage: index.html - diff --git a/doc/source/Todos.rst b/doc/source/Todos.rst deleted file mode 100644 index 98696dbc4..000000000 --- a/doc/source/Todos.rst +++ /dev/null @@ -1,34 +0,0 @@ -.. role:: envvar(literal) -.. role:: command(literal) -.. role:: file(literal) -.. role:: ref(title-reference) -.. _overview: - -**To do for contributors** -========================== - -This to do list includes aspects that require a few hours up to a few months of work. -Whenever possible, a link to a document describing the problem in details is provided. - - -Math and geometry: ------------------- -* Write a C routine for (very) fast computation of solid angle in non-trival cases using spherical geometry and write a python / cython wrapper (weeks) - - -Coding: -------- -* Parallelize (frist CPU then GPU) the key functions of the geometry module (months) -* Branch the meshing module to allow compatibility with CAID/Pigasus (months) -* Branch the matrix computation module for the same reason (months) -* Branch the inversion module for the same reason (months) - -Long term: ----------- -* Create a parallel library called ToFuG, which provides all ToFu functionalities through a GUI for each ToFu module (year) - - - -.. Local Variables: -.. mode: rst -.. End: diff --git a/doc/source/Tutorial_AUG.rst b/doc/source/Tutorial_AUG.rst deleted file mode 100644 index eee76d8cb..000000000 --- a/doc/source/Tutorial_AUG.rst +++ /dev/null @@ -1,63 +0,0 @@ -.. role:: envvar(literal) -.. role:: command(literal) -.. role:: file(literal) -.. role:: ref(title-reference) - -AUG-specific tutorial -===================== - -How to access the ToFu library ------------------------------- - -The plugin for ASDEX Upgrade (AUG) is hosted on the theory (Tok) clusters of the Max-Planck Institute for Plasma Physics (IPP) in Garching. -If you have an account in IPP, you can then connect to one of the tok clusters where the library is hosted, via the command: - ->>> ssh toki01 - -Enter your password and then you need to load the module in the terminal - ->>> module load tofu - -You may need to load other modules on which ToFu depends (see the dependencies_). - -.. _dependencies : Dependencies.html - -You can then start a ipython console and load the AUG plugin for ToFu: - ->>> import tofu.plugins.AUG as tfAUG - - -How to load existing geometry ------------------------------- - -You can now load the geometry that was already computed and stored for some diagnostics (only the Soft X-Ray diagnostic at this date). -In general loading the geometry means using a method of the plugin that will load and return a list of :class:`tofu.geom.GDetect` instances. -On AUG, each :class:`tofu.geom.GDetect` instance corresponds to a camera head. -Since the geometry (position, aperture size...) of each camera head may change in time (changes are sometimes implemented between experimental campaigns), you can specify a shot number and the plugin will return the latest geometry that was computed before that shot number (only a few have been computed so far, but more will come). - ->>> LGD = tfAUG.SXR.geom.load(shot=31801) - -This command returns a list of :class:`tofu.geom.GDetect` instances with the latest geometry computed before shot 31801. - - -How to load SXR data --------------------- - -the ToFu plugin for AUG also comes with a data loading and formatting routine. -In addition to a shot number and a time window, you can choose whether the data is returned as numpy arrays or as a ToFu-compatible object for data pre-treatment via the Tofu keyword argument. - ->>> pre = tfAUG.SXR.data.load(shot=30801, Dt=[2.,2.01], Method='SX', Tofu=True) - -This command will return the SXR data for shot 30801 in the [2.,2.01] s time window using diagnostic 'SX.' (instead of SSX), in the form of a ToFu-compatible object. -See the documentation of the method for more details. - - -Indices and tables ------------------- -* Homepage_ -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` - -.. _Homepage: index.html - diff --git a/doc/source/Tutorial_Geom_Advanced.rst b/doc/source/Tutorial_Geom_Advanced.rst deleted file mode 100644 index 7b4ba7d6d..000000000 --- a/doc/source/Tutorial_Geom_Advanced.rst +++ /dev/null @@ -1,102 +0,0 @@ -.. role:: envvar(literal) -.. role:: command(literal) -.. role:: file(literal) -.. role:: ref(title-reference) - -How to create a diagnostic geometry -==================================== - -It is the geometry module that provides all the necessary tools for creating a new diagnostic. -A diagnostic comprises a set of detectors (ToFu creates one object for each detector and you can then group them into a larger object to represent cameras). -Each detector is basically defined by its active surface, which should be a planar polygon, and by a set of optics through which it 'sees' the plasma. -The optics can be a converging spherical lens or an arbitrary number of apertures (of arbitrary shape). -Each detector is also assigned to a vessel, which defines the linear or toroidal volume in which the plasma can exist. - -The following guides you through the creation of these objects in the famous 'hello-world' example: - -To find out more about what you can do with the geometry module check out the advanced_ tutorial. - -.. _advanced: - -Creating a vessel ------------------ - -If a vessel object does not exist yet, you have to create one (otherwise you can just load it an existing one). -A vessel object is basically defined by a 2D simple polygon (i.e.: non self-intersecting), - - - - - - - - - - - - -**Open-source:** - ToFu is distributed under the very permissive MIT_ license, thus allowing free use, keeping in mind that neither the author nor any of the laboratories in which he worked can be held responsible for unwanted behaviour or results. - It is instead transparency that is considered for as a warranty of quality on the long-term. - - ToFu is hosted on github_. - -.. _MIT: https://opensource.org/licenses/MIT -.. _github: https://github.com/ - -**Versions:** - A list of the successive versions of ToFu, with a brief description can be found here_. - -.. _here: Versions.html - -**Dependences:** - ToFu uses the following python packages_. - -.. _packages: Dependencies.html - - -**Citing ToFu:** - If you decide to use ToFu for research and published results please acknowledge this work by citing_ the project. - -.. _citing: Citation.html - - -Contents: ---------- - -**Description of the library modules:** - -.. toctree:: - :maxdepth: 1 - - overview - -**Code documentation:** - -.. toctree:: - :maxdepth: 1 - - Auto_tofu.geom - Auto_tofu.plugins.AUG.SXR.geom - Auto_tofu.plugins.ITER.Bolo.geom - - -**Tutorials and how to's:** - * How to build a diagnostic geometry - Create apertures and detectors to test a new configuration, to apply ToFu to your own problems, to design a prospetive diagnostic... - * How to compute integrated signal from 2D or 3D synthetic emissivity - Use an already-existing diagnostic geometry in a synthetic diagnostic approach to solve the direct problem and compute the line Of Sight and / or Volume of Sight integrated signals from a simulated emissivity field that you provide as an input. - * How to compute tomographic inversions - Use existing diagnostic geometry and signals to solve the inverse problem and compute tomographic inversions using a choice of discretization basis functions and regularisation functionals. - * How to contribute (to do's) - - -Indices and tables -================== -* Homepage_ -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` - -.. _Homepage: index.html - diff --git a/doc/source/Tutorial_Geom_HowToCreateGeometry.rst b/doc/source/Tutorial_Geom_HowToCreateGeometry.rst deleted file mode 100644 index 4104db9ef..000000000 --- a/doc/source/Tutorial_Geom_HowToCreateGeometry.rst +++ /dev/null @@ -1,224 +0,0 @@ -.. role:: envvar(literal) -.. role:: command(literal) -.. role:: file(literal) -.. role:: ref(title-reference) - -How to create a diagnostic geometry -==================================== - -It is the geometry module that provides all the necessary tools for creating a new diagnostic. -A diagnostic comprises a set of detectors (ToFu creates one object for each detector and you can then group them into a larger object to represent cameras). -Each detector is basically defined by its active surface, which should be a planar polygon, and by a set of optics through which it 'sees' the plasma. -The optics can be a converging spherical lens or an arbitrary number of apertures (of arbitrary shape). -Each detector is also assigned to a vessel, which defines the linear or toroidal volume in which the plasma can exist. - -The following guides you through the creation of these objects in the famous 'hello-world' example: - -To find out more about what you can do with the geometry module check out the advanced_ tutorial. - -.. _advanced: Tutorial_Geom_Advanced.html - - -As a pre-requisite, let's load some basic useful libraries in a ipython session, as well as the geometry module of ToFu: - ->>> import numpy as np ->>> import matplotlib.pyplot as plt ->>> plt.ion() ->>> # tofu-specific ->>> import tofu.geom as tfg - - -Creating, plotting and saving a vessel --------------------------------------- - -If a vessel object does not exist yet, you have to create one (otherwise you can just load it an existing one). -A vessel object is basically defined by a 2D simple polygon (i.e.: non self-intersecting), that is then expanded linearly or toroidally depending on the desired configuration. -This polygon limits the volume available for the plasma, where the emissivity can be non-zero. It is typically defined by the inner wall in a tokamak. - -Let's define the polygon limiting the vessel as a circle with a divertor-like shape at the bottom: - ->>> # Define the center, radius and lower limit ->>> R0, Z0, rad, ZL = 2., 0., 1., -0.85 ->>> # Define the key points in the divertor region below ZL ->>> Div_R, Div_Z = [R0-0.2, R0, R0+0.2], [-1.2, -0.9, -1.2] ->>> # Find the angles corresponding to ZL and span the rest ->>> thet1 = np.arcsin((ZL-Z0)/rad) ->>> thet2 = np.pi - thet1 ->>> thet = np.linspace(thet1,thet2,100) ->>> # Assemble the polygon ->>> poly_R = np.append(R0+rad*np.cos(thet), Div_R) ->>> poly_Z = np.append(Z0+rad*np.sin(thet), Div_Z) ->>> # Plot for checking ->>> f, l, a = plt.figure(facecolor='w', figsize=(6,6)), plt.plot(poly_R, poly_Z), plt.axis('equal') - -.. figure:: figures_doc/Fig_Tutor_Geom_Basic_01.png - :height: 300px - :width: 300 px - :scale: 100 % - :alt: Polygon used for defining the vaccum vessel where the plasma may live - :align: center - - Polygon used for defining the vaccum vessel where the plasma may live - -Notice that the polygon does not have to be closed, ToFu will anyway check that and close it automatically if necessary - -Now let's feed this 2D polygon to the appropriate ToFu class and specify that it should be a toroidal type (if linear type is chosen, the length should be specified by the 'DLong' keyword argument). -ToFu also asks for a name to be associated to this instance, and an experiment ('Exp') and a shot number (useful when the same experiment changes geometry in time). - ->>> # Create a toroidal Ves instance with name 'World', associated to experiment 'Misc' (for 'Miscellaneous') and shot number 0 ->>> ves = tfg.Ves(Name='HelloWorld', Poly=[poly_R,poly_Z], Type='Tor', Exp='Misc', shot=0) - -Now the vessel instance is created. I provides you with several key attributes and methods (see :class:`~tofu.geom.Ves` for details). -Among them the Id attribute is itself a class instance that contains all useful information about this vessel instance for identification, saving... In particular, that's where the name, the default saving path, the Type, the experiment, the shot number... are all stored. -A default name for saving was also created that automatically includes not only the name you gave but also the module from which this instance was created (tofu.geom or tfg), the type of object, the experiment, the shot number... -This recommended default pattern is useful for quick identification of saved object, it is advised not to modify it. - ->>> print(ves.Id.SaveName) -TFG_VesTor_Misc_World_sh0 - -Now, we can simply visualise the created vessel by using the dedicated method (keyword argument 'Elt' specifies the elements of the instance we want to plot, typically one letter corresponds to one element, here we just want the polygon): - ->>> # Plot the polygon, by default in two projections (cross-section and horizontal) and return the list of axes ->>> Lax = ves.plot(element='P') - -.. figure:: figures_doc/Fig_Tutor_Geom_Basic_02.png - :height: 300px - :width: 600 px - :scale: 100 % - :alt: The created vessel instance, plotted in cross-section and horizontal projections - :align: center - - The created vessel instance, plotted in cross-section and horizontal projections - - -Since the vessel is an important object (it defines where the plasma can live), all the other ToFu objects rely on it. It is thus important that you save it so that it can be used by other ToFu objects when necessary. - ->>> ves.save(Path='./') - -This method will save the instance as a numpy compressed file (.npz), using the path and file name found in ves.Id.SavePath and ves.Id.SaveName. -While it is highly recommended to stick to the default value for the SaveName, but you can easily modify the saving path if you want by specifying it using keyword argument Path. - - - -Creating, plotting and saving structural elements and configurations ---------------------------------------------------------------------- - -Unlike the vessel, which is important for physics reasons, the structural elements that ToFu allows to create are purely for illustrative purposes. They are entirely passive and have no effect whatsoever on the computation of the volume of sight of the detectors or on the plasma volume and are just made available for illustrations. - -Like for a vessel, a structural element is mostly defined by a 2D polygon. If a vessel instance is provided, the type of the structural element (toroidal or linear) is automatically the same as the type of the vessel, otherwise the type must be specified. - -A configuration, short for geometrical configuration is a set of vessel, and structural elements. - ->>> # Define two polygons, one that does not enclose the vessel and one that does ->>> thet = np.linspace(0.,2.*np.pi,100) ->>> poly1 = [[2.5,3.5,3.5,2.5],[0.,0.,0.5,0.5]] ->>> poly2 = [R0+1.5*np.cos(thet),1.5*np.sin(thet)] ->>> # Create the structural elements with the appropriate ToFu class, specifying the experiment and a shot number for keeping track of changes ->>> s1 = tfg.PFC(Name='S1', Poly=poly1, Exp='Misc', shot=0) ->>> # now we create a structure that is not continuous along phi ->>> s2 = tfg.PFC(Name='S2', Poly=poly2, Exp='Misc', shot=0, Lim=[[0., np.pi], [np.pi/2.,np.pi*3./2.]]) ->>> # Creating a configuration with vessel and structures ->>> config = tf.geom.Config(Name="test", Exp="Misc", lStruct=[ves,s1,s2]) ->>> config.set_colors_random() # to see different colors ->>> config.plot() ->>> config.save() - -.. figure:: figures_doc/config_plot.png - :height: 300px - :width: 600 px - :scale: 100 % - :alt: The created structural elements, plotted over the structural elements on both projections - :align: center - - The created structural elements, plotted over the structural elements on both projections - - -It is not necessary for ToFu (since structural elements are used by no other objects) but for convenience you can save a structral element using the same save() method as for any other object. - - - -Creating apertures ------------------- - -An aperture is also mosly defined by a planar polygon, except that the polygon coordinates should be provided in 3D cartesian coordinates (even though the polygon is planar, it mey not live in the same plane as other apertures or as the detector). - -We can easily define two different polygons for two different apertures - ->>> # Define the planes in which they will live by a point (O) and a vector (n) ->>> O1, n1 = (3.0,0.00,0.52), (-1.,0.1,-0.9) ->>> O2, n2 = (2.9,0.01,0.48), (-1.,0.0,-1.0) ->>> # Compute local orthogonal basis vectors in the planes ->>> e11, e21 = np.cross(n1,(0.,0.,1.)), np.cross(n2,(0.,0.,1.)) ->>> e12, e22 = np.cross(e11,n1), np.cross(e21,n2) ->>> # Normalize ->>> e11, e12 = e11/np.linalg.norm(e11), e12/np.linalg.norm(e12) ->>> e21, e22 = e21/np.linalg.norm(e21), e22/np.linalg.norm(e22) ->>> # Implement the planar polygons 2D coordinates ->>> p1_2D = 0.005*np.array([[-1.,1.,1.,-1],[-1.,-1.,1.,1.]]) ->>> p2_2D = 0.01*np.array([[-1.,1.,1.,-1],[-1.,-1.,1.,1.]]) ->>> # Compute the 3D coordinates ->>> p1 = [O1[0] + e11[0]*p1_2D[0,:] + e12[0]*p1_2D[1,:], O1[1] + e11[1]*p1_2D[0,:] + e12[1]*p1_2D[1,:], O1[2] + e11[2]*p1_2D[0,:] + e12[2]*p1_2D[1,:]] ->>> p2 = [O2[0] + e21[0]*p2_2D[0,:] + e22[0]*p2_2D[1,:], O2[1] + e21[1]*p2_2D[0,:] + e22[1]*p2_2D[1,:], O2[2] + e21[2]*p2_2D[0,:] + e22[2]*p2_2D[1,:]] ->>> # Create the apertures, specifying also the diagnostic the apertures belong to ->>> a1 = tfg.Apert('A1', p1, Ves=ves, Exp='Misc', shot=0, Diag='misc') ->>> a2 = tfg.Apert('A2', p2, Ves=ves, Exp='Misc', shot=0, Diag='misc') ->>> # Plot them, both the polygon and the vector, with the associated vessel (using EltVes), in 3D ->>> Lax = a1.plot(Elt='PV', EltVes='P') ->>> Lax = a2.plot(Lax=Lax, Elt='PV') - -.. figure:: figures_doc/Fig_Tutor_Geom_Basic_04.png - :height: 300px - :width: 600 px - :scale: 100 % - :alt: The created apertures, plotted over the vessel on both projections - :align: center - - The created apertures, plotted over the vessel on both projections - -ToFu allows you to save the apertures, if you wish, but if you created then only to pass tem on to detectors, you can also skip saving them. Indeed, once the detector associated to these apertures is created, you will save the detector object instead, and ToFu will automatically store all information about the apertures (everything necessary to re-create them when loading the detector object). - - -Creating cameras ----------------- - -Creating 1D cameras - ->>> cam1d = tf.geom.utils.create_CamLOS1D(config=config, P=[3.,0,-0.5], N12=100, F=0.1, D12=0.1, angs=[np.pi,0,0], Name='', Exp='Misc', Diag='') ->>> cam1d.plot() ->>> cam1d.plot_touch() # for an interactive plot (helpful to see each LOS) - -.. figure:: figures_doc/cam1d_plot.png - :height: 300px - :width: 600 px - :scale: 100 % - :alt: Plot of a 1D Camera - :align: center - -.. figure:: figures_doc/cam1d_plot_touch.png - :scale: 70 % - :alt: Interactive plot of a 1D Camera - :align: center - -Creating 2D cameras. We are going to create a 2D camera with a slight rotation of the angles of sight to have a more tangential view of the tokamak and the structures. - ->>> cam2 = tf.geom.utils.create_CamLOS2D(config=config, P=[3.,0,-0.5], N12=100, F=0.1, D12=0.1, angs=[np.pi,0.2,0], Name='', Exp='Misc', Diag='') ->>> cam2.plot_touch() # also interactive ! click on the left plot and see for yourself! - -.. figure:: figures_doc/cam2d_plot_touch.png - :scale: 70 % - :alt: Interactive plot of a 2D Camera - :align: center - -Congratulations ! You completed the basic tutorial for getting started and creating your own geometry, take you time now to explore all the methods and attributes of the classes introduced in :mod:`tofu.geom`. - - - -Indices and tables ------------------- -* Homepage_ -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` - -.. _Homepage: index.html - diff --git a/doc/source/Tutorial_Geom_SynthDiag_Basic.rst b/doc/source/Tutorial_Geom_SynthDiag_Basic.rst deleted file mode 100644 index f3e4c6ceb..000000000 --- a/doc/source/Tutorial_Geom_SynthDiag_Basic.rst +++ /dev/null @@ -1,94 +0,0 @@ -.. role:: envvar(literal) -.. role:: command(literal) -.. role:: file(literal) -.. role:: ref(title-reference) - -How to compute integrated signal from synthetic emissivity -========================================================== - - -We are assuming here that you have access to an existing geometry (i.e. to :class:`~tofu.geom.Detect` or :class:`~tofu.geom.GDetect` objects that you or someone else created or that you can load). -It if is not the case you should first create the geometry you need, by following the basic_ geometry tutorial. - -.. _basic: Tutorial_Geom_HowToCreateGeometry.html - -We are also assuming that you have a code that can produce as output a simulated isotropic emissivity. Either directly or by spacial interpolation, you should be able to write a python function that computes an emissivity value in any arbitrary point inside the vessel volume. - - -As a prerequisite load the necessary modules: - ->>> import numpy as np ->>> import matplotlib.pyplot as plt ->>> plt.ion() ->>> # tofu-specific ->>> import tofu.pathfile as tfpf - - -Writing the input function --------------------------- - -In the following, all is done assuming **gd** is a :class:`~tofu.geom.GDetect` object, but the same would apply if it is just a :class:`~tofu.geom.Detect` object. -If the :class:`~tofu.geom.GDetect` object you want to use is not already existing in your session, you can load it (with its absolute path and file name) using the :meth:`tofu.pathfile.Open()` function or a dedicated plugin function. - -Instances of :class:`~tofu.geom.GDetect` have a method called :meth:`~tofu.geom.GDetect.calc_Sig()`, which takes as input **ff** a python function able to evaluate the emissivity value in any number of points provided in 3D cartesian coordinates. - -This function should obey the following constraints: - * It is a callable with one input argument and optionally keyword arguments - * The input argument is a (3,N) numpy.ndarray, where N is the number of points at which one wants to evaluate the emissivity, provided in 3D cartesian coordinates (X,Y,Z) - -Hence, suppose that we simulate a 2D (i.e.: invariant along the 3rd dimension) gaussian emissivity centered on point (2.,0.), we can define ff as - ->>> def ff(Pts, A=1., DR=1., DZ=1.): ->>> R = np.hypot(Pts[0,:],Pts[1,:]) ->>> Z = Pts[2,:] ->>> Emiss = A*np.exp(-(R-2.)**2/DR**2 - (Z-0.)**2/DZ**2) ->>> return Emiss - -What will happen when we feed ff to :meth:`~tofu.geom.GDetect.calc_Sig()` depends on the choice of method for the integration: - * If we want a volumic integration, the VOS of each detector will be discretized and ff will be called to evaluate the emissivity at each point before perfoming the integration - * If a Line Of Sight integration is desired, only the LOS is discretized for integration and the result is multiplied by the etendue - -By default, the method uses a pre-computed discretization of the VOS (because re-computing the solid angle for each point every time is costly), but this feature can be suppressed by setting PreComp=False if you want to use customized integration parameters. -For example, in both cases, the numerical integration can be done by choosing the resolution of the discretization, or by using an iterative algorithm that only stops when the required relative error on the integral value is reached. -In our case: - ->>> # Compute synthetic signal using a volume approach with resolution-fixed numerical integration method ->>> sigVOS, ldet = gd.calc_Sig(ff, extargs={'A':1.,'DR':1.,'DZ':1.}, Method='Vol', Mode='simps', PreComp=False) ->>> sigLOS, ldet = gd.calc_Sig(ff, extargs={'A':1.}, Method='LOS', Mode='quad', PreComp=False) ->>> print sigVOS, sigLOS -[[ 1.31675917e-06 1.40620027e-06]] [[ 1.31408026e-06 1.39941326e-06]] - -Notice that when using the 'quad' numerical integration method, only one extra argument can be passed on to ff. -Notice the small differences in the volume and LOS approaches, due to the small non-zero second derivative of the emissivity field and to boundary effects (where there is small partial obstruction of the VOS). - - -If your code gives a tabulated emissivity field ------------------------------------------------ - -Then you simply have to include an intermediate function that interpolates your emissivity field to compute it at any point. Like in the following example: - ->>> def ff(Pts): ->>> R = np.hypot(Pts[0,:],Pts[1,:]) ->>> Z = Pts[2,:] ->>> Emiss = ff_interp(R,Z) ->>> return Emiss - -Where ff_interp() is an interpolating function using tabulated output from your code. - -Plotting the result -------------------- - -The :meth:`~tofu.geom.GDetect.plot_Sig()` method provides a way of plotting the result, either by feeding it the output signal of :meth:`~tofu.geom.GDetect.calc_Sig()` or directly **ff** (in which case it simply calls :meth:`~tofu.geom.GDetect.plot_Sig()` for you). -This feature is only available for :class:`~tofu.geom.GDetect` objects since the signal of a single detector is just a single value that does not really require plotting... - - - -Indices and tables ------------------- -* Homepage_ -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` - -.. _Homepage: index.html - diff --git a/doc/source/Tutorial_ITER.rst b/doc/source/Tutorial_ITER.rst deleted file mode 100644 index ad5247d2e..000000000 --- a/doc/source/Tutorial_ITER.rst +++ /dev/null @@ -1,53 +0,0 @@ -.. role:: envvar(literal) -.. role:: command(literal) -.. role:: file(literal) -.. role:: ref(title-reference) - -ITER-specific tutorial -====================== - -How to access the ToFu library ------------------------------- - -The plugin for ITER is hosted on the theory (Tok) clusters of the Max-Planck Institute for Plasma Physics (IPP) in Garching. -If you have an account in IPP, you can then connect to one of the tok clusters where the library is hosted, via the command: - ->>> ssh toki01 - -Enter your password and then you need to load the module in the terminal - ->>> module load tofu - -You may need to load other modules on which ToFu depends (see the dependencies_). - -.. _dependencies : Dependencies.html - -You can then start a ipython console and load the AUG plugin for ToFu: - ->>> import tofu.plugins.ITER as tfITER - - -How to load existing geometry ------------------------------- - -You can now load the geometry that was already computed and stored for some diagnostics (only the Soft X-Ray diagnostic at this date). -In general loading the geometry means using a method of the plugin that will load and return a list of :class:`tofu.geom.GDetect` instances. -On AUG, each :class:`tofu.geom.GDetect` instance corresponds to a camera head. -Since the geometry (position, aperture size...) of each camera head may change in time (changes are sometimes implemented between experimental campaigns), you can specify a shot number and the plugin will return the latest geometry that was computed before that shot number (only a few have been computed so far, but more will come). - ->>> LGD = tfAUG.SXR.geom.load(shot=31801) - -This command returns a list of :class:`tofu.geom.GDetect` instances with the latest geometry computed before shot 31801. - - - - -Indices and tables ------------------- -* Homepage_ -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` - -.. _Homepage: index.html - diff --git a/doc/source/Versions.rst b/doc/source/Versions.rst deleted file mode 100644 index 65b56bd46..000000000 --- a/doc/source/Versions.rst +++ /dev/null @@ -1,36 +0,0 @@ -.. role:: envvar(literal) -.. role:: command(literal) -.. role:: file(literal) -.. role:: ref(title-reference) - -Versions of ToFu: -================= - -Many versions of ToFu have been developped before reaching a stable and somewhat satisfactory state. Several versions were already used for producing physcis results and tomographic inversions before the open-source release, which requires documentation and a certain degree of user-friendlyness, thus more work. - -The versioning convention used by ToFu is semantic_ versioning and the module metadata is implemented according to PEP426_. - -.. _semantic: http://semver.org/ -.. _PEP426: https://www.python.org/dev/peps/pep-0426/ - - -The following only lists the versions advanced enough for release: - -* **1.1.0** (default) - This is the first version released in open-source, it only includes the geometry module (for diagnostic designing and synthetic diagnostic) and the pre-treatment module (for data handling) - - - - - - - -Indices and tables ------------------- -* Homepage_ -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` - -.. _Homepage: index.html - diff --git a/doc/source/aboutus.rst b/doc/source/aboutus.rst new file mode 100644 index 000000000..0372f55e4 --- /dev/null +++ b/doc/source/aboutus.rst @@ -0,0 +1,49 @@ +======== +About us +======== + +---------------- + +.. note:: + If you decide to use **tofu** for research and published results please + acknowledge this work by citing_ the project. + +.. _citing: citation.html + +------- +History +------- + +**ToFu** (TOmography for FUsion) is an open-source python library first created +at the Max-Planck Institute for Plasma Physics (IPP) in Garching (Germany) by +Didier Vezinet (as a postdoc) through the years 2014-2016. +It is continuously maintained, debugged and upgraded to this day. + +.. + Authors + +.. include:: authors.rst + +----------- +Contact us +----------- + +If you found a bug in **tofu**, or if you a suggestion, the best is to open +an issue directly on our `github page `_. + +If you want to chat, join our `gitter chat `_. + + +------- +License +------- + +**tofu** is distributed under the very permissive MIT license, thus allowing +free use, keeping in mind that neither the author nor any of the laboratories +in which he worked can be held responsible for unwanted behaviour or results. +It is instead transparency, reproducibility and incremental improvements that +guarantee quality on the long-term. + +--------- + +.. include:: ../../LICENSE.txt diff --git a/doc/source/authors.rst b/doc/source/authors.rst new file mode 100644 index 000000000..c8448659e --- /dev/null +++ b/doc/source/authors.rst @@ -0,0 +1,9 @@ +-------- +Authors +-------- + +* Didier Vezinet (creator) +* Laura S. Mendoza (developper since 2018) +* Florian Le Bourdais +* Jorge Morales +* Arpan Khandelwal diff --git a/doc/source/Citation.rst b/doc/source/citation.rst similarity index 89% rename from doc/source/Citation.rst rename to doc/source/citation.rst index 7cf988cb7..13277ac0f 100644 --- a/doc/source/Citation.rst +++ b/doc/source/citation.rst @@ -3,7 +3,7 @@ .. role:: file(literal) .. role:: ref(title-reference) -Citing ToFu: +Citing ToFu ============ An article dedicated to describing ToFu and its capacities is in preparation, in the meantime please cite this one_ [#]_, which briefly describes it and uses it to present physics results. Since this paper may not present enough details for the interested reader, please also include a url pointing to this web-based documentation. @@ -17,7 +17,7 @@ An article dedicated to describing ToFu and its capacities is in preparation, in :: @article{0029-5515-56-8-086001, - author={D. Vezinet and V. Igochine and M. Weiland and Q. Yu and A. Gude and D. Meshcheriakov and M. Sertoli and the Asdex Upgrade + author={D. Vezinet and V. Igochine and M. Weiland and Q. Yu and A. Gude and D. Meshcheriakov and M. Sertoli and the Asdex Upgrade Team and the EUROfusion MST1 Team}, title={Non-monotonic growth rates of sawtooth precursors evidenced with a new method on ASDEX Upgrade}, journal={Nuclear Fusion}, @@ -27,15 +27,3 @@ An article dedicated to describing ToFu and its capacities is in preparation, in url={http://stacks.iop.org/0029-5515/56/i=8/a=086001}, year={2016}, } - - - -Indices and tables ------------------- -* Homepage_ -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` - -.. _Homepage: index.html - diff --git a/doc/source/columns.html b/doc/source/columns.html new file mode 100644 index 000000000..5812a32d7 --- /dev/null +++ b/doc/source/columns.html @@ -0,0 +1,22 @@ +
+
+
+
+

More about tofu

+

Who are we ? When was tofu created ? + Who are our collaborators ?

+ About us +
+
+
+
+
+
+

Tofu's history

+

History of all releases of tofu. + Learn what's new on the latest version

+ Releases +
+
+
+
diff --git a/doc/source/conf.py b/doc/source/conf.py index 447d16c11..68c38191d 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -10,16 +10,24 @@ # # All configuration values have a default; values that are commented out # serve to show the default. +import os +import sys +import tofu as tf +import sphinx_bootstrap_theme -import sys, os +# Getting tofu version +tf_version = tf.__version__[:3] +tf_release = tf.__version__[:5] # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. -# sys.path.insert(0, os.path.abspath('.')) -sys.path.insert(0, os.path.abspath('/afs/ipp-garching.mpg.de/home/d/didiv/Python/tofu/')) +sys.path.insert(0, os.path.abspath(".")) +sys.path.insert(0, os.path.abspath("../tofu/geom")) +sys.path.insert(0, os.path.abspath("../tofu/data")) +sys.path.insert(0, os.path.abspath("../tofu/dumpro")) -# -- General configuration ----------------------------------------------------- +# -- General configuration ---------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. # needs_sphinx = '1.0' @@ -27,42 +35,43 @@ # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.doctest', - 'sphinx.ext.napoleon', - 'sphinx.ext.intersphinx', - 'sphinx.ext.todo', - 'sphinx.ext.coverage', - 'sphinx.ext.mathjax', - 'sphinx.ext.ifconfig', - 'sphinx.ext.viewcode', - 'sphinx_gallery.gen_gallery' + "sphinx.ext.autodoc", + "sphinx.ext.doctest", + "sphinx.ext.napoleon", + "sphinx.ext.intersphinx", + "sphinx.ext.todo", + "sphinx.ext.coverage", + "sphinx.ext.mathjax", + "sphinx.ext.ifconfig", + "sphinx.ext.viewcode", + "sphinx_gallery.gen_gallery", ] # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ["_templates"] # The suffix of source filenames. -source_suffix = '.rst' +source_suffix = {".rst": "restructuredtext", + ".txt": "restructuredtext"} # The encoding of source files. # source_encoding = 'utf-8-sig' # The master toctree document. -master_doc = 'index' +master_doc = "index" # General information about the project. -project = u'tofu_doc' -copyright = u'2016, Didier VEZINET' +project = u"tofu" +copyright = u"2016, Didier VEZINET" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. -version = '1.1' +version = tf_version # The full version, including alpha/beta/rc tags. -release = '1.1.0' +release = tf_release # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -78,7 +87,7 @@ # directories to ignore when looking for source files. exclude_patterns = [] -# The reST default role (used for this markup: `text`) to use for all documents. +# The reST default role (used for this markup: `text`) to use for all documents # default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. @@ -93,13 +102,13 @@ # show_authors = False # The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' +pygments_style = "sphinx" # A list of ignored prefixes for module index sorting. # modindex_common_prefix = [] -# -- Napoleon settings --------------------------------------------------- +# -- Napoleon settings -------------------------------------------------------- napoleon_google_docstring = True napoleon_numpy_docstring = True @@ -112,23 +121,27 @@ napoleon_use_param = True napoleon_use_rtype = False -# -- Options for HTML output --------------------------------------------------- +# -- Options for HTML output -------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. -html_theme = 'default' # 'sphinx_rtd_theme' +html_theme = "bootstrap" # 'sphinx_rtd_theme' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. -# html_theme_options = {} +# html_theme_options = { +# "rightsidebar": "true", +# "relbarbgcolor": "black" +# } + # Add any paths that contain custom themes here, relative to this directory. -# html_theme_path = [] +html_theme_path = sphinx_bootstrap_theme.get_html_theme_path() # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". -html_title = 'tofu v1.1' +html_title = "tofu v" + tf_version # A shorter title for the navigation bar. Default is the same as html_title. # html_short_title = None @@ -145,8 +158,22 @@ # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] - +html_static_path = [] # "_static"] + +html_theme_options = { + "source_link_position": "footer", + "bootswatch_theme": "flatly", + "navbar_sidebarrel": False, + "bootstrap_version": "3", + "nosidebar": True, + "navbar_links": [ + ("Gallery", "auto_examples/index"), + ("Installation", "installation"), + ("About us", "aboutus"), + ("Versions", "releases"), + ("Code doc", "tofu"), + ], +} # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. # html_last_updated_fmt = '%b %d, %Y' @@ -156,7 +183,7 @@ # html_use_smartypants = True # Custom sidebar templates, maps document names to template names. -# html_sidebars = {} +html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. @@ -189,17 +216,17 @@ # html_file_suffix = None # Output file base name for HTML help builder. -htmlhelp_basename = 'tofu_docdoc' +htmlhelp_basename = "tofu_docdoc" -# -- Options for LaTeX output -------------------------------------------------- +# -- Options for LaTeX output ------------------------------------------------- latex_elements = { # The paper size ('letterpaper' or 'a4paper'). # 'papersize': 'letterpaper', - # The font size ('10pt', '11pt' or '12pt'). # 'pointsize': '10pt', - + # The font size ('10pt', '11pt' or '12pt'). + # 'pointsize': '10pt', # Additional stuff for the LaTeX preamble. # 'preamble': '', } @@ -207,8 +234,11 @@ # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ - ('index', 'tofu_doc.tex', u'tofu\\_doc Documentation', - u'Didier VEZINET', 'manual'), + ("index", + "tofu_doc.tex", + u"tofu\\_doc Documentation", + u"Didier VEZINET", + "manual") ] # The name of an image file (relative to this directory) to place at the top of @@ -232,28 +262,35 @@ # latex_domain_indices = True -# -- Options for manual page output -------------------------------------------- +# -- Options for manual page output ------------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). -man_pages = [ - ('index', 'tofu_doc', u'tofu_doc Documentation', - [u'Didier VEZINET'], 1) -] +man_pages = [("index", + "tofu_doc", + u"tofu_doc Documentation", + u"Didier VEZINET", + 1)] # If true, show URL addresses after external links. # man_show_urls = False -# -- Options for Texinfo output ------------------------------------------------ +# -- Options for Texinfo output ----------------------------------------------- # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - ('index', 'tofu_doc', u'tofu_doc Documentation', - u'Didier VEZINET', 'tofu_doc', 'One line description of project.', - 'Miscellaneous'), + ( + "index", + "tofu_doc", + u"tofu_doc Documentation", + u"Didier VEZINET", + "tofu_doc", + "Library for synthetic diagnostics and tomography for Fusion devices.", + "Miscellaneous", + ) ] # Documents to append as an appendix to all manuals. @@ -266,13 +303,13 @@ # texinfo_show_urls = 'footnote' -# -- Options for Epub output --------------------------------------------------- +# -- Options for Epub output -------------------------------------------------- # Bibliographic Dublin Core info. -epub_title = u'tofu_doc' -epub_author = u'Didier VEZINET' -epub_publisher = u'Didier VEZINET' -epub_copyright = u'2016, Didier VEZINET' +epub_title = u"tofu_doc" +epub_author = u"Didier VEZINET" +epub_publisher = u"Didier VEZINET" +epub_copyright = u"2016, Didier VEZINET" # The language of the text. It defaults to the language option # or en if the language is not set. @@ -310,10 +347,14 @@ # Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = {'http://docs.python.org/': None} +intersphinx_mapping = {"http://docs.python.org/": None} # sphinx-gallery configuration sphinx_gallery_conf = { - 'examples_dirs': '../../examples', # path to your example scripts - 'gallery_dirs': 'auto_examples', # path where to save gallery generated output + "examples_dirs": "../../examples", # path to your example scripts + "gallery_dirs": "auto_examples", # path to save gallery generated output } + + +def setup(app): + app.add_stylesheet("custom.css") # also can be a full URL diff --git a/doc/source/index.rst b/doc/source/index.rst index 920897c94..943865847 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -1,114 +1,108 @@ -.. tofu_doc documentation master file, created by - sphinx-quickstart on Tue Jul 26 17:00:43 2016. - You can adapt this file completely to your liking, but it should at least - contain the root `toctree` directive. - +================================ Welcome to tofu's documentation! ================================ -**ToFu** (TOmography for FUsion) is an open-source python library first created at the Max-Planck Institute for Plasma Physics (IPP) in Garching (Germany) by Didier Vezinet (as a postdoc) through the years 2014-2016. -It is continuously maintained, debugged and upgraded to this day. - -It aims at providing the fusion and plasma community with an object-oriented, transparent and documented tool for designing tomography diagnostics, computing synthetic signal (direct problem) as well as tomographic inversions (inverse problem). -It gives access to a full 3D description of the diagnostic geometry, thus reducing the impact of geometrical approximations on the direct and, most importantly, on the inverse problem. - -It is modular and generic in the sense that it was developed with the objective of being machine-independent, thus guaranteeing that it can be used for arbitrary geometries and with an arbitrary number of apertures for each detector. - - -**Open-source:** - ToFu is distributed under the very permissive MIT_ license, thus allowing free use, keeping in mind that neither the author nor any of the laboratories in which he worked can be held responsible for unwanted behaviour or results. - It is instead transparency, reproducibility and incremental improvements that guarantee quality on the long-term. - - ToFu is hosted on github_. - -.. _MIT: https://opensource.org/licenses/MIT -.. _github: https://github.com/ - -**Versions:** - A list of the successive versions of ToFu, with a brief description can be found here_. - -.. _here: Versions.html - -**Dependences:** - ToFu uses the following python packages_. - -.. _packages: Dependencies.html - - -**Citing ToFu:** - If you decide to use ToFu for research and published results please acknowledge this work by citing_ the project. - -.. _citing: Citation.html - -**Feedback - bug report - wish list** - To provide feedback on ToFu itself please use the github_ page. -.. _github: https://github.com/ - -To provide feedback on a specific plugin, please refer to that plugin's webpage where a contact will be indicated. - - -**Miscellaneous** - ToFu is tested with the nose_/1.3.4 library (not all methods are tested yet, in process...) - ToFu can be installed using the distutils_ library. -.. _nose: https://pypi.python.org/pypi/nose -.. _distutils: https://docs.python.org/2/distutils/ +**tofu** stands for **To**\mography for **Fu**\sion, it is an IMAS-compatible +open-source machine-independent python library +with non-open source plugins containing all machine-dependent routines. + +It aims at providing the **fusion** and **plasma** community with an object- +oriented, transparent and documented tool for designing +**tomography diagnostics**, computing **synthetic signal** (direct problem) +as well as **tomographic inversions** (inverse problem). It gives access to a +full 3D description of the diagnostic geometry, thus reducing the impact of +geometrical approximations on the direct and, most importantly, on the inverse +problem. + +**tofu** is relevant for all diagnostics integrating, in a finitie field of +view or along a set of lines of sight, a quantity (scalar or vector) for which +the plasma can be considered transparent (e.g.: light in the visible, UV, soft +and hard X-ray ranges, or electron density for interferometers). + +**tofu** is **command-line oriented**, for maximum flexibility and +scriptability. The absence of a GUI is compensated by built-in one-liners for +interactive plots. + +**tofu** is hosted on github_. + +.. _github: https://github.com/tofuproject/tofu + +.. + Adding thumbnails to some tutorials +.. raw:: html + +
+ Contents: --------- -**Description of the library structure:** +**Tutorials and how to's:** .. toctree:: :maxdepth: 1 - overview - auto_examples/index.rst + How to install tofu + All tutorials and examples + +* How to create / handle a diagnostic geometry + - Visit the basic_ tutorial for getting started: create, plot and save + your first configuration: a vessel and its structures; + - To know how to load a configuration and create 1D and 2D cameras, + see the cameras_ tutorial. +* How to compute integrated signal from 2D or 3D synthetic emissivity + - Visit the tutorial_ for getting started: load an already-existing + diagnostic geometry in a synthetic diagnostic approach to solve the direct + problem and compute the line Of Sight and / or Volume of Sight integrated + signals from a simulated emissivity field that you provide as an input. +* How to compute tomographic inversions (to do) + - Use existing diagnostic geometry and signals to solve the inverse problem + and compute tomographic inversions using a choice of discretization basis + functions and regularisation functionals. + How to contribute (todos_) + +.. _basic: auto_examples/tutorials/plot_create_geometry.html +.. _cameras: auto_examples/tutorials/plot_basic_tutorial.html +.. _tutorial: Tutorial_Geom_SynthDiag_Basic.html +.. _todos: Todos.html + **Code documentation:** -Notice that the main ToFu classes and methods have docstrings so you can access contextual help with the usual python syntax from a iython console (print .__doc__, or ?). +.. note:: + Main **tofu** classes and methods have docstrings so you can + access contextual help with the usual python syntax from a `ipython` console + (`print .__doc__`, or `?`). .. toctree:: - :maxdepth: 2 - :numbered: + :maxdepth: 1 :titlesonly: - - Auto_tofu.geom - Auto_tofu.treat - Auto_tofu.pathfile - Auto_tofu.plugins - -**Tutorials and how to's:** - * How to create / handle a diagnostic geometry - - Visit the basic_ tutorial for getting started: create, plot and save a vessel, apertures and detectors and group them - - Check out the complete set of detailed_ tutorials for more info on each of these aspects and on others. - * How to compute integrated signal from 2D or 3D synthetic emissivity - - Visit the tutorial_ for getting started: load an already-existing diagnostic geometry in a synthetic diagnostic approach to solve the direct problem and compute the line Of Sight and / or Volume of Sight integrated signals from a simulated emissivity field that you provide as an input. - * How to compute tomographic inversions (to do) - Use existing diagnostic geometry and signals to solve the inverse problem and compute tomographic inversions using a choice of discretization basis functions and regularisation functionals. - * How to contribute (todos_) - -.. _basic: Tutorial_Geom_HowToCreateGeometry.html -.. _detailed: Tutorial_Geom_Advanced.html -.. _tutorial: Tutorial_Geom_SynthDiag_Basic.html -.. _todos: Todos.html + tofu + tofu.geom + tofu.dumpro + tofu.data + tofu.dust -**Plugin-specific tutorials:** - * AUG_ : load the existing geometry, load data - * ITER_ : load existing geometry... -.. _AUG : Tutorial_AUG.html -.. _ITER : Tutorial_ITER.html +.. raw:: html + :file: columns.html -Indices and tables -================== -* Homepage_ -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` +---------------- .. _Homepage: index.html - diff --git a/doc/source/installation.rst b/doc/source/installation.rst new file mode 100644 index 000000000..2d61fad35 --- /dev/null +++ b/doc/source/installation.rst @@ -0,0 +1,7 @@ +.. _installation: + +Installing tofu +================ + +.. raw:: html + :file: installation_tabs_source.html diff --git a/doc/source/installation_tabs_source.html b/doc/source/installation_tabs_source.html new file mode 100644 index 000000000..009709f15 --- /dev/null +++ b/doc/source/installation_tabs_source.html @@ -0,0 +1,245 @@ + +
+
+

Installing tofu on Linux

+ This is a quick tutorial on how to install and use ToFu on Linux. +

Installing Anaconda

+

First thing first: get a python package manager.

+

We recommend Miniconda (light version of Anaconda, + but you can also work with Anaconda, pip + or another python package manager of your choice). +

+ +

Installing tofu

+

Now you only need to install tofu

+
$ conda install -c tofuproject tofu 
+

For testing tofu we recommend you also install ipython

+
$ conda install ipython 
+

You are all set, open an ipython console and try importing tofu.

+
$ ipython
+In [1]: import tofu as tf 
+

Now you can + follow a tutorial. +

+
+

Installing tofu on Mac OS X

+ This is a quick tutorial on how to install and use ToFu on Linux. +

Installing Anaconda

+

First thing first: get a python package manager.

+

We recommend Miniconda (light version of Anaconda, + but you can also work with Anaconda, pip + or another python package manager of your choice). +

+ +

Installing tofu

+

First install the dependencies

+
$ conda install pip cython numpy scipy ipython 
+

tofu is not (yet) packaged with anaconda so we need to install it + using pip

+
$ pip install tofu 
+

You are all set, open an ipython console and try importing tofu.

+
$ ipython
+In [1]: import tofu as tf 
+

Now you can + follow a tutorial. +

+
+

Installing tofu on Windows

+ This is a quick tutorial on how to install and use ToFu on Windows. +

Installing Anaconda

+

We will use Miniconda (light version of Anaconda, + but you can also work with Anaconda or another python package manager of + your choice) not only to install and manage the packages necessary for + installing ToFu, but also to have a working bash-like Terminal.

+ +

Creating a conda environment

+

We are going to create an environment specific for ToFu.

+
$ conda create -n tofu3 python=3.6 scipy numpy cython git
+$ conda activate tofu3
+$ conda install m2-base # Get some basic Linux/bash commands (ls, cd, mv, ...)
+

This creates a conda environment named "tofu3" and installs scipy, + numpy and cython. The second command activates this environment.

+

Get the repository

+
    +
  • Create a ssh public key and add it to your GitHub account: + follow this tutorial.
  • +
  • Go to ToFu's GitHub repository: here.
  • +
  • Click on "clone or download" and swith to the option "Use SSH". Copy the link.
  • +
  • Move to where you would like to install ToFu + $ cd some_path
  • +
  • $ git clone git@github.com:ToFuProject/tofu.git (make + sure you remember the path where you are installing, if you want to + install it into your home repository, just make sure to + cd ~ before the git clone...)
  • +
+

Installing ToFu

+
    +
  • Move to the tofu directory, probably: cd ~/tofu
  • +
  • Switch to the git branch you will be working on. + If you are just starting you probably want to start from the latest + develop branch: git checkout devel. If you are not + familiar with git take a look at + this tutorial (long) + or this short + one
  • +
  • Compile python setup.py build_ext --inplace
  • +
  • We suggest you installing python inside tofu/usr, + you will have to modify your $PYTHONPATH to include this + path. + + How to modify environment variables on Windows
  • +
  • python setup.py install --prefix=$TOFU_DIR\\usr
  • +
  • Make sure tests are running nosetests
  • +
+

Contribute

+

If you wish to contribute, you will probably need a text editor, you can use Visual Studio's editor.

+
+
+

Using tofu on a ITER cluster

+

If you have an ITER account, you can use + tofu directly from ITER Computing Cluster. + No need to install tofu !

+
    +
  • Ask for access to ITER servers, if you don't have them already.
  • +
  • For information about the cluster, see + + this link.
  • +
  • Open a new terminal and connect to server (see link above)
  • +
  • Create a new file in your $HOME directory, you can + name it load_tofu_modules.sh
  • +
  • Open it and add the following lines:
  • +
+
module refresh
+source /etc/profile.d/modules.sh # make sure you have the module environment
+module purge # unload any previously loaded modules
+module load IMAS/3.24.0-4.1.5 # for IMAS data base
+module load IPython/6.3.1-intel-2018a-Python-3.6.4 # for iPython
+module load PySide2/5.12.0-intel-2018a-Python-3.6.4
+module load ToFu/1.4.0-intel-2018a-Python-3.6.4 # Load tofu :)
+
    +
  • Convert it as an exectuable, from terminal: + chmod +x ~/load_tofu_modules.sh
  • +
  • Execute it: ./load_tofu_modules.sh
  • +
  • If you are going to use tofu often, you might want to add + the execution of the script to your .bash_profile + (or .bashrc file):
  • +
+
echo './load_tofu_modules.sh' >> .bash_profile
+

You are all set, open an ipython console and try importing tofu.

+
$ ipython
+In [1]: import tofu as tf
+

Now you can + follow a tutorial. +

+
+

Installing tofu as a developer or contributor

+ You found a bug, or you want to add something to the library ? + This tutorial will show you how to get the repository and the + first steps to contribute to the project. +

First steps

+

There are many tools and concepts to get familiar with when contributing + to an open-source python library. A good place to get started is + the + scikit-project. And here is a list of tools you should get familiar + with: +

    +
  • python: the main language of tofu +
  • ipython: powerful interactive shell for python, and + check this + tutorial
  • +
  • git, and the + + feature branch workflow
  • +
  • github: follow and watch our project +
  • A text editor: emacs, vim, sublime, or whichever you want +
+

+

Installing Anaconda

+

We will use Miniconda (light version of Anaconda, + but you can also work with Anaconda or another python package manager of + your choice) not only to install and manage the packages necessary for + installing ToFu, but also to have a working bash-like Terminal.

+ +

Creating a conda environment

+

We are going to create an environment specific for ToFu.

+
$ conda create -n tofu3 python scipy numpy cython git ipython
+$ conda activate tofu3
+

This creates a conda environment named "tofu3" and installs scipy, + numpy, git, ipython and cython. + The second command activates this environment.

+

Get the repository

+
    +
  • Create a ssh public key and add it to your GitHub account: + follow this tutorial.
  • +
  • Go to ToFu's GitHub repository: here.
  • +
  • Click on "clone or download" and swith to the option "Use SSH". Copy the link.
  • +
  • Move to where you would like to install ToFu + $ cd some_path
  • +
  • $ git clone git@github.com:ToFuProject/tofu.git + (make sure you remember the path where you are installing, + if you want to install it into your home repository, just make sure to + cd ~ before the git clone...)
  • +
+

Installing ToFu

+
    +
  • Move to the tofu directory, probably: cd ~/tofu
  • +
  • Switch to the git branch you will be working on. + If you are just starting you probably want to start from the + latest develop branch: git checkout devel. + If you are not familiar with git take a look at + this tutorial + (long) or this + short one
  • +
  • Compile python setup.py build_ext --inplace
  • +
  • Make sure tests are running nosetests
  • +
+

Contribute

+

If you wish to contribute, but don't know where to start, check + our open issues. + You can also read + this tutorial, on how to contribute to a github project. + Before modifying the code, you should create a new branch and switch to + it.

+
git checkout -b <theNameOfYourBranch> # probably IssueNumber eg. Issue123
+# change the source code
+git add <files you changed>
+git commit -m "[a tag] a message that explains what you changed"
+git push -u origin <theNameOfYourBranch>
+

Now you can open a pull request in our github page, + from your branch, theNameOfYourBranch to devel. We will review it, + comment it, and accept it. +

+
diff --git a/doc/source/overview.rst b/doc/source/overview.rst deleted file mode 100644 index 9b56cb6e4..000000000 --- a/doc/source/overview.rst +++ /dev/null @@ -1,86 +0,0 @@ -.. role:: envvar(literal) -.. role:: command(literal) -.. role:: file(literal) -.. role:: ref(title-reference) -.. _overview: - -**Overview** -============ - -(This project is not finalised yet, work in progress...) - - -**ToFu**, which stands for "TOmography for FUsion" is a python package (with parts in C/C++) providing all necessary tools for tomography diagnostics for the Fusion community, it is particularly relevant for X-ray and bolometer diagnostics on Tokamaks. On of the objectoves is to provide a common tool for tomographic inversions, with both accurate methods and enough flexibility to be easily adapted to any Tokamak and to the specific requirements of each user. The main language (Python) has been chosen for its open-source philosophy, for its object-oriented capacities, and for the good performance / flexibility ratio that it offers. The architecture of the **ToFu** package is intended to be modular to allow again for maximum flexibility and to facilitate customisation and evolutivity from the users. - -**ToFu**: provides in particular, but not only, the main following functionnalities : - - Using the 3D geometry of the diagnostic (positions of detectors and apertures are provided as inputs) to compute quantities of interest (e.g.: the optimal line of sight, the exact etendue..). This is done by the module ToFu_Geom. - - Building of a variable grid size mesh for spatial discretisation of the solution (i.e. emissivity field) on which B-splines of any degree can be added to serve as Local Basis Functions. This is done by the module ToFu_Mesh. - - Computing of the geometry matrix associated to a set of detectors and a set of basis functions, both with a full 3D approach or with a Line Of Sight (LOS) approximation. This is done by the module ToFu_MatComp, which uses both ToFu_Geom and ToFu_Mesh. - - Computing tomographic inversions based on the constructed geometry matrix and Phillips-Tikhonov inversion with a choice of objective functionals (among which first order and second order derivatives or Fisher information, and more to come). This is done by the module ToFu_Inv, which uses the matrix computed by ToFu_MatComp. - - Visualizing, exploring and interpreting the resulting inversions using a built-in Graphic User Interface. - -The joint use of a full 3D approach and of regular basis functions (B-splines) allows for advanced functionalities and flexibility, like in particular : - - Accurate computation of etendue and geometry matrix. - - Exact differential operators (provided sufficient degree of the basis function) instead of discretised operators (this feature and the previous one aim at improving the accuracy of tomographic inversions). - - Accurate description of toroidal-viewing detectors with potentially large viewing cones and for which the LOS approximation cannot be used. - - Making possible 3D inversions (provided the geometrical coverage of the plasma volume is sufficient, for example thanks to toroidal-viewing detectors). - - Enabling proper taking into acccount of anisotropic radiation (for example due to fast electrons due to disruptions). - -The **ToFu** package has built-in mesh and B-spline definitions, however, if used alone, it can only create and handle rectangular mesh (with variable grid size though). In order to allow for more optimised mesh and basis functions, the **ToFu** package is fully compatible with **Pigasus** (and **CAID**), which is a another Python package (with a Fortran core), which uses cutting-edge technologies from Computer-Assisted Design (CAD) to create optimised mesh (using Non-Unifrom - Rational B-Splines, or NURBS, curves) on which it can also add several different types of regular basis functions. It is a next-gen solution for optimisation of plasma-physics simulation codes. Hence, the final idea is that the same mesh and tools can be used for running CPU-expensive plasma physics simulations and, from their output, to compute the associated simulated measurements on any radiation diagnostics. This synthetic diagnostic approach is aimed at facilitating direct - comparisons between simulations and experimental measurements and at providing the community with flexible and cross-compatible tools to fit their needs. Plasma physics codes that are planning on using **Pigasus** in a near future include in particuler **JOREK** (in its **Django** version) and **GYSELA** (**SELALIB** in its next version). More information about **Pigasus** (lien), **JOREK** (lien) and **GYSELA** can be found on their respective pages. - -In order to avoid too much dependency issues, the **ToFu** package resorts to widely used Python libraries like scipy, numpy and matplotlib. Whenever it was possible, the idea was either to use a very common and accessible library or to have built-in methods doing the job. It can be run as a stand-alone on an offline computer (i.e.: on a laptop while travelling), in an online mode (using a central database on the internet) and with or without **Pigasus** (keeping in mind that only rectangular mesh can be created without it). - -For faster computation, some modules and/or methods are coded with Cython or Boost.Pyton. It is also intended to be MPI and OpenMP parallelized. - -The general architecture is briefly represented in the following figure: - -.. figure:: /figures_doc/Fig_Tutor_BigPicture_General.png - :height: 700px - :width: 1000px - :scale: 100 % - :alt: ToFu big picture - :align: center - - Modular architecture of ToFu, with its main modules. - -This general overview shows all the **ToFu** modules and their main functionnalities and dependancies. Particularly important are the modules **ToFu_Geom**, **ToFu_Mesh** and **ToFu_MatComp** which provide all necessary tools to pre-calculate the geometry matrix which is a key feature of the two main uses of **ToFu**. - -On the one hand, **ToFu** can be used as a synthetic diagnostic since from a simulated emissivity field it can compute the corresponding synthetic measurements for comparison with experimental measurements. This, as illustrated below, can be done in different ways depending on whether the simualted is used directly as a function, projected on a predefined mesh of the plasma volume, or if the simulated emissivity itself was computed on a mesh using the **Pigasus/CAID** code suite which is directly compatible with **ToFu**. These three possibilities are illustrated in the following figure: - -.. figure:: /figures_doc/Fig_Tutor_BigPicture_SynthDiag.png - :height: 700px - :width: 1000px - :scale: 100 % - :alt: ToFu big picture for synthetic diagnostics - :align: center - - Modular architecture of ToFu, with its main modules for synthetic diagnostics. - -On the other hand, **ToFu** can be used the other way around : use the experimental measurements to compute a reconstructed experimental emissivity field via a tomographic inversion, for comparisopn with a simulated emissivity field or simply for getting an idea of what the emissivity field looks like, which is illustrated in the following figure: - -.. figure:: /figures_doc/Fig_Tutor_BigPicture_Tomo.png - :height: 700px - :width: 1000px - :scale: 100 % - :alt: ToFu big picture for tomography - :align: center - - Modular architecture of ToFu, with its main modules for tomography. - -The following will go into further details regarding each module. - - -ToDo list: - - Rest of documentation, with relevant references (like :cite:Ingesson08FST) and figures - - Tutorial - - ToFu_Inv - - GUI (one for each module) - - Accelerate existing modules with Cython, Boost.Python + Parallelization - - Use it to do some physics at last !!! - - -.. Local Variables: -.. mode: rst -.. End: diff --git a/doc/source/release_notes/release_notes_140.txt b/doc/source/release_notes/release_notes_140.txt new file mode 100644 index 000000000..8c0773d68 --- /dev/null +++ b/doc/source/release_notes/release_notes_140.txt @@ -0,0 +1,41 @@ +What's new in 1.4.0 +-------------------- + +* All structures are now inherited from an abstract class (in tofu.geom) and are either of type: + - 'In': there can be plasma inside, they are empty structures (e.g.: Vessel) + - 'Out': there is only plasma outside, they are solid blocks (e.g.: PFC) + +* The Config (in tofu.geom) class handles all Struct instances and provides an easy way to manipulate / visualize the whoel tokamak + +* CamLOS1D and CamLOS2D (standing for 'Camera made of Lines of Sight, arranged in 1D or 2D) are subclasses of the abstract Rays class (in tofu.geom), they: + - provide an easy way to handle multiple Rays / LOS + - compute their intersections with the Struct instances (i.e.: detect vignetting, entry and exit points...) + - plot the LOS in pre-defined interactive figures (plot(), plot_touch() and plot_sinogram() methods) + - provide methods for computing : + the length of each LOS inside an user-provided polygon (e.g.: separatrix) + the distance to a 3D flat circle centered on the tokamak's vertical axis (e.g.magnetic axis) + the synthetic signal (i.e: the LOS-integrals of a user-provided scalar 2D or 3D emissivity field), and plot it using a DataCam1D or DataCam2D class + +* Many LOS-computing routines have been optimized and parallelized by Laura Mendoza using Cython, in particular but not only: + - computation of entry / exit points of each LOS for a large number of PFC / Struct (~ seconds for 1 million LOS and ~ 100 Struct) + - computation of the length of each LOS inside a Polygon (e.g.: separatrix) + - computation of the distance to a circle (e.g.: magnetic axis) + - computation of distance to closed polygons (e.g.: spearatrix) when the LOS passed outside of it + +* DataCam1D and DataCam2D and data-handling classes (in tofu.data), designed to handle data from CamLOS1D or CamLOS2D (i.e.: from 1D or 2D cameras), providing: + - data visualization pre-defined interactive matplotlib figures (plot(), plot_compare() and plot_combine() methods) + - basic data-treatment methods (time step and channel selection, interpolation, base signal substraction, fft, svd, ...) + - spectrogram and svd interactive plotting methods + +* DataCam1DSpectral and DataCam2D spectral (tofu.data) provide equivalent classes for handling data with a spectral resolution in addition coming from 1D or 2D cameras + +* Plasma2D (tofu.data) provides a class for handling multiple 1D (radial) and 2D (cross-section) plasma quantities profiles (Te, ne, rho, psi, zeff...) and: + - provides methods for easy plotting + - allows each quantity to depend on its own time and space references + - handles triangular meshes + - can exports to DataCam1D any 1D profile + +* imas2tofu is a new sub-package addressing imas / tofu interacing, it provides in particular: + - load_Config() : an easy way to load a Config instance from an ids dict provided by the user (from 'wall' ids) + - load_Plasma2D() : an easy way to load a Plasma2D instance from an ids dict provided by the user (from 'equilibrium, core_profile' and 'core_sources' idss) + - load_Diag() : an easy way to load a CamLOS1D instance from an ids dict provided by the user (from a diagnostic-specific ids, e.g.: 'bolometer', 'ece'...) diff --git a/doc/source/release_notes/release_notes_141.rst b/doc/source/release_notes/release_notes_141.rst new file mode 100644 index 000000000..3ad9c8380 --- /dev/null +++ b/doc/source/release_notes/release_notes_141.rst @@ -0,0 +1,291 @@ +==================== +What's new in 1.4.1 +==================== + +Summary +======= + +General +------- + +- All tofu object have overloaded **repr** method +- units tests improved, Continuous Integration more complete, several + bugs fixed +- More robust wndows pip installation +- More robust saving to .mat +- tofuplot and tofucalc now provide simple bash interfaces + +The geometry module is now more complete +---------------------------------------- + +- A Config class handles the tokamak geometry +- A CamLOS1D class handles arbitrary sets of LOS +- A CamLOS2D class handles 2D cameras approximated as a set of LOS +- Basic reflexions are taken into account +- Ray-tracing, LOS-campling and LOS-integration algorithls have been + accelerated and parallelized +- Several utility function implemented for easy instance creation and + useful geometrical computations +- The basics of a magnetic field-line tracing algorithm and plotting + routine have been implemented + +IMAS-interfacing +---------------- + +- More robust MultiIDSLoader class for IMAS interfacing +- Can import from IMAS and export as tofu classes +- Very flexible and customizable +- Some classes have a save\_to\_imas() method + +Next to come +------------ + +- Solid angles, solid angles, solid angles + +Detailed Changelog +================== + +Enhancements +------------ + +Geometry +~~~~~~~~ + +Algorithms to compute distance between LOS and a flux surfaces +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +- Compute distance between LOS and a circle (*+ vectorial version*) +- Test if a LOS and a circle are close to a epsilon (*+ vectorial + version*) +- Compute distance between LOS and VPoly (*+ vectorial version*) +- Test if a LOS and a VPoly are close to a epsilon (*+ vectorial + version*) +- Compute which LOS is closer to a VPoly +- Compute which VPoly is closer to a LOS + +Algorithms for discretization and sampling +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +- Optimization of discretization of 1D lines (simple + complex + version), 2D lines, 2D polygons +- Optimization of LOS sampling and all the different rules: + parallelized and using less memory. + +Calc signal (function integration over LOS): +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +- ``LOS_calc_signal`` now cythonized for isotropic and anisotropic + emissivity and several sampling / integration strategies + +Algorithms to check if visible +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +- Optimization ``LOS_isVis_PtFromPts_VesStruct`` checks if a point is + visible with respect to a list of points and taking into account a + vessel (with structures, limits, etc.) : function cythonized + properly, speed up ~50% +- ``LOS_areVis_PtsFromPts_VesStruct`` equivalent to last function but + input is a list of points +- ``Dust_calc_SolidAngle`` is now using new versions of above mentioned + functions + +Vignetting +^^^^^^^^^^ + +- Added functions to compute the 3d bounding box of a polygon in 3d + space +- Added functions for the triangulation of a polygon by earclipping +- Added function that tests if intersection between ray and triangle in + space +- Added functions for vignetting : for a set of rays and a sets of + polygons, test if the rays go through the polygons or not. + +Structures and Configuration +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +- ``tf.geom.Struct._get_phithetaproj()``: to get the (phi, theta) + limits in a project of each toroidal occurence of Struct, with + respect to a refpt in (R,Z) +- ``tf.geom.Struct._get_phithetaproj_dist()``: + get the distance +- ``tf.geom.dist._get_phithetaproj_dist()``: generalize to all Struct + of a Config +- Config has set\_colors\_random() + +Solid angles +^^^^^^^^^^^^ + +- Added ``_GG.Dust_calc_SolidAngle`` for computation of a solid angle + on dust particle (multi-pos, multi-pts, with and without vect, with + and without approx, with and without block) + +Basic Reflexions +^^^^^^^^^^^^^^^^ + +- Rays subclasses can now have added reflections + (self.add\_reflections()) +- Reflections can alos be extracted (instead of stored) as a list of + separated cameras using Rays.get\_reflections\_as\_cam() +- Reflections can be of type 'specular', 'diffusive' or 'ccube' +- The reflection type can be forced by the user (identical for all LOS + of a camera) or automatically set by the Structural elements each LOS + touches +- There can be any number of reflections +- Rays.plot() and Rays.plot\_touch() have been updated to properly + represent reflections +- Rays.calc\_signal() and Rays.calc\_signal\_from\_Plasma2D() have been + updated to account for reflections with a user-provided coefficient + +Cythonization +^^^^^^^^^^^^^ + +- Re wrote some numpy function to avoid over heading: hypothenus and + composition of minimum of hypotenus, minimum of vector, tile, + +Extra +^^^^^ + +- Erased *old* functions: + + - ``SLOW_LOS_Calc_PInOut_VesStruct`` + - ``Calc_LOS_PInOut_Lin`` + - ``Calc_LOS_PInOut_Tor`` + +- extract\_svd() now compatible with Py27 and Py36 +- Rays.dgeom['indout'][0,:] now refers to the global index of each + structure (as in config.lStruct) +- Operator overloading of \_\_\_\_repr\_\_\_\_ of all tofu objects with + attribute get\_summary() + +Cameras and visualization +~~~~~~~~~~~~~~~~~~~~~~~~~ + +- overloaded **add** operator to allow for easy CamLOS1D concatenation +- ``tf.geom.dist.plot_phithetaproj_dist()``: plot a static figure with + a place holder for time traces, the (phi,theta) projection (with + aspect ratio), the cross and hor Config projections and legend +- ``Rays.plot_touch()`` now handles: angles (wrote docstring) + +General +~~~~~~~ + +- get\_summary() is now a method of the AbstractToFuObject parent + class, implemented for Config, CamLOS1D, Plasma2D +- saving to .mat file is now more robust (operational) +- Added benchmarking for ``calc_signal`` + +IMAS interfacing +---------------- + +1. libraries that need imas2tofu are only imported if the **IMAS** + module is found (Warning not Error) + +2. **MultiIDSLoader** class now handles all imas interfacing: + +- allows for loading several ids from different idd +- dynamic printing of ids loading +- get\_summary() methods giving an overview of content +- provides a dictionary of shortcuts for fast typing of pre-recorded + imas signals +- provides dictionary of preset ids and signals +- Flexible instanciation, from idd of idd args, ids or ids args, open + or not, get or not +- provides add\_idd(), remove\_idd(), add\_ids(), remove\_ids() +- Include to\_Config(), to\_Plasma2D(), to\_Diag() to export to tofu + objects + +3. \*\*All stored in a single \_core.py\*\*: + +- MultiIDSLoader +- load\_Config(), load\_Plasma2D(), load\_Diag() + +4. **save\_to\_imas()** + +- Actual routines implemented in tf.imas2tofu.\_core +- methods implemented for Struct, Config, CamLOS1D + +5. Other + +- MultiIDSLoader now has calc\_signal() +- ids = 'magfieldlines' returns mag field line tracking from IMAS + equilibrium +- More robust / detailed sanity checks of triangular meshes from IMAS +- Synthetic data and experimental data are now time-synchronized +- Synthetic diag operational on WEST for interferometer, polarimeter, + bremsstrahlung and bolometers + +bash interface: +--------------- + +- tofuplot debugged +- tofucalc created + +Code structure and format +------------------------- + +Restructuring of the geometry modules +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Created Cython include files ``*.pxd`` and ``*.pyx`` for the following +group of functions: - ``_basic_geom_tools.*``: global variables +definition (``_VSMALL`` and ``_SMALL``), and basic geometric tools +(vector calculus, path distance point-point, point-vector,...) - +``_raytracing_tools.*``: for intersection of LOS and different objects +(bounding boxes, poly, surfaces, ...) - ``_distance_tools.*``: distance +between LOS and circle, VPoly and so on - ``_sampling_tools.*``: line, +LOS, poly, volume, and surface sampling + +Installation and portability +---------------------------- + +- Had to use some cpp tools, so had to update the ``setup.py`` +- Updated the ``setup.py`` to be able to "clean" an installation (erase + compilation files) +- Took out the possibility of not using cython, as this is now + impossible +- git dependency is now optional (issue #67 ) +- changes in ``setup.py`` for **Windows** portability +- Now only supporting ``Cython`` versions ``>=0.26`` +- Removed all **pandas** dependencies +- Using ``-O3`` flag instead of ``-O0`` for faster execution time even + if compilation is slower +- Removed all **Polygon** dependencies + +Unit test +--------- + +- Added unit tests for triangulations, and vignetting +- Added unit test for computation of kmin, kmax + ``LOS_Calc_kMinkMax_VesStruct`` +- Update of ``in _vessel`` tests +- Added tests for ``is_visble`` (vectorized and point wise) +- Now by default ``python setup.py nosetests`` with run with: verbose, + detailed erorrs, coverage (nose) and other utilities for debugging. + But most importantly **only tests in ``tofu/tofu/tests/`` will be + run**. +- Testing all get\_sample options in a short new unit test +- Testing all options for LOS\_calc\_signal (method of discretization, + of integration, steps relative, absolute, unique or changing for each + los, etc.). + +Update of documentation +----------------------- + +- Added documentation on how to install on Windows +- Updated, restructured and adde figures to README. Change of format + ``*.rst`` to ``*.md`` +- Updated Wiki pages on GitHub + +Bugs +---- + +- Found several small bugs in the function that computes for a list of + flux surfaces and a list of rays the kmin, kmax +- There was a bug in some special cases of 1D camera definition, when + all Ds are on a similar plane sharing the same D for the 2 first LOS, + solved +- There was a bug in tf.data.\ *plot*\ combine() (wrong graph), solved + (issue #65 ) +- There was another bug with plot\_combine() when several equilibria + were provided, the reference time was not properly defined + (short-term fix, on the long term issue #79 should fix it) + diff --git a/doc/source/releases.rst b/doc/source/releases.rst new file mode 100644 index 000000000..aec92da53 --- /dev/null +++ b/doc/source/releases.rst @@ -0,0 +1,8 @@ +Latest release +============== + +.. toctree:: + :maxdepth: 1 + + release_notes/release_notes_141.rst + release_notes/release_notes_140.txt diff --git a/doc/source/tofu.data.rst b/doc/source/tofu.data.rst new file mode 100644 index 000000000..a294cb363 --- /dev/null +++ b/doc/source/tofu.data.rst @@ -0,0 +1,54 @@ +tofu.data package +================= + +Submodules +---------- + +tofu.data.\_comp module +----------------------- + +.. automodule:: tofu.data._comp + :members: + :undoc-members: + :show-inheritance: + +tofu.data.\_core module +----------------------- + +.. automodule:: tofu.data._core + :members: + :undoc-members: + :show-inheritance: + +tofu.data.\_def module +---------------------- + +.. automodule:: tofu.data._def + :members: + :undoc-members: + :show-inheritance: + +tofu.data.\_physics module +-------------------------- + +.. automodule:: tofu.data._physics + :members: + :undoc-members: + :show-inheritance: + +tofu.data.\_plot module +----------------------- + +.. automodule:: tofu.data._plot + :members: + :undoc-members: + :show-inheritance: + + +Module contents +--------------- + +.. automodule:: tofu.data + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/tofu.dumpro.rst b/doc/source/tofu.dumpro.rst new file mode 100644 index 000000000..cdcc0331a --- /dev/null +++ b/doc/source/tofu.dumpro.rst @@ -0,0 +1,62 @@ +tofu.dumpro package +=================== + +Submodules +---------- + +tofu.dumpro.\_comp module +------------------------- + +.. automodule:: tofu.dumpro._comp + :members: + :undoc-members: + :show-inheritance: + +tofu.dumpro.\_comp\_clusters module +----------------------------------- + +.. automodule:: tofu.dumpro._comp_clusters + :members: + :undoc-members: + :show-inheritance: + +tofu.dumpro.\_core module +------------------------- + +.. automodule:: tofu.dumpro._core + :members: + :undoc-members: + :show-inheritance: + +tofu.dumpro.\_def module +------------------------ + +.. automodule:: tofu.dumpro._def + :members: + :undoc-members: + :show-inheritance: + +tofu.dumpro.\_draft module +-------------------------- + +.. automodule:: tofu.dumpro._draft + :members: + :undoc-members: + :show-inheritance: + +tofu.dumpro.\_plot module +------------------------- + +.. automodule:: tofu.dumpro._plot + :members: + :undoc-members: + :show-inheritance: + + +Module contents +--------------- + +.. automodule:: tofu.dumpro + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/tofu.dust.rst b/doc/source/tofu.dust.rst new file mode 100644 index 000000000..ec5e91793 --- /dev/null +++ b/doc/source/tofu.dust.rst @@ -0,0 +1,38 @@ +tofu.dust package +================= + +Submodules +---------- + +tofu.dust.\_comp module +----------------------- + +.. automodule:: tofu.dust._comp + :members: + :undoc-members: + :show-inheritance: + +tofu.dust.\_core module +----------------------- + +.. automodule:: tofu.dust._core + :members: + :undoc-members: + :show-inheritance: + +tofu.dust.\_plot module +----------------------- + +.. automodule:: tofu.dust._plot + :members: + :undoc-members: + :show-inheritance: + + +Module contents +--------------- + +.. automodule:: tofu.dust + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/tofu.geom.rst b/doc/source/tofu.geom.rst new file mode 100644 index 000000000..a9e81a053 --- /dev/null +++ b/doc/source/tofu.geom.rst @@ -0,0 +1,118 @@ +tofu.geom package +================= + +Submodules +---------- + +tofu.geom.\_GG module +--------------------- + +.. automodule:: tofu.geom._GG + :members: + :undoc-members: + :show-inheritance: + +tofu.geom.\_GG02 module +----------------------- + +.. automodule:: tofu.geom._GG02 + :members: + :undoc-members: + :show-inheritance: + +tofu.geom.\_GG03 module +----------------------- + +.. automodule:: tofu.geom._GG03 + :members: + :undoc-members: + :show-inheritance: + +tofu.geom.\_basic\_geom\_tools module +------------------------------------- + +.. automodule:: tofu.geom._basic_geom_tools + :members: + :undoc-members: + :show-inheritance: + +tofu.geom.\_comp module +----------------------- + +.. automodule:: tofu.geom._comp + :members: + :undoc-members: + :show-inheritance: + +tofu.geom.\_core module +----------------------- + +.. automodule:: tofu.geom._core + :members: + :undoc-members: + :show-inheritance: + +tofu.geom.\_def module +---------------------- + +.. automodule:: tofu.geom._def + :members: + :undoc-members: + :show-inheritance: + +tofu.geom.\_distance\_tools module +---------------------------------- + +.. automodule:: tofu.geom._distance_tools + :members: + :undoc-members: + :show-inheritance: + +tofu.geom.\_plot module +----------------------- + +.. automodule:: tofu.geom._plot + :members: + :undoc-members: + :show-inheritance: + +tofu.geom.\_raytracing\_tools module +------------------------------------ + +.. automodule:: tofu.geom._raytracing_tools + :members: + :undoc-members: + :show-inheritance: + +tofu.geom.\_sampling\_tools module +---------------------------------- + +.. automodule:: tofu.geom._sampling_tools + :members: + :undoc-members: + :show-inheritance: + +tofu.geom.\_vignetting\_tools module +------------------------------------ + +.. automodule:: tofu.geom._vignetting_tools + :members: + :undoc-members: + :show-inheritance: + +tofu.geom.utils module +---------------------- + +.. automodule:: tofu.geom.utils + :members: + :undoc-members: + :show-inheritance: + + +Module contents +--------------- + +.. automodule:: tofu.geom + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/tofu.rst b/doc/source/tofu.rst new file mode 100644 index 000000000..0ad09fb31 --- /dev/null +++ b/doc/source/tofu.rst @@ -0,0 +1,64 @@ +tofu package +============ + +Subpackages +----------- + +.. toctree:: + + tofu.data + tofu.dumpro + tofu.dust + tofu.geom + +Submodules +---------- + +tofu.\_plot module +------------------ + +.. automodule:: tofu._plot + :members: + :undoc-members: + :show-inheritance: + +tofu.defaults module +-------------------- + +.. automodule:: tofu.defaults + :members: + :undoc-members: + :show-inheritance: + +tofu.pathfile module +-------------------- + +.. automodule:: tofu.pathfile + :members: + :undoc-members: + :show-inheritance: + +tofu.utils module +----------------- + +.. automodule:: tofu.utils + :members: + :undoc-members: + :show-inheritance: + +tofu.version module +------------------- + +.. automodule:: tofu.version + :members: + :undoc-members: + :show-inheritance: + + +Module contents +--------------- + +.. automodule:: tofu + :members: + :undoc-members: + :show-inheritance: diff --git a/examples/README.rst b/examples/README.rst index 0a9253bdf..ee8e6c071 100644 --- a/examples/README.rst +++ b/examples/README.rst @@ -1,4 +1,4 @@ -`tofu` examples -=============== +**tofu** examples and tutorials +=============================== -This directory contains examples for `tofu`. \ No newline at end of file +This directory contains examples and tutorials for **tofu**. diff --git a/examples/tutorials/plot_basic_tutorial.py b/examples/tutorials/plot_basic_tutorial.py index 911facfe2..14b2b4a85 100644 --- a/examples/tutorials/plot_basic_tutorial.py +++ b/examples/tutorials/plot_basic_tutorial.py @@ -2,12 +2,16 @@ 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. +This is a tutorial that aims to get a new user a little familiar with tofu's + structure. """ +import matplotlib import matplotlib.pyplot as plt +matplotlib.use('Qt5Agg') ############################################################################### -# We start by loading `tofu`. You might see some warnings at this stage since optional modules for `tofu` could +# 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. import tofu as tf @@ -29,21 +33,39 @@ import numpy as np -cam1d = tf.geom.utils.create_CamLOS1D(config=configB2, - P=[3.4, 0, 0], - N12=100, F=0.1, D12=0.1, angs=[np.pi, 0, 0], - Name='', Exp='', Diag='') +cam1d = tf.geom.utils.create_CamLOS1D( + config=configB2, + P=[3.4, 0, 0], + N12=100, + F=0.1, + D12=0.1, + angs=[np.pi, 0, 0], + Name="", + Exp="", + Diag="", +) +# interactive plot cam1d.plot_touch() ############################################################################### # The principle is similar for 2D cameras. -cam2d = tf.geom.utils.create_CamLOS2D(config=configB2, P=[3.4, 0, 0], N12=100, F=0.1, D12=0.1, angs=[np.pi, 0, 0], - Name='', Exp='', Diag='') +cam2d = tf.geom.utils.create_CamLOS2D( + config=configB2, + P=[3.4, 0, 0], + N12=100, + F=0.1, + D12=0.1, + angs=[np.pi, 0, 0], + Name="", + Exp="", + Diag="", +) cam2d.plot_touch() ############################################################################### # 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. - +# 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. diff --git a/examples/tutorials/plot_create_geometry.py b/examples/tutorials/plot_create_geometry.py new file mode 100644 index 000000000..12306022b --- /dev/null +++ b/examples/tutorials/plot_create_geometry.py @@ -0,0 +1,160 @@ +""" +Creating your first Geometry +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This is a tutorial that shows you how to create a simple geometry. +""" + +import numpy as np +import matplotlib.pyplot as plt +import tofu.geom as tfg + + +############################################################################### +# Creating an empty Vessel +# ------------------------ +# +# If a vessel object does not exist yet, you have to create one (otherwise you +# can just load an existing one). +# A vessel object is basically defined by a 2D simple polygon +# (i.e.: non self-intersecting), that is then expanded linearly or toroidally +# depending on the desired configuration. +# This polygon limits the volume available for the plasma, where the emissivity +# can be non-zero. It is typically defined by the inner wall in a tokamak. +# +# Let's define the polygon limiting the vessel as a circle with a divertor-like +# shape at the bottom: + + +# Define the center, radius and lower limit +R0, Z0, rad, ZL = 2.0, 0.0, 1.0, -0.85 +# Define the key points in the divertor region below ZL +Div_R, Div_Z = [R0 - 0.2, R0, R0 + 0.2], [-1.2, -0.9, -1.2] +# Find the angles corresponding to ZL and span the rest +thet1 = np.arcsin((ZL - Z0) / rad) +thet2 = np.pi - thet1 +thet = np.linspace(thet1, thet2, 100) +# Assemble the polygon +poly_R = np.append(R0 + rad * np.cos(thet), Div_R) +poly_Z = np.append(Z0 + rad * np.sin(thet), Div_Z) +# Plot for checking +plt.figure(facecolor="w", figsize=(6, 6)) +plt.plot(poly_R, poly_Z) +plt.axis("equal") + +############################################################################### +# Notice that the polygon does not have to be closed, ToFu will anyway check +# that and close it automatically if necessary. +# Now let's feed this 2D polygon to the appropriate ToFu class and specify that +# it should be a toroidal type (if linear type 'Lin' is chosen, the length +# should be specified by the 'Lim' keyword argument). +# **tofu** also asks for a name to be associated to this instance, and an +# experiment ('Exp') and a shot number (useful when the same experiment changes +# geometry in time). + +# Create a toroidal Ves instance with name 'MyFirstVessel', associated to +# the experiment 'Misc' (for 'Miscellaneous') and shot number 0 +ves = tfg.Ves( + Name="MyFirstVessel", + Poly=[poly_R, poly_Z], + Type="Tor", + Exp="Misc", + shot=0 +) + +############################################################################### +# Now the vessel instance is created. It provides you several key attributes +# and methods (see :class:`~tofu.geom` for details). +# Among them the Id attribute is itself a class instance that contains all +# useful information about this vessel instance for identification, saving... +# In particular, that's where the name, the default saving path, the Type, the +# experiment, the shot number... are all stored. +# A default name for saving was also created that automatically includes not +# only the name you gave but also the module from which this instance was +# created (tofu.geom or tfg), the type of object, the experiment, the shot +# number... +# This recommended default pattern is useful for quick identification of saved +# object, it is advised not to modify it. + +print(ves.Id.SaveName) + +############################################################################### +# Now, we can simply visualise the created vessel by using the dedicated method +# (keyword argument 'Elt' specifies the elements of the instance we want to +# plot, typically one letter corresponds to one element, here we just want the +# polygon): + +# Plot the polygon by default in two projections (cross-section and horizontal) +# and return the list of axes +Lax = ves.plot(element="P") + + +############################################################################### +# The created vessel instance, plotted in cross-section and horizontal +# projections +# Since the vessel is an important object (it defines where the plasma lives), +# all the other ToFu objects rely on it. It is thus important that you save +# it so that it can be used by other ToFu objects when necessary. + +ves.save(path="./") + +############################################################################### +# This method will save the instance as a numpy compressed file (.npz), using +# the path and file name found in ves.Id.SavePath and ves.Id.SaveName. While +# it is highly recommended to stick to the default value for the SaveName, +# but you can easily modify the saving path if you want by specifying it using +# keyword argument Path. + +############################################################################### +# Adding structural elements +# --------------------------- +# +# Like for a vessel, a structural element is mostly defined by a 2D polygon. +# If a vessel instance is provided, the type of the structural element +# (toroidal or linear) is automatically the same as the type of the vessel, +# otherwise the type must be specified. + +# A configuration, short for geometrical configuration is a set of vessel, +# and structural elements. + +# Define two polygons, one that does not enclose the vessel and one that does +thet = np.linspace(0.0, 2.0 * np.pi, 100) +poly1 = [[2.5, 3.5, 3.5, 2.5], [0.0, 0.0, 0.5, 0.5]] # a rectangle +poly2 = [R0 + 0.5 * np.cos(thet), -1.0 + 0.5 * np.sin(thet)] # a circle +poly3 = [[0.8, 1.3, 1.3, 0.8], [-0.5, -0.5, 0.5, 0.5]] # another rectangle +# Create the structural elements with the appropriate ToFu class, specifying +# the experiment and a shot number for keeping track of changes +s1 = tfg.PFC(Name="S1", + Poly=poly1, + Exp="Misc", + shot=0) +# now we create a structure that is not continuous along phi +# but is only defined within certain limits +s2 = tfg.PFC( + Name="S2", + Poly=poly2, + Exp="Misc", + shot=0, + Lim=[[0.0, np.pi], [np.pi / 2.0, np.pi * 3.0 / 2.0]], +) +# and another one, now defined as repetitions centered a position `pos` +# and with a certain `extent` +# here we wanted a structure uniformly repeated 5 times along phi +s3 = tfg.PFC( + Name="S3", + Poly=poly3, + # we dont take the last element of the list as it is 2.*pi = 0 + pos=np.linspace(0.0, 2.0 * np.pi, 6)[:-1], + # 5 repetitions + 5 empty spaces = 10 subdivision of 2. pi + extent=np.pi * 2.0 / 10.0, + Exp="Misc", + shot=0, +) +# Creating a configuration with vessel and structures +config = tfg.Config(Name="test", + Exp="Misc", + lStruct=[ves, s1, s2, s3]) +config.set_colors_random() # to see different colors +config.plot() +config.save() +# sphinx_gallery_thumbnail_number = 3 diff --git a/release_notes/release_notes_140.txt b/release_notes/release_notes_140.txt index 8786f5c65..96ec2db52 100644 --- a/release_notes/release_notes_140.txt +++ b/release_notes/release_notes_140.txt @@ -1,4 +1,5 @@ What's new in 1.4.0: +-------------------- * All structures are now inherited from an abstract class (in tofu.geom) and are either of type: - 'In': there can be plasma inside, they are empty structures (e.g.: Vessel) diff --git a/release_notes/release_notes_141.md b/release_notes/release_notes_141.md index 2a8e10a10..42fb7d68f 100644 --- a/release_notes/release_notes_141.md +++ b/release_notes/release_notes_141.md @@ -1,4 +1,5 @@ What's new in 1.4.1: +-------------------- # Summary diff --git a/setup.py b/setup.py index 7b8209ea2..2939eeee2 100644 --- a/setup.py +++ b/setup.py @@ -378,7 +378,14 @@ def get_version_tofu(path=_HERE): # for example: # $ pip install -e .[dev,test] extras_require={ - "dev": ["check-manifest", "coverage", "nose==1.3.4", "sphinx", "sphinx-gallery"], + "dev": [ + "check-manifest", + "coverage", + "nose==1.3.4", + "sphinx", + "sphinx-gallery", + "sphinx_bootstrap_theme", + ] }, # If there are data files included in your packages that need to be # installed, specify them here. If using Python 2.6 or less, then these