-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmoveout.py
99 lines (83 loc) · 2.69 KB
/
moveout.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import pygmt
import numpy as np
import os
import glob
import obspy
from datetime import datetime, timedelta
def extract_substring(text, search_string, length=10):
# Find the starting index of the search string
start_index = text.find(search_string)
if start_index == -1:
return None # Return None if the search string is not found
# Extract the substring of the specified length starting from the search string
return text[start_index:start_index + length]
'''
# Define the path to the folder containing your .sac files
r = "ts_pws"
sac_folder_path = f'Data/cc/Stacked_CC1b_{r}'
destination = f"Moveouts/Stacked_CC1b_{r}"
os.makedirs(destination,exist_ok=True)
t=np.arange(-59.9-0.04,59.9+0.04,0.04)
# Start and end dates
start_date = datetime.strptime("2024-09-20", "%Y-%m-%d")
end_date = datetime.strptime("2024-10-06", "%Y-%m-%d")
# Loop through each date in the range
current_date = start_date
sac_files_list = {}
while current_date <= end_date:
date_str = current_date.strftime("%Y-%m-%d")
sac_files_list[date_str] = []
current_date += timedelta(days=1)
#break
for filename in os.listdir(sac_folder_path):
date = extract_substring(filename,"2024",10)
if date in sac_files_list.keys():
sac_files_list[date].append(os.path.join(sac_folder_path,filename))
for date_str in sac_files_list.keys():
fig = pygmt.Figure()
fig.basemap(region=[-5, 5, 0, 4], projection="X10c", frame=["x2","y0.5"])
for sac_file in sac_files_list[date_str]:
st=obspy.read(sac_file)
d=st[0].stats.sac.dist* np.ones(len(t))
fig.wiggle(
x=t,
y=d,
z=st[0].data, #*(5*10**3)
# Set anomaly scale to 20 centimeters
scale="20c",
# Fill positive areas red
fillpositive="red",
# Fill negative areas gray
fillnegative="gray",
# Set the outline width to 1.0 point
pen="0.01p",
)
fig.savefig(f"{destination}/moveout_{date_str}.png")
#break
'''
# Define the path to the folder containing your .sac files
r = "ts_pws_1_10"
sac_folder_path = f'Data/cc/Filtered_All_day_stack_PCC_{r}'
destination = f"Moveouts/Filtered_All_day_stack_PCC_{r}"
os.makedirs(destination,exist_ok=True)
t=np.arange(-59.9-0.04,59.9+0.04,0.04)
sac_files_list = glob.glob(sac_folder_path+"/*.sac")
fig = pygmt.Figure()
fig.basemap(region=[-5, 5, 0, 4], projection="X10c", frame=["x2","y0.5"])
for sac_file in sac_files_list:
st=obspy.read(sac_file)
d=st[0].stats.sac.dist* np.ones(len(t))
fig.wiggle(
x=t,
y=d,
z=st[0].data*1000, #*(5*10**3)
# Set anomaly scale to 20 centimeters
scale="20c",
# Fill positive areas red
fillpositive="red",
# Fill negative areas gray
fillnegative="gray",
# Set the outline width to 1.0 point
pen="0.01p",
)
fig.savefig(f"{destination}/moveout.png")