# Path: pyneb/utils/physics.py
# IP = {}


import numpy as np
import pyCloudy as pc
import matplotlib.pyplot as plt
from pyneb.utils.physics import IP
    
    print('He2/H:  {0:.2e} {1:.2e} {2:.2e}'.format(Ms[0].get_ab_ion_vol('He', 2), 
                                                   Ms[1].get_ab_ion_vol('He', 2), 
                                                   Ms[2].get_ab_ion_vol('He', 2)))
    for elem in ['N', 'O', 'Ne', 'S', 'Ar']:
        for i in np.arange(4):
            print('{0:2s}{1}/H:  {2:.2e} {3:.2e} {4:.2e}'.format(elem, i, Ms[0].get_ab_ion_vol(elem, i), 
                                                             Ms[1].get_ab_ion_vol(elem, i), 
                                                             Ms[2].get_ab_ion_vol(elem, i)))
        
def plot_SED(name, models_dir = './', unit='Jy'):
    Ms = pc.load_models('{0}/{1}'.format(models_dir, name), read_emis = False)
    plt.figure()
    plt.subplot(2, 1, 1)
    for M in Ms:
        plt.plot(M.get_cont_x(unit = 'eV'), np.log10(M.get_cont_y(unit = 'esHz')), label=M.model_name_s)
    plt.xlim((10., 60))
    plt.ylim((18, 24))
    plt.ylabel('log [erg.s-1.Hz-1]')
    plt.legend(loc=3)
    
    plt.subplot(2, 1, 2)
    for M in Ms:
        plt.plot(M.get_cont_x(unit = 'eV'), np.log10(M.get_cont_y(unit = 'Q')), label=M.model_name_s)
    plt.xlim((10., 60))
    plt.ylim((42., 50))
    plt.xlabel('E [eV]')
    plt.ylabel('QH0(E)')
    # TODO: avoid overlap
    for ip in IP:

# Path: pyneb/utils/physics.py
# IP = {}


# Path: pyneb/sample_scripts/Choroni_School/ex6_2.py
import numpy as np
import pyCloudy as pc
import matplotlib.pyplot as plt
from pyneb.utils.physics import IP

    
    print('He2/H:  {0:.2e} {1:.2e} {2:.2e}'.format(Ms[0].get_ab_ion_vol('He', 2), 
                                                   Ms[1].get_ab_ion_vol('He', 2), 
                                                   Ms[2].get_ab_ion_vol('He', 2)))
    for elem in ['N', 'O', 'Ne', 'S', 'Ar']:
        for i in np.arange(4):
            print('{0:2s}{1}/H:  {2:.2e} {3:.2e} {4:.2e}'.format(elem, i, Ms[0].get_ab_ion_vol(elem, i), 
                                                             Ms[1].get_ab_ion_vol(elem, i), 
                                                             Ms[2].get_ab_ion_vol(elem, i)))
        
def plot_SED(name, models_dir = './', unit='Jy'):
    Ms = pc.load_models('{0}/{1}'.format(models_dir, name), read_emis = False)
    plt.figure()
    plt.subplot(2, 1, 1)
    for M in Ms:
        plt.plot(M.get_cont_x(unit = 'eV'), np.log10(M.get_cont_y(unit = 'esHz')), label=M.model_name_s)
    plt.xlim((10., 60))
    plt.ylim((18, 24))
    plt.ylabel('log [erg.s-1.Hz-1]')
    plt.legend(loc=3)
    
    plt.subplot(2, 1, 2)
    for M in Ms:
        plt.plot(M.get_cont_x(unit = 'eV'), np.log10(M.get_cont_y(unit = 'Q')), label=M.model_name_s)
    plt.xlim((10., 60))
    plt.ylim((42., 50))
    plt.xlabel('E [eV]')
    plt.ylabel('QH0(E)')
    # TODO: avoid overlap
    for ip in IP:

        plt.plot([IP[ip], IP[ip]], [49, 50])