diff --git a/.gitignore b/.gitignore index a94e3bed3..e382e1279 100644 --- a/.gitignore +++ b/.gitignore @@ -70,3 +70,6 @@ doc/source/auto_examples/ # do not commit nose tests files *.noseids + +# no pip wheel metadata +pip-wheel-metadata/ diff --git a/.travis.yml b/.travis.yml index d5bd833db..ed1bca620 100644 --- a/.travis.yml +++ b/.travis.yml @@ -59,8 +59,9 @@ deploy: skip_cleanup: true - provider: pypi user: "Didou09" - distributions: "sdist bdist_wheel" + distributions: "sdist" skip_cleanup: true + skip_existing: true on: tags: true all_branches: true diff --git a/Debug_JINTRACMesh.pdf b/Debug_JINTRACMesh.pdf deleted file mode 100644 index e69de29bb..000000000 diff --git a/Debug_JINTRACMesh.svg b/Debug_JINTRACMesh.svg deleted file mode 100644 index 890803549..000000000 --- a/Debug_JINTRACMesh.svg +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - diff --git a/Notes_Upgrades/meetings/nov_2019.md b/Notes_Upgrades/meetings/nov_2019.md new file mode 100644 index 000000000..8a0db0a8e --- /dev/null +++ b/Notes_Upgrades/meetings/nov_2019.md @@ -0,0 +1,60 @@ +Meeting November 2019 +===================== + + +Agenda +------ + +- How to package Tofu + - pip wheel + - where to set the requirements ? +- Which testing package to use ? + - nose2 + - pytest +- Travis + - platforms / matrix +- tutorials as tests ? +- matplotlib blog + +Present +-------- + +- Didier Vezinet (@Didou09) +- Florian Lebourdais (@flothesof) +- Laura Mendoza (@lasofivec) + +Summary of meeting 27/11/2019 +------------------------------ + +- Summary of the recent problems with setuptools, travis, distribution (pypi) + **Assignee**: Laura + +- Documentation problems: + + - More and more users asking for doc (mostly on IMAS). + - docstring: + Didier will update docstring of main user functions + **Assignee**: Didier + - website: + - add tutorials/cases with different configurations (ITER, WEST, JET, ...) [FLORIAN] + - add tutorial for only plot_touch: different types of shading, saving/exports and plotting selected pixels for plot_touch + - add tutorial for reflexions (number and types) + - 2d radiations with ITER data (best case) or fake data -> update the tutorial called Computing a camera image with custom emissivity + - sinogram: to be added to an existing tutorial + - how to build cameras: add more comments on how to create a camera (in the 5 minutes to Tofu) what are the different parameters. Maybe separate camera 1D and camera 2D and go into details on how it works. + + **Assignee**: Laura + Didier + Florian ? + Deadline: December ? + +- Which tool for tests: + - pytest : it looks like transition nose to pytest will be easy (pytest support nose tests and nose functions not used). Will have to clean imports from nose. + http://doc.pytest.org/en/latest/nose.html + Assignee: Florian + Deadline: next release. + +- Adding Tofu to conda-forge: + Florian proposes to add tofu to the conda-forge. For the next release ? + **Assignee**: - + Deadline: next release ? + +- matplotlib blog : we will re discuss this, once the tutorial are updated and that we have more examples/images diff --git a/TODO_EndOfVisit_20181212.txt b/TODO_EndOfVisit_20181212.txt deleted file mode 100644 index a2e89a891..000000000 --- a/TODO_EndOfVisit_20181212.txt +++ /dev/null @@ -1,118 +0,0 @@ -Salut Laura, - -Alors les prochaines étapers que je vois (ton avis est évidemment bienvenu): - - -######################### -* Function principale (kIn kOut, indout, vect): -x - Terminer proprement l'optimisation CPU -x - Comprendre et terminer optimisation / profilage mémoire (résidu?) -x - Terminer parallélisation -x - La connecter à la partie orientée objet, en sortant les calculs - preliminaires (limites des boites...) qui ne changeront pas si la - caméra bouge et qu'on refait le calcul (pour optimisation de la - position) - - -######################### -* Autres fonctions nécessaire (inspirées de la principale): - -x 0/ Calculer, pour N points (R,Z) (donc cercle plat en 3D), le point le - long de la LOS le plus proche du cercle: (projection de la ligne - (hyperbole) ou en 3D pbm 4d), retourner k et distance - -x 0.1/ Same as 0/ but give back bool when dist < eps => True - (eps as parameter). - -x 1/ Calculer uniquement kIn / kOut pour N (~1-100) polygones - (ex.: des surfaces de flux) - TODO: pas de structs !! - -x 2/ Calculer, pour N polygones, et lorsque les lignes de visée ne les - traversent pas, la distance la plus courte d entre une ligne et un - polygone (et le paramètre k du point associé sur la ligne). - Retourner d=0 si la ligne traverse (i.e. si il existe un kIn et/ou - un kout) - > parametres entrées: (nvert, poly, vin, lims si lin, los_origin, - los_direction) - - >> Only did it for toroidal polygons... is it really necessary ? - - o Interface Python: - qui appelle une des deux (si il existe un parametre epislon) - x vectoriser à plusieurs polys - x version true/false si >0 et < eps (tableau booleen nlos*npoly) - o Interface Python : - qui appelle une des deux avex une variable pour choisir si LOS/poly ou l'inverse - x plein LOS, plein poly, pour chaque ligne: tableau d'indice (de taille nlos) - indiquant le poly pourlequel la LOS est le plus proche. (min(distance) mais - pour laquelle la LOS ne passe pas à l'intérieur). - Poly sont ordonnees : du plus petit au plus grand - x plein LOS, plein poly, pour chaque poly: tableau d'indice (de taille npoly) - indiquant la LOS pourlequel le poly est le plus proche. (min(distance) mais - pour laquelle la LOS ne passe pas à l'intérieur). - -> 2.1/ Ask Didier (vignetting algo ?) - > In : (list los_orig, list los_dirc, list contour3d, ncontour, list nvert...) - > Out : (list bool[ncontour * nlos]) - > contour 'simple' 3d = sans recoupe. - > 1. bbox - los - triangulation du polygon - - 3/ Calculer, pour N points de l'espace (~10-100) s'il sont visibles par - M autres points (~10^4-10^6), dans une configuration donnée (ex.: des - points le long d'une trajectoire dans la chambre à vide, on veut savoir - quels sont les points du plasma - échantilloné - qui rayonnent - dessus). Retourner un tableau 2D (N,M) de booleens. Je calculerai - l'angle solide et le vecteur directeur vectoriellement ensuite en me - basant sur ce booleen. Un fonction qui retourne ce tableau est donc - suffisante. - - 4/ Idem, mais pour N polygons 3D plans (ou quasi-plans), attention, le - polygone a un sens (i.e.: une face visible, l'autre ne compte pas), - seuls les points du bon coté doivent être comptés comme le voyant - - Eventuellement retourner plutot un tableau d'entier (flags) avec - code (0=pas vu, 1=partiellement, 2=entier), avec tests sur le centre - de masse et les sommets) - - Non-prioritaire : mattre un flag pour désactiver le calcul - d'un seul côté - - 5/ Idem mais calculer aussi l'angle solide associé et le vecteur - directeur vers le centre de masse du polygon - Prioritaire : uniquement pour les polygones vu en entier - - 6/ Pour les fonction 3/ et 5/, dans le cas ou le champ par lequel on - eut multiplier l'angle solide est axisymmétrique (toroidalement - invariant), on peut le multiplier par l'intégrale toroidale de l'angle - solideau lieu de faire un calcul détaillé dans tout le volume. Dans ce - cas, le calcul doit aller plus vite et économiser pas mal de mémoire - puisqu'on écrase sur une dimension). Il fut alors: - - Echantilloner le volume qui nous intéresse (fonction - sample_V() existante, s'en inspirer), en faisant une boucle sur - le grand rayon R (car c'est lui qui détermine le nombre - d'échantillonages toroidaux), c'est cette boucle supérieure - que l'on pourra ensuite parallliser.. - - En déduire un échantillonage (phi,Z), pour chaque point de - l'échantillonage voir si le point / polygone est visible, le - cas échéant calculer l'angle solide (et le vecteur ? à - discuter), puis l'intégrer sur phi. - - A la fin on obtient une carte 2D (R,Z) de l'angle solide - intégré en phi - - 7/ Faire la même chose que 5/ mais en intercalant un nombre arbitraire - d'ouvertires polygonles et de grilles polygonales, calculer l'angle - solide correspondant à l'intersection de tous ces polygones vu du - plasma (i.e. : les photons doivent passer à travers toutes les - ouvertures / griles avant d'atteindre les détecteurs). - - 7/ On va commencer à gérer: - - Les réflexions (spéculaires et diffusives) - - Les réflexions sur un cristal à simple ou double courbure - (pour les spectromètres) - - - 8/ S'attaquer aux maillages (an 2) - -J'arrive ;-) -A toute -Didier diff --git a/XICS_mask.npz b/XICS_mask.npz deleted file mode 100644 index 6f349523f..000000000 Binary files a/XICS_mask.npz and /dev/null differ diff --git a/examples/tutorials/tuto_plot_basic.py b/examples/tutorials/tuto_plot_basic.py index 5f4a63265..ca804088d 100644 --- a/examples/tutorials/tuto_plot_basic.py +++ b/examples/tutorials/tuto_plot_basic.py @@ -2,8 +2,7 @@ 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. """ # The following imports matplotlib, preferably using a diff --git a/examples/tutorials/tuto_plot_gallery_fusion_machines.py b/examples/tutorials/tuto_plot_gallery_fusion_machines.py new file mode 100644 index 000000000..ebadfeb12 --- /dev/null +++ b/examples/tutorials/tuto_plot_gallery_fusion_machines.py @@ -0,0 +1,38 @@ +""" +A gallery of Fusion Machines +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This tutorial functions as a gallery of fusion machines that can easily be loaded with `tofu`. +""" + +############################################################################### +# We start by importing `tofu`. + +import tofu as tf + +############################################################################### +# `tofu` provides a geometry helper function that allows creating a configuration with a single call. +# +# Calling with empty arguments results in a default configuration. At the time of writing, this is ITER. +# By printing the `config` object, a text representation of its components is printed. This allows inspecting +# component names, number of sections, color or visibility. + +config = tf.geom.utils.create_config() +print(config) + +############################################################################### +# To get a list of all available built-in configs, one has to know some details about `tofu`. +# Configurations can either be accessed by names (ITER, WEST, JET). + +print(tf.geom.utils._DCONFIG_TABLE.keys()) + +############################################################################### +# With that being said, let's create a gallery of the "top 3" fusion machines provided by `tofu` to accelerate +# diagnostic development. + +import matplotlib.pyplot as plt + +fig, ax = plt.subplots() +for fusion_machine in ['ITER', 'WEST', 'JET']: + config = tf.geom.utils.create_config(fusion_machine) + config.plot() \ No newline at end of file diff --git a/tofu/imas2tofu/__init__.py b/tofu/imas2tofu/__init__.py index 184fc8773..842ecaef4 100644 --- a/tofu/imas2tofu/__init__.py +++ b/tofu/imas2tofu/__init__.py @@ -6,13 +6,13 @@ """ import warnings import traceback +import itertools as itt try: try: from tofu.imas2tofu._core import * except Exception: from ._core import * - del warnings, traceback except Exception as err: if str(err) == 'imas not available': msg = "" @@ -26,5 +26,72 @@ msg += "\n\n => the optional sub-package tofu.imas2tofu is not usable\n" raise Exception(msg) + +# ----------------------------------------------- +# Check IMAS version vs latest available in linux modules +# ----------------------------------------------- + +_KEYSTR = 'IMAS/' + + +# extract all IMAS versions from a str returned by modules +def extractIMAS(ss, keystr=_KEYSTR): + if keystr not in ss: + raise Exception + ls = ss[ss.index(keystr):].split('\n') + ls = itt.chain.from_iterable([s.split(' ') for s in ls]) + ls = [s for s in ls if keystr in s] + ls = [s[len(keystr):s.index('(')] if '(' in s else s[len(keystr):] + for s in ls] + return sorted(ls) + + +# Compare current and latest available IMAS versions +def check_IMAS_version(verb=True, keystr=_KEYSTR): + import subprocess + + # Get currently loaded IMAS + cmd = "module list" + proc = subprocess.run(cmd, check=True, shell=True, + stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + lcur = extractIMAS(proc.stdout.decode(), keystr=keystr) + if len(lcur) != 1: + msg = ("You seem to have no / several IMAS version loaded:\n" + + "\t- module list: {}".format(lcur)) + raise Exception(msg) + + # Get all available IMAS + cmd = "module av IMAS" + proc = subprocess.run(cmd, check=True, shell=True, + stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + lav = extractIMAS(proc.stdout.decode(), keystr=keystr) + if len(lav) == 0: + msg = "There is not available IMAS version" + raise Exception(msg) + + # Compare and warn + if lcur[0] not in lav: + msg = "The current IMAS version is not available!" + raise Exception(msg) + + msg = None + if lav.index(lcur[0]) != len(lav)-1: + msg = ("\nYou do not seem to be using the latest IMAS version:\n" + + "'module list' vs 'module av IMAS' suggests:\n" + + "\t- Current version: {}\n".format(lcur[0]) + + "\t- Latest version : {}".format(lav[-1])) + warnings.warn(msg) + return lcur[0], lav + + +# Try comparing and warning +try: + _, _ = check_IMAS_version(verb=True) +except Exception as err: + # This warning is an optional luxury, should not block anything + pass + + __all__ = ['MultiIDSLoader', 'load_Config', 'load_Plasma2D', 'load_Cam', 'load_Data'] +del warnings, traceback, itt, _KEYSTR diff --git a/tofu/version.py b/tofu/version.py index a9ed57da4..53c102bb6 100644 --- a/tofu/version.py +++ b/tofu/version.py @@ -1,2 +1,2 @@ # Do not edit, pipeline versioning governed by git tags! -__version__ = '1.4.2a3' +__version__ = '1.4.2a3-2-gfaeb7af'