Exemplo n.º 1
0
    def __init__(self, **kwargs):
        IGMSurvey.__init__(self, 'DLA', **kwargs)

        # define the cosmology (for H0)
        try:
            _ = self.cosmo
        except ValueError:
            self.cosmo = acc.FlatLambdaCDM(70., 0.3)
Exemplo n.º 2
0
def cosm_xz(z, cosmo=None, zmin=0., flg=0):
    """ Calculates X(z) -- absorption path length or dXdz
    Parameters:
      z: float or ndarray
        Redshift to evaluate at.  May be an array
      cosmo: astropy.cosmology
        Cosmological model to adopt 
      zmin: float (0.)
        Minimum redshift to evaluate at 
      flg: int (0)
        Flag controlling the output
          0 = X(z)
          1 = dX/dz at z

    Returns:
      Xz or dXdz: 
        Absorption path or its derivative

    ToDo:

    JXP 08 Nov 2014
    """

    # Cosmology
    if cosmo == None:
        from astropy.cosmology import core as acc
        cosmo = acc.FlatLambdaCDM(70., 0.3)
        #cosmo = Planck13

    # Flat?
    if cosmo.Ok(0.) == 0:
        if flg == 0:  # X(z)
            rslt = cosmo.absorption_distance(z)
        elif flg == 1:  # dX/dz
            rslt = cosmo._xfunc(z)
        else:
            raise ValueError('igm_utils.cosm_xz: Bad flg %d' % flg)
    else:
        raise ValueError(
            'igm_utils.cosm_xz: Not prepared for non-flat cosmology')

    #
    return rslt
Exemplo n.º 3
0
def cosm_xz(z, cosmo=None, flg_return=0):
    """ Calculates X(z) -- absorption path length or dXdz

    Parameters
    ----------
    z : float or ndarray
       Redshift to evaluate at.  May be an array
    cosmo : astropy.cosmology
       Cosmological model to adopt
    flg_return : int, optional (0)
       Flag controlling the output
         0 = X(z)
         1 = dX/dz at z

    Returns
    -------
    Xz or dXdz :
      Absorption path or its derivative
      Set by flag
    """

    # Cosmology
    if cosmo is None:
        from astropy.cosmology import core as acc
        cosmo = acc.FlatLambdaCDM(70., 0.3)

    # Flat?
    if cosmo.Ok(0.) == 0:
        if flg_return == 0:  # X(z)
            rslt = cosmo.absorption_distance(z)
        elif flg_return == 1:  # dX/dz
            try:
                rslt = cosmo.abs_distance_integrand(z)
            except AttributeError:
                rslt = cosmo._xfunc(z)
        else:
            raise ValueError('pyigm.utils.cosm_xz: Bad flg {:d}'.format(flg_return))
    else:
        raise ValueError('pyigm.utils.cosm_xz: Not prepared for non-flat cosmology')

    #
    return rslt
Exemplo n.º 4
0
def cosm_xz(z, cosmo=None, flg_return=0):
    """ Calculates X(z) -- absorption path length or dXdz

    Parameters
    ----------
    z : float or ndarray
       Redshift to evaluate at.  May be an array
    cosmo : astropy.cosmology
       Cosmological model to adopt
    flg_return : int, optional (0)
       Flag controlling the output
         0 = X(z)
         1 = dX/dz at z

    Returns
    -------
    Xz or dXdz :
      Absorption path or its derivative
      Set by flag
    """

    # Cosmology
    if cosmo is None:
        from astropy.cosmology import core as acc
        cosmo = acc.FlatLambdaCDM(H0=70., Om0=0.3)

    # Flat?
    if flg_return == 0:  # X(z)
        rslt = cosmo.absorption_distance(z)
    elif flg_return == 1:  # dX/dz
        try:
            rslt = cosmo.abs_distance_integrand(z)
        except AttributeError:  # Deprecated in astropy
            rslt = cosmo._xfunc(z)
    #
    return rslt