# Path: pyneb/utils/misc.py
# def parseAtom(atom):
#     '''
#     Parses an atom label into the element and spectrum parts
#     '''
# 
#     iso = ''
#     elem = ''
#     spec = ''
#     cont = True
#     firstdigit = True
#     for l in atom:
#         if l.isalpha() and cont:
#             elem += l
#             firstdigit = False
#         elif l.isdigit():
#             if firstdigit:
#                 iso += l
#             else:
#                 spec += l
#                 cont = False
#     return iso+str.capitalize(elem), spec


import numpy as np
import matplotlib.pyplot as plt
import pyneb as pn
from pyneb.utils.misc import parseAtom
"""
this file contains the definitions of the functions used to answer the questions of
exercise  2.1 of  PLASMA DIAGNOSTICS

to execute these functions, one first needs to
import a few libraries as listed at the beginning of the file run_ex.py
as well as this file.
the functions can then be called  as explained in the file run_ex.py

the functions defined here can be modified. 
In that case, is is necessary, before using the modified version, 
to do "reload(ex1_1)" from the terminal
sometimes this does not work well. 
it is then recommended to quit python (ctrl D) and enter again (ipython --pylab)
"""

#pn.atomicData.setDataFile('cl_iii_atom_M83-KS86.fits')

def p1(ion):
        # split ion into elem and spec, e.g 'O3' into 'O' and 3

# Path: pyneb/utils/misc.py
# def parseAtom(atom):
#     '''
#     Parses an atom label into the element and spectrum parts
#     '''
# 
#     iso = ''
#     elem = ''
#     spec = ''
#     cont = True
#     firstdigit = True
#     for l in atom:
#         if l.isalpha() and cont:
#             elem += l
#             firstdigit = False
#         elif l.isdigit():
#             if firstdigit:
#                 iso += l
#             else:
#                 spec += l
#                 cont = False
#     return iso+str.capitalize(elem), spec


# Path: pyneb/sample_scripts/Choroni_School/ex2_1.py
import numpy as np
import matplotlib.pyplot as plt
import pyneb as pn
from pyneb.utils.misc import parseAtom

"""
this file contains the definitions of the functions used to answer the questions of
exercise  2.1 of  PLASMA DIAGNOSTICS

to execute these functions, one first needs to
import a few libraries as listed at the beginning of the file run_ex.py
as well as this file.
the functions can then be called  as explained in the file run_ex.py

the functions defined here can be modified. 
In that case, is is necessary, before using the modified version, 
to do "reload(ex1_1)" from the terminal
sometimes this does not work well. 
it is then recommended to quit python (ctrl D) and enter again (ipython --pylab)
"""

#pn.atomicData.setDataFile('cl_iii_atom_M83-KS86.fits')

def p1(ion):
        # split ion into elem and spec, e.g 'O3' into 'O' and 3

        elem, spec = parseAtom(ion)