def test_gmfs(self): f1 = 'file://' + os.path.join(CDIR, 'ghorka_grid.xml') f2 = 'file://' + os.path.join(CDIR, 'ghorka_uncertainty.xml') uridict = dict(kind='usgs_xml', grid_url=f1, uncertainty_url=f2) sitecol, shakemap, *_ = get_sitecol_shakemap(uridict.pop('kind'), uridict, imt_dt.names) n = 4 # number of sites self.assertEqual(len(sitecol), n) gmf_by_imt, _ = mean_std(shakemap, site_effects=True) aae(gmf_by_imt, [[0.0062040, 0.0262588, 0.0497097, 0.0239060], [0.0069831, 0.0298023, 0.0602146, 0.0294691], [0.0069507, 0.0296108, 0.0594237, 0.0286251], [0.0080306, 0.0341960, 0.0762080, 0.0379360]])
def test_from_files(self): # files provided by Vitor Silva, without site amplification f1 = 'file://' + os.path.join(CDIR, 'test_shaking.xml') f2 = 'file://' + os.path.join(CDIR, 'test_uncertainty.xml') uridict = dict(kind='usgs_xml', grid_url=f1, uncertainty_url=f2) sitecol, shakemap, *_ = get_sitecol_shakemap(uridict.pop('kind'), uridict, imt_dt.names) n = 4 # number of sites self.assertEqual(len(sitecol), n) gmf_by_imt, std_by_imt = mean_std(shakemap, site_effects=False) # PGA, SA(0.3), SA(1.0), SA(3.0) aae(gmf_by_imt, [[0.1168263, 0.3056736, 0.0356231, 0.7957914], [0.2422977, 0.6275377, 0.0369565, 0.8191154], [0.3604619, 0.7492331, 0.0380028, 0.8229756], [0.4631292, 1.1679310, 0.0369009, 0.8002559]]) aae(std_by_imt, [[0.5922380, 0.6723980, 0.6325073, 0.6445988], [0.6077153, 0.6661571, 0.6296381, 0.668559], [0.6146356, 0.6748830, 0.6714424, 0.6613612], [0.5815353, 0.6460007, 0.6491335, 0.6603457]])
def test_for_mmi(self): f1 = 'file://' + os.path.join(CDIR, 'ghorka_grid.xml') f2 = 'file://' + os.path.join(CDIR, 'ghorka_uncertainty.xml') uridict = dict(kind='usgs_xml', grid_url=f1, uncertainty_url=f2) sitecol, shakemap, *_ = get_sitecol_shakemap(uridict.pop('kind'), uridict, imt_dt.names) n = 4 # number of sites self.assertEqual(len(sitecol), n) _, gmfs = to_gmfs(shakemap, {'kind': 'mmi'}, False, trunclevel=3, num_gmfs=1000, seed=42, imts=['MMI']) gmf_by_imt = gmfs.mean(axis=1) std_by_imt = gmfs.std(axis=1) aae(gmf_by_imt, [[3.80704848], [3.89791949], [3.88040454], [3.93584243]]) aae(std_by_imt, [[0.71068558], [0.72233552], [0.72033749], [0.69906908]])