99import numpy as np
1010import pandas as pd
1111import plotly .graph_objects as go
12-
12+ from args import parse_args
1313
1414# %%
15- def parse_args ():
16- parser = argparse .ArgumentParser ()
17- parser .add_argument ("root_path" , nargs = "?" , type = str , default = "local" , help = "root path" )
18- parser .add_argument ("region" , nargs = "?" , type = str , default = "demo" , help = "region" )
19- return parser .parse_args ()
20-
21-
2215args = parse_args ()
2316
2417# %%
@@ -49,6 +42,7 @@ def parse_args():
4942routine_catalog = f"{ root_path } /{ region } /obspy/catalog.csv"
5043routine_exist = False
5144if os .path .exists (routine_catalog ):
45+ print (f"Reading { routine_catalog } " )
5246 routine_exist = True
5347 routine_catalog = pd .read_csv (routine_catalog , parse_dates = ["time" ])
5448
@@ -57,6 +51,7 @@ def parse_args():
5751gamma_file = f"{ root_path } /{ region } /gamma/gamma_events_000_001.csv"
5852gamma_exist = False
5953if os .path .exists (gamma_file ):
54+ print (f"Reading { gamma_file } " )
6055 gamma_exist = True
6156 gamma_catalog = pd .read_csv (gamma_file , parse_dates = ["time" ])
6257 # gamma_catalog["depth_km"] = gamma_catalog["depth(m)"] / 1e3
@@ -66,6 +61,7 @@ def parse_args():
6661adloc_file = f"{ root_path } /{ region } /adloc/ransac_events.csv"
6762adloc_exist = False
6863if os .path .exists (adloc_file ):
64+ print (f"Reading { adloc_file } " )
6965 adloc_exist = True
7066 adloc_catalog = pd .read_csv (adloc_file , parse_dates = ["time" ])
7167 # adloc_catalog["magnitude"] = 0.0
@@ -75,20 +71,23 @@ def parse_args():
7571adloc_dt_file = f"{ root_path } /{ region } /adloc_dd/adloc_dt_events.csv"
7672adloc_dt_exist = False
7773if os .path .exists (adloc_dt_file ):
74+ print (f"Reading { adloc_dt_file } " )
7875 adloc_dt_exist = True
7976 adloc_dt_catalog = pd .read_csv (adloc_dt_file , parse_dates = ["time" ])
8077
8178# %%
8279adloc_dtcc_file = f"{ root_path } /{ region } /adloc_dd/adloc_dtcc_events.csv"
8380adloc_dtcc_exist = False
8481if os .path .exists (adloc_dtcc_file ):
82+ print (f"Reading { adloc_dtcc_file } " )
8583 adloc_dtcc_exist = True
8684 adloc_dtcc_catalog = pd .read_csv (adloc_dtcc_file , parse_dates = ["time" ])
8785
8886# %%
8987hypodd_file = f"{ root_path } /{ region } /hypodd/hypodd_ct.reloc"
9088hypodd_ct_exist = False
9189if os .path .exists (hypodd_file ):
90+ print (f"Reading { hypodd_file } " )
9291 hypodd_ct_exist = True
9392 columns = [
9493 "ID" ,
@@ -140,6 +139,7 @@ def parse_args():
140139hypodd_file = f"{ root_path } /{ region } /hypodd/hypodd_cc.reloc"
141140hypodd_cc_exist = False
142141if os .path .exists (hypodd_file ):
142+ print (f"Reading { hypodd_file } " )
143143 hypodd_cc_exist = True
144144 columns = [
145145 "ID" ,
@@ -191,6 +191,7 @@ def parse_args():
191191growclust_file = f"{ root_path } /{ region } /growclust/growclust_ct_catalog.txt"
192192growclust_ct_exist = False
193193if os .path .exists (growclust_file ):
194+ print (f"Reading { growclust_file } " )
194195 growclust_ct_exist = True
195196 columns = [
196197 "yr" ,
@@ -235,6 +236,7 @@ def parse_args():
235236growclust_file = f"{ root_path } /{ region } /growclust/growclust_cc_catalog.txt"
236237growclust_cc_exist = False
237238if os .path .exists (growclust_file ):
239+ print (f"Reading { growclust_file } " )
238240 growclust_cc_exist = True
239241 columns = [
240242 "yr" ,
@@ -746,6 +748,7 @@ def parse_args():
746748 ax [2 , 0 ].set_title (f"HypoDD (CT): { len (catalog_ct_hypodd )} " )
747749 ax [2 , 0 ].set_xlim (xlim )
748750 ax [2 , 0 ].set_ylim (ylim )
751+
749752if hypodd_cc_exist and (len (catalog_cc_hypodd ) > 0 ):
750753 ax [2 , 1 ].scatter (
751754 catalog_cc_hypodd ["LAT" ],
@@ -950,6 +953,25 @@ def plot3d(x, y, z, config, fig_name):
950953 config_plot3d ,
951954 f"{ root_path } /{ figure_path } /earthquake_location_adloc.html" ,
952955 )
956+
957+ if adloc_dt_exist and len (adloc_dt_catalog ) > 0 :
958+ plot3d (
959+ adloc_dt_catalog ["longitude" ],
960+ adloc_dt_catalog ["latitude" ],
961+ adloc_dt_catalog ["depth_km" ],
962+ config_plot3d ,
963+ f"{ root_path } /{ figure_path } /earthquake_location_adloc_dt.html" ,
964+ )
965+
966+ if adloc_dtcc_exist and len (adloc_dtcc_catalog ) > 0 :
967+ plot3d (
968+ adloc_dtcc_catalog ["longitude" ],
969+ adloc_dtcc_catalog ["latitude" ],
970+ adloc_dtcc_catalog ["depth_km" ],
971+ config_plot3d ,
972+ f"{ root_path } /{ figure_path } /earthquake_location_adloc_dtcc.html" ,
973+ )
974+
953975 if hypodd_ct_exist and len (catalog_ct_hypodd ) > 0 :
954976 plot3d (
955977 catalog_ct_hypodd ["LON" ],
0 commit comments