本文整理汇总了Python中openquake.baselib.general.AccumDict.calc_times[trt_model_id]方法的典型用法代码示例。如果您正苦于以下问题:Python AccumDict.calc_times[trt_model_id]方法的具体用法?Python AccumDict.calc_times[trt_model_id]怎么用?Python AccumDict.calc_times[trt_model_id]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openquake.baselib.general.AccumDict
的用法示例。
在下文中一共展示了AccumDict.calc_times[trt_model_id]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: compute_ruptures
# 需要导入模块: from openquake.baselib.general import AccumDict [as 别名]
# 或者: from openquake.baselib.general.AccumDict import calc_times[trt_model_id] [as 别名]
def compute_ruptures(branch_info, source, sitecol, oqparam, monitor):
"""
Returns the ruptures as a TRT set
:param str branch_info:
Tuple of (ltbr, branch_id, branch_weight)
:param source:
Instance of the UCERFSESControl object
:param sitecol:
Site collection :class: openquake.hazardlib.site.SiteCollection
:param info:
Instance of the :class: openquake.commonlib.source.CompositionInfo
:returns:
Dictionary of rupture instances associated to a TRT ID
"""
integration_distance = oqparam.maximum_distance[DEFAULT_TRT]
res = AccumDict()
res.calc_times = AccumDict()
serial = 1
filter_mon = monitor('update_background_site_filter', measuremem=False)
event_mon = monitor('sampling ruptures', measuremem=False)
for trt_model_id, (ltbrid, branch_id, _) in enumerate(branch_info):
t0 = time.time()
with filter_mon:
source.update_background_site_filter(sitecol, integration_distance)
# set the seed before calling generate_event_set
numpy.random.seed(oqparam.random_seed + trt_model_id)
ses_ruptures = []
for ses_idx in range(1, oqparam.ses_per_logic_tree_path + 1):
with event_mon:
rups, n_occs = source.generate_event_set(
branch_id, sitecol, integration_distance)
for i, rup in enumerate(rups):
rup.seed = oqparam.random_seed # to think
rrup = rup.surface.get_min_distance(sitecol.mesh)
r_sites = sitecol.filter(rrup <= integration_distance)
if r_sites is None:
continue
indices = r_sites.indices
events = []
for j in range(n_occs[i]):
# NB: the first 0 is a placeholder for the eid that will be
# set later, in EventBasedRuptureCalculator.post_execute;
# the second 0 is the sampling ID
events.append((0, ses_idx, j, 0))
if len(events):
ses_ruptures.append(
event_based.EBRupture(
rup, indices,
numpy.array(events, event_based.event_dt),
source.source_id, trt_model_id, serial))
serial += 1
dt = time.time() - t0
res.calc_times[trt_model_id] = (ltbrid, dt)
res[trt_model_id] = ses_ruptures
res.trt = DEFAULT_TRT
return res