예제 #1
0
def compute_gmfs_and_curves(eb_ruptures, sitecol, imts, rlzs_assoc,
                            min_iml, monitor):
    """
    :param eb_ruptures:
        a list of blocks of EBRuptures of the same SESCollection
    :param sitecol:
        a :class:`openquake.hazardlib.site.SiteCollection` instance
    :param imts:
        a list of IMT string
    :param rlzs_assoc:
        a RlzsAssoc instance
    :param monitor:
        a Monitor instance
    :returns:
        a dictionary (rlzi, imt) -> [gmfarray, haz_curves]
   """
    oq = monitor.oqparam
    # NB: by construction each block is a non-empty list with
    # ruptures of the same src_group_id
    trunc_level = oq.truncation_level
    correl_model = readinput.get_correl_model(oq)
    gmfadict = create(
        calc.GmfColl, eb_ruptures, sitecol, imts, rlzs_assoc, trunc_level,
        correl_model, min_iml, monitor).by_rlzi()
    result = {rlzi: [gmfadict[rlzi], None]
              if oq.ground_motion_fields else [None, None]
              for rlzi in gmfadict}
    if oq.hazard_curves_from_gmfs:
        with monitor('bulding hazard curves', measuremem=False):
            duration = oq.investigation_time * oq.ses_per_logic_tree_path
            for rlzi in gmfadict:
                gmvs_by_sid = group_array(gmfadict[rlzi], 'sid')
                result[rlzi][POEMAP] = calc.gmvs_to_poe_map(
                    gmvs_by_sid, oq.imtls, oq.investigation_time, duration)
    return result
예제 #2
0
파일: hazard.py 프로젝트: gem/oq-risklib
def _get_gmfs(dstore, serial, eid):
    oq = dstore['oqparam']
    min_iml = event_based.fix_minimum_intensity(oq.minimum_intensity, oq.imtls)
    rlzs_assoc = dstore['csm_info'].get_rlzs_assoc()
    sitecol = dstore['sitecol'].complete
    N = len(sitecol.complete)
    rup = dstore['sescollection/' + serial]
    correl_model = readinput.get_correl_model(oq)
    gsims = rlzs_assoc.gsims_by_trt_id[rup.trt_id]
    rlzs = [rlz for gsim in map(str, gsims)
            for rlz in rlzs_assoc[rup.trt_id, gsim]]
    gmf_dt = numpy.dtype([('%03d' % rlz.ordinal, F32) for rlz in rlzs])
    gmfadict = create(event_based.GmfColl,
                      [rup], sitecol, oq.imtls, rlzs_assoc,
                      oq.truncation_level, correl_model, min_iml).by_rlzi()
    for imti, imt in enumerate(oq.imtls):
        gmfa = numpy.zeros(N, gmf_dt)
        for rlzname in gmf_dt.names:
            rlzi = int(rlzname)
            gmvs = get_array(gmfadict[rlzi], eid=eid, imti=imti)['gmv']
            gmfa[rlzname][rup.indices] = gmvs
        yield gmfa, imt
예제 #3
0
def _get_gmfs(dstore, serial, eid):
    oq = dstore['oqparam']
    min_iml = calc.fix_minimum_intensity(oq.minimum_intensity, oq.imtls)
    rlzs_assoc = dstore['csm_info'].get_rlzs_assoc()
    sitecol = dstore['sitecol'].complete
    N = len(sitecol.complete)
    rup = dstore['sescollection/' + serial]
    correl_model = readinput.get_correl_model(oq)
    gsims = rlzs_assoc.gsims_by_trt_id[rup.trt_id]
    rlzs = [
        rlz for gsim in map(str, gsims) for rlz in rlzs_assoc[rup.trt_id, gsim]
    ]
    gmf_dt = numpy.dtype([('%03d' % rlz.ordinal, F32) for rlz in rlzs])
    gmfadict = create(calc.GmfColl, [rup], sitecol, oq.imtls, rlzs_assoc,
                      oq.truncation_level, correl_model, min_iml).by_rlzi()
    for imti, imt in enumerate(oq.imtls):
        gmfa = numpy.zeros(N, gmf_dt)
        for rlzname in gmf_dt.names:
            rlzi = int(rlzname)
            gmvs = get_array(gmfadict[rlzi], eid=eid, imti=imti)['gmv']
            gmfa[rlzname][rup.indices] = gmvs
        yield gmfa, imt
예제 #4
0
def compute_gmfs_and_curves(eb_ruptures, sitecol, imts, rlzs_assoc, min_iml,
                            monitor):
    """
    :param eb_ruptures:
        a list of blocks of EBRuptures of the same SESCollection
    :param sitecol:
        a :class:`openquake.hazardlib.site.SiteCollection` instance
    :param imts:
        a list of IMT string
    :param rlzs_assoc:
        a RlzsAssoc instance
    :param monitor:
        a Monitor instance
    :returns:
        a dictionary (rlzi, imt) -> [gmfarray, haz_curves]
   """
    oq = monitor.oqparam
    # NB: by construction each block is a non-empty list with
    # ruptures of the same trt_model_id
    trunc_level = oq.truncation_level
    correl_model = readinput.get_correl_model(oq)
    gmfadict = create(GmfColl, eb_ruptures, sitecol, imts, rlzs_assoc,
                      trunc_level, correl_model, min_iml, monitor).by_rlzi()
    result = {
        rlzi:
        [gmfadict[rlzi], None] if oq.ground_motion_fields else [None, None]
        for rlzi in gmfadict
    }
    if oq.hazard_curves_from_gmfs:
        with monitor('bulding hazard curves', measuremem=False):
            duration = oq.investigation_time * oq.ses_per_logic_tree_path
            for rlzi in gmfadict:
                gmvs_by_sid = group_array(gmfadict[rlzi], 'sid')
                result[rlzi][POEMAP] = gmvs_to_poe_map(gmvs_by_sid, oq.imtls,
                                                       oq.investigation_time,
                                                       duration)
    return result