def test_origin(): fault_text = """30.979788 103.454422 1 31.691615 104.419160 1 31.723569 104.374760 1 32.532213 105.220821 1 32.641450 105.135050 20 31.846790 104.246202 20 31.942158 104.205286 20 31.290105 103.284388 20 30.979788 103.454422 1""" event_text = """<?xml version="1.0" encoding="US-ASCII" standalone="yes"?> <earthquake id="2008ryan" lat="30.9858" lon="103.3639" mag="7.9" year="2008" month="05" day="12" hour="06" minute="28" second="01" timezone="GMT" depth="19.0" locstring="EASTERN SICHUAN, CHINA" created="1211173621" otime="1210573681" type="" /> """ source_text = "mech=RS" ffile = io.StringIO(fault_text) efile = io.StringIO(event_text) sfile = io.StringIO(source_text) origin = Origin.fromFile(efile, sourcefile=sfile) testdict = {'mag': 7.9, 'id': '2008ryan', 'locstring': 'EASTERN SICHUAN, CHINA', 'mech': 'RS', 'lon': 103.3639, 'lat': 30.9858, 'depth': 19.0} for key in testdict.keys(): value = eval('origin.%s' % key) if type(value) is str: assert testdict[key] == value if type(value) is float: np.testing.assert_almost_equal(testdict[key], value)
def test_virtualipe(): # # Set up the GMPE, IPE, and GMICE # gmpe_cy14 = ChiouYoungs2014() gmpe = MultiGMPE.from_list([gmpe_cy14], [1.0]) gmice = WGRW12() ipe = VirtualIPE.fromFuncs(gmpe, gmice) # # Use the Calexico event info # homedir = os.path.dirname(os.path.abspath(__file__)) datadir = os.path.abspath(os.path.join(homedir, '..', 'data', 'eventdata', 'Calexico', 'input')) # # Read the event, origin, and rupture files and produce Rupture and Origin # objects # inputfile = os.path.join(datadir, 'stationlist_dat.xml') dyfifile = os.path.join(datadir, 'ciim3_dat.xml') eventfile = os.path.join(datadir, 'event.xml') rupturefile = os.path.join(datadir, 'wei_fault.txt') origin_obj = Origin.fromFile(eventfile) rupture_obj = read_rupture_file(origin_obj, rupturefile) rx = rupture_obj.getRuptureContext([gmpe]) rx.rake = 45. smdx = 0.0083333333 smdy = 0.0083333333 lonspan = 6.0 latspan = 4.0 vs30filename = os.path.join(datadir, '..', 'vs30', 'vs30.grd') sites_obj_grid = Sites.fromCenter( rx.hypo_lon, rx.hypo_lat, lonspan, latspan, smdx, smdy, defaultVs30=760.0, vs30File=vs30filename, vs30measured_grid=None, padding=False, resample=False ) npts = 200 lats = np.empty(npts) lons = np.empty(npts) depths = np.zeros(npts) for i in range(npts): lats[i] = rx.hypo_lat lons[i] = rx.hypo_lon + i * 0.01 lldict = {'lats': lats, 'lons': lons} sx = sites_obj_grid.getSitesContext(lldict=lldict, rock_vs30=760.0) dobj = Distance(gmpe, lons, lats, depths, rupture_obj) dx = dobj.getDistanceContext() sd_types = [oqconst.StdDev.TOTAL] mmi_const_vs30, mmi_sd_const_vs30 = \ ipe.get_mean_and_stddevs(sx, rx, dx, MMI(), sd_types) # These prints are just so a human can examine the outputs # print(mmi_const_vs30) # print(mmi_sd_const_vs30) sx = sites_obj_grid.getSitesContext(lldict=lldict) mmi_variable_vs30, mmi_sd_variable_vs30 = \ ipe.get_mean_and_stddevs(sx, rx, dx, MMI(), sd_types) # print(mmi_variable_vs30) # print(mmi_sd_variable_vs30) sd_types = [oqconst.StdDev.TOTAL, oqconst.StdDev.INTRA_EVENT, oqconst.StdDev.INTER_EVENT] mmi_variable_vs30_intra, mmi_sd_variable_vs30_intra = \ ipe.get_mean_and_stddevs(sx, rx, dx, MMI(), sd_types) # print(mmi_variable_vs30_intra) # print(mmi_sd_variable_vs30_intra) # assert(0) # Assert causes test to fail and prints to be displayed # # Try with PGA # gmpe.DEFINED_FOR_INTENSITY_MEASURE_TYPES.remove(PGV) gmpe.ALL_GMPES_HAVE_PGV = False ipe = VirtualIPE.fromFuncs(gmpe, gmice) mmi_pga, mmi_sd_pga = \ ipe.get_mean_and_stddevs(sx, rx, dx, MMI(), sd_types) # # Try with SA(1.0) # gmpe.DEFINED_FOR_INTENSITY_MEASURE_TYPES.remove(PGA) ipe = VirtualIPE.fromFuncs(gmpe, gmice) mmi_psa, mmi_sd_psa = \ ipe.get_mean_and_stddevs(sx, rx, dx, MMI(), sd_types) # # This should raise an exception because the IMT isn't MMI # with pytest.raises(ValueError) as e: mmi_psa, mmi_sd_psa = \ ipe.get_mean_and_stddevs(sx, rx, dx, PGA(), sd_types) # # This should raise an exception because no valid IMTs are available # gmpe.DEFINED_FOR_INTENSITY_MEASURE_TYPES.remove(SA) with pytest.raises(ShakeMapException) as e: ipe = VirtualIPE.fromFuncs(gmpe, gmice) # # Now do a GMPE that uses Rjb instead of Rrup # gmpe_ba14 = BooreEtAl2014() gmpe = MultiGMPE.from_list([gmpe_ba14], [1.0]) ipe = VirtualIPE.fromFuncs(gmpe, gmice) rx = rupture_obj.getRuptureContext([gmpe]) rx.rake = 45. dobj = Distance(gmpe, lons, lats, depths, rupture_obj) dx = dobj.getDistanceContext() mmi_rjb, mmi_sd_rjb = \ ipe.get_mean_and_stddevs(sx, rx, dx, MMI(), sd_types) # # Test the results against a known standard # savefile = os.path.abspath(os.path.join(homedir, '..', 'data', 'eventdata', 'Calexico', 'virtualipe_test', 'savefile.npz')) # # If things change, set remake_save to True, and it will rebuild the # saved data file against which the comparisons are done # Remember to set this back to False once you've remade the test datafile # remake_save = False if remake_save: np.savez_compressed(savefile, mmi_const_vs30 = mmi_const_vs30, mmi_sd_const_vs30 = mmi_sd_const_vs30[0], mmi_variable_vs30 = mmi_variable_vs30, mmi_sd_variable_vs30 = mmi_sd_variable_vs30[0], mmi_variable_vs30_intra = mmi_variable_vs30_intra, mmi_sd_variable_vs30_total = mmi_sd_variable_vs30_intra[0], mmi_sd_variable_vs30_intra = mmi_sd_variable_vs30_intra[1], mmi_sd_variable_vs30_inter = mmi_sd_variable_vs30_intra[2], mmi_pga = mmi_pga, mmi_sd_pga = mmi_sd_pga[0], mmi_psa = mmi_psa, mmi_sd_psa = mmi_sd_psa[0], mmi_rjb = mmi_rjb, mmi_sd_rjb = mmi_sd_rjb[0]) td = np.load(savefile) assert(np.allclose(td['mmi_const_vs30'], mmi_const_vs30)) assert(np.allclose(td['mmi_sd_const_vs30'], mmi_sd_const_vs30[0])) assert(np.allclose(td['mmi_variable_vs30'], mmi_variable_vs30)) assert(np.allclose(td['mmi_sd_variable_vs30'], mmi_sd_variable_vs30[0])) assert(np.allclose(td['mmi_variable_vs30_intra'], mmi_variable_vs30_intra)) assert(np.allclose(td['mmi_sd_variable_vs30_total'], mmi_sd_variable_vs30_intra[0])) assert(np.allclose(td['mmi_sd_variable_vs30_intra'], mmi_sd_variable_vs30_intra[1])) assert(np.allclose(td['mmi_sd_variable_vs30_inter'], mmi_sd_variable_vs30_intra[2])) assert(np.allclose(td['mmi_pga'], mmi_pga)) assert(np.allclose(td['mmi_sd_pga'], mmi_sd_pga[0])) assert(np.allclose(td['mmi_psa'], mmi_psa)) assert(np.allclose(td['mmi_sd_psa'], mmi_sd_psa[0])) assert(np.allclose(td['mmi_rjb'], mmi_rjb)) assert(np.allclose(td['mmi_sd_rjb'], mmi_sd_rjb[0])) # The total uncertainties should be greater than the intra-event assert(np.all(mmi_sd_variable_vs30[0] > mmi_sd_variable_vs30_intra[1])) # The combined intra and inter-event uncertainty should be equal # to the total tot = np.sqrt(mmi_sd_variable_vs30_intra[1]**2 + mmi_sd_variable_vs30_intra[2]**2) assert(np.allclose(tot, mmi_sd_variable_vs30_intra[0], rtol=1e-2))
def test_ss3_move_hypo1(): magnitude = 7.2 dip = np.array([90]) rake = 180.0 width = np.array([15]) rupx = np.array([0, 0]) rupy = np.array([0, 80]) zp = np.array([0.0]) epix = np.array([1.0]) epiy = np.array([-1.0]) # Convert to lat/lon proj = geo.utils.get_orthographic_projection(-122, -120, 39, 37) tlon, tlat = proj(rupx, rupy, reverse=True) epilon, epilat = proj(epix, epiy, reverse=True) # Origin origin = Origin({'lat':epilat[0], 'lon':epilon[0], 'depth':-1, 'mag':magnitude, 'id':'ss3', 'rake':rake}) rup = rupture.QuadRupture.fromTrace( np.array([tlon[0]]), np.array([tlat[0]]), np.array([tlon[1]]), np.array([tlat[1]]), zp, width, dip, origin, reference='ss3') x = np.linspace(0, 20, 6) y = np.linspace(0, 90, 11) site_x, site_y = np.meshgrid(x, y) slon, slat = proj(site_x, site_y, reverse=True) deps = np.zeros_like(slon) test1 = Bayless2013(origin, rup, slat, slon, deps, T=1.0) phyp = copy.deepcopy(test1.phyp[0]) plat, plon, pdep = ecef2latlon(phyp.x, phyp.y, phyp.z) px, py = proj(plon, plat, reverse=False) np.testing.assert_allclose(plat, 38.004233219183604, rtol=1e-4) np.testing.assert_allclose(plon, -120.98636122402166, rtol=1e-4) np.testing.assert_allclose(pdep, 7.4999999989205968, rtol=1e-4) #--------------------------------------------------------------------------- # Also for multiple segments #--------------------------------------------------------------------------- dip = np.array([90., 90., 90.]) rake = 180.0 width = np.array([15., 15., 10.]) rupx = np.array([0., 0., 10., 20.]) rupy = np.array([0., 20., 60., 80.]) zp = np.array([0., 0., 0.]) epix = np.array([0.]) epiy = np.array([0.]) # Convert to lat/lon proj = geo.utils.get_orthographic_projection(-122, -120, 39, 37) tlon, tlat = proj(rupx, rupy, reverse=True) epilon, epilat = proj(epix, epiy, reverse=True) rup = rupture.QuadRupture.fromTrace( np.array(tlon[0:3]), np.array(tlat[0:3]), np.array(tlon[1:4]), np.array(tlat[1:4]), zp, width, dip, origin, reference='') event = {'lat': epilat[0], 'lon': epilon[0], 'depth': 1.0, 'mag': magnitude, 'id': '', 'locstring': 'test', 'type': 'SS', 'timezone': 'UTC'} event['time'] = ShakeDateTime.utcfromtimestamp(int(time.time())) event['created'] = ShakeDateTime.utcfromtimestamp(int(time.time())) x = np.linspace(0, 20, 6) y = np.linspace(0, 90, 11) site_x, site_y = np.meshgrid(x, y) slon, slat = proj(site_x, site_y, reverse=True) deps = np.zeros_like(slon) origin = Origin(event) origin.rake = rake test1 = Bayless2013(origin, rup, slat, slon, deps, T=1.0) # 1st pseudo-hyp phyp = copy.deepcopy(test1.phyp[0]) plat, plon, pdep = ecef2latlon(phyp.x, phyp.y, phyp.z) px, py = proj(plon, plat, reverse=False) np.testing.assert_allclose(plat, 38.004233219183604, rtol=1e-4) np.testing.assert_allclose(plon, -120.98636122402166, rtol=1e-4) np.testing.assert_allclose(pdep, 7.4999999989205968, rtol=1e-4) # 2nd pseudo-hyp phyp = copy.deepcopy(test1.phyp[1]) plat, plon, pdep = ecef2latlon(phyp.x, phyp.y, phyp.z) px, py = proj(plon, plat, reverse=False) np.testing.assert_allclose(plat, 38.184097835787796, rtol=1e-4) np.testing.assert_allclose(plon, -120.98636122402166, rtol=1e-4) np.testing.assert_allclose(pdep, 7.4999999989103525, rtol=1e-4) # 3rd pseudo-hyp phyp = copy.deepcopy(test1.phyp[2]) plat, plon, pdep = ecef2latlon(phyp.x, phyp.y, phyp.z) px, py = proj(plon, plat, reverse=False) np.testing.assert_allclose(plat, 38.543778594535752, rtol=1e-4) np.testing.assert_allclose(plon, -120.87137783362499, rtol=1e-4) np.testing.assert_allclose(pdep, 4.9999999995063993, rtol=1e-4)
def test_distance_no_rupture(): event = {'lat': 34.1, 'lon': -118.2, 'depth': 1, 'mag': 6, 'id': '', 'locstring': '', 'timezone': 'UTC'} origin = Origin(event) origin.setMechanism('ALL') # Make sites instance vs30file = os.path.join(shakedir, 'tests/data/Vs30_test.grd') cx = -118.2 cy = 34.1 dx = 0.0083 dy = 0.0083 xspan = 0.0083 * 5 yspan = 0.0083 * 5 site = Sites.fromCenter(cx, cy, xspan, yspan, dx, dy, vs30File=vs30file, padding=True, resample=False) # Make souce instance # - Unknown/no tectonic region # - Mech is ALL gmpe = AbrahamsonEtAl2014() rupture = PointRupture(origin) dists = Distance.fromSites(gmpe, site, rupture) dctx = dists.getDistanceContext() rjb = np.array([[ 1.03475736, 0.82507289, 0.69891123, 0.6553167 , 0.69891123, 0.82507289, 1.03475736], [ 0.72918893, 0.50725874, 0.36675284, 0.31957002, 0.36675284, 0.50725874, 0.72918893], [ 0.53487557, 0.30135487, 0.14776055, 0.09290799, 0.14776055, 0.30135487, 0.53487557], [ 0.46963915, 0.2280053 , 0.06643829, 0. , 0.06643829, 0.2280053 , 0.46963915], [ 0.53495323, 0.30139344, 0.14777086, 0.09290799, 0.14777086, 0.30139344, 0.53495323], [ 0.72933979, 0.50732902, 0.36677229, 0.31957002, 0.36677229, 0.50732902, 0.72933979], [ 1.03497272, 0.82517579, 0.69893672, 0.6553167 , 0.69893672, 0.82517579, 1.03497272]]) np.testing.assert_allclose( rjb, dctx.rjb, rtol=0, atol=0.01) rrup = np.array([[ 8.26004043, 8.11921658, 8.11376473, 8.09579991, 8.11376473, 8.11921658, 8.26004043], [ 8.12023764, 8.01816823, 7.93517669, 7.9600631 , 7.93517669, 8.01816823, 8.12023764], [ 8.00702434, 7.95888951, 7.8881565 , 7.88352525, 7.8881565 , 7.95888951, 8.00702434], [ 8.02022568, 7.90722113, 7.85639147, 0. , 7.85639147, 7.90722113, 8.02022568], [ 8.00698213, 7.95890141, 7.88813785, 7.88352525, 7.88813785, 7.95890141, 8.00698213], [ 8.12025813, 8.01814988, 7.93520725, 7.9600631 , 7.93520725, 8.01814988, 8.12025813], [ 8.26012423, 8.11931772, 8.1137722 , 8.09579991, 8.1137722 , 8.11931772, 8.26012423]]) np.testing.assert_allclose( rrup, dctx.rrup, rtol=0, atol=0.01) # Souce instance # - Tectonic region unsupported # - Mech is ALL origin._tectonic_region = 'Volcano' dists = Distance.fromSites(gmpe, site, rupture) dctx = dists.getDistanceContext() rjbt = np.array([[ 1.03475736, 0.82507289, 0.69891123, 0.6553167 , 0.69891123, 0.82507289, 1.03475736], [ 0.72918893, 0.50725874, 0.36675284, 0.31957002, 0.36675284, 0.50725874, 0.72918893], [ 0.53487557, 0.30135487, 0.14776055, 0.09290799, 0.14776055, 0.30135487, 0.53487557], [ 0.46963915, 0.2280053 , 0.06643829, 0. , 0.06643829, 0.2280053 , 0.46963915], [ 0.53495323, 0.30139344, 0.14777086, 0.09290799, 0.14777086, 0.30139344, 0.53495323], [ 0.72933979, 0.50732902, 0.36677229, 0.31957002, 0.36677229, 0.50732902, 0.72933979], [ 1.03497272, 0.82517579, 0.69893672, 0.6553167 , 0.69893672, 0.82517579, 1.03497272]]) np.testing.assert_allclose( rjbt, dctx.rjb, rtol=0, atol=0.01) # Souce instance # - Tectonic region: active # - Mech is ALL origin.setMechanism('ALL') origin._tectonic_region = 'Active Shallow Crust' dists = Distance.fromSites(gmpe, site, rupture) dctx = dists.getDistanceContext() rjb = np.array([[ 1.10115976, 0.88331216, 0.75077594, 0.70491937, 0.75077594, 0.88331216, 1.10115976], [ 0.78261273, 0.54865189, 0.39914713, 0.34852149, 0.39914713, 0.54865189, 0.78261273], [ 0.57800579, 0.32895654, 0.16294131, 0.10290794, 0.16294131, 0.32895654, 0.57800579], [ 0.50865092, 0.25000954, 0.07371315, 0. , 0.07371315, 0.25000954, 0.50865092], [ 0.57808833, 0.32899797, 0.16295256, 0.10290794, 0.16295256, 0.32899797, 0.57808833], [ 0.78277133, 0.5487266 , 0.39916785, 0.34852149, 0.39916785, 0.5487266 , 0.78277133], [ 1.10138329, 0.88341918, 0.75080275, 0.70491937, 0.75080275, 0.88341918, 1.10138329]]) np.testing.assert_allclose( rjb, dctx.rjb, rtol=0, atol=0.01) rrup = np.array([[ 8.72726953, 8.58534811, 8.58323541, 8.5654409 , 8.58323541, 8.58534811, 8.72726953], [ 8.58922774, 8.4871601 , 8.40244887, 8.4297141 , 8.40244887, 8.4871601 , 8.58922774], [ 8.47470803, 8.42880892, 8.35631312, 8.35201539, 8.35631312, 8.42880892, 8.47470803], [ 8.49021276, 8.37536496, 8.32350188, 0. , 8.32350188, 8.37536496, 8.49021276], [ 8.47466149, 8.42882081, 8.35629324, 8.35201539, 8.35629324, 8.42882081, 8.47466149], [ 8.58924512, 8.48713903, 8.4024808 , 8.4297141 , 8.4024808 , 8.48713903, 8.58924512], [ 8.72735075, 8.58545174, 8.5832426 , 8.5654409 , 8.5832426 , 8.58545174, 8.72735075]]) np.testing.assert_allclose( rrup, dctx.rrup, rtol=0, atol=0.01) # Souce instance # - Tectonic region: active # - Mech is RS origin.setMechanism('RS') origin._tectonic_region = 'Active Shallow Crust' dists = Distance.fromSites(gmpe, site, rupture) dctx = dists.getDistanceContext() rjb = np.array([[ 0.94405696, 0.73298036, 0.61025288, 0.56806407, 0.61025288, 0.73298036, 0.94405696], [ 0.63960501, 0.42680989, 0.29738908, 0.25562246, 0.29738908, 0.42680989, 0.63960501], [ 0.45239173, 0.23958848, 0.10874248, 0.06508855, 0.10874248, 0.23958848, 0.45239173], [ 0.39203111, 0.17571632, 0.04480241, 0. , 0.04480241, 0.17571632, 0.39203111], [ 0.45246373, 0.2396224 , 0.1087508 , 0.06508855, 0.1087508 , 0.2396224 , 0.45246373], [ 0.63975135, 0.42687494, 0.29740691, 0.25562246, 0.29740691, 0.42687494, 0.63975135], [ 0.94427453, 0.73308353, 0.61027758, 0.56806407, 0.61027758, 0.73308353, 0.94427453]]) np.testing.assert_allclose( rjb, dctx.rjb, rtol=0, atol=0.01) rrup = np.array([[ 8.81700098, 8.67259556, 8.6707467 , 8.65288076, 8.6707467 , 8.67259556, 8.81700098], [ 8.67672238, 8.57444747, 8.49014736, 8.5183922 , 8.49014736, 8.57444747, 8.67672238], [ 8.56159881, 8.51774523, 8.44708824, 8.44391005, 8.44708824, 8.51774523, 8.56159881], [ 8.57788943, 8.46484058, 8.41567031, 0. , 8.41567031, 8.46484058, 8.57788943], [ 8.56155103, 8.51775668, 8.44706792, 8.44391005, 8.44706792, 8.51775668, 8.56155103], [ 8.67673955, 8.5744255 , 8.49017946, 8.5183922 , 8.49017946, 8.5744255 , 8.67673955], [ 8.81708413, 8.67270074, 8.67075389, 8.65288076, 8.67075389, 8.67270074, 8.81708413]]) np.testing.assert_allclose( rrup, dctx.rrup, rtol=0, atol=0.01) # Souce instance # - Tectonic region: active # - Mech is NM origin.setMechanism('NM') origin._tectonic_region = 'Active Shallow Crust' dists = Distance.fromSites(gmpe, site, rupture) dctx = dists.getDistanceContext() rjb = np.array([[ 0.7899535 , 0.61128249, 0.50843465, 0.47310349, 0.50843465, 0.61128249, 0.7899535 ], [ 0.53301769, 0.35495992, 0.24706995, 0.21231668, 0.24706995, 0.35495992, 0.53301769], [ 0.37628889, 0.19897762, 0.09028387, 0.05409271, 0.09028387, 0.19897762, 0.37628889], [ 0.32596438, 0.14586493, 0.03728933, 0. , 0.03728933, 0.14586493, 0.32596438], [ 0.37634892, 0.19900584, 0.09029076, 0.05409271, 0.09029076, 0.19900584, 0.37634892], [ 0.53314026, 0.35501415, 0.24708481, 0.21231668, 0.24708481, 0.35501415, 0.53314026], [ 0.79013775, 0.61136979, 0.50845534, 0.47310349, 0.50845534, 0.61136979, 0.79013775]]) np.testing.assert_allclose( rjb, dctx.rjb, rtol=0, atol=0.01) rrup = np.array([[ 7.94857792, 7.8097532 , 7.80275055, 7.78489184, 7.80275055, 7.8097532 , 7.94857792], [ 7.80938707, 7.70839546, 7.62713392, 7.65061937, 7.62713392, 7.70839546, 7.80938707], [ 7.69799123, 7.64933048, 7.58013644, 7.57530397, 7.58013644, 7.64933048, 7.69799123], [ 7.7099614 , 7.59905656, 7.54904995, 0. , 7.54904995, 7.59905656, 7.7099614 ], [ 7.69795153, 7.64934225, 7.58011859, 7.57530397, 7.58011859, 7.64934225, 7.69795153], [ 7.80940883, 7.70837861, 7.62716348, 7.65061937, 7.62716348, 7.70837861, 7.80940883], [ 7.94866209, 7.80985208, 7.80275807, 7.78489184, 7.80275807, 7.80985208, 7.94866209]]) np.testing.assert_allclose( rrup, dctx.rrup, rtol=0, atol=0.01) # Souce instance # - Tectonic region: active # - Mech is SS origin.setMechanism('SS') origin._tectonic_region = 'Active Shallow Crust' dists = Distance.fromSites(gmpe, site, rupture) dctx = dists.getDistanceContext() rjb = np.array([[ 2.00333625, 1.69987873, 1.49778447, 1.42682201, 1.49778447, 1.69987873, 2.00333625], [ 1.54679373, 1.17582687, 0.914992 , 0.81812345, 0.914992 , 1.17582687, 1.54679373], [ 1.22626178, 0.78021345, 0.43426687, 0.29180829, 0.43426687, 0.78021345, 1.22626178], [ 1.10672645, 0.62338097, 0.21787328, 0. , 0.21787328, 0.62338097, 1.10672645], [ 1.22640328, 0.7802939 , 0.43429295, 0.29180829, 0.43429295, 0.7802939 , 1.22640328], [ 1.54703738, 1.17595553, 0.9150287 , 0.81812345, 0.9150287 , 1.17595553, 1.54703738], [ 2.00364385, 1.7000298 , 1.49782584, 1.42682201, 1.49782584, 1.7000298 , 2.00364385]]) np.testing.assert_allclose( rjb, dctx.rjb, rtol=0, atol=0.01) rrup = np.array([[ 7.97494557, 7.79806013, 7.76281765, 7.735536 , 7.76281765, 7.79806013, 7.97494557], [ 7.77614524, 7.62644695, 7.5120851 , 7.52225031, 7.5120851 , 7.62644695, 7.77614524], [ 7.62326525, 7.51608628, 7.40624352, 7.38577101, 7.40624352, 7.51608628, 7.62326525], [ 7.61851685, 7.44728324, 7.35263272, 0. , 7.35263272, 7.44728324, 7.61851685], [ 7.62324614, 7.51610811, 7.40622914, 7.38577101, 7.40622914, 7.51610811, 7.62324614], [ 7.77620063, 7.62644821, 7.51211876, 7.52225031, 7.51211876, 7.62644821, 7.77620063], [ 7.97507013, 7.798177 , 7.76283076, 7.735536 , 7.76283076, 7.798177 , 7.97507013]]) np.testing.assert_allclose( rrup, dctx.rrup, rtol=0, atol=0.01) # Souce instance # - Tectonic region: stable # - Mech is all origin.setMechanism('ALL') origin._tectonic_region = 'Stable Shallow Crust' dists = Distance.fromSites(gmpe, site, rupture) dctx = dists.getDistanceContext() rjb = np.array([[ 1.25490086, 1.00456938, 0.85266727, 0.80013341, 0.85266727, 1.00456938, 1.25490086], [ 0.8891456 , 0.621322 , 0.4507253 , 0.39310934, 0.4507253 , 0.621322 , 0.8891456 ], [ 0.65483395, 0.37085259, 0.18246645, 0.11472522, 0.18246645, 0.37085259, 0.65483395], [ 0.57566287, 0.28111922, 0.08186392, 0. , 0.08186392, 0.28111922, 0.57566287], [ 0.65492818, 0.37089972, 0.18247916, 0.11472522, 0.18247916, 0.37089972, 0.65492818], [ 0.88932733, 0.62140729, 0.45074894, 0.39310934, 0.45074894, 0.62140729, 0.88932733], [ 1.2551578 , 1.00469232, 0.85269799, 0.80013341, 0.85269799, 1.00469232, 1.2551578 ]]) np.testing.assert_allclose( rjb, dctx.rjb, rtol=0, atol=0.01) rrup = np.array([[ 6.37308879, 6.21401632, 6.17868645, 6.15460391, 6.17868645, 6.21401632, 6.37308879], [ 6.19096821, 6.06108712, 5.96682577, 5.97487576, 5.96682577, 6.06108712, 6.19096821], [ 6.05926472, 5.97000316, 5.88510619, 5.87109182, 5.88510619, 5.97000316, 6.05926472], [ 6.05384337, 5.91573235, 5.84608701, 0. , 5.84608701, 5.91573235, 6.05384337], [ 6.05925153, 5.97002045, 5.88509436, 5.87109182, 5.88509436, 5.97002045, 6.05925153], [ 6.1910207 , 6.0610899 , 5.96685295, 5.97487576, 5.96685295, 6.0610899 , 6.1910207 ], [ 6.37320723, 6.21411804, 6.17869829, 6.15460391, 6.17869829, 6.21411804, 6.37320723]]) np.testing.assert_allclose( rrup, dctx.rrup, rtol=0, atol=0.01) # Souce instance # - Tectonic region: stable # - Mech is RS origin.setMechanism('RS') origin._tectonic_region = 'Stable Shallow Crust' dists = Distance.fromSites(gmpe, site, rupture) dctx = dists.getDistanceContext() rjb = np.array([[ 1.06775489, 0.83169032, 0.69344486, 0.645892 , 0.69344486, 0.83169032, 1.06775489], [ 0.72652464, 0.48639585, 0.33959401, 0.2920419 , 0.33959401, 0.48639585, 0.72652464], [ 0.51540522, 0.27378007, 0.12450057, 0.07451822, 0.12450057, 0.27378007, 0.51540522], [ 0.44695345, 0.20099496, 0.05123817, 0. , 0.05123817, 0.20099496, 0.44695345], [ 0.51548687, 0.2738187 , 0.12451008, 0.07451822, 0.12451008, 0.2738187 , 0.51548687], [ 0.72668956, 0.48646962, 0.33961424, 0.2920419 , 0.33961424, 0.48646962, 0.72668956], [ 1.06799812, 0.83180576, 0.6934727 , 0.645892 , 0.6934727 , 0.83180576, 1.06799812]]) np.testing.assert_allclose( rjb, dctx.rjb, rtol=0, atol=0.01) rrup = np.array([[ 6.34187696, 6.18689857, 6.15537676, 6.13263668, 6.15537676, 6.18689857, 6.34187696], [ 6.1667275 , 6.04409157, 5.9555343 , 5.96586226, 5.9555343 , 6.04409157, 6.1667275 ], [ 6.04113522, 5.96186983, 5.88482917, 5.87387645, 5.88482917, 5.96186983, 6.04113522], [ 6.03838637, 5.91117189, 5.85034216, 0. , 5.85034216, 5.91117189, 6.03838637], [ 6.04111884, 5.96188527, 5.88481675, 5.87387645, 5.88481675, 5.96188527, 6.04111884], [ 6.16677535, 6.04409147, 5.9555607 , 5.96586226, 5.9555607 , 6.04409147, 6.16677535], [ 6.34199129, 6.18699823, 6.15538781, 6.13263668, 6.15538781, 6.18699823, 6.34199129]]) np.testing.assert_allclose( rrup, dctx.rrup, rtol=0, atol=0.01) # Souce instance # - Tectonic region: stable # - Mech is NM origin.setMechanism('NM') origin._tectonic_region = 'Stable Shallow Crust' dists = Distance.fromSites(gmpe, site, rupture) dctx = dists.getDistanceContext() rjb = np.array([[ 1.11595412, 0.87047978, 0.72608143, 0.6763976 , 0.72608143, 0.87047978, 1.11595412], [ 0.7606424 , 0.50965507, 0.35594865, 0.30612448, 0.35594865, 0.50965507, 0.7606424 ], [ 0.5400275 , 0.28698884, 0.13052973, 0.0781228 , 0.13052973, 0.28698884, 0.5400275 ], [ 0.46835876, 0.21071547, 0.05370847, 0. , 0.05370847, 0.21071547, 0.46835876], [ 0.54011298, 0.28702933, 0.1305397 , 0.0781228 , 0.1305397 , 0.28702933, 0.54011298], [ 0.76081471, 0.50973231, 0.35596982, 0.30612448, 0.35596982, 0.50973231, 0.76081471], [ 1.116207 , 0.87059985, 0.72611052, 0.6763976 , 0.72611052, 0.87059985, 1.116207 ]]) np.testing.assert_allclose( rjb, dctx.rjb, rtol=0, atol=0.01) rrup = np.array([[ 6.09163676, 5.92783781, 5.88815939, 5.8632258 , 5.88815939, 5.92783781, 6.09163676], [ 5.9012656 , 5.76798442, 5.67370059, 5.68021406, 5.67370059, 5.76798442, 5.9012656 ], [ 5.76720934, 5.67516593, 5.59187321, 5.57813972, 5.59187321, 5.67516593, 5.76720934], [ 5.75981247, 5.62205686, 5.55427369, 0. , 5.55427369, 5.62205686, 5.75981247], [ 5.76719951, 5.67518325, 5.59186206, 5.57813972, 5.59186206, 5.67518325, 5.76719951], [ 5.90132265, 5.76798949, 5.67372705, 5.68021406, 5.67372705, 5.76798949, 5.90132265], [ 6.09176251, 5.92794056, 5.88817184, 5.8632258 , 5.88817184, 5.92794056, 6.09176251]]) np.testing.assert_allclose( rrup, dctx.rrup, rtol=0, atol=0.01) # Souce instance # - Tectonic region: stable # - Mech is SS origin.setMechanism('SS') origin._tectonic_region = 'Stable Shallow Crust' dists = Distance.fromSites(gmpe, site, rupture) dctx = dists.getDistanceContext() rjb = np.array([[ 1.7978181 , 1.48474703, 1.28392745, 1.21396452, 1.28392745, 1.48474703, 1.7978181 ], [ 1.3323943 , 0.97123526, 0.72919945, 0.64364445, 0.72919945, 0.97123526, 1.3323943 ], [ 1.01846151, 0.61039475, 0.3191157 , 0.20751973, 0.3191157 , 0.61039475, 1.01846151], [ 0.90673813, 0.47477623, 0.15160737, 0. , 0.15160737, 0.47477623, 0.90673813], [ 1.01859418, 0.61046522, 0.3191364 , 0.20751973, 0.3191364 , 0.61046522, 1.01859418], [ 1.33263554, 0.97135557, 0.72923321, 0.64364445, 0.72923321, 0.97135557, 1.33263554], [ 1.79813761, 1.48490175, 1.28396831, 1.21396452, 1.28396831, 1.48490175, 1.79813761]]) np.testing.assert_allclose( rjb, dctx.rjb, rtol=0, atol=0.01) rrup = np.array([[ 5.27459324, 5.06456452, 4.9821571 , 4.94467172, 4.9821571 , 5.06456452, 5.27459324], [ 5.00483041, 4.80820132, 4.67381918, 4.65867853, 4.67381918, 4.80820132, 5.00483041], [ 4.81923672, 4.64680257, 4.514164 , 4.47986499, 4.514164 , 4.64680257, 4.81923672], [ 4.78581905, 4.57286829, 4.44979468, 0. , 4.44979468, 4.57286829, 4.78581905], [ 4.81926166, 4.64683299, 4.51415954, 4.47986499, 4.51415954, 4.64683299, 4.81926166], [ 5.00493679, 4.80823501, 4.67384847, 4.65867853, 4.67384847, 4.80823501, 5.00493679], [ 5.27477487, 5.06468553, 4.98217732, 4.94467172, 4.98217732, 5.06468553, 5.27477487]]) np.testing.assert_allclose( rrup, dctx.rrup, rtol=0, atol=0.01)