コード例 #1
0
def test_teff():
    fN_default = FNModel.default_model()
    zval, teff_LL = pyteff.lyman_limit(fN_default, 0.5, 2.45)
    #
    np.testing.assert_allclose(zval[0], 0.5)
    #np.testing.assert_allclose(teff_LL[0], 1.8176161746504436) scipy 0.16
    np.testing.assert_allclose(teff_LL[0], 1.8190744845274058)  # scipy 0.17
コード例 #2
0
ファイル: test_taueff.py プロジェクト: ninoc/pyigm
def test_teff():
    fN_default = FNModel.default_model()
    zval,teff_LL = pyteff.lyman_limit(fN_default, 0.5, 2.45)
    #
    np.testing.assert_allclose(zval[0], 0.5)
    #np.testing.assert_allclose(teff_LL[0], 1.8176161746504436) scipy 0.16
    np.testing.assert_allclose(teff_LL[0], 1.8190744845274058) # scipy 0.17
コード例 #3
0
def teff_LL(outfil='Figures/teff_LL.pdf'):
    """ Plot teff_LL from z=3.5 down
    """
    # z
    zem = 3.5
    z912 = 3.

    # f(N)
    fnmodel = FNModel.default_model()
    fnmodel.zmnx = (0.5, 4)  # extend default range

    # Calculate
    zval, teff_LL = lyman_limit(fnmodel, z912, zem)

    # Start the plot
    xmnx = (3.5, 3)
    pp = PdfPages(outfil)
    fig = plt.figure(figsize=(8.0, 5.0))

    plt.clf()
    gs = gridspec.GridSpec(1, 1)

    # Lya line
    ax = plt.subplot(gs[0])
    #ax.xaxis.set_minor_locator(plt.MultipleLocator(0.5))
    #ax.xaxis.set_major_locator(plt.MultipleLocator(20.))
    #ax.yaxis.set_minor_locator(plt.MultipleLocator(0.1))
    #ax.yaxis.set_major_locator(plt.MultipleLocator(0.2))
    ax.set_xlim(xmnx)
    ax.set_ylim(0., 2)
    ax.set_ylabel(r'$\tau_{\rm eff}^{\rm LL}$')
    ax.set_xlabel('z')

    lw = 2.
    # Data
    ax.plot(zval, teff_LL, 'b', linewidth=lw)  #, label='SDSS QSOs (z=4)')

    # Label
    csz = 17
    ax.text(0.10,
            0.80,
            'Source at z=3.5',
            color='black',
            transform=ax.transAxes,
            size=csz,
            ha='left')
    xputils.set_fontsize(ax, 17.)
    # Layout and save
    print('Writing {:s}'.format(outfil))
    plt.tight_layout(pad=0.2, h_pad=0.0, w_pad=0.4)
    plt.subplots_adjust(hspace=0)
    pp.savefig(bbox_inches='tight')
    plt.close()
    # Finish
    pp.close()
コード例 #4
0
def teff_LL(outfil='Figures/teff_LL.pdf'):
    """ Plot teff_LL from z=3.5 down
    """
    # z
    zem = 3.5
    z912 = 3.

    # f(N)
    fnmodel = FNModel.default_model()
    fnmodel.zmnx = (0.5,4) # extend default range

    # Calculate
    zval, teff_LL = lyman_limit(fnmodel, z912, zem)

    # Start the plot
    xmnx = (3.5, 3)
    pp = PdfPages(outfil)
    fig = plt.figure(figsize=(8.0, 5.0))

    plt.clf()
    gs = gridspec.GridSpec(1,1)

    # Lya line
    ax = plt.subplot(gs[0])
    #ax.xaxis.set_minor_locator(plt.MultipleLocator(0.5))
    #ax.xaxis.set_major_locator(plt.MultipleLocator(20.))
    #ax.yaxis.set_minor_locator(plt.MultipleLocator(0.1))
    #ax.yaxis.set_major_locator(plt.MultipleLocator(0.2))
    ax.set_xlim(xmnx)
    ax.set_ylim(0., 2)
    ax.set_ylabel(r'$\tau_{\rm eff}^{\rm LL}$')
    ax.set_xlabel('z')

    lw = 2.
    # Data
    ax.plot(zval, teff_LL, 'b', linewidth=lw)#, label='SDSS QSOs (z=4)')

    # Label
    csz = 17
    ax.text(0.10, 0.80, 'Source at z=3.5',
        color='black', transform=ax.transAxes, size=csz, ha='left')
    xputils.set_fontsize(ax, 17.)
    # Layout and save
    print('Writing {:s}'.format(outfil))
    plt.tight_layout(pad=0.2,h_pad=0.0,w_pad=0.4)
    plt.subplots_adjust(hspace=0)
    pp.savefig(bbox_inches='tight')
    plt.close()
    # Finish
    pp.close()
コード例 #5
0
    def mfp(self, zem, neval=5000, nzeval=300, cosmo=None, zmin=0.6):
        """ Calculate mean free path

        Parameters
        ----------
        zem : float
          Redshift of source
        cosmo : astropy.cosmology, optional
          Cosmological model to adopt (as needed)
        neval : int, optional
          Discretization parameter for NHI (5000)
        zmin: float, optional
          Minimum redshift in the calculation (0.5)

        Returns
        -------
        mfp : Quantity
          Mean free path from zem (physical Mpc)
          
        """
        # Imports
        from pyigm.fN import tau_eff as pyteff

        # Cosmology
        if cosmo is None:
            cosmo = cosmology.core.FlatLambdaCDM(70., 0.3)

        # Calculate teff
        zval, teff_LL = pyteff.lyman_limit(self,
                                           zmin,
                                           zem,
                                           N_eval=neval,
                                           N_zeval=nzeval,
                                           cosmo=cosmo)

        # Find tau=1
        zt_interp = scii.interp1d(teff_LL, zval)
        ztau1 = zt_interp(1.)  # Will probably break if 1 is not covered

        # MFP
        mfp = np.fabs(
            cosmo.lookback_distance(ztau1) -
            cosmo.lookback_distance(zem))  # Mpc
        # Return
        return mfp
コード例 #6
0
ファイル: fnmodel.py プロジェクト: pyigm/pyigm
    def mfp(self, zem, neval=5000, cosmo=None, zmin=0.6):
        """ Calculate mean free path

        Parameters
        ----------
        zem : float
          Redshift of source
        cosmo : astropy.cosmology, optional
          Cosmological model to adopt (as needed)
        neval : int, optional
          Discretization parameter (5000)
        zmin: float, optional
          Minimum redshift in the calculation (0.5)

        Returns
        -------
        mfp : Quantity
          Mean free path from zem (physical Mpc)
        """
        # Imports
        from pyigm.fN import tau_eff as pyteff

        # Cosmology
        if cosmo is None:
            cosmo = cosmology.core.FlatLambdaCDM(70., 0.3)

        # Calculate teff
        zval, teff_LL = pyteff.lyman_limit(self, zmin, zem, N_eval=neval, cosmo=cosmo)

        # Find tau=1
        zt_interp = scii.interp1d(teff_LL, zval)
        ztau1 = zt_interp(1.)  # Will probably break if 1 is not covered

        # MFP
        mfp = np.fabs(cosmo.lookback_distance(ztau1) -
                        cosmo.lookback_distance(zem))  # Mpc
        # Return
        return mfp
コード例 #7
0
ファイル: test_taueff.py プロジェクト: yzhenggit/pyigm
def test_teff():
    fN_default = FNModel.default_model()
    zval, teff_LL = pyteff.lyman_limit(fN_default, 0.5, 2.45)
    #
    np.testing.assert_allclose(zval[0], 0.5)
    np.testing.assert_allclose(teff_LL[0], 1.8197, rtol=1e-4)  # scipy 0.19