示例#1
0
 def check_avg_gmf(self):
     # checking avg_gmf with a single site
     min_iml = self.calc.oqparam.min_iml
     df = self.calc.datastore.read_df('gmf_data', 'sid')
     weights = self.calc.datastore['weights'][:]
     rlzs = self.calc.datastore['events']['rlz_id']
     [(sid, avgstd)] = compute_avg_gmf(df, weights[rlzs], min_iml).items()
     avg_gmf = self.calc.datastore['avg_gmf'][:]  # 2, N, M
     aac(avg_gmf[:, 0], avgstd)
示例#2
0
 def test_compute_avg_gmf(self):
     numpy.random.seed(42)
     E = 1000
     eids = numpy.arange(E)
     min_iml = numpy.array([.05])
     gmvs = numpy.random.lognormal(mean=-2.0, sigma=.5, size=E)
     ok = gmvs >= min_iml
     self.assertEqual(ok.sum(), 983)
     gmf_df = pandas.DataFrame(dict(eid=eids[ok], gmv_0=gmvs[ok]),
                               numpy.zeros(E, int)[ok])
     weights = numpy.ones(E)
     [(sid, avgstd)] = compute_avg_gmf(gmf_df, weights, min_iml).items()
     # aac(avgstd, [[0.13664978], [1.63127694]]) without cutting min_iml
     # aac(avgstd, [[0.14734], [1.475266]], atol=1E-6)  # cutting at .10
     aac(avgstd, [[0.137023], [1.620616]], atol=1E-6)