コード例 #1
0
ファイル: plot_multinest.py プロジェクト: sofiasi/darcoda
def fill_nice(r0, M95lo, M68lo, Mmedi, M68hi, M95hi):
    gpl.fill_between(r0, M95lo, M95hi, color='black', alpha=0.2, lw=0.1)
    gpl.plot(r0, M95lo, color='black', lw=0.4)
    gpl.plot(r0, M95hi, color='black', lw=0.3)
    gpl.fill_between(r0, M68lo, M68hi, color='black', alpha=0.4, lw=0.1)
    gpl.plot(r0, M68lo, color='black', lw=0.4)
    gpl.plot(r0, M68hi, color='black', lw=0.3)
    gpl.plot(r0, Mmedi, 'r', lw=1)
    gpl.axvline(gp.rstarhalf, color='gray', lw=0.5) # [pc]
    gpl.xlim([r0[0], r0[-1]])
    return
コード例 #2
0
ファイル: plot_multinest.py プロジェクト: sofiasi/darcoda
def plot_data(r0, prof, pop):
    if prof=='nu':
        # get 2D data here
        # Rbin [Rscale], Binmin [Rscale], Binmax [Rscale], Nu(R)/Nu(0) [1], error [1]
        DATA_2D = np.transpose(np.loadtxt(gp.files.nufiles[pop], unpack=False, skiprows=1))
        Nudat = DATA_2D[4-1]; Nuerr = DATA_2D[5-1]
        Nudat *= gp.Nu0pc[pop]; Nuerr *= gp.Nu0pc[pop]
        dat = Nudat; err = Nuerr
    elif prof=='sig':
        DATA = np.transpose(np.loadtxt(gp.files.sigfiles[pop], unpack=False, skiprows=1))
        sigdat = DATA[4-1];        sigerr = DATA[5-1]
        sigdat *= gp.maxvlos[pop]; sigerr *= gp.maxvlos[pop]
        dat = sigdat; err = sigerr
    gpl.fill_between(r0, dat-err, dat+err, color='blue', alpha=0.2, lw=1)
    return
コード例 #3
0
ファイル: test_splines.py プロジェクト: sofiasi/darcoda
from scipy.interpolate import splrep, splev
import gl_plot as gpl


xnew = np.array([   0.   ,   40.156,   58.552,   74.426,   91.87 ,  110.166,
        130.44 ,  155.967,  192.224,  248.297,  255.215,  262.119,
        269.01 ,  275.887])

ynew = np.array([ 2426.404,  2294.581,  1828.642,  1144.447,   918.291,   681.606,
         321.61 ,   200.627,   116.21 ,    19.241,    17.438,    14.488,
          12.037,    10.   ])

errorinpercent = npr.uniform(0.05, 0.15, len(xnew))

gpl.plot(xnew,ynew,'.',lw=2)
gpl.fill_between(xnew,ynew*(1.-errorinpercent),ynew*(1.+errorinpercent),alpha=0.5,color='blue')

# gives warning
pdb.set_trace()
tcknu  = splrep(xnew, ynew, k=2, s=0.1) # interpolation in real space
gpl.plot(xnew, splev(xnew,splrep(xnew,ynew, k=2, s=0.1)))

# try with third order
tcknu  = splrep(xnew, ynew, k=3, s=0.1) # interpolation in real space

# better, uses weights

w = 1/(errorinpercent*ynew)
tcknu  = splrep(xnew, ynew, w=w, k=2, s=0.1) # interpolation in real space