malcolmw / pykonal

Travel-time calculator based on the fast-marching method solution to the Eikonal equation.
https://malcolmw.github.io/pykonal-docs/
GNU General Public License v3.0
147 stars 54 forks source link

Suggested improvement to raypath calculator #15

Closed SquirrelKnight closed 2 years ago

SquirrelKnight commented 3 years ago

Hi, I am currently using Pykonal to generate traveltime grids for hundreds of stations in an effort to relocate events in New Zealand. These grids are in turn being used to pinpoint likely event hypocenters from associated phase arrivals.

Overall, I am very happy with the features of this program, however I would like to accurately gauge the raypath from source to receiver with a bit more confidence. Currently, I establish the travel time grid with the source index set as the rounded receiver location. For this step, I actually compute the approximate travel time to the nearest surrounding nodes, since the receivers do not actually fall on nodes. The velocity model is fairly coarse, with 10 km spacing in X and Y directions. Because of this, there can sometimes be several kilometers between the nearest node and the actual receiver location. It would be wonderful if I could input both start and end points for the raypath, as opposed to just the end point, as I feel this would give a more accurate result (albeit not significantly different given the scale I am working at).

malcolmw commented 3 years ago

Hi, @SquirrelKnight,

You can use the PointSourceSolver class to achieve this. Take a look at the example in the documentation and let me know if you have any questions.

- Malcolm

SquirrelKnight commented 3 years ago

Hi Malcolm,

I’ve had a look at the PointSourceSolver class, and I think that I have figured it out after some experimenting.

To start, I establish the velocity grid with min coordinates of -1200, -1200, -15, with 10 km spacing in the X and Y directions and 4 km in the Z directions. This ends up with nodes of 240, 240, and 192. I compute the exact coordinates of the seismometer in this coordinate system so that a seismometer at a seismometer located at -134.48, 83.84, 0.12 is closest to node 107, 128, 4. Here is an example of how I input it in my script:

solver = pykonal.EikonalSolver(coord_sys="cartesian") solver.velocity.min_coords = round(min_coords[0]), round(min_coords[1]), round(min_coords[2]) solver.velocity.node_intervals = 10, 10, 4 solver.velocity.npts = x_int, y_int, z_int solver.velocity.values = vp_model

solver.trial.push(*(sta_x,sta_y,sta_z))

Solve the system.

solver.solve()

I've now changed this so that it reads:

solver = pykonal.solver.PointSourceSolver(coord_sys="cartesian") solver.velocity.min_coords = round(min_coords[0]), round(min_coords[1]), round(min_coords[2]) solver.velocity.node_intervals = 10, 10, 4 solver.velocity.npts = x_int, y_int, z_int solver.velocity.values = vp_model solver.src_loc = np.array([sta_x_orig,sta_y_orig,-el/1000])

Solve the system.

solver.solve()

Where sta_x_orig, sta_y_orig, and -el/1000 are the coordinates in the system (in km), not the grid location. This seems to be working well and functions with trace_ray when I use the command solver.tt.trace_ray(x,y,z). Thanks for the pointer!

-Sincerely, Jesse

On Sat, Jul 3, 2021 at 11:00 AM Malcolm White @.***> wrote:

Hi, @SquirrelKnight https://github.com/SquirrelKnight,

You can use the PointSourceSolver https://malcolmw.github.io/pykonal-docs/examples/point_source_solver.html class to achieve this. Take a look at the example in the documentation and let me know if you have any questions.

  • Malcolm

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/malcolmw/pykonal/issues/15#issuecomment-873446082, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJ5LPP5RPHOHHLDLNVLG7TLTV5F4PANCNFSM47XPWRCQ .