本文整理汇总了Python中openquake.baselib.general.AccumDict.eps方法的典型用法代码示例。如果您正苦于以下问题:Python AccumDict.eps方法的具体用法?Python AccumDict.eps怎么用?Python AccumDict.eps使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openquake.baselib.general.AccumDict
的用法示例。
在下文中一共展示了AccumDict.eps方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_assets_by_taxo
# 需要导入模块: from openquake.baselib.general import AccumDict [as 别名]
# 或者: from openquake.baselib.general.AccumDict import eps [as 别名]
def get_assets_by_taxo(assets, epspath=None):
"""
:param assets: an array of assets
:param epspath: hdf5 file where the epsilons are (or None)
:returns: assets_by_taxo with attributes eps and idxs
"""
assets_by_taxo = AccumDict(group_array(assets, 'taxonomy'))
assets_by_taxo.idxs = numpy.argsort(numpy.concatenate([
a['ordinal'] for a in assets_by_taxo.values()]))
assets_by_taxo.eps = {}
if epspath is None: # no epsilons
return assets_by_taxo
# otherwise read the epsilons and group them by taxonomy
with hdf5.File(epspath, 'r') as h5:
dset = h5['epsilon_matrix']
for taxo, assets in assets_by_taxo.items():
lst = [dset[aid] for aid in assets['ordinal']]
assets_by_taxo.eps[taxo] = numpy.array(lst)
return assets_by_taxo