fsciortino / Aurora

Modern toolbox for impurity transport, neutrals and radiation modeling in magnetically-confined plasmas

Home Page:https://aurora-fusion.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Identical wavelength for different transitions in the same file

Didou09 opened this issue · comments

Motivations:

  • In its current version, aurora load spectral lines from ADAS adf15 files into a dictionary where they are sorted by wavelength (i.e.: the wavelentgth, as a float, is the key of the dictionary)
  • This breaks down if, unfortunately, several different transitions share the same wavelength.
  • A long-term fix would be to set a unique key to each transition, using something else than the wavelength.
  • This issue was encountered while following tutorial #46

Current behaviour:

On python 3.7.11, the behaviour when fed several times the same key is that the dict will only retain the last provided value:

In [1]: {0: 1, 0: 2}
Out[1]: {0: 2}

It means that in its current version, aurora, when confronted with several transitions of identical wavelengths, will only provide the one it encounters last in the file.

Example:

  • Interestingly, it happens for Ar16+, when ones looks for the k lines, it turns out a different transition with the same wavelength (3.9900 A) exists in the same file pec#ar15.dat:
    image

Hi @fsciortino , thanks for the update on master.

Using it raised one error, that I corrected on my fork of aurora, and then a second error occured, that I also corrected on my fork.

Then it works, but I started thinking that when a line wavelength is shifted, the code should raise a warning so the user knows it, so I implemented the warning.

Using that version of the code revealed that there are actually many lines with redundant wavelengths.

So I implemented a more synthetic warning that is raised only once and gives the list of all redundant wavelengths (ordered according to the wavelength).

For file pec#ar15.dat here is the result: 183 lines have redundant wavelength.

In [11]: import aurora

In [12]: filepath_li = '/Home/DV226270/Diag_XICS/Atomic_data/Aurora/pec#ar15.dat'

In [13]: di = aurora.read_adf15(filepath_li)

image

I see at least 2 causes for concern:

  1. you will notice that more than 2 transitions can share the same wavelength
    => shifting the wavelength by +1e-6 A is not enough, because when 3 lines have the same wavelength, 2 of them will remain redundant (both shifted by 1e-6 A, so still equal)
    => Incremental shifts may fix that
  2. you will see that some different lines can, unfortunately,be separated by ...1e-6 A.
    => If lines a and b share the same wavelength lam, and line c has wavelength lam+1.e-6, if line b is shifted by 1.e-6 A, it will become redundant with line c, which originally, was not redundant with any other line.

Thoughts on this:

  • I think a solid fix would be to set index_lines=True by default, and to prefer that kind of indexing everywhere in the code, but obviously that's non-negligible work that may take some time
  • A temporary fix might be to:
    • shift lines by an increment smaller than 1.e-6 A (maybe 1.e-10 A ?) to avoid case 2 (even though it theory, it can still happen)
    • implement the possibility of multiple increments to avoid case 1.

Proposition:

  • I submit my code changes for merging into master in PR #49, feel free to merge it or just to keep it for back-up and select parts of the changes for your own changes.