# 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 pyneb as pn
import matplotlib.pyplot as plt
from pyneb.utils.misc import parseAtom
# Analysis of a simple two-component model, meant to illustrate the bias arising from assuming
# that the region is homogeneous in density
# First, an emission region made up of two different subregions is modelled,
# each with a different mass and density. The resulting overall emissivity is computed
# Second, the region is analyzed as if it were a homogeneous region



def plot_2comp(tem1=1e4, tem2=1e4, dens1=3e2, dens2=5e5, mass1=1, mass2=5e-4):
        
    # List of diagnostics used to analyze the region
    diags = pn.Diagnostics()
    
    for diag in pn.diags_dict:
        if diag[0:7] != '[FeIII]':
            diags.addDiag(diag)
    diags.addClabel('[SIII] 6312/9069', '[SIII]A')
    diags.addClabel('[OIII] 4363/5007', '[OIII]A')
    
    # Define all the ions that are involved in the diagnostics
    all_atoms = diags.atomDict
    
    pn.log_.message('Atoms built')
    
    obs = pn.Observation(corrected = True)
    for atom in all_atoms:
        # Computes all the intensities of all the lines of all the ions considered
        for wavelength in all_atoms[atom].lineList:

# 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/ex7_3.py
import pyneb as pn
import matplotlib.pyplot as plt
from pyneb.utils.misc import parseAtom

# Analysis of a simple two-component model, meant to illustrate the bias arising from assuming
# that the region is homogeneous in density
# First, an emission region made up of two different subregions is modelled,
# each with a different mass and density. The resulting overall emissivity is computed
# Second, the region is analyzed as if it were a homogeneous region



def plot_2comp(tem1=1e4, tem2=1e4, dens1=3e2, dens2=5e5, mass1=1, mass2=5e-4):
        
    # List of diagnostics used to analyze the region
    diags = pn.Diagnostics()
    
    for diag in pn.diags_dict:
        if diag[0:7] != '[FeIII]':
            diags.addDiag(diag)
    diags.addClabel('[SIII] 6312/9069', '[SIII]A')
    diags.addClabel('[OIII] 4363/5007', '[OIII]A')
    
    # Define all the ions that are involved in the diagnostics
    all_atoms = diags.atomDict
    
    pn.log_.message('Atoms built')
    
    obs = pn.Observation(corrected = True)
    for atom in all_atoms:
        # Computes all the intensities of all the lines of all the ions considered
        for wavelength in all_atoms[atom].lineList:

            elem, spec = parseAtom(atom)