Beispiel #1
0
def view_gmv_by_rup(token, dstore):
    """
    Display a synthetic gmv per rupture serial for debugging purposes
    """
    rup_id = dstore['events']['rup_id']
    serial = dstore['ruptures']['serial']
    data = dstore['gmf_data/data'][()]
    gmv = fast_agg3(data, 'eid', ['gmv'])
    gmv['eid'] = serial[rup_id[gmv['eid']]]
    gm = fast_agg3(gmv, 'eid', ['gmv'])
    return rst_table(gm, header=['serial', 'gmv'])
Beispiel #2
0
def view_times_by_source_class(token, dstore):
    """
    Returns the calculation times depending on the source typology
    """
    totals = fast_agg3(dstore['source_info']['code', 'calc_time'],
                       'code', ['calc_time'])
    return rst_table(totals)
Beispiel #3
0
 def check_dmg_by_event(self):
     number = self.calc.datastore['assetcol/array']['number']
     data = self.calc.datastore['dd_data/data'][()]
     if len(data):
         data_by_eid = fast_agg3(data, 'eid', ['dd'], number[data['aid']])
         dmg_by_event = self.calc.datastore['dmg_by_event'][()]
         for rec1, rec2 in zip(data_by_eid, dmg_by_event):
             aae(rec1['dd'], rec2['dmg'][:, 1:], decimal=1)
Beispiel #4
0
 def test_supertask(self):
     # this test has 4 supertasks generating 4 + 5 + 3 + 5 = 17 subtasks
     allargs = [('aaaaeeeeiii', ), ('uuuuaaaaeeeeiii', ),
                ('aaaaaaaaeeeeiii', ), ('aaaaeeeeiiiiiooooooo', )]
     numchars = sum(len(arg) for arg, in allargs)  # 61
     tmpdir = tempfile.mkdtemp()
     tmp = os.path.join(tmpdir, 'calc_1.hdf5')
     performance.init_performance(tmp, swmr=True)
     smap = parallel.Starmap(supertask, allargs, h5=hdf5.File(tmp, 'a'))
     res = smap.reduce()
     smap.h5.close()
     self.assertEqual(res, {'n': numchars})
     # check that the correct information is stored in the hdf5 file
     with hdf5.File(tmp, 'r') as h5:
         num = general.countby(h5['performance_data'][()], 'operation')
         self.assertEqual(num[b'waiting'], 4)
         self.assertEqual(num[b'total supertask'], 4)  # tasks
         self.assertEqual(num[b'total get_length'], 17)  # subtasks
         info = h5['task_info'][()]
         dic = dict(general.fast_agg3(info, 'taskname', ['received']))
         self.assertGreater(dic[b'get_length'], 0)
         self.assertGreater(dic[b'supertask'], 0)
     shutil.rmtree(tmpdir)
Beispiel #5
0
def view_ruptures_per_grp(token, dstore):
    info = dstore['source_info'][()]
    agg = fast_agg3(
        info, 'grp_id', ['num_sites', 'num_ruptures', 'eff_ruptures'])
    agg['num_sites'] /= agg['eff_ruptures']
    return rst_table(agg)