Exemplo n.º 1
0
Arquivo: model.py Projeto: nhmc/LAE
def plot_model(pars):    
    """ Plot the observed values and errors, along with the predicted
    model values.
    """
    import matplotlib.pyplot as pl
    from barak.plot import draw_arrows, puttext

    fig = pl.figure(figsize=(6.4, 3.4))
    ax = fig.add_subplot(111)
    ms = 6
    ipot = [get_ionization_energy(t) for t in tr_plot]
    for i,tr in enumerate(tr_plot):
        if use_ipot:
            ind = ipot[i]
        else:
            ind = i
        if tr in obs:
            colour = 'k' if tr in trans else 'w'
            fmt = 'o' + colour
            val, siglo, sighi = obs[tr]
            if siglo == 0:
                draw_arrows(ind, val, direction='up', ax=ax,lw=1)
                ax.plot(ind, val, fmt,ms=ms)
            elif sighi == 0:
                draw_arrows(ind, val, direction='down', ax=ax,lw=1)
                ax.plot(ind, val, fmt,ms=ms)
            else:
                ax.plot([ind, ind], [val-siglo, val+sighi], 'k',lw=1)
                ax.plot(ind, val, fmt,ms=ms)
            ax.text(ind, val + 0.8, tr,
                    fontsize=10, ha='center')
        else:
            puttext(ind, 0.02, tr, ax=ax, xcoord='data',
                    fontsize=10, ha='center')

    puttext(0.9,0.1, 'Model', ax, color='r', ha='right')

    xvals = list(range(len(tr_plot)))
    #print np.asarray(pars).shape
    for par in pars:
        Nmodel = model(par, for_plot=True)
        if use_ipot:
            if len(pars) == 1:
                ax.plot(ipot, Nmodel, 'r.-', lw=1, zorder=0)
            else:
                ax.plot(ipot, Nmodel, 'r-', lw=0.2, zorder=0)
        else:
            if len(pars) == 1:
                ax.plot(xvals, Nmodel, 'r.-', lw=1, zorder=0)
            else:
                ax.plot(xvals, Nmodel, 'r-', lw=0.2, zorder=0)

    if use_ipot:
        ax.set_xlabel('Ionization potential (eV)')
        ax.set_xlim(ipot[0]-1, ipot[-1] + 1)
    else:
        ax.set_xlim(-0.5, xvals[-1] + 0.5)
        ax.set_xticks([])

    ax.set_ylabel(r'$\log_{10}\ N$')
    fig.tight_layout()
    #return fig, ax
    return fig
Exemplo n.º 2
0
Arquivo: model.py Projeto: nhmc/LAE
    for tr in dont_use:
        if tr in trans:
            trans.remove(tr)
    print 'Using these transitions'
    print trans


if 1:
    ################################################################
    # Read the cloudy grids and make the interpolators
    ################################################################ 
    tr_plot = ('MgI CaII OI OII OIII OIV MgII FeII FeIII SiII AlII CII AlIII '
               'NI NII NIII NIV SiIII SII SIV SV '
               'SiIV CIII CIV NV OVI').split()

    ipot = [get_ionization_energy(t) for t in tr_plot]
    isort = np.argsort(ipot)
    tr_plot = [tr_plot[i] for i in isort]
    assert all(tr in tr_plot for tr in trans)
    Ncloudy, Ncloudy_raw, Models, aUV = make_interpolators_uvbtilt(
        tr_plot, simnames)
    M = Models[0]

if 0 and testing:
    # check they look ok

    nrows, ncols = get_nrows_ncols(len(trans) * 2)
    fig = pl.figure(figsize=(8.4, 8.4))
    Z = np.linspace(M.Z[0], M.Z[-1], 100)
    nH = np.linspace(M.nH[0], M.nH[-1], 101)
    nH1, Z1 = np.meshgrid(nH, Z, indexing='ij')
Exemplo n.º 3
0
from barak.sed import flambda_to_fnu
logfnu = np.log10(flambda_to_fnu(wa, 10**logFlam))
wa1 = 10**np.linspace(np.log10(wa[0]), np.log10(wa[-1]), 10*len(wa))
logfnu1 = np.interp(wa1, wa, logfnu)
starburst = np.rec.fromarrays(
    [wa1, logfnu1], names='wa,logfnu')

trans = ('CII CIII CIV SiII SiIII SiIV HI AlII '
         'AlIII NV OVI MgII NII').split()  # MgI

trans = ('CII CIII CIV SiII SiIII SiIV HI AlII '
         'AlIII NV OVI MgII NII FeII FeIII MgI OI OII OIII '
         'CaII NI CI').split()  # MgI

IP = np.array(get_ionization_energy(trans))

import pylab as plt
from atpy import Table

prefix = "/Users/ncrighton/Projects/MPIA_QSO_LBG/Cloudy/J0004/comp1"

names = sorted(glob(prefix + "/uvb_k0[0246]/*tilted*tbl"))

fig1 = pl.figure(figsize=(5.1,4.7))
fig1.subplots_adjust(left=0.2, bottom=0.15, top=0.96,right=0.96)
fig2 = pl.figure(figsize=(5.1,4.7))
fig2.subplots_adjust(left=0.2, bottom=0.15, top=0.96,right=0.96)
ax1 = fig1.add_subplot(111)
ax2 = fig2.add_subplot(111)
Exemplo n.º 4
0
import numpy as np

import astropy.units as u
import astropy.constants as c

import barak.absorb
from barak.absorb import get_ionization_energy
from barak.plot import puttext, axvlines, make_log_xlabels

plt.rc('xtick.major',pad=8)
plt.rc('ytick.major',pad=7)

from barak.sed import flambda_to_fnu

get_ionization_energy('HI')

T = barak.absorb.ION_CACHE['table'].data
prob = 8

c0 = (T['P'] > prob) & (T['wrest'] > 600)
trans = T['species'][c0]
tr_wrest = T['wrest'][c0]
# trans = ('CII CIII CIV SiII SiIII SiIV HI AlII '
#          'AlIII NV OVI MgII NII').split()  # MgI

# trans = ('CI CII CIII CIV SiII SiIII SiIV HI AlII '
#          'AlIII NI NII NIII NIV NV MgII FeII FeIII MgI OI OII OIII OIV OV OVI '
#          'CaII MnII CrII NeVIII ZnII MgX').split()  # MgI

IP = np.array(get_ionization_energy(trans))
Exemplo n.º 5
0
def plot_model(pars):
    """ Plot the observed values and errors, along with the predicted
    model values.
    """
    import matplotlib.pyplot as pl
    from barak.plot import draw_arrows, puttext

    fig = pl.figure(figsize=(6.4, 3.4))
    ax = fig.add_subplot(111)
    ms = 6
    ipot = [get_ionization_energy(t) for t in tr_plot]
    for i, tr in enumerate(tr_plot):
        if use_ipot:
            ind = ipot[i]
        else:
            ind = i
        if tr in obs:
            colour = 'k' if tr in trans else 'w'
            fmt = 'o' + colour
            val, siglo, sighi = obs[tr]
            if siglo == 0:
                draw_arrows(ind, val, direction='up', ax=ax, lw=1)
                ax.plot(ind, val, fmt, ms=ms)
            elif sighi == 0:
                draw_arrows(ind, val, direction='down', ax=ax, lw=1)
                ax.plot(ind, val, fmt, ms=ms)
            else:
                ax.plot([ind, ind], [val - siglo, val + sighi], 'k', lw=1)
                ax.plot(ind, val, fmt, ms=ms)
            ax.text(ind, val + 0.8, tr, fontsize=10, ha='center')
        else:
            puttext(ind,
                    0.02,
                    tr,
                    ax=ax,
                    xcoord='data',
                    fontsize=10,
                    ha='center')

    puttext(0.9, 0.1, 'Model', ax, color='r', ha='right')

    xvals = list(range(len(tr_plot)))
    #print np.asarray(pars).shape
    for par in pars:
        Nmodel = model(par, for_plot=True)
        if use_ipot:
            if len(pars) == 1:
                ax.plot(ipot, Nmodel, 'r.-', lw=1, zorder=0)
            else:
                ax.plot(ipot, Nmodel, 'r-', lw=0.2, zorder=0)
        else:
            if len(pars) == 1:
                ax.plot(xvals, Nmodel, 'r.-', lw=1, zorder=0)
            else:
                ax.plot(xvals, Nmodel, 'r-', lw=0.2, zorder=0)

    if use_ipot:
        ax.set_xlabel('Ionization potential (eV)')
        ax.set_xlim(ipot[0] - 1, ipot[-1] + 1)
    else:
        ax.set_xlim(-0.5, xvals[-1] + 0.5)
        ax.set_xticks([])

    ax.set_ylabel(r'$\log_{10}\ N$')
    fig.tight_layout()
    #return fig, ax
    return fig
Exemplo n.º 6
0
    print dont_use
    for tr in dont_use:
        if tr in trans:
            trans.remove(tr)
    print 'Using these transitions'
    print trans

if 1:
    ################################################################
    # Read the cloudy grids and make the interpolators
    ################################################################
    tr_plot = ('MgI CaII OI OII OIII OIV MgII FeII FeIII SiII AlII CII AlIII '
               'NI NII NIII NIV SiIII SII SIV SV '
               'SiIV CIII CIV NV OVI').split()

    ipot = [get_ionization_energy(t) for t in tr_plot]
    isort = np.argsort(ipot)
    tr_plot = [tr_plot[i] for i in isort]
    assert all(tr in tr_plot for tr in trans)
    Ncloudy, Ncloudy_raw, Models, aUV = make_interpolators_uvbtilt(
        tr_plot, simnames)
    M = Models[0]

if 0 and testing:
    # check they look ok

    nrows, ncols = get_nrows_ncols(len(trans) * 2)
    fig = pl.figure(figsize=(8.4, 8.4))
    Z = np.linspace(M.Z[0], M.Z[-1], 100)
    nH = np.linspace(M.nH[0], M.nH[-1], 101)
    nH1, Z1 = np.meshgrid(nH, Z, indexing='ij')