コード例 #1
0
ファイル: test_absline.py プロジェクト: linetools/linetools
def test_aodm():
    # Make fake spectrum
    wave = np.linspace(1210, 1220, 100)*u.AA
    npix = wave.size
    fx = np.ones(npix)
    fx[npix//2-5:npix//2+5] = 0.8
    fx[npix//2] = 0.01
    sig = np.ones(npix)*0.1
    wrest = 1215.670*u.AA
    fval = 0.4
    velo = (wave-wrest)/wrest * 3e5*u.km/u.s
    # Operate
    N, sig_N, flag_sat = aodm((velo, fx, sig), (wrest, fval))
    # Test
    assert flag_sat is True
    np.testing.assert_allclose((N.value, sig_N.value),
                               (96652191688169.72, 194151305045168.12))
    assert N.unit == u.cm**-2
コード例 #2
0
def test_aodm():
    # Make fake spectrum
    wave = np.linspace(1210, 1220, 100) * u.AA
    npix = wave.size
    fx = np.ones(npix)
    fx[npix // 2 - 5:npix // 2 + 5] = 0.8
    fx[npix // 2] = 0.01
    sig = np.ones(npix) * 0.1
    wrest = 1215.670 * u.AA
    fval = 0.4
    velo = (wave - wrest) / wrest * 3e5 * u.km / u.s
    # Operate
    N, sig_N, flag_sat = aodm((velo, fx, sig), (wrest, fval))
    # Test
    assert flag_sat is True
    np.testing.assert_allclose((N.value, sig_N.value),
                               (96652191688169.72, 194151305045168.12))
    assert N.unit == u.cm**-2
コード例 #3
0
    def measure_aodm(self, nsig=3., normalize=True):
        """ AODM calculation

        It sets these attributes:
          * self.attrib[ 'N', 'sig_N', 'logN', 'sig_logN' ]:
            Column densities and errors, linear and log

        Parameters
        ----------
        nsig : float, optional
          Number of sigma significance required for a "detection"
        normalize : bool, optional
          Normalize first?
        """
        # Cut spectrum
        fx, sig, xdict = self.cut_spec(normalize=normalize)
        velo = xdict['velo']
        # Check that there is sufficient data
        if len(fx) <= 1:
            warnings.warn("Spectrum does not cover {:g}".format(self.wrest))
            self.attrib['flag_N'] = 0
            return

        # Calculate
        N, sig_N, flg_sat = laa.aodm((velo, fx, sig),
                                     (self.wrest, self.data['f']))

        # Flag
        if flg_sat:
            self.attrib['flag_N'] = 2
        else:
            if N > nsig * sig_N:
                self.attrib['flag_N'] = 1
            else:
                self.attrib['flag_N'] = 3

        # Values
        self.attrib['N'] = N
        self.attrib['sig_N'] = sig_N

        # Log
        laa.log_clm(self.attrib)
コード例 #4
0
ファイル: spectralline.py プロジェクト: linetools/linetools
    def measure_aodm(self, nsig=3., normalize=True):
        """ AODM calculation

        It sets these attributes:
          * self.attrib[ 'N', 'sig_N', 'logN', 'sig_logN' ]:
            Column densities and errors, linear and log

        Parameters
        ----------
        nsig : float, optional
          Number of sigma significance required for a "detection"
        normalize : bool, optional
          Normalize first?
        """
        # Cut spectrum
        fx, sig, xdict = self.cut_spec(normalize=normalize)
        velo = xdict['velo']
        # Check that there is sufficient data
        if len(fx) <= 1:
            warnings.warn("Spectrum does not cover {:g}".format(self.wrest))
            self.attrib['flag_N'] = 0
            return

        # Calculate
        N, sig_N, flg_sat = laa.aodm((velo, fx, sig), (self.wrest,self.data['f']))

        # Flag
        if flg_sat:
            self.attrib['flag_N'] = 2
        else:
            if N > nsig*sig_N:
                self.attrib['flag_N'] = 1
            else:
                self.attrib['flag_N'] = 3

        # Values
        self.attrib['N'] = N
        self.attrib['sig_N'] = sig_N

        # Log
        laa.log_clm(self.attrib)
コード例 #5
0
ファイル: spectralline.py プロジェクト: Waelthus/linetools
    def measure_aodm(self, nsig=3.):
        """  AODM calculation
        Parameters
        ----------
        nsig: float, optional
          Number of sigma significance required for a "detection"

        Fills:
        -------
        self.attrib[ 'N', 'sigN', 'logN', 'sig_logN' ]  
          Column densities and errors, linear and log
        """
        reload(laa)

        # Cut spectrum
        fx, sig, xdict = self.cut_spec(normalize=True)
        velo = xdict['velo']

        # Calculate
        N,sigN,flg_sat = laa.aodm( (velo, fx, sig), (self.wrest,self.data['f']) )

        # Flag
        if flg_sat:
            self.attrib['flagN'] = 2
        else:
            if N > nsig*sigN:
                self.attrib['flagN'] = 1
            else:
                self.attrib['flagN'] = 3

        # Values
        self.attrib['N'] = N
        self.attrib['sigN'] = sigN

        # Log
        logN = np.log10( self.attrib['N'].value ) 
        lgvar = ((1. / (np.log(10.)*self.attrib['N'].value))**2) * self.attrib['sigN'].value**2
        sig_logN = np.sqrt(lgvar)
        self.attrib['logN'] = logN # Dimensionless
        self.attrib['sig_logN'] = sig_logN # Dimensionless
コード例 #6
0
ファイル: spectralline.py プロジェクト: nhmc/linetools
    def measure_aodm(self, nsig=3.):
        """ AODM calculation

        It sets these attributes:
          * self.attrib[ 'N', 'sigN', 'logN', 'sig_logN' ]:
            Column densities and errors, linear and log

        Parameters
        ----------
        nsig : float, optional
          Number of sigma significance required for a "detection"
        """
        # Cut spectrum
        fx, sig, xdict = self.cut_spec(normalize=True)
        velo = xdict['velo']

        # Calculate
        N,sigN,flg_sat = laa.aodm( (velo, fx, sig), (self.wrest,self.data['f']) )

        # Flag
        if flg_sat:
            self.attrib['flagN'] = 2
        else:
            if N > nsig*sigN:
                self.attrib['flagN'] = 1
            else:
                self.attrib['flagN'] = 3

        # Values
        self.attrib['N'] = N
        self.attrib['sigN'] = sigN

        # Log
        logN, sig_logN = laa.log_clm(self.attrib)
        self.attrib['logN'] = logN # Dimensionless
        self.attrib['sig_logN'] = sig_logN # Dimensionless