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
|
from EQTransformer.utils.hdf5_maker import preprocessor
from EQTransformer.core.predictor import predictor
from EQTransformer.utils.associator import run_associator
from obspy import read, UTCDateTime
import numpy as np
import shutil, os
length = 2*3600
#start_time = UTCDateTime("2022-01-12T19:00:00")
#end_time = start_time + length
end_time = UTCDateTime()
end_time = end_time - 2*60*60*24
start_time = end_time - length
stime = str(start_time.year)+'-'+str(start_time.month)+'-'+str(start_time.day)+' '+str(start_time.hour)+':'+str(start_time.minute)+':'+str(start_time.second)+'.00'
etime = str(end_time.year)+'-'+str(end_time.month)+'-'+str(end_time.day)+' '+str(end_time.hour)+':'+str(end_time.minute)+':'+str(end_time.second)+'.00'
st = read('Data/*')
dt = UTCDateTime(start_time)
st.trim(dt, dt + length)
st.merge(method=0, fill_value='interpolate', interpolation_samples=0)
st.filter('bandpass', freqmin=1.00, freqmax=10.0, corners=2, zerophase=True)
#st = read('*.SAC')
n = np.arange(0, len(st), 1)
for i in n:
tr = st[i]
network = tr.stats.network
station = tr.stats.station
channel = tr.stats.channel
starttime = tr.stats.starttime
starttime=str(starttime)
endtime = tr.stats.endtime
endtime = str(endtime)
Year = starttime.split('-')[0]
Month = starttime.split('-')[1]
Day = starttime.split('-')[2][0:2]
Hour = starttime.split(':')[0][11:13]
Minute = starttime.split(':')[1]
Second = starttime.split(':')[2][0:2]
Year_end = endtime.split('-')[0]
Month_end = endtime.split('-')[1]
Day_end = endtime.split('-')[2][0:2]
Hour_end = endtime.split(':')[0][11:13]
Minute_end = endtime.split(':')[1]
Second_end = endtime.split(':')[2][0:2]
name = network+'.'+station+'..'+channel+'__'+str(Year)+str(Month)+str(Day)+'T.'+str(Hour)+str(Minute)+str(Second_end)+'__'+str(Year_end)+str(Month_end)+str(Day_end)+'T.'+str(Hour_end)+str(Minute_end)+str(Second_end)+'Z'+'.mseed'
tr.write(name , format="MSEED")
directory = station
# Parent Directory path
parent_dir = "/home/sysop/Muhajir/AutoLoc1.0/downloads_mseeds/"
# Path
path = os.path.join(parent_dir, directory)
#os.mkdir(path)
os.makedirs(path, exist_ok=True)
source = "/home/sysop/Muhajir/AutoLoc1.0/"+name
destination = "/home/sysop/Muhajir/AutoLoc1.0/downloads_mseeds/"+directory
shutil.move(source, destination)
json_basepath = os.path.join(os.getcwd(),"json/station_list.json")
preprocessor(preproc_dir="preproc", mseed_dir='downloads_mseeds', stations_json=json_basepath, overlap=0.3, n_processor=2)
predictor(input_dir= 'downloads_mseeds_processed_hdfs', input_model='EqT_model.h5', output_dir='detections', detection_threshold=0.3, P_threshold=0.1, S_threshold=0.1, number_of_plots=100, plot_mode='time')
out_dir = "asociation"
try:
shutil.rmtree(out_dir)
except Exception:
pass
os.makedirs(out_dir)
run_associator(input_dir='detections', start_time=stime, end_time=etime, moving_window=25, pair_n=3)
|