cherab / solps

Other
6 stars 5 forks source link

Look up in cherab.core.atomic.elements instead of using _popular_species and _species_symbol_map dicts #33

Closed vsnever closed 3 years ago

vsnever commented 4 years ago

I suggest that instead of using _popular_species dict when reading the data from raw or balance files, we should search for the matches in cherab.core.atomic.elements. First, get all isotopes with a given nuclear charge, second, from them find the one with the closest atomic mass to the given one.

Similarly, _species_symbol_map dict must be replaced with the search for the matching element symbol in cherab.core.atomic.elements. Extracting the nuclear charge from the balance file also must be improved the same way.

CnlPepper commented 4 years ago

I built these search functions to simplify element handling:

https://github.com/cherab/core/blob/d58c8c26470209be9643a8c23b9dc9385bbe30e9/cherab/core/atomic/elements.pyx#L136

You can lookup the element by name, atomic number etc....

vsnever commented 4 years ago

Yes @CnlPepper, it's exactly what I was looking for, thank you. I'll update the code and make the PR then.

@jacklovell, could you please provide me with any balance.nc file for testing? All examples in SOLPS-ITER are in md5.

vsnever commented 4 years ago

Current representation of species in SOLPSSimulation class as a list of strings (symbol + charge) in unsafe. Let's say we have He3 in the plasma, for the neutral He3, re.match(_SPECIES_REGEX, sp).groups() will return ('He', 30). It's better to keep the species as the list of (symbol, charge) tuples or even (Element/Isotope, charge) tuples. In the latter case, we can avoid try-except for Element/Isotope when initialising Species.

vsnever commented 3 years ago

Fixed in #35.