當前位置: 首頁>>代碼示例>>Python>>正文


Python Group.filename方法代碼示例

本文整理匯總了Python中larch.Group.filename方法的典型用法代碼示例。如果您正苦於以下問題:Python Group.filename方法的具體用法?Python Group.filename怎麽用?Python Group.filename使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在larch.Group的用法示例。


在下文中一共展示了Group.filename方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: copy_group

# 需要導入模塊: from larch import Group [as 別名]
# 或者: from larch.Group import filename [as 別名]
    def copy_group(self, filename, new_filename=None):
        """copy XAS group (by filename) to new group"""
        groupname = self.file_groups[filename]
        if not hasattr(self.larch.symtable, groupname):
            return

        ogroup = self.get_group(groupname)

        ngroup = Group(datatype=ogroup.datatype,
                       copied_from=groupname)

        for attr in dir(ogroup):
            do_copy = True
            if attr in ('xdat', 'ydat', 'i0', 'data' 'yerr',
                        'energy', 'mu'):
                val = getattr(ogroup, attr)*1.0
            elif attr in ('norm', 'flat', 'deriv', 'deconv',
                          'post_edge', 'pre_edge', 'norm_mback',
                          'norm_vict', 'norm_poly'):
                do_copy = False
            else:
                try:
                    val = copy.deepcopy(getattr(ogroup, attr))
                except ValueError:
                    do_copy = False
            if do_copy:
                setattr(ngroup, attr, val)

        if new_filename is None:
            new_filename = filename + '_1'
        ngroup.filename = unique_name(new_filename, self.file_groups.keys())
        ngroup.groupname = unique_name(groupname, self.file_groups.values())
        setattr(self.larch.symtable, ngroup.groupname, ngroup)
        return ngroup
開發者ID:xraypy,項目名稱:xraylarch,代碼行數:36,代碼來源:xasgui.py

示例2: read_xdi

# 需要導入模塊: from larch import Group [as 別名]
# 或者: from larch.Group import filename [as 別名]
def read_xdi(filename, labels=None, _larch=None):
    """simple mapping of XDI file to larch groups"""
    xdif = XDIFile(filename, labels=labels)
    group = Group()
    for key, val in xdif.__dict__.items():
        if not key.startswith('_'):
            if six.PY3 and key in string_attrs:
                val = tostr(val)
            setattr(group, key, val)
    group.__name__ ='XDI file %s' % filename
    doc = ['%i arrays, %i npts' % (xdif.narrays, xdif.npts)]
    arr_labels = getattr(xdif, 'array_labels', None)
    if arr_labels is not None:
        doc.append("Array Labels: %s" % repr(arr_labels))
    group.__doc__ = '\n'.join(doc)

    group.path = filename
    path, fname = os.path.split(filename)
    group.filename = fname
    return group
開發者ID:maurov,項目名稱:xraylarch,代碼行數:22,代碼來源:xdi.py


注:本文中的larch.Group.filename方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。