当前位置: 首页>>代码示例>>Python>>正文


Python AbsLine.attrib['N']方法代码示例

本文整理汇总了Python中linetools.spectralline.AbsLine.attrib['N']方法的典型用法代码示例。如果您正苦于以下问题:Python AbsLine.attrib['N']方法的具体用法?Python AbsLine.attrib['N']怎么用?Python AbsLine.attrib['N']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在linetools.spectralline.AbsLine的用法示例。


在下文中一共展示了AbsLine.attrib['N']方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_voigt_multi_line

# 需要导入模块: from linetools.spectralline import AbsLine [as 别名]
# 或者: from linetools.spectralline.AbsLine import attrib['N'] [as 别名]
def test_voigt_multi_line():
    # Wavelength array
    wave = np.linspace(3644, 3650, 100)*u.AA
    imn = np.argmin(np.abs(wave.value-3646.2))
    # HI line
    abslin = AbsLine(1215.670*u.AA, z=2.)
    abslin.attrib['N'] = 10**17.5/u.cm**2
    abslin.attrib['b'] = 20.*u.km/u.s
    # DI line
    abslin2 = AbsLine('DI 1215', z=2.)
    abslin2.attrib['N'] = 10**13./u.cm**2
    abslin2.attrib['b'] = 15.*u.km/u.s
    # Voigt
    vmodel3 = lav.voigt_from_abslines(wave,[abslin,abslin2])
    np.testing.assert_allclose(vmodel3.flux[imn].value,0.5715512949324375)
开发者ID:jnburchett,项目名称:linetools,代码行数:17,代码来源:test_voigt.py

示例2: add_DLA

# 需要导入模块: from linetools.spectralline import AbsLine [as 别名]
# 或者: from linetools.spectralline.AbsLine import attrib['N'] [as 别名]
    def add_DLA(self,z, NHI=20.3,bval=30.*u.km/u.s, comment='None', model=True):
        """Generate a new DLA
        """
        # Lya, Lyb
        dla_lines = []  # For convenience
        for trans in ['HI 1025', 'HI 1215']:
            iline = AbsLine(trans)
            iline.attrib['z'] = z
            iline.attrib['N'] = 10**NHI / u.cm**2
            iline.attrib['b'] = bval
            iline.attrib['coord'] = SkyCoord(ra=0*u.deg,dec=0*u.deg)
            dla_lines.append(iline)
        # Generate system
        new_sys = DLASystem.from_abslines(dla_lines) #(0*u.deg,0*u.deg),z,None,NHI)
        new_sys.bval = bval # This is not standard, but for convenience
        new_sys.comment = comment
        new_sys.dla_lines = dla_lines  # Also for convenience
        # Name
        self.count_dla += 1
        new_sys.label = 'DLA_Sys_{:d}'.format(self.count_dla)
        # Add
        self.abssys_widg.add_fil(new_sys.label)
        self.abssys_widg.all_abssys.append(new_sys)
        self.abssys_widg.abslist_widget.item(
            len(self.abssys_widg.all_abssys)).setSelected(True)

        # Update
        self.llist['Plot'] = False # Turn off metal-lines
        if model:  # For dealing with initialization
            self.update_model()
开发者ID:jhennawi,项目名称:xastropy,代码行数:32,代码来源:xfitdlagui.py

示例3: fill_lls_lines

# 需要导入模块: from linetools.spectralline import AbsLine [as 别名]
# 或者: from linetools.spectralline.AbsLine import attrib['N'] [as 别名]
    def fill_lls_lines(self, bval=20.*u.km/u.s, do_analysis=1):
        """
        Generate an HI line list for an LLS.
        Goes into self.lls_lines 

        Now generates a component too.
        Should have it check for an existing HI component..

        Parameters
        ----------
        bval : float, optional
          Doppler parameter in km/s
        do_analysis : int, optional
          flag for analysis
        """
        from linetools.lists import linelist as lll

        # May be replaced by component class (as NT desires)
        HIlines = lll.LineList('HI')

        self.lls_lines = []
        Nval = 10**self.NHI / u.cm**2
        for lline in HIlines._data:
            aline = AbsLine(lline['wrest'], linelist=HIlines)
            # Attributes
            aline.attrib['N'] = Nval
            aline.attrib['b'] = bval
            aline.attrib['z'] = self.zabs
            aline.analy['vlim'] = self.vlim
            aline.analy['do_analysis'] = do_analysis
            aline.attrib['coord'] = self.coord
            self.lls_lines.append(aline)
        # Generate a component (should remove any previous HI)
        self.add_component(AbsComponent.from_abslines(self.lls_lines))
开发者ID:mneeleman,项目名称:pyigm,代码行数:36,代码来源:lls.py

示例4: test_add_component

# 需要导入模块: from linetools.spectralline import AbsLine [as 别名]
# 或者: from linetools.spectralline.AbsLine import attrib['N'] [as 别名]
def test_add_component():
    radec = SkyCoord(ra=123.1143*u.deg, dec=-12.4321*u.deg)
    # HI Lya, Lyb
    lya = AbsLine(1215.670*u.AA)
    lya.analy['vlim'] = [-300.,300.]*u.km/u.s
    lya.attrib['z'] = 2.92939
    lya.attrib['N'] = 1e17 /  u.cm**2
    lyb = AbsLine(1025.7222*u.AA)
    lyb.analy['vlim'] = [-300.,300.]*u.km/u.s
    lyb.attrib['z'] = lya.attrib['z']
    abscomp = AbsComponent.from_abslines([lya,lyb])
    abscomp.coord = radec
    # Instantiate
    abssys = GenericAbsSystem.from_components([abscomp])
    # New component
    oi = AbsLine('OI 1302')
    oi.analy['vlim'] = [-300.,300.]*u.km/u.s
    oi.attrib['z'] = lya.attrib['z']
    abscomp2 = AbsComponent.from_abslines([oi])
    abscomp2.coord = radec
    # Standard
    assert abssys.add_component(abscomp2)
    # Fail
    abssys = GenericAbsSystem.from_components([abscomp])
    abscomp2.vlim = [-400.,300.]*u.km/u.s
    assert not abssys.add_component(abscomp2)
    # Overlap
    assert abssys.add_component(abscomp2, overlap_only=True)
开发者ID:lwymarie,项目名称:linetools,代码行数:30,代码来源:test_init_abssys.py

示例5: test_voigt_model

# 需要导入模块: from linetools.spectralline import AbsLine [as 别名]
# 或者: from linetools.spectralline.AbsLine import attrib['N'] [as 别名]
def test_voigt_model():
    from astropy.modeling import fitting
    # Wavelength array
    wave = np.linspace(3644, 3650, 100)*u.AA
    # HI line
    abslin = AbsLine(1215.670*u.AA, z=2.)
    abslin.attrib['N'] = 10**14./u.cm**2
    abslin.attrib['b'] = 25.*u.km/u.s
    # Voigt
    vmodel = abslin.generate_voigt(wave=wave)
    vmodel.sig = 0.1
    # Voigt fit
    abslin.analy['spec'] = vmodel
    abslin.limits.set([-100.,100]*u.km/u.s)
    abslin.measure_aodm(normalize=False)  # Sets analysis pixels
    fitvoigt = lav.single_voigt_model(logN=np.log10(abslin.attrib['N'].value),
        b=abslin.attrib['b'].value, z=2., wrest=abslin.wrest.value,
        gamma=abslin.data['gamma'].value,
        f=abslin.data['f'], fwhm=3.)
    # Restrict parameter space
    fitvoigt.logN.min = 12.
    fitvoigt.b.min = 10.
    fitvoigt.z.min = 2. + -100. * (1 + 2.) / c_kms
    fitvoigt.z.max = 2. + 100 * (1 + 2.) / c_kms

    # Fit
    fitter = fitting.LevMarLSQFitter()
    parm = fitter(fitvoigt,vmodel.wavelength[abslin.analy['pix']].value,
                  vmodel.flux[abslin.analy['pix']].value)
    assert np.abs(parm.logN.value-np.log10(abslin.attrib['N'].value)) < 0.1
开发者ID:linetools,项目名称:linetools,代码行数:32,代码来源:test_voigt.py

示例6: fill_lls_lines

# 需要导入模块: from linetools.spectralline import AbsLine [as 别名]
# 或者: from linetools.spectralline.AbsLine import attrib['N'] [as 别名]
    def fill_lls_lines(self, bval=20.*u.km/u.s):
        """
        Generate an HI line list for an LLS.
        Goes into self.lls_lines 

        Parameters
        ----------
        bval : float (20.)  Doppler parameter in km/s
        """
        from linetools.lists import linelist as lll
        from linetools.spectralline import AbsLine

        # May be replaced by component class (as NT desires)
        HIlines = lll.LineList('HI')

        self.lls_lines = []
        for lline in HIlines._data:
            aline = AbsLine(lline['wrest'],linelist=HIlines)
            # Attributes
            aline.attrib['N'] = self.NHI
            aline.attrib['b'] = bval
            aline.attrib['z'] = self.zabs
            # Could set RA and DEC too
            aline.attrib['RA'] = self.coord.ra
            aline.attrib['DEC'] = self.coord.dec
            self.lls_lines.append(aline)
开发者ID:nhmc,项目名称:xastropy,代码行数:28,代码来源:lls_utils.py

示例7: plot_absline

# 需要导入模块: from linetools.spectralline import AbsLine [as 别名]
# 或者: from linetools.spectralline.AbsLine import attrib['N'] [as 别名]
def plot_absline(iinp,logN,b, show=True):
    """Plot an absorption line with N,b properties

    Parameters
    ----------
    iinp : float or str
      Rest wavelength (Ang) or name of transition (e.g. CIV1548)
    logN : float
      Log10 column
    b : float
      Doppler parameter (km/s)
    show : bool
      Whether to display the plot (set False for running
      tests). Default True.
    """
    import numpy as np
    from linetools.spectralline import AbsLine
    from astropy import units as u

    # Search for the closest absline
    if isinstance(iinp,basestring):
        aline = AbsLine(iinp, closest=True)
    else:
        aline = AbsLine(iinp*u.AA, closest=True)
    wrest = aline.wrest.value

    # Generate a fake wavelength array near the line
    wvoff = 50. # Ang
    dwv = wrest/100000. # Ang (echelle)
    wave = np.arange(wrest-wvoff, wrest+wvoff, dwv)

    # Generate spectrum with voigt
    aline.attrib['N'] = 10**logN * u.cm**-2
    aline.attrib['b'] = b * u.km/u.s
    xspec = aline.generate_voigt(wave=wave*u.AA)
    # get the plotting limits
    # remove first and last pixels
    fl = xspec.flux.value[1:-2]
    ind = np.flatnonzero(fl < 1 - 0.1 * (1 - np.min(fl)))
    ind += 1
    wmin = xspec.wavelength[max(0, ind[0] - 10)]
    wmax = xspec.wavelength[min(len(xspec.flux) - 1,  ind[-1] + 10)]
    #import pdb; pdb.set_trace()
    xspec.constant_sig(0.1) # S/N = 10 per pix

    # Calculate EW
    aline.analy['spec'] = xspec
    aline.analy['wvlim'] = np.array([wrest-15., wrest+15])*u.AA
    aline.measure_ew()
    print(aline)
    print('EW = {:g}'.format(aline.attrib['EW']))

    # Plot
    xspec.plot(xlim=(wmin.to(u.AA).value, wmax.to(u.AA).value), show=show)
开发者ID:banados,项目名称:linetools,代码行数:56,代码来源:lt_absline.py

示例8: test_voigt_sngl_tau

# 需要导入模块: from linetools.spectralline import AbsLine [as 别名]
# 或者: from linetools.spectralline.AbsLine import attrib['N'] [as 别名]
def test_voigt_sngl_tau():
    # Wavelength array
    wave = np.linspace(3644, 3650, 100)*u.AA
    imn = np.argmin(np.abs(wave.value-3647))
    # HI line
    abslin = AbsLine(1215.670*u.AA, z=2.)
    abslin.attrib['N'] = 10**14./u.cm**2
    abslin.attrib['b'] = 25.*u.km/u.s
    # Tau
    tau = lav.voigt_from_abslines(wave,abslin,ret='tau')
    np.testing.assert_allclose(tau[imn], 2.9681283001576779)
开发者ID:jnburchett,项目名称:linetools,代码行数:13,代码来源:test_voigt.py

示例9: test_voigt_sngl_line

# 需要导入模块: from linetools.spectralline import AbsLine [as 别名]
# 或者: from linetools.spectralline.AbsLine import attrib['N'] [as 别名]
def test_voigt_sngl_line():
    # Wavelength array
    wave = np.linspace(3644, 3650, 100)*u.AA
    imn = np.argmin(np.abs(wave.value-3647))
    # HI line
    abslin = AbsLine(1215.670*u.AA, z=2.)
    abslin.attrib['N'] = 10**14./u.cm**2
    abslin.attrib['b'] = 25.*u.km/u.s
    # Voigt
    vmodel = abslin.generate_voigt(wave=wave)
    np.testing.assert_allclose(vmodel.flux[imn].value,0.05145500775919881)
开发者ID:jnburchett,项目名称:linetools,代码行数:13,代码来源:test_voigt.py

示例10: test_DLA_from_components

# 需要导入模块: from linetools.spectralline import AbsLine [as 别名]
# 或者: from linetools.spectralline.AbsLine import attrib['N'] [as 别名]
def test_DLA_from_components():
    radec = SkyCoord(ra=123.1143*u.deg, dec=-12.4321*u.deg)
    # HI Lya, Lyb
    lya = AbsLine(1215.670*u.AA)
    lya.analy['vlim'] = [-300.,300.]*u.km/u.s
    lya.attrib['z'] = 2.92939
    lya.attrib['N'] = 3e20 / u.cm**2
    lyb = AbsLine(1025.7222*u.AA)
    lyb.analy['vlim'] = [-300.,300.]*u.km/u.s
    lyb.attrib['z'] = lya.attrib['z']
    lyb.attrib['N'] = 3e20 / u.cm**2
    abscomp = AbsComponent.from_abslines([lya,lyb])
    abscomp.coord = radec
    # Instantiate
    HIsys = DLASystem.from_components([abscomp])
    # Test
    np.testing.assert_allclose(HIsys.NHI, 20.477121254719663)
    assert len(HIsys._components) == 1
    assert HIsys._components[0].Zion[0] == 1
    assert HIsys._components[0].Zion[1] == 1
开发者ID:ninoc,项目名称:pyigm,代码行数:22,代码来源:test_dlasys.py

示例11: lyman_comp

# 需要导入模块: from linetools.spectralline import AbsLine [as 别名]
# 或者: from linetools.spectralline.AbsLine import attrib['N'] [as 别名]
def lyman_comp(radec, z=2.92939):
    # HI Lya, Lyb
    lya = AbsLine(1215.670*u.AA, z=z, linelist=ism)
    lya.limits.set([-300.,300.]*u.km/u.s)
    lya.attrib['flag_N'] = 1
    lya.attrib['N'] = 1e17 /  u.cm**2
    lya.attrib['sig_N'] = 1e16 /  u.cm**2
    lya.attrib['coord'] = radec
    # Lyb
    lyb = AbsLine(1025.7222*u.AA, z=z, linelist=ism)
    lyb.limits.set([-300.,300.]*u.km/u.s)
    lyb.attrib['coord'] = radec
    lyb.attrib['flag_N'] = 1
    lyb.attrib['N'] = 1e17 /  u.cm**2
    lyb.attrib['sig_N'] = 1e16 /  u.cm**2
    # Build
    abscomp = AbsComponent.from_abslines([lya,lyb])
    #abscomp.synthesize_colm()

    return abscomp
开发者ID:linetools,项目名称:linetools,代码行数:22,代码来源:utils.py

示例12: lyman_comp

# 需要导入模块: from linetools.spectralline import AbsLine [as 别名]
# 或者: from linetools.spectralline.AbsLine import attrib['N'] [as 别名]
def lyman_comp(radec):
    # HI Lya, Lyb
    lya = AbsLine(1215.670*u.AA)
    lya.analy['vlim'] = [-300.,300.]*u.km/u.s
    lya.attrib['z'] = 2.92939
    lya.attrib['N'] = 1e17 /  u.cm**2
    lyb = AbsLine(1025.7222*u.AA)
    lyb.analy['vlim'] = [-300.,300.]*u.km/u.s
    lyb.attrib['z'] = lya.attrib['z']
    abscomp = AbsComponent.from_abslines([lya,lyb])
    abscomp.coord = radec
    return abscomp
开发者ID:banados,项目名称:linetools,代码行数:14,代码来源:test_init_abssys.py

示例13: plot_absline

# 需要导入模块: from linetools.spectralline import AbsLine [as 别名]
# 或者: from linetools.spectralline.AbsLine import attrib['N'] [as 别名]
def plot_absline(wrest,logN,b):
    """Plot an absorption line with N,b properties

    Parameters
    ----------
    wrest : float
      Rest wavelength (Ang)
    logN : float
      Log10 column
    b : float
      Doppler parameter (km/s)
    """
    import numpy as np
    from linetools.spectra.xspectrum1d import XSpectrum1D
    from linetools.lists.linelist import LineList
    from linetools.spectralline import AbsLine
    from linetools.analysis import voigt as lav
    from astropy import units as u

    # Search for the closest absline
    aline = AbsLine(wrest*u.AA, closest=True)

    # Generate a fake wavelength array near the line
    wvoff = 50. # Ang
    dwv = wrest/100000. # Ang (echelle)
    wave = np.arange(wrest-wvoff, wrest+wvoff, dwv)

    # Generate spectrum with voigt
    aline.attrib['N'] = logN
    aline.attrib['b'] = b * u.km/u.s
    xspec = aline.generate_voigt(wave=wave*u.AA)
    xspec.constant_sig(0.1) # S/N = 10 per pix


    # Calculate EW
    aline.analy['spec'] = xspec
    aline.analy['wvlim'] = np.array([wrest-15., wrest+15])*u.AA
    aline.measure_ew()
    print(aline)
    print('EW = {:g}'.format(aline.attrib['EW']))

    # Plot
    xspec.plot()
开发者ID:ntejos,项目名称:linetools,代码行数:45,代码来源:linet_absline.py

示例14: test_one_component

# 需要导入模块: from linetools.spectralline import AbsLine [as 别名]
# 或者: from linetools.spectralline.AbsLine import attrib['N'] [as 别名]
def test_one_component():
    radec = SkyCoord(ra=123.1143*u.deg, dec=-12.4321*u.deg)
    # HI Lya, Lyb
    lya = AbsLine(1215.670*u.AA)
    lya.analy['vlim'] = [-300.,300.]*u.km/u.s
    lya.attrib['z'] = 2.92939
    lya.attrib['N'] = 1e17 /  u.cm**2
    lyb = AbsLine(1025.7222*u.AA)
    lyb.analy['vlim'] = [-300.,300.]*u.km/u.s
    lyb.attrib['z'] = lya.attrib['z']
    abscomp = AbsComponent.from_abslines([lya,lyb])
    abscomp.coord = radec
    # Instantiate
    HIsys = LymanAbsSystem.from_components([abscomp])
    # Test
    assert HIsys.abs_type == 'HILyman'
    assert len(HIsys._components) == 1
    assert HIsys._components[0].Zion[0] == 1
    assert HIsys._components[0].Zion[1] == 1
开发者ID:lwymarie,项目名称:linetools,代码行数:21,代码来源:test_init_abssys.py

示例15: add_forest

# 需要导入模块: from linetools.spectralline import AbsLine [as 别名]
# 或者: from linetools.spectralline.AbsLine import attrib['N'] [as 别名]
 def add_forest(self,inp,z):
     '''Add a Lya/Lyb forest line
     '''
     from xastropy.igm.abs_sys.abssys_utils import GenericAbsSystem
     forest = GenericAbsSystem((0.*u.deg,0.*u.deg), z, [-300.,300.]*u.km/u.s)
     # NHI
     NHI_dict = {'6':12.,'7':13.,'8':14.,'9':15.}
     forest.NHI=NHI_dict[inp]
     # Lines
     for name in ['HI 1215','HI 1025', 'HI 972']:
         aline = AbsLine(name,
             linelist=self.llist[self.llist['List']])
         # Attributes
         aline.attrib['N'] = 10**forest.NHI * u.cm**-2
         aline.attrib['b'] = 20.*u.km/u.s
         aline.attrib['z'] = forest.zabs
         # Append
         forest.lines.append(aline)
     # Append to forest lines
     self.all_forest.append(forest)
开发者ID:banados,项目名称:xastropy,代码行数:22,代码来源:xfitllsgui.py


注:本文中的linetools.spectralline.AbsLine.attrib['N']方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。