コード例 #1
0
 def test_reduce_source_model(self):
     case2 = os.path.dirname(case_2.__file__)
     smlt = os.path.join(case2, 'source_model_logic_tree.xml')
     found, total = readinput.reduce_source_model(smlt, [], remove=False)
     self.assertEqual(found, 0)
     found, total = readinput.reduce_source_model(smlt, {}, remove=False)
     self.assertEqual(found, 0)
コード例 #2
0
def reduce_sm(calc_id):
    """
    Reduce the source model of the given (pre)calculation by discarding all
    sources that do not contribute to the hazard.
    """
    with datastore.read(calc_id) as dstore:
        oqparam = dstore['oqparam']
        info = dstore['source_info'].value
        ok = info['weight'] > 0
        source_ids = set(info[ok]['source_id'])
    with performance.Monitor() as mon:
        readinput.reduce_source_model(
            oqparam.inputs['source_model_logic_tree'], source_ids)
    print(mon)
コード例 #3
0
ファイル: reduce_sm.py プロジェクト: gem/oq-engine
def reduce_sm(calc_id):
    """
    Reduce the source model of the given (pre)calculation by discarding all
    sources that do not contribute to the hazard.
    """
    with datastore.read(calc_id) as dstore:
        oqparam = dstore['oqparam']
        info = dstore['source_info'].value
        ok = info['weight'] > 0
        source_ids = set(info[ok]['source_id'])
    with performance.Monitor() as mon:
        readinput.reduce_source_model(
            oqparam.inputs['source_model_logic_tree'], source_ids)
    print(mon)
コード例 #4
0
ファイル: reduce_sm.py プロジェクト: sankexing/oq-engine
def reduce_sm(calc_id):
    """
    Reduce the source model of the given (pre)calculation by discarding all
    sources that do not contribute to the hazard.
    """
    with datastore.read(calc_id) as dstore:
        oqparam = dstore['oqparam']
        info = dstore['source_info'][()]
    bad_ids = set(info[info['eff_ruptures'] == 0]['source_id'])
    if len(bad_ids) == 0:
        logging.warning('All sources are relevant, nothing to remove')
        return
    ok = info['eff_ruptures'] > 0
    if ok.sum() == 0:
        raise RuntimeError('All sources were filtered away!')
    ok_ids = general.group_array(info[ok][['source_id', 'code']], 'source_id')
    with performance.Monitor() as mon:
        good, total = readinput.reduce_source_model(
            oqparam.inputs['source_model_logic_tree'], ok_ids)
    logging.info('Removed %d/%d sources', total - good, good)
    srcs, cnts = np.unique(info[['source_id', 'code']], return_counts=True)
    dupl = srcs[cnts > 1]
    if bad_ids & set(dict(dupl)):
        logging.info('There were duplicated sources %s', dupl)
    print(mon)
コード例 #5
0
ファイル: reduce_sm.py プロジェクト: pheresi/oq-engine
def main(calc_id: int):
    """
    Reduce the source model of the given (pre)calculation by discarding all
    sources that do not contribute to the hazard.
    """
    if os.environ.get('OQ_DISTRIBUTE') not in ('no', 'processpool'):
        os.environ['OQ_DISTRIBUTE'] = 'processpool'
    with datastore.read(calc_id) as dstore:
        oqparam = dstore['oqparam']
        info = dstore['source_info'][()]
    src_ids = info['source_id']
    num_ids = len(src_ids)
    bad_ids = info[info['eff_ruptures'] == 0]['source_id']
    logging.info('Found %d far away sources', len(bad_ids))
    bad_ids = set(
        src_id.split(';')[0] for src_id in python3compat.decode(bad_ids))
    bad_dupl = bad_ids & get_dupl(python3compat.decode(src_ids))
    if bad_dupl:
        logging.info('Duplicates %s not removed' % bad_dupl)
    ok = info['eff_ruptures'] > 0
    if ok.sum() == 0:
        raise RuntimeError('All sources were filtered away!')
    ok_ids = general.group_array(info[ok][['source_id', 'code']], 'source_id')
    with performance.Monitor() as mon:
        good, total = readinput.reduce_source_model(
            oqparam.inputs['source_model_logic_tree'], ok_ids)
    logging.info('Removed %d/%d sources', total - good, num_ids)
    print(mon)
コード例 #6
0
def reduce_sm(calc_id):
    """
    Reduce the source model of the given (pre)calculation by discarding all
    sources that do not contribute to the hazard.
    """
    with datastore.read(calc_id) as dstore:
        oqparam = dstore['oqparam']
        info = dstore['source_info'][()]
        ok = info['calc_time'] > 0
        source_ids = set(info[ok]['source_id'])
    if ok.sum() == 0:
        raise RuntimeError('All sources were filtered away!')
    with performance.Monitor() as mon:
        readinput.reduce_source_model(
            oqparam.inputs['source_model_logic_tree'], source_ids)
    print(mon)
コード例 #7
0
ファイル: reduce_sm.py プロジェクト: drotheram/oq-engine
def reduce_sm(calc_id):
    """
    Reduce the source model of the given (pre)calculation by discarding all
    sources that do not contribute to the hazard.
    """
    with datastore.read(calc_id) as dstore:
        oqparam = dstore['oqparam']
        info = dstore['source_info'][()]
    num_ids = len(info['source_id'])
    bad_ids = set(info[info['eff_ruptures'] == 0]['source_id'])
    if len(bad_ids) == 0:
        dupl = info[info['multiplicity'] > 1]['source_id']
        if len(dupl) == 0:
            logging.info('Nothing to remove')
        else:
            logging.info('Nothing to remove, but there are duplicated source '
                         'IDs that could prevent the removal: %s' % dupl)
        return
    logging.info('Found %d far away sources', len(bad_ids))
    ok = info['eff_ruptures'] > 0
    if ok.sum() == 0:
        raise RuntimeError('All sources were filtered away!')
    ok_ids = general.group_array(info[ok][['source_id', 'code']], 'source_id')
    with performance.Monitor() as mon:
        good, total = readinput.reduce_source_model(
            oqparam.inputs['source_model_logic_tree'], ok_ids)
    logging.info('Removed %d/%d sources', total - good, num_ids)
    print(mon)
コード例 #8
0
 def test_reduce_source_model(self):
     case2 = os.path.dirname(case_2.__file__)
     smlt = os.path.join(case2, 'source_model_logic_tree.xml')
     readinput.reduce_source_model(smlt, [])
コード例 #9
0
ファイル: readinput_test.py プロジェクト: gem/oq-engine
 def test_reduce_source_model(self):
     case2 = os.path.dirname(case_2.__file__)
     smlt = os.path.join(case2, 'source_model_logic_tree.xml')
     readinput.reduce_source_model(smlt, [], False)