コード例 #1
0
def plot_one(rates, plotname, *p, frac=0.05, age=13.6):
    brates = u.gimme_rebinned_data(rates,
                                   splits=arange(0, 1.167, 0.167).tolist())
    scale_k = quad(imf.salpeter, 3, 8)[0] / quad(imf.salpeter1, 0.1, 125)[0]
    scale = scale_k * 0.7**2. * 1e4  ## factors of h...
    dt = 0.05
    tt = arange(0.1, age, dt)  ## forward time
    lbt = age - tt
    zz = [ct.cosmoz(x) for x in lbt]

    sfh = rz.sfr_behroozi_12(tt)
    dtd = step_dtd(tt, *p)
    norm_dtd = sum(step_dtd(tt, *p)) * dt
    dtd = dtd / norm_dtd

    tmp = convolve(
        sfh, dtd,
        'full') * dt * frac * scale  ## now convolved result in forward time
    rate_fn = tmp[:len(dtd)]
    clf()
    ax = subplot(111)
    ax2 = ax.twinx()
    ax2.plot(zz, sfh, 'r-')
    ax.plot(zz, rate_fn, 'k-')
    ax.errorbar(rates[:, 0],
                rates[:, 1],
                yerr=[rates[:, 3], rates[:, 2]],
                fmt='o',
                color='0.6')
    ax.errorbar(brates[:, 0],
                brates[:, 1],
                yerr=[brates[:, 3], brates[:, 2]],
                xerr=[brates[:, 5], brates[:, 4]],
                fmt='o',
                color='0.0',
                zorder=10)

    pwrl = (-1.0, 1.0)
    ax.set_xlim(0, 2.5)
    ax.set_xlabel('Redshift')
    ax.set_ylabel(r'SN Ia Rate')
    ax.set_ylabel(r'$10^{-4}$ SNe Ia per year per Mpc$^3$')
    ax2.set_ylabel(r'SF Rate')

    ax3 = axes([0.65, 0.6, 0.23, 0.2])
    ax3.plot(tt, dtd, 'b-',
             label='Fit')  #label='Norm = %1.1f' %(simps(dtd,x=time)))
    ax3.plot(tt, rz.powerdtd(tt, *pwrl), 'b:', label=r'$t^{%.1f}$' % (pwrl[0]))
    pn = (-20, 8.8, 11)
    ax3.plot(tt, rz.dtdfunc(tt, *pn), 'b--', label='Best model')
    ax.set_title(r' $k=%.4f$ M$_{\odot}^{-1}$, $f=%2.1f\%%$' %
                 (scale_k, frac * 100))

    ax3.set_ylabel('$\Phi$')
    ax3.set_xlabel('Delay Time (Gyr)')
    ax3.set_xlim(0, 12)
    ax3.set_ylim(0, 1.3)
    ax3.legend(frameon=False)
    savefig(plotname)
    return ()
コード例 #2
0
def plot_one(rates, plotname, *p, frac=0.05, age=13.6):
    brates = u.gimme_rebinned_data(rates,
                                   splits=arange(0, 1.125, 0.125).tolist())
    scale_k = quad(imf.salpeter, 3, 8)[0] / quad(imf.salpeter1, 0.1, 125)[0]
    scale = scale_k * 0.7**2. * 1e4  ## factors of h...
    dt = 0.05
    tt = arange(dt, age, dt)
    lbt = age - tt
    zz = [ct.cosmoz(x, ho=70) for x in lbt]

    par_model = [0.0134, 2.55, 3.3, 6.1]

    sfh = rz.csfh_time(tt, *par_model)
    dtd = rz.dtdfunc(tt, *p)
    pwrl = (-1.0, 1.0)
    dud = rz.powerdtd(tt, *pwrl)

    tmp = convolve(
        sfh, dtd,
        'full') * dt * frac * scale  ## now convolved result in forward time
    rate_fn = tmp[:len(dtd)]

    jdud = convolve(sfh, dud, 'full') * dt * scale * 0.065
    jdud = jdud[:len(dtd)]
    clf()
    ax = subplot(111)
    ax2 = ax.twinx()
    ax2.plot(zz, sfh, 'r-', label='CSFH')
    ax.plot(zz, rate_fn, 'k-', label='Fit', zorder=3)
    ax.plot(zz, jdud, 'k:', label=r'$t^{%.1f}$' % (pwrl[0]))

    ax.errorbar(rates[:, 0],
                rates[:, 1],
                yerr=[rates[:, 3], rates[:, 2]],
                fmt='o',
                color='0.6',
                alpha=0.4)
    ax.errorbar(brates[:, 0],
                brates[:, 1],
                yerr=[brates[:, 3], brates[:, 2]],
                xerr=[brates[:, 5], brates[:, 4]],
                fmt='o',
                color='0.0',
                zorder=10)

    pwrl = (-1.0, 1.0)
    ax.set_xlim(0, 2.6)
    ax.set_ylim(0, 1.8)
    ax2.set_ylim(0, 0.16)

    ax3 = axes([0.65, 0.62, 0.23, 0.2])
    ## ax3 = axes([0.55, 0.6, 0.33, 0.25])
    ax3.plot(tt, log10(dtd), 'b-',
             label='Fit')  #label='Norm = %1.1f' %(simps(dtd,x=time)))
    ax3.plot(tt,
             log10(rz.powerdtd(tt, *pwrl)),
             'b:',
             label=r'$t^{%.1f}$' % (pwrl[0]))
    ax3.set_ylabel('$\log(\Phi)$')
    ax3.set_xlabel('Delay Time (Gyr)')
    ax3.set_xlim(0, 12)
    ax3.set_ylim(-3, 0.5)
    ##ax3.set_ylim(0,1)
    ## ax3.legend(loc=1,ncol=1,frameon=False, fontsize=8)
    ax.set_xlabel('Redshift')
    ax.set_ylabel(r'$10^{-4}$ SNe Ia per year per Mpc$^3$')
    ax2.set_ylabel(r'M$_{\odot}$ per year per Mpc$^3$')
    ## ax.set_title(r' $k=%.4f$ M$_{\odot}^{-1}$, $f=%2.1f\%%$' %(scale_k,frac*100))
    ax.set_title(r'$k=%.4f\,M_{\odot}^{-1},\,\,\varepsilon=%2.1f\%%$' %
                 (scale_k, frac * 100))
    ax.legend(loc=2, frameon=False)
    ax2.legend(loc=4, frameon=False)

    savefig(plotname)
    return ()
コード例 #3
0
    ax2.plot(tt,
             log10(rz.powerdtd(tt, *pwrl)),
             'b:',
             label=r'$t^{%.1f}$' % (pwrl[0]))

    frac = 0.065

    rates = loadtxt('SNeIa_rates.txt')
    rates[:, 1:] = rates[:, 1:]  #*1.0e-4 ## put on the right scale
    rates = rates[:, :4]
    brates = u.gimme_rebinned_data(rates,
                                   splits=arange(0, 1.125, 0.125).tolist())
    scale_k = quad(imf.salpeter, 3, 8)[0] / quad(imf.salpeter1, 0.1, 125)[0]
    scale = scale_k * 0.7**2. * 1e4  ## factors of h...
    lbt = age - tta
    zz = [ct.cosmoz(x, ho=70) for x in lbt]

    ax.errorbar(rates[:, 0],
                rates[:, 1],
                yerr=[rates[:, 3], rates[:, 2]],
                fmt='o',
                color='0.6',
                alpha=0.4)
    ax.errorbar(brates[:, 0],
                brates[:, 1],
                yerr=[brates[:, 3], brates[:, 2]],
                xerr=[brates[:, 5], brates[:, 4]],
                fmt='o',
                color='0.0',
                zorder=10)
コード例 #4
0
def plot_one(rates, plotname, *p, frac=0.05, age=13.6):
    brates = u.gimme_rebinned_data(rates,
                                   splits=arange(0, 1.125, 0.125).tolist())
    scale_k = quad(imf.salpeter, 3, 8)[0] / quad(imf.salpeter1, 0.1, 125)[0]
    scale = scale_k * 0.7**2. * 1e4  ## factors of h...
    dt = 0.05
    tt = arange(dt, age, dt)  ## forward time
    lbt = age - tt
    zz = [ct.cosmoz(x) for x in lbt]

    par_model = [0.0134, 2.55, 3.3, 6.1]
    sfh = rz.csfh_time(tt, *par_model)
    dtd = rz.dtdfunc(tt, *p)
    pwrl = (-1.0, 1.0)
    dud = rz.powerdtd(tt, *pwrl)

    tmp = convolve(
        sfh, dtd,
        'full') * dt * frac * scale  ## now convolved result in forward time
    rate_fn = tmp[:len(dtd)]

    jdud = convolve(sfh, dud, 'full') * dt * scale * 0.065
    jdud = jdud[:len(dtd)]
    clf()
    ax = subplot(111)
    ax2 = ax.twinx()
    ax2.plot(zz, sfh, 'r-')
    ax.plot(zz, rate_fn, 'k-')
    ax.plot(zz, jdud, 'k:')

    ax.errorbar(rates[:, 0],
                rates[:, 1],
                yerr=[rates[:, 3], rates[:, 2]],
                fmt='o',
                color='0.6')
    ax.errorbar(brates[:, 0],
                brates[:, 1],
                yerr=[brates[:, 3], brates[:, 2]],
                xerr=[brates[:, 5], brates[:, 4]],
                fmt='o',
                color='0.0',
                zorder=10)

    ax.set_xlim(0, 2.5)
    ax.set_ylim(0, 1.8)
    ax.set_xlabel('Redshift')
    ax.set_ylabel(r'SN Ia Rate')
    ax.set_ylabel(r'$10^{-4}$ SNe Ia per year per Mpc$^3$')
    ax2.set_ylabel(r'SF Rate')

    ax3 = axes([0.65, 0.6, 0.23, 0.2])
    ax3.plot(tt, dtd, 'b-',
             label='Fit')  #label='Norm = %1.1f' %(simps(dtd,x=time)))
    ax3.plot(tt, dud, 'b:', label=r'$t^{%.1f}$' % (pwrl[0]))

    ax3.set_ylabel('$\Phi$')
    ax3.set_xlabel('Delay Time (Gyr)')
    ax3.set_xlim(0, 12)
    ax3.set_ylim(0, 1.3)
    ax3.legend(frameon=False)
    savefig(plotname)
    return ()