当前位置: 首页>>代码示例>>Python>>正文


Python AccumDict.update方法代码示例

本文整理汇总了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
开发者ID:rcgee,项目名称:oq-engine,代码行数:73,代码来源:ucerf_event_based.py


注:本文中的openquake.baselib.general.AccumDict.update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。