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


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

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


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

示例1: read_ion_file

# 需要导入模块: from linetools.spectralline import AbsLine [as 别名]
# 或者: from linetools.spectralline.AbsLine import attrib['Dec'] [as 别名]
    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,代码行数:32,代码来源:abssys_utils.py

示例2: read_ion_file

# 需要导入模块: from linetools.spectralline import AbsLine [as 别名]
# 或者: from linetools.spectralline.AbsLine import attrib['Dec'] [as 别名]
def read_ion_file(ion_fil,lines=None,components=None,linelist=None,toler=0.05*u.AA):
    """ Read in JXP-style .ion file in an appropriate manner

    NOTE: If program breaks in this function, check the .ion file
    to see if it is properly formatted.

    If components is passed in, these are filled as applicable.

    Parameters
    ----------
    ion_fil : str
      Full path to .ion file
    lines : list, optional
      List of AbsLine objects [used for historical reasons, mainly]
    components : list, optional
      List of AbsComponent objects
    linelist : LineList
      May speed up performance
    toler : Quantity, optional
      Tolerance for matching wrest
    """
    assert False # USE LINETOOLS
    # Read
    names=('wrest', 'logN', 'sig_logN', 'flag_N', 'flg_inst')
    table = ascii.read(ion_fil, format='no_header', names=names)

    if components is None:
        if lines is None:
            lines = []
        # Generate AbsLine's
        for row in table:
            # Generate the line
            aline = AbsLine(row['wrest']*u.AA, linelist=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
            aline.attrib['coord'] = self.coord
            aline.attrib['logN'] = row['logN']
            aline.attrib['sig_logN'] = row['sig_logN']
            aline.attrib['flag_N'] = row['flag_N']
            aline.analy['flg_inst'] = row['flg_inst']
            # Check against existing lines
            mt = [kk for kk,oline in enumerate(lines) if oline.ismatch(aline)]
            if len(mt) > 0:
                mt.reverse()
                for imt in mt:
                    print('read_ion_file: Removing line {:g}'.format(lines[imt].wrest))
                    lines.pop(imt)
            # Append
            lines.append(aline)
            return lines
    else: # Fill entries in components
        # Generate look-up table for quick searching
        all_wv = []
        all_idx = []
        for jj,comp in enumerate(components):
            for kk,iline in enumerate(comp._abslines):
                all_wv.append(iline.wrest)
                all_idx.append((jj,kk))
        all_wv = u.Quantity(all_wv)
        # Loop now
        for row in table:
            mt = np.where(np.abs(all_wv-row['wrest']*u.AA)<toler)[0]
            if len(mt) == 0:
                pass
            elif len(mt) == 1:
                # Fill
                jj = all_idx[mt[0]][0]
                kk = all_idx[mt[0]][1]
                components[jj]._abslines[kk].attrib['flag_N'] = row['flag_N']
                components[jj]._abslines[kk].attrib['logN'] = row['logN']
                components[jj]._abslines[kk].attrib['sig_logN'] = row['sig_logN']
                components[jj]._abslines[kk].analy['flg_inst'] = row['flg_inst']
            else:
                raise ValueError("Matched multiple lines in read_ion_file")
        # Return
        return table
开发者ID:banados,项目名称:xastropy,代码行数:80,代码来源:ionclms.py


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