Example #1
0
    def get_tau0(self, N, b):
        """It returns the optical depth at the line center, tau0,
        for a given column density and Doppler parameter. It uses
        approximation given in Draine 2011 (see Chapter 9).
        It neglects stimulated emission which is fine for IGM or ISM
        except for radio-frequency transitions.

        Parameters
        ----------
        N : Quantity or Quantity array
            Column density
        b : Quantity or Quantity array of same shape as N
            Doppler parameter

        Returns
        -------
        tau0: float or array
            Optical depth at the line center. If N and b are
            arrays they must be of same shape.

        Notes
        -----
        This is a wrapper to linetools.analysis.absline.get_tau0()
        """
        try:
            fosc = self.data['f']
        except KeyError:
            raise NotImplementedError('AbsLine {} has not set its oscillator strength.'.format(self.__repr__))
        return laa.get_tau0(self.wrest, fosc, N, b)
Example #2
0
    def get_tau0(self, N, b):
        """It returns the optical depth at the line center, tau0,
        for a given column density and Doppler parameter. It uses
        approximation given in Draine 2011 (see Chapter 9).
        It neglects stimulated emission which is fine for IGM or ISM
        except for radio-frequency transitions.

        Parameters
        ----------
        N : Quantity or Quantity array
            Column density
        b : Quantity or Quantity array of same shape as N
            Doppler parameter

        Returns
        -------
        tau0: float or array
            Optical depth at the line center. If N and b are
            arrays they must be of same shape.

        Notes
        -----
        This is a wrapper to linetools.analysis.absline.get_tau0()
        """
        try:
            fosc = self.data['f']
        except KeyError:
            raise NotImplementedError(
                'AbsLine {} has not set its oscillator strength.'.format(
                    self.__repr__))
        return laa.get_tau0(self.wrest, fosc, N, b)
Example #3
0
def test_get_tau0():
    hi_list = LineList('HI')
    lya = hi_list['HI 1215']
    # test float format
    N = 10**13.0 / (u.cm*u.cm)
    b = 10*u.km / u.s
    tau0 = get_tau0(lya['wrest'], lya['f'], N, b)

    np.testing.assert_allclose(tau0, 0.75797320235476873, rtol=1e-5)
    # test array format
    N = [10**13.0, 10**13.0, 10**13.0] / (u.cm*u.cm)
    b = [10., 10, 10]*u.km/u.s
    tau0 = get_tau0(lya['wrest'], lya['f'], N, b)
    assert len(tau0) == len(N)
    np.testing.assert_allclose(tau0, 0.75797320235476873, rtol=1e-5)
    # test errors
    with pytest.raises(IOError):
        tau0 = get_tau0(lya['wrest'], lya['f'], N, b[:2])  # wrong shape for b
    with pytest.raises(IOError):
        tau0 = get_tau0(lya['wrest'], lya['f']*u.AA, N[0], b[0])  # wrong input units (i.e. fosc has units)
def test_get_tau0():
    hi_list = LineList('HI')
    lya = hi_list['HI 1215']
    # test float format
    N = 10**13.0 / (u.cm * u.cm)
    b = 10 * u.km / u.s
    tau0 = get_tau0(lya['wrest'], lya['f'], N, b)

    np.testing.assert_allclose(tau0, 0.75797320235476873, rtol=1e-5)
    # test array format
    N = [10**13.0, 10**13.0, 10**13.0] / (u.cm * u.cm)
    b = [10., 10, 10] * u.km / u.s
    tau0 = get_tau0(lya['wrest'], lya['f'], N, b)
    assert len(tau0) == len(N)
    np.testing.assert_allclose(tau0, 0.75797320235476873, rtol=1e-5)
    # test errors
    with pytest.raises(IOError):
        tau0 = get_tau0(lya['wrest'], lya['f'], N, b[:2])  # wrong shape for b
    with pytest.raises(IOError):
        tau0 = get_tau0(lya['wrest'], lya['f'] * u.AA, N[0],
                        b[0])  # wrong input units (i.e. fosc has units)
Example #5
0
def get_tau0_peak(wa0, fosc, logN, b):
    """Get the value of the optical depth at the line center,
    tau0. From Draine 2011 (see Chapter 9). It neglects estimulated
    emission which is fine for IGM or ISM except for radio-frecuency
    transitions.
    
    Inputs
    ------
    wa0:   rest-frame wavelenght of the transition in A
    fosc:  oscillator strenght for the transition
    logN:  log10 of the column density in cm^-2
    b:     Doppler parameter in km/s
    
    Returns
    -------
    tau0:  optical depth at the line center
    """
    # give units
    wa0 = wa0 * u.AA
    b = b * u.km / u.s
    return ltaa.get_tau0(wa0, fosc, logN, b)
Example #6
0
def get_tau0_peak(wa0,fosc,logN,b):
    """Get the value of the optical depth at the line center,
    tau0. From Draine 2011 (see Chapter 9). It neglects estimulated
    emission which is fine for IGM or ISM except for radio-frecuency
    transitions.
    
    Inputs
    ------
    wa0:   rest-frame wavelenght of the transition in A
    fosc:  oscillator strenght for the transition
    logN:  log10 of the column density in cm^-2
    b:     Doppler parameter in km/s
    
    Returns
    -------
    tau0:  optical depth at the line center
    """
    # give units
    wa0 = wa0 * u.AA
    b = b * u.km/u.s
    return ltaa.get_tau0(wa0, fosc, logN, b)