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


Python AbsLine.cut_spec方法代码示例

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


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

示例1: load_abskin

# 需要导入模块: from linetools.spectralline import AbsLine [as 别名]
# 或者: from linetools.spectralline.AbsLine import cut_spec [as 别名]
    def load_abskin(self, flg=1, kin_file=None, kin_init_file=None):
        """ Load the absorption-line kinematic data for COS-Halos (or COS-Dwarfs)
        Calculate from scratch if needed

        Parameters
        ----------
        flg: int, optional 
          Flag indicating how to load the data
            0 = Load from file
            1 = Generate
        kin_init_file: str
          Name of kinematics driver file
        kin_file: str
          Name of kinematics output file [First made for John Forbes]
        """
    
        if flg == 0: # Load
            if kin_file is None:
                kin_file = os.path.abspath(os.environ.get('DROPBOX_DIR')+'/COS-Halos/Kin/'+
                                                  'COS-Halos_kin.fits')
            hdu = fits.open(kin_file)
            # Metals
            metals = Table(hdu[1].data)
            for row in metals:
                mt = np.where( (row['field']==self.field) & 
                    (row['gal_id']==self.gal_id))[0]
                pdb.set_trace()

        elif flg == 1: # Generate
            # Read init file
            if kin_init_file is None:
                kin_init_file = self.kin_init_file
            kin_init = ascii.read(kin_init_file,guess=False)
    
            # Loop to my loop
            fgal = zip(self.field, self.gal_id)
            for qq,cgm_abs in enumerate(self.cgm_abs):
                # Match to kin_init
                mt = np.where((kin_init['QSO'] == cgm_abs.field) &
                               (kin_init['Galaxy'] == cgm_abs.gal_id))[0]
                if len(mt) == 0:
                    warnings.warn('load_kin: No kinematics for {:s}, {:s}'.format(cgm_abs.field,
                                                                          cgm_abs.gal_id))
                    continue
                mt = mt[0]

                # Metals
                if kin_init['flgL'][mt] > 0:
                    wrest = kin_init['mtl_wr'][mt]*u.AA 
                    if wrest.value <= 1:
                        pdb.set_trace()
                    spec = self.load_bg_cos_spec(qq, wrest)
                    vmnx = (kin_init['L_vmn'][mt], kin_init['L_vmx'][mt])*u.km/u.s
                    # Process
                    aline = AbsLine(wrest)
                    aline.analy['spec'] = spec
                    aline.analy['vlim'] = vmnx
                    aline.attrib['z'] = cgm_abs.igm_sys.zabs
                    fx, sig, cdict = aline.cut_spec()
                    # Kin
                    stau = laak.generate_stau(cdict['velo'], fx, sig)
                    cgm_abs.igm_sys.kin['Metal'] = laak.pw97_kin(cdict['velo'], stau, per=0.07)
                    cgm_abs.igm_sys.kin['Metal'].update(laak.cgm_kin(cdict['velo'], stau, per=0.07))
                    # Save spec
                    #cgm_abs.igm_sys.kin['Metal']['spec'] = spec
                else:
                    cgm_abs.igm_sys.kin['Metal'] = {}

                # HI
                if kin_init['flgH'][mt] > 0:
                    wrest = kin_init['HI_wrest'][mt]*u.AA 
                    if wrest.value <= 1:
                        pdb.set_trace()
                    spec = self.load_bg_cos_spec( qq, wrest )
                    if spec is None:
                        pdb.set_trace()
                    vmnx = (kin_init['HIvmn'][mt], kin_init['HIvmx'][mt])*u.km/u.s
                    # Process
                    aline = AbsLine(wrest)
                    aline.analy['spec'] = spec
                    aline.analy['vlim'] = vmnx
                    aline.attrib['z'] = cgm_abs.igm_sys.zabs
                    fx, sig, cdict = aline.cut_spec()
                    # Kin
                    stau = laak.generate_stau(cdict['velo'], fx, sig)
                    cgm_abs.igm_sys.kin['HI'] = laak.pw97_kin(cdict['velo'], stau, per=0.07)
                    cgm_abs.igm_sys.kin['HI'].update(laak.cgm_kin(cdict['velo'], stau, per=0.07))
                else:
                    # Fill with zeros (for the keys)
                    cgm_abs.igm_sys.kin['HI'] = {}
开发者ID:pyigm,项目名称:pyigm,代码行数:92,代码来源:cos_halos.py


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