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


Python spectralline.AbsLine类代码示例

本文整理汇总了Python中linetools.spectralline.AbsLine的典型用法代码示例。如果您正苦于以下问题:Python AbsLine类的具体用法?Python AbsLine怎么用?Python AbsLine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: test_add_component

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,代码行数:28,代码来源:test_init_abssys.py

示例2: stack_plot

 def stack_plot(self, inp, use_lines=None, ymnx=None, add_lines=None, **kwargs):
     """ Generate a stack plot of the key lines for a given COS-Halos system
     Parameters
     ----------
     inp : int or tuple
       int -- Index of the cgm_abs list
       tuple -- (field,gal_id)
     add_lines : list, optional
       List of additional lines to plot
     """
     # Init
     from linetools.analysis import plots as ltap
     if ymnx is None:
         ymnx=(-0.1,1.2)
     cgm_abs = self[inp]
     abs_lines = []
     # Setup the lines (defaults to a key seto)
     if use_lines is None:
         use_lines = [1215.6700, 1025.7223, 1334.5323, 977.020, 1031.9261, 1037.6167,
                      1260.4221, 1206.500, 1393.7550, 2796.352]*u.AA
         if add_lines is not None:
             use_lines = list(use_lines.value) + add_lines
             use_lines.sort()
             use_lines = use_lines*u.AA
     for iline in use_lines:
         spec = self.load_bg_cos_spec(inp, iline)
         if spec is None:
             print('Skipping {:g}. Assuming no coverage'.format(iline))
         aline = AbsLine(iline, closest=True)
         aline.analy['spec'] = spec
         aline.attrib['z'] = cgm_abs.galaxy.z
         abs_lines.append(aline)
     # Execute
     ltap.stack_plot(abs_lines, vlim=[-400., 400]*u.km/u.s, ymnx=ymnx, **kwargs)
开发者ID:pyigm,项目名称:pyigm,代码行数:34,代码来源:cos_halos.py

示例3: read_ion_file

    def read_ion_file(self,ion_fil,zabs=0.,RA=0.*u.deg, Dec=0.*u.deg):
        """Read in JXP-style .ion file in an appropriate manner

        NOTE: If program breaks in this function, check the all file 
        to see if it is properly formatted.
        """
        # Read
        names=('wrest', 'clm', 'sig_clm', 'flg_clm', 'flg_inst') 
        table = ascii.read(ion_fil, format='no_header', names=names) 

        if self.linelist is None:
            self.linelist = LineList('ISM')

        # Generate AbsLine's
        for row in table:
            # Generate the line
            aline = AbsLine(row['wrest']*u.AA, linelist=self.linelist, closest=True)
            # Set z, RA, DEC, etc.
            aline.attrib['z'] = self.zabs
            aline.attrib['RA'] = self.coord.ra
            aline.attrib['Dec'] = self.coord.dec
            # Check against existing lines
            mt = [kk for kk,oline in enumerate(self.lines) if oline.ismatch(aline)]
            if len(mt) > 0:
                mt.reverse()
                for imt in mt:
                    print('read_ion_file: Removing line {:g}'.format(self.lines[imt].wrest))
                    self.lines.pop(imt)
            # Append
            self.lines.append(aline)
开发者ID:nhmc,项目名称:xastropy,代码行数:30,代码来源:abssys_utils.py

示例4: add_DLA

    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,代码行数:30,代码来源:xfitdlagui.py

示例5: test_init_single_absline

def test_init_single_absline():
    # Single AbsLine
    lya = AbsLine(1215.670*u.AA)
    lya.analy['vlim'] = [-300.,300.]*u.km/u.s
    lya.attrib['z'] = 2.92939
    abscomp = AbsComponent.from_abslines([lya])
    # Test
    assert abscomp.Zion[0] == 1
    np.testing.assert_allclose(abscomp.zcomp,2.92939)
开发者ID:nhmc,项目名称:linetools,代码行数:9,代码来源:test_init_abscomp.py

示例6: dla_vary_NHI

def dla_vary_NHI(outfil='Figures/dla_vary_NHI.pdf'):
    """ DLA profiles with NHI varying
    """
    # Wavelength array for my 'perfect' instrument
    wave = np.linspace(1160., 1270., 20000) * u.AA
    vel = (wave-1215.67*u.AA)/(1215.67*u.AA) * const.c.to('km/s')

    # Lya line
    lya = AbsLine(1215.6700*u.AA)
    #lya.attrib['N'] = 10.**(13.6)/u.cm**2
    lya.attrib['b'] = 30 * u.km/u.s
    lya.attrib['z'] = 0.

    aNHI = [20.3, 21., 21.5, 22.]

    # Start the plot
    xmnx = (-10000, 10000)
    ymnx = (0., 1.0)
    pp = PdfPages(outfil)
    fig = plt.figure(figsize=(8.0, 5.0))

    plt.clf()
    gs = gridspec.GridSpec(1,1)

    # Lya line
    ax = plt.subplot(gs[0])
    #ax.xaxis.set_minor_locator(plt.MultipleLocator(0.5))
    #ax.xaxis.set_major_locator(plt.MultipleLocator(20.))
    #ax.yaxis.set_minor_locator(plt.MultipleLocator(0.1))
    #ax.yaxis.set_major_locator(plt.MultipleLocator(0.2))
    ax.set_xlim(xmnx)
    ax.set_ylim(ymnx)
    ax.set_ylabel('Normalized Flux')
    ax.set_xlabel('Relative Velocity (km/s)') 

    lw = 1.5
    # Data
    for NHI in aNHI:
        lyai = copy.deepcopy(lya)
        lyai.attrib['N'] = 10**NHI / u.cm**2
        f_obsi = ltav.voigt_from_abslines(wave, [lyai])
        ax.plot(vel, f_obsi.flux, linewidth=lw, 
            label=r'$\log N_{\rm HI} = $'+'{:0.2f}'.format(NHI))

    # Legend
    legend = plt.legend(loc='lower left', scatterpoints=1, borderpad=0.3, 
        handletextpad=0.3, fontsize='large', numpoints=1)
    xputils.set_fontsize(ax, 17.)
    # Layout and save
    print('Writing {:s}'.format(outfil))
    plt.tight_layout(pad=0.2,h_pad=0.0,w_pad=0.4)
    plt.subplots_adjust(hspace=0)
    pp.savefig(bbox_inches='tight')
    plt.close()
    # Finish
    pp.close()
开发者ID:Tuo-Ji,项目名称:SaasFee2016,代码行数:56,代码来源:saasfee16_figures.py

示例7: test_add_absline

def test_add_absline():
    abscomp,_ = mk_comp('HI', zcomp=0.)
    abscomp.add_absline(AbsLine('HI 972'), chk_sep=False, chk_vel=False)
    with pytest.raises(ValueError):
        abscomp.add_absline(AbsLine('HI 949'), vtoler=-10)
    # failed addition
    bad_absline = AbsLine('CIV 1550')
    bad_absline.limits.set([500, 1000]*u.km/u.s)
    bad_absline.attrib['coord'] = SkyCoord(20,20, unit='deg')
    abscomp.add_absline(bad_absline)
开发者ID:lwymarie,项目名称:linetools,代码行数:10,代码来源:test_use_abscomp.py

示例8: test_ismatch

def test_ismatch():
    # Test Simple kinematics
    abslin1 = AbsLine('NiII 1741', z=1.)
    abslin2 = AbsLine('NiII 1741', z=1.)
    # Run
    answer = abslin1.ismatch(abslin2)
    assert answer
    # Tuple too
    answer2 = abslin1.ismatch((1., abslin1.wrest))
    assert answer2
开发者ID:linetools,项目名称:linetools,代码行数:10,代码来源:test_absline_anly.py

示例9: test_list_of_abslines

def test_list_of_abslines():
    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
    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
    # SiII
    SiIItrans = ['SiII 1260', 'SiII 1304', 'SiII 1526', 'SiII 1808']
    abslines = []
    for trans in SiIItrans:
        iline = AbsLine(trans)
        iline.attrib['z'] = 2.92939
        iline.analy['vlim'] = [-250.,80.]*u.km/u.s
        abslines.append(iline)
    #
    SiII_comp = AbsComponent.from_abslines(abslines)
    SiII_comp.coord = radec
    # Instantiate
    gensys = GenericAbsSystem.from_components([abscomp,SiII_comp])
    # Now the list
    abslines = gensys.list_of_abslines()
    # Test
    assert len(abslines) == 6
    # Grab one line
    lyb = gensys.get_absline('HI 1025')
    np.testing.assert_allclose(lyb.wrest.value, 1025.7222)
    lyb = gensys.get_absline(1025.72*u.AA)
    np.testing.assert_allclose(lyb.wrest.value, 1025.7222)
开发者ID:ntejos,项目名称:linetools,代码行数:33,代码来源:test_use_abssys.py

示例10: test_multi_components

def test_multi_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
    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
    # SiII
    SiIItrans = ['SiII 1260', 'SiII 1304', 'SiII 1526', 'SiII 1808']
    abslines = []
    for trans in SiIItrans:
        iline = AbsLine(trans)
        iline.attrib['z'] = 2.92939
        iline.analy['vlim'] = [-250.,80.]*u.km/u.s
        abslines.append(iline)
    #
    SiII_comp = AbsComponent.from_abslines(abslines)
    SiII_comp.coord = radec
    # Instantiate
    LLSsys = GenericAbsSystem.from_components([abscomp,SiII_comp])
    # Test
    assert len(LLSsys._components) == 2
开发者ID:MSeifert04,项目名称:linetools,代码行数:26,代码来源:test_init_abssys.py

示例11: test_voigt_sngl_line

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,代码行数:11,代码来源:test_voigt.py

示例12: test_voigt_sngl_tau

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,代码行数:11,代码来源:test_voigt.py

示例13: test_init_multi_absline

def test_init_multi_absline():
    # AbsLine(s)
    lya = AbsLine(1215.670*u.AA, z=2.92939)
    lya.limits.set([-300.,300.]*u.km/u.s)
    lyb = AbsLine(1025.7222*u.AA)
    lyb.setz(lya.z)
    lyb.limits.set([-300.,300.]*u.km/u.s)
    # Instantiate
    abscomp = AbsComponent.from_abslines([lya,lyb])
    # Test
    assert len(abscomp._abslines) == 2
    np.testing.assert_allclose(abscomp.zcomp,2.92939)
开发者ID:lwymarie,项目名称:linetools,代码行数:12,代码来源:test_init_abscomp.py

示例14: test_measurekin_absline

def test_measurekin_absline():
    # Test Simple kinematics
    abslin = AbsLine('NiII 1741',z=2.307922)

    # Set spectrum
    abslin.analy['spec'] = lsio.readspec(data_path('PH957_f.fits'))
    abslin.limits.set([-70., 70.]*u.km/u.s)

    # Measure Kin
    abslin.measure_kin()
    np.testing.assert_allclose(abslin.attrib['kin']['Dv'].value, 75.)
    np.testing.assert_allclose(abslin.attrib['kin']['fedg'], 0.20005782376000183)
开发者ID:linetools,项目名称:linetools,代码行数:12,代码来源:test_absline_anly.py

示例15: test_dicts

def test_dicts():
    # Init HI Lya
    abslin = AbsLine(1215.6700*u.AA)
    adict = abslin.to_dict()
    assert isinstance(adict, dict)
    # Write
    #pdb.set_trace()
    ltu.savejson('tmp.json', adict, overwrite=True)
    # Read
    newdict = ltu.loadjson('tmp.json')
    newlin = SpectralLine.from_dict(newdict)
    assert newlin.name == 'HI 1215'
开发者ID:MSeifert04,项目名称:linetools,代码行数:12,代码来源:test_init_absline.py


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