@@ -33,7 +33,7 @@ def plotting(stations, figure_path, config, picks, events_old, locations, statio
3333 im = ax [0 , 1 ].scatter (
3434 stations ["x_km" ],
3535 stations ["y_km" ],
36- c = stations ["station_term " ],
36+ c = stations ["station_term_time_p " ],
3737 cmap = "viridis_r" ,
3838 s = 100 ,
3939 marker = "^" ,
@@ -43,7 +43,7 @@ def plotting(stations, figure_path, config, picks, events_old, locations, statio
4343 ax [0 , 1 ].set_ylim ([ymin , ymax ])
4444 cbar = fig .colorbar (im , ax = ax [0 , 1 ])
4545 cbar .set_label ("Residual (s)" )
46- ax [0 , 1 ].set_title (f"Station term: { np .mean (np .abs (stations ['station_term ' ].values )):.4f} s" )
46+ ax [0 , 1 ].set_title (f"Station term (P) : { np .mean (np .abs (stations ['station_term_time_p ' ].values )):.4f} s" )
4747
4848 im = ax [1 , 0 ].scatter (
4949 locations ["x_km" ],
@@ -265,14 +265,21 @@ def plotting_ransac(stations, figure_path, config, picks, events_init, events, s
265265 plt .savefig (os .path .join (figure_path , f"error{ suffix } .png" ), bbox_inches = "tight" , dpi = 300 )
266266 plt .close (fig )
267267
268- xmin , xmax = config ["xlim_km" ]
269- ymin , ymax = config ["ylim_km" ]
270- zmin , zmax = config ["zlim_km" ]
271- vmin , vmax = config ["zlim_km" ]
268+ # xmin, xmax = config["xlim_km"]
269+ # ymin, ymax = config["ylim_km"]
270+ # zmin, zmax = config["zlim_km"]
271+ # vmin, vmax = config["zlim_km"]
272+ xmin = events ["x_km" ].min ()
273+ xmax = events ["x_km" ].max ()
274+ ymin = events ["y_km" ].min ()
275+ ymax = events ["y_km" ].max ()
276+ zmin = events ["z_km" ].min ()
277+ zmax = events ["z_km" ].max ()
278+ vmin , vmax = zmin , zmax
272279 events = events .sort_values ("time" , ascending = True )
273280 s = max (0.1 , min (10 , 5000 / len (events )))
274281 alpha = 0.8
275- fig , ax = plt .subplots (2 , 3 , figsize = (18 , 8 ), gridspec_kw = {"height_ratios" : [2 , 1 ]})
282+ fig , ax = plt .subplots (2 , 4 , figsize = (25 , 8 ), gridspec_kw = {"height_ratios" : [2 , 1 ]})
276283 # fig, ax = plt.subplots(2, 3, figsize=(15, 8), gridspec_kw={"height_ratios": [2, 1]})
277284 im = ax [0 , 0 ].scatter (
278285 events ["x_km" ],
@@ -299,7 +306,7 @@ def plotting_ransac(stations, figure_path, config, picks, events_init, events, s
299306 im = ax [0 , 1 ].scatter (
300307 stations ["x_km" ],
301308 stations ["y_km" ],
302- c = stations ["station_term_time " ],
309+ c = stations ["station_term_time_p " ],
303310 cmap = "viridis_r" ,
304311 s = 100 ,
305312 marker = "^" ,
@@ -312,12 +319,12 @@ def plotting_ransac(stations, figure_path, config, picks, events_init, events, s
312319 ax [0 , 1 ].set_ylabel ("Y (km)" )
313320 cbar = fig .colorbar (im , ax = ax [0 , 1 ])
314321 cbar .set_label ("Residual (s)" )
315- ax [0 , 1 ].set_title (f"Station term: { np .mean (np .abs (stations ['station_term_time ' ].values )):.4f} s" )
322+ ax [0 , 1 ].set_title (f"Station term (P) : { np .mean (np .abs (stations ['station_term_time_p ' ].values )):.4f} s" )
316323
317324 im = ax [0 , 2 ].scatter (
318325 stations ["x_km" ],
319326 stations ["y_km" ],
320- c = stations ["station_term_amplitude " ],
327+ c = stations ["station_term_time_s " ],
321328 cmap = "viridis_r" ,
322329 s = 100 ,
323330 marker = "^" ,
@@ -329,8 +336,26 @@ def plotting_ransac(stations, figure_path, config, picks, events_init, events, s
329336 ax [0 , 2 ].set_xlabel ("X (km)" )
330337 ax [0 , 2 ].set_ylabel ("Y (km)" )
331338 cbar = fig .colorbar (im , ax = ax [0 , 2 ])
339+ cbar .set_label ("Residual (s)" )
340+ ax [0 , 2 ].set_title (f"Station term (S): { np .mean (np .abs (stations ['station_term_time_s' ].values )):.4f} s" )
341+
342+ im = ax [0 , 3 ].scatter (
343+ stations ["x_km" ],
344+ stations ["y_km" ],
345+ c = stations ["station_term_amplitude" ],
346+ cmap = "viridis_r" ,
347+ s = 100 ,
348+ marker = "^" ,
349+ alpha = alpha ,
350+ )
351+ ax [0 , 3 ].set_aspect ("equal" , "box" )
352+ ax [0 , 3 ].set_xlim ([xmin , xmax ])
353+ ax [0 , 3 ].set_ylim ([ymin , ymax ])
354+ ax [0 , 3 ].set_xlabel ("X (km)" )
355+ ax [0 , 3 ].set_ylabel ("Y (km)" )
356+ cbar = fig .colorbar (im , ax = ax [0 , 3 ])
332357 cbar .set_label ("Residual (log10 cm/s)" )
333- ax [0 , 2 ].set_title (f"Station term: { np .mean (np .abs (stations ['station_term_amplitude' ].values )):.4f} s " )
358+ ax [0 , 3 ].set_title (f"Station term: { np .mean (np .abs (stations ['station_term_amplitude' ].values )):.4f} (log10 cm/s) " )
334359
335360 ## Separate P and S station term
336361 # im = ax[0, 1].scatter(
@@ -402,5 +427,146 @@ def plotting_ransac(stations, figure_path, config, picks, events_init, events, s
402427 # ax[1, 1].set_ylabel("Depth (km)")
403428 cbar = fig .colorbar (im , ax = ax [1 , 1 ])
404429 cbar .set_label ("Depth (km)" )
430+
431+ if "magnitude" in events .columns :
432+ im = ax [1 , 2 ].hist (events ["magnitude" ], bins = 30 , edgecolor = "white" )
433+ ax [1 , 2 ].set_yscale ("log" )
434+ ax [1 , 2 ].set_xlabel ("Magnitude" )
435+ ax [1 , 2 ].set_ylabel ("Count" )
436+
405437 plt .savefig (os .path .join (figure_path , f"location{ suffix } .png" ), bbox_inches = "tight" , dpi = 300 )
406438 plt .close (fig )
439+
440+
441+ # %%
442+ def plotting_dd (events , stations , config , figure_path , events_old , suffix = "" ):
443+
444+ xmin , xmax = config ["xlim_km" ]
445+ ymin , ymax = config ["ylim_km" ]
446+ zmin , zmax = config ["zlim_km" ]
447+ vmin , vmax = zmin , zmax
448+
449+ s = max (0.1 , min (10 , 5000 / len (events )))
450+ alpha = 0.8
451+
452+ fig , ax = plt .subplots (3 , 2 , figsize = (10 , 10 ), gridspec_kw = {"height_ratios" : [2 , 1 , 1 ]})
453+ im = ax [0 , 0 ].scatter (
454+ events_old ["x_km" ],
455+ events_old ["y_km" ],
456+ c = events_old ["z_km" ],
457+ cmap = "viridis_r" ,
458+ s = s ,
459+ marker = "o" ,
460+ vmin = vmin ,
461+ vmax = vmax ,
462+ alpha = alpha ,
463+ linewidth = 0.0 ,
464+ )
465+ ax [0 , 0 ].set_xlim ([xmin , xmax ])
466+ ax [0 , 0 ].set_ylim ([ymin , ymax ])
467+ cbar = fig .colorbar (im , ax = ax [0 , 0 ])
468+ cbar .set_label ("Depth (km)" )
469+ ax [0 , 0 ].set_title (f"ADLoc: { len (events_old )} events" )
470+
471+ im = ax [0 , 1 ].scatter (
472+ events ["x_km" ],
473+ events ["y_km" ],
474+ c = events ["z_km" ],
475+ cmap = "viridis_r" ,
476+ s = s ,
477+ marker = "o" ,
478+ vmin = vmin ,
479+ vmax = vmax ,
480+ alpha = alpha ,
481+ linewidth = 0.0 ,
482+ )
483+ ax [0 , 1 ].set_xlim ([xmin , xmax ])
484+ ax [0 , 1 ].set_ylim ([ymin , ymax ])
485+ cbar = fig .colorbar (im , ax = ax [0 , 1 ])
486+ cbar .set_label ("Depth (km)" )
487+ ax [0 , 1 ].set_title (f"ADLoc DD: { len (events )} events" )
488+
489+ # im = ax[1, 0].scatter(
490+ # events_new["x_km"],
491+ # events_new["z_km"],
492+ # c=events_new["z_km"],
493+ # cmap="viridis_r",
494+ # s=1,
495+ # marker="o",
496+ # vmin=vmin,
497+ # vmax=vmax,
498+ # )
499+ # ax[1, 0].set_xlim([xmin, xmax])
500+ # ax[1, 0].set_ylim([zmax, zmin])
501+ # cbar = fig.colorbar(im, ax=ax[1, 0])
502+ # cbar.set_label("Depth (km)")
503+
504+ im = ax [1 , 0 ].scatter (
505+ events_old ["x_km" ],
506+ events_old ["z_km" ],
507+ c = events_old ["z_km" ],
508+ cmap = "viridis_r" ,
509+ s = s ,
510+ marker = "o" ,
511+ vmin = vmin ,
512+ vmax = vmax ,
513+ alpha = alpha ,
514+ linewidth = 0.0 ,
515+ )
516+ ax [1 , 0 ].set_xlim ([xmin , xmax ])
517+ ax [1 , 0 ].set_ylim ([zmax , zmin ])
518+ cbar = fig .colorbar (im , ax = ax [1 , 0 ])
519+ cbar .set_label ("Depth (km)" )
520+
521+ im = ax [1 , 1 ].scatter (
522+ events ["x_km" ],
523+ events ["z_km" ],
524+ c = events ["z_km" ],
525+ cmap = "viridis_r" ,
526+ s = s ,
527+ marker = "o" ,
528+ vmin = vmin ,
529+ vmax = vmax ,
530+ alpha = alpha ,
531+ linewidth = 0.0 ,
532+ )
533+ ax [1 , 1 ].set_xlim ([xmin , xmax ])
534+ ax [1 , 1 ].set_ylim ([zmax , zmin ])
535+ cbar = fig .colorbar (im , ax = ax [1 , 1 ])
536+ cbar .set_label ("Depth (km)" )
537+
538+ im = ax [2 , 0 ].scatter (
539+ events_old ["y_km" ],
540+ events_old ["z_km" ],
541+ c = events_old ["z_km" ],
542+ cmap = "viridis_r" ,
543+ s = s ,
544+ marker = "o" ,
545+ vmin = vmin ,
546+ vmax = vmax ,
547+ alpha = alpha ,
548+ linewidth = 0.0 ,
549+ )
550+ ax [2 , 0 ].set_xlim ([ymin , ymax ])
551+ ax [2 , 0 ].set_ylim ([zmax , zmin ])
552+ cbar = fig .colorbar (im , ax = ax [2 , 0 ])
553+ cbar .set_label ("Depth (km)" )
554+
555+ im = ax [2 , 1 ].scatter (
556+ events ["y_km" ],
557+ events ["z_km" ],
558+ c = events ["z_km" ],
559+ cmap = "viridis_r" ,
560+ s = s ,
561+ marker = "o" ,
562+ vmin = vmin ,
563+ vmax = vmax ,
564+ alpha = alpha ,
565+ linewidth = 0.0 ,
566+ )
567+ ax [2 , 1 ].set_xlim ([ymin , ymax ])
568+ ax [2 , 1 ].set_ylim ([zmax , zmin ])
569+ cbar = fig .colorbar (im , ax = ax [2 , 1 ])
570+ cbar .set_label ("Depth (km)" )
571+
572+ plt .savefig (os .path .join (figure_path , f"location{ suffix } .png" ), bbox_inches = "tight" , dpi = 300 )
0 commit comments