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


Python AbsLine.attrib["z"]方法代码示例

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


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

示例1: add_forest

# 需要导入模块: from linetools.spectralline import AbsLine [as 别名]
# 或者: from linetools.spectralline.AbsLine import attrib["z"] [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.0 * u.deg, 0.0 * u.deg), z, [-300.0, 300.0] * u.km / u.s)
        # NHI
        NHI_dict = {"6": 12.0, "7": 13.0, "8": 14.0, "9": 15.0}
        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.0 * u.km / u.s
            aline.attrib["z"] = forest.zabs
            # Append
            forest.lines.append(aline)
        # Append to forest lines
        self.all_forest.append(forest)
开发者ID:ntejos,项目名称:xastropy,代码行数:22,代码来源:xfitllsgui.py

示例2: read_clmfile

# 需要导入模块: from linetools.spectralline import AbsLine [as 别名]
# 或者: from linetools.spectralline.AbsLine import attrib["z"] [as 别名]
def read_clmfile(clm_file, linelist=None):
    """ Read in a .CLM file in an appropriate manner

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


    RETURNS two dictionaries CLM and LINEDIC. CLM contains the contents of CLM
    for the given DLA. THe LINEDIC that is passed (when not None) is updated appropriately.

    Keys in the CLM dictionary are:
      INST - Instrument used
      FITS - a list of fits files
      ZABS - absorption redshift
      ION - .ION file location
      HI - THe HI column and error; [HI, HIerr]
      FIX - Any abundances that need fixing from the ION file
      VELS - Dictioanry of velocity limits, which is keyed by
        FLAGS - Any measurment flags assosicated with VLIM
        VLIM - velocity limits in km/s [vmin,vmax]
        ELEM - ELement (from get_elem)

    See get_elem for properties of LINEDIC

    Parameters
    ----------
    clm_file : str
      Full path to the .clm file
    linelist : LineList
      can speed up performance
    """
    clm_dict = {}
    # Read file
    f = open(clm_file, "r")
    arr = f.readlines()
    f.close()
    nline = len(arr)
    # Data files
    clm_dict["flg_data"] = int(arr[1][:-1])
    clm_dict["fits_files"] = {}
    ii = 2
    for jj in range(0, 6):
        if (clm_dict["flg_data"] % (2 ** (jj + 1))) > (2 ** jj - 1):
            clm_dict["fits_files"][2 ** jj] = arr[ii].strip()
            ii += 1

    # Redshift
    clm_dict["zsys"] = float(arr[ii][:-1])
    ii += 1
    clm_dict["ion_fil"] = arr[ii].strip()
    ii += 1
    # NHI
    tmp = arr[ii].split(",")
    ii += 1
    if len(tmp) != 2:
        raise ValueError("ionic_clm: Bad formatting {:s} in {:s}".format(arr[ii - 1], clm_file))
    clm_dict["NHI"] = float(tmp[0])
    clm_dict["sigNHI"] = float(tmp[1])
    # Abundances by hand
    numhand = int(arr[ii][:-1])
    ii += 1
    clm_dict["fixabund"] = {}
    if numhand > 0:
        for jj in range(numhand):
            # Atomic number
            atom = int(arr[ii][:-1])
            ii += 1
            # Values
            tmp = arr[ii].strip().split(",")
            ii += 1
            clm_dict["fixabund"][atom] = float(tmp[0]), float(tmp[1]), int(tmp[2])
    # Loop on lines
    clm_dict["lines"] = {}
    while ii < (nline - 1):
        # No empty lines allowed
        if len(arr[ii].strip()) == 0:
            break
        # Read flag
        ionflg = int(arr[ii].strip())
        ii += 1
        # Read the rest
        tmp = arr[ii].split(",")
        ii += 1
        if len(tmp) != 4:
            raise ValueError("ionic_clm: Bad formatting {:s} in {:s}".format(arr[ii - 1], clm_file))
        vmin = float(tmp[1].strip())
        vmax = float(tmp[2].strip())
        key = float(tmp[0].strip())  # Using a numpy float not string!
        # Generate
        clm_dict["lines"][key] = AbsLine(key * u.AA, closest=True, linelist=linelist)
        clm_dict["lines"][key].attrib["z"] = clm_dict["zsys"]
        clm_dict["lines"][key].analy["FLAGS"] = ionflg, int(tmp[3].strip())
        # By-hand
        if ionflg >= 8:
            clm_dict["lines"][key].attrib["N"] = 10.0 ** vmin / u.cm ** 2
            clm_dict["lines"][key].attrib["sig_N"] = (10.0 ** (vmin + vmax) - 10.0 ** (vmin - vmax)) / 2 / u.cm ** 2
        else:
            clm_dict["lines"][key].analy["vlim"] = [vmin, vmax] * u.km / u.s
    # Return
    return clm_dict
开发者ID:nhmc,项目名称:pyigm,代码行数:101,代码来源:utils.py


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