def test_locate_on_surface(self): """ Should locate a receiver on a surface. """ inst_id = 100 dx = 1 iref = 0 for _vmfile in TEST_MODELS: vmfile = get_example_file(_vmfile) vm = readVM(vmfile) # calculate synthetic times pickdb = PickDatabaseConnection(':memory:') x0 = np.mean(vm.x) y0 = np.mean(vm.y) picks = [] xsearch = vm.xrange2i(max(vm.r1[0], x0 - dx), min(vm.r2[0], x0 + dx)) for i, ix in enumerate(xsearch): x = vm.x[ix] iy = vm.x2i([y0])[0] z0 = vm.rf[iref][ix][iy] pickdb.add_pick(event='Pw', ensemble=inst_id, trace=i, time=1e30, source_x=x, source_y=y0, source_z=0.006, receiver_x=x0, receiver_y=y0, receiver_z=z0, vm_branch=1, vm_subid=0) rayfile = 'temp.ray' raytrace(vmfile, pickdb, rayfile) raydb = rayfan2db(rayfile, 'temp.syn.sqlite', synthetic=True) os.remove(rayfile) # run locate x, y, z, rms = locate_on_surface(vmfile, raydb, 0, x0=x0, y0=y0, dx=dx, dy=dx) # compare result self.assertAlmostEqual(x, x0, 0) self.assertAlmostEqual(y, y0, 0)
'source_x': _sx, 'source_y': 0.0, 'source_z': 1.0, 'receiver_x': _rx, 'receiver_y': 0.0, 'receiver_z': 2.0, 'offset' : np.abs(_rx - _sx)} pickdb.update_pick(**d) pickdb.commit() # Raytrace with these picks raytrace(vmfile, pickdb, rayfile) pickdb.close() # Transfer traced to a picks to a new pick database and add noise pickdb = rayfan2db(rayfile, pickdb_file, synthetic=True, noise=0.02) # Raytrace with the new pick database raytrace(vmfile, pickdb, rayfile) # Plot the traced rays and traveltimes fig = plt.figure() ax = fig.add_subplot(211) vm.plot(ax=ax) rays = readRayfanGroup(rayfile) rays.plot_raypaths(ax=ax) ax = fig.add_subplot(212) rays.plot_time_vs_position(ax=ax) ax.set_xlim([vm.r1[0], vm.r2[0]]) plt.show()