本文整理汇总了Python中openquake.baselib.general.AccumDict.update方法的典型用法代码示例。如果您正苦于以下问题:Python AccumDict.update方法的具体用法?Python AccumDict.update怎么用?Python AccumDict.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openquake.baselib.general.AccumDict
的用法示例。
在下文中一共展示了AccumDict.update方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: compute_ruptures_gmfs_curves
# 需要导入模块: from openquake.baselib.general import AccumDict [as 别名]
# 或者: from openquake.baselib.general.AccumDict import update [as 别名]
def compute_ruptures_gmfs_curves(
source_models, sitecol, rlzs_assoc, monitor):
"""
Returns the ruptures as a TRT set
:param source_models:
A list of UCERF source models, one per branch
:param sitecol:
Site collection :class:`openquake.hazardlib.site.SiteCollection`
:param rlzs_assoc:
Instance of :class:`openquake.commonlib.source.RlzsAssoc`
:param monitor:
Instance of :class:`openquake.baselib.performance.Monitor`
:returns:
Dictionary of rupture instances associated to a TRT ID
"""
oq = monitor.oqparam
correl_model = oq.get_correl_model()
imts = list(oq.imtls)
min_iml = calc.fix_minimum_intensity(oq.minimum_intensity, imts)
integration_distance = oq.maximum_distance[DEFAULT_TRT]
res = AccumDict()
res.calc_times = AccumDict()
serial = 1
event_mon = monitor('sampling ruptures', measuremem=False)
res['ruptures'] = rupdic = AccumDict()
rupdic.num_events = 0
rupdic.trt = DEFAULT_TRT
rlzs_by_grp = rlzs_assoc.get_rlzs_by_grp_id()
for grp_id, source_model in enumerate(source_models):
[grp] = source_model.src_groups # one source group per source model
[ucerf] = grp # one source per source group
t0 = time.time()
# set the seed before calling generate_event_set
numpy.random.seed(oq.random_seed + grp_id)
ses_ruptures = []
eid = 0
ucerf.idx_set = ucerf.build_idx_set()
background_sids = ucerf.get_background_sids(
sitecol, integration_distance)
for ses_idx in range(1, oq.ses_per_logic_tree_path + 1):
with event_mon:
rups, n_occs = ucerf.generate_event_set(background_sids)
for i, rup in enumerate(rups):
rup.seed = oq.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]):
events.append((eid, ses_idx, j, 0)) # 0 is the sampling ID
eid += 1
if events:
ses_ruptures.append(
event_based.EBRupture(
rup, indices,
numpy.array(events, event_based.event_dt),
ucerf.source_id, grp_id, serial))
serial += 1
rupdic.num_events += len(events)
res['ruptures'][grp_id] = ses_ruptures
gsims = [dic[DEFAULT_TRT] for dic in rlzs_assoc.gsim_by_trt]
gg = riskinput.GmfGetter(gsims, ses_ruptures, sitecol,
imts, min_iml, oq.truncation_level,
correl_model, rlzs_assoc.samples[grp_id])
rlzs = rlzs_by_grp[grp_id]
res.update(event_based.compute_gmfs_and_curves(gg, rlzs, monitor))
res.calc_times[grp_id] = (ucerf.source_id, len(sitecol),
time.time() - t0)
return res