コード例 #1
0
ファイル: skience.py プロジェクト: drJfunk/skience
    def __init__(self,scat=None,z=1.,Y=1.):
        '''
        Gerneral class for making the Gamma, Rph, R0
        calculations from different flux files
        
        The assumption in the readers is that there is
        a thermal and non-thermal flux measured


        '''
        if scat != None:
            kT = scat.GetParamArray("Black Body","kT")
            
            kTErr = kT[:,1]
            kT = kT[:,0]

            self.tt = kT > 0 

            self.kT =  map(lambda v,e: self._Convert2Ufloat(v,e),kT[self.tt],kTErr[self.tt])

        Mpc2cm =3.08567758E24
        
        self.Ld = (luminosity_distance(z)*Mpc2cm).value
        self.z=z
        self.Y=Y
コード例 #2
0
    def __init__(self, scat=None, z=1., Y=1.):
        '''
        Gerneral class for making the Gamma, Rph, R0
        calculations from different flux files
        
        The assumption in the readers is that there is
        a thermal and non-thermal flux measured


        '''
        if scat != None:
            kT = scat.GetParamArray("Black Body", "kT")

            kTErr = kT[:, 1]
            kT = kT[:, 0]

            self.tt = kT > 0

            self.kT = map(lambda v, e: self._Convert2Ufloat(v, e), kT[self.tt],
                          kTErr[self.tt])

        Mpc2cm = 3.08567758E24

        self.Ld = (luminosity_distance(z) * Mpc2cm).value
        self.z = z
        self.Y = Y
コード例 #3
0
def distance_from_comoving_volume(vc, **kwargs):
    r"""Returns the luminosity distance from the given comoving volume.

    Parameters
    ----------
    vc : float
        The comoving volume, in units of cubed Mpc.
    \**kwargs :
        All other keyword args are passed to :py:func:`get_cosmology` to
        select a cosmology. If none provided, will use
        :py:attr:`DEFAULT_COSMOLOGY`.

    Returns
    -------
    float :
        The luminosity distance at the given comoving volume.
    """
    cosmology = get_cosmology(**kwargs)
    z = redshift_from_comoving_volume(vc, cosmology=cosmology)
    return cosmology.luminosity_distance(z).value
コード例 #4
0
ファイル: cosmology.py プロジェクト: bhooshan-gadre/pycbc
def distance_from_comoving_volume(vc, **kwargs):
    r"""Returns the luminosity distance from the given comoving volume.

    Parameters
    ----------
    vc : float
        The comoving volume, in units of cubed Mpc.
    \**kwargs :
        All other keyword args are passed to :py:func:`get_cosmology` to
        select a cosmology. If none provided, will use
        :py:attr:`DEFAULT_COSMOLOGY`.

    Returns
    -------
    float :
        The luminosity distance at the given comoving volume.
    """
    cosmology = get_cosmology(**kwargs)
    z = redshift_from_comoving_volume(vc, cosmology=cosmology)
    return cosmology.luminosity_distance(z).value
コード例 #5
0
def distance_from_comoving_volume(vc, interp=True, **kwargs):
    r"""Returns the luminosity distance from the given comoving volume.

    Parameters
    ----------
    vc : float
        The comoving volume, in units of cubed Mpc.
    interp : bool, optional
        If true, this will setup an interpolator between distance and comoving
        volume the first time this function is called. This is useful when
        making many successive calls to this function (such as when using this
        function in a transform for parameter estimation).  However, setting up
        the interpolator the first time takes O(10)s of seconds. If you will
        only be making a single call to this function, or will only run it on
        an array with < ~100000 elements, it is faster to not use the
        interpolator (i.e., set ``interp=False``). Default is ``True``.
    \**kwargs :
        All other keyword args are passed to :py:func:`get_cosmology` to
        select a cosmology. If none provided, will use
        :py:attr:`DEFAULT_COSMOLOGY`.

    Returns
    -------
    float :
        The luminosity distance at the given comoving volume.
    """
    cosmology = get_cosmology(**kwargs)
    lookup = _v2ds if interp else {}
    try:
        dist = lookup[cosmology.name](vc)
    except KeyError:
        # not using interp or not a standard cosmology,
        # call the redshift function directly
        z = z_at_value(cosmology.comoving_volume, vc, units.Mpc**3)
        dist = cosmology.luminosity_distance(z).value
    return dist