本文整理汇总了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
示例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