# Path: pyneb/utils/physics.py
# IP = {}
# 
# 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 pyneb as pn
from pyneb.utils.physics import IP
from pyneb.utils.misc import parseAtom

    return ab_dic

def getElemAb(ab_dic, printAb = True):
    # Instantiation of the ICF object
    icf = pn.ICF()
    # Computing the elemental abundances from all ICF rules.
    icf_labels = []
    #for label in icf_labels:
    #    print('{0} is a rule for {1}'.format(label, icf.all_icfs[label]['elem']))
    
    # The following computes the elemental abundances from the rules.
    elem_abun = icf.getElemAbundance(ab_dic, icf_labels)
    if printAb:
        for icf_ref in np.sort(elem_abun.keys()):
            if np.log10(elem_abun[icf_ref]) > -10:
                print('{0} {1}={3:.3} using {2}'.format(icf_ref, 
                                              icf.all_icfs[icf_ref]['elem'],
                                              icf.getExpression(icf_ref), 
                                              np.log10(elem_abun[icf_ref])+12))

    return elem_abun
    
def p5():

    # this will plot all the available data in pyneb for the omegas
    ions = ['C2','C3', 'N2', 'N3','O2', 'O3', 'O4','Ne2','Ne3', 'Ne5', 'S2', 'S3', 'S4','Cl3', 'Ar2','Ar3','Ar4','Ar5',]

    for ion in ions:
        # split ion into elem and spec, e.g 'O3' into 'O' and 3

# Path: pyneb/utils/physics.py
# IP = {}
# 
# 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/ex3_1.py
import numpy as np
import pyneb as pn
from pyneb.utils.physics import IP
from pyneb.utils.misc import parseAtom


    return ab_dic

def getElemAb(ab_dic, printAb = True):
    # Instantiation of the ICF object
    icf = pn.ICF()
    # Computing the elemental abundances from all ICF rules.
    icf_labels = []
    #for label in icf_labels:
    #    print('{0} is a rule for {1}'.format(label, icf.all_icfs[label]['elem']))
    
    # The following computes the elemental abundances from the rules.
    elem_abun = icf.getElemAbundance(ab_dic, icf_labels)
    if printAb:
        for icf_ref in np.sort(elem_abun.keys()):
            if np.log10(elem_abun[icf_ref]) > -10:
                print('{0} {1}={3:.3} using {2}'.format(icf_ref, 
                                              icf.all_icfs[icf_ref]['elem'],
                                              icf.getExpression(icf_ref), 
                                              np.log10(elem_abun[icf_ref])+12))

    return elem_abun
    
def p5():

    # this will plot all the available data in pyneb for the omegas
    ions = ['C2','C3', 'N2', 'N3','O2', 'O3', 'O4','Ne2','Ne3', 'Ne5', 'S2', 'S3', 'S4','Cl3', 'Ar2','Ar3','Ar4','Ar5',]

    for ion in ions:
        # split ion into elem and spec, e.g 'O3' into 'O' and 3

        elem, spec = parseAtom(ion)