-
Notifications
You must be signed in to change notification settings - Fork 1
/
read_arrivals_asc.py
179 lines (163 loc) · 8.04 KB
/
read_arrivals_asc.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
from numpy import *
def read_arrivals_asc(filename=None):
#*******************************************************************************
# Faro, Seg 11 Abr 2022 12:50:20 WEST
# Written by Orlando Camargo Rodriguez
# Based on read_arrivals_asc.m by Michael Porter
#*******************************************************************************
Arr = []
Pos = []
Narrmx = 100
maxnarr = 0
fid = open(filename,'r')
flag = str( fid.readline() )
if flag[2] == '2':
freq = float( fid.readline() )
theline = str( fid.readline() )
datai = theline.split()
Nsz = int( datai[0] )
source_depths = zeros(Nsz)
for i in range(Nsz):
source_depths[i] = float( datai[i+1] )
theline = str( fid.readline() )
datai = theline.split()
Nrz = int( datai[0] )
receiver_depths = zeros(Nrz)
for i in range(Nrz):
receiver_depths[i] = float( datai[i+1] )
theline = str( fid.readline() )
datai = theline.split()
Nrr = int( datai[0] )
receiver_ranges = zeros(Nrr)
for i in range(Nrr):
receiver_ranges[i] = float( datai[i+1] )
Narr = zeros( (Nrr, Nrz, Nsz) )
A = zeros( (Nrr, Narrmx, Nrz, Nsz) ) + 1j*zeros( (Nrr, Narrmx, Nrz, Nsz) )
delay = zeros( (Nrr, Narrmx, Nrz, Nsz) ) + 1j*zeros( (Nrr, Narrmx, Nrz, Nsz) )
SrcAngle = zeros( (Nrr, Narrmx, Nrz, Nsz) )
RcvrAngle = zeros( (Nrr, Narrmx, Nrz, Nsz) )
NumTopBnc = zeros( (Nrr, Narrmx, Nrz, Nsz) )
NumBotBnc = zeros( (Nrr, Narrmx, Nrz, Nsz) )
for isd in range(Nsz):
Narrmx2 = int( fid.readline() )
for ird in range(Nrz):
for irr in range(Nrr):
narr = int( fid.readline() )
Narr[ irr, ird, isd ] = narr
maxnarr = max( narr, maxnarr )
if narr > 0:
narr = min( narr, Narrmx )
for k in range(narr):
theline = str( fid.readline() )
datai = theline.split()
amp = float( datai[0] )
phase = float( datai[1] )
A[ irr, k, ird, isd ] = amp*exp( 1j*phase*pi/180.0 )
rtau = float( datai[2] )
itau = float( datai[3] )
delay[ irr, k, ird, isd ] = rtau + 1j*itau
source_angle = float( datai[4] )
SrcAngle[ irr, k, ird, isd ] = source_angle
receiver_angle = float( datai[5] )
RcvrAngle[ irr, k, ird, isd ] = receiver_angle
bounces = int( datai[6] )
NumTopBnc[ irr, k, ird, isd ] = bounces
bounces = int( datai[7] )
NumBotBnc[ irr, k, ird, isd ] = bounces
A = A[ :,0:maxnarr,:,:]
delay = delay[ :,0:maxnarr,:,:]
SrcAngle = SrcAngle[ :,0:maxnarr,:,:]
RcvrAngle = RcvrAngle[:,0:maxnarr,:,:]
NumTopBnc = NumTopBnc[:,0:maxnarr,:,:]
NumBotBnc = NumBotBnc[:,0:maxnarr,:,:]
Pos = {'freq':freq,'source_depths':source_depths,'receiver_depths':receiver_depths,'receiver_ranges':receiver_ranges}
Arr = {'Narr':Narr,'A':A,'delay':delay,'SrcAngle':SrcAngle,'RcvrAngle':RcvrAngle,'NumTopBnc':NumTopBnc,'NumBotBnc':NumBotBnc}
else:
freq = float( fid.readline() )
theline = str( fid.readline() )
datai = theline.split()
Nsx = int( datai[0] )
sourcex = zeros(Nsx)
for i in range(Nsx):
sourcex[i] = float( datai[i+1] )
theline = str( fid.readline() )
datai = theline.split()
Nsy = int( datai[0] )
sourcey = zeros(Nsy)
for i in range(Nsy):
sourcey[i] = float( datai[i+1] )
theline = str( fid.readline() )
datai = theline.split()
Nsz = int( datai[0] )
sourcez = zeros(Nsz)
for i in range(Nsz):
sourcez[i] = float( datai[i+1] )
theline = str( fid.readline() )
datai = theline.split()
Nrz = int( datai[0] )
receiver_depths = zeros(Nrz)
for i in range(Nrr):
receiver_depths[i] = float( datai[i+1] )
theline = str( fid.readline() )
datai = theline.split()
Nrr = int( datai[0] )
receiver_ranges = zeros(Nrr)
for i in range(Nrr):
receiver_ranges[i] = float( datai[i+1] )
theline = str( fid.readline() )
datai = theline.split()
Nrtheta = int( datai[0] )
receiver_thetas = zeros(Nrtheta)
for i in range(Nrtheta):
receiver_thetas[i] = float( datai[i+1] )
Narr = zeros( (Nrr, Nrz, Nrtheta, Nsz) )
A = zeros( (Nrr, Narrmx, Nrz, Nrtheta, Nsz) ) + 1j*zeros( (Nrr, Narrmx, Nrz, Nrtheta, Nsz) )
delay = zeros( (Nrr, Narrmx, Nrz, Nrtheta, Nsz) ) + 1j*zeros( (Nrr, Narrmx, Nrz, Nrtheta, Nsz) )
SrcDeclAngle = zeros( (Nrr, Narrmx, Nrz, Nrtheta, Nsz) )
SrcAzimAngle = zeros( (Nrr, Narrmx, Nrz, Nrtheta, Nsz) )
RcvrDeclAngle= zeros( (Nrr, Narrmx, Nrz, Nrtheta, Nsz) )
RcvrAzimAngle= zeros( (Nrr, Narrmx, Nrz, Nrtheta, Nsz) )
NumTopBnc = zeros( (Nrr, Narrmx, Nrz, Nrtheta, Nsz) )
NumBotBnc = zeros( (Nrr, Narrmx, Nrz, Nrtheta, Nsz) )
for isd in range(Nsz):
Narrmx2 = int( fid.readline() )
for irtheta in range(Nrtheta):
for irz in range(Nrz):
for irr in range(Nrr):
Narr[ irr, ird, irtheta, isd ] = narr
maxnarr = max( narr, maxnarr )
if narr > 0:
narr = min( narr, Narrmx )
for k in range(narr):
theline = str( fid.readline() )
datai = theline.split()
amp = float( datai[0] )
phase = float( datai[1] )
A[ irr, k, ird, irtheta, isd ] = amp*exp( 1j*phase*pi/180.0 )
rtau = float( datai[2] )
itau = float( datai[3] )
delay[ irr, k, ird, irtheta, isd ] = rtau + 1j*itau
theangle = float( datai[4] )
SrcDeclAngle[ irr, k, ird, irtheta, isd ] = theangle
theangle = float( datai[5] )
SrcAzimAngle[ irr, k, ird, irtheta, isd ] = theangle
theangle = float( datai[6] )
RcvrDeclAngle[ irr, k, ird, irtheta, isd ] = theangle
theangle = float( datai[7] )
RcvrAzimAngle[ irr, k, ird, irtheta, isd ] = theangle
bounces = int( datai[8] )
NumTopBnc[ irr, k, ird, irtheta, isd ] = bounces
bounces = int( datai[9] )
NumBotBnc[ irr, k, ird, irtheta, isd ] = bounces
A = A[ :,0:maxnarr,:,:,:]
delay = delay[ :,0:maxnarr,:,:,:]
SrcDeclAngle = SrcDeclAngle[ :,0:maxnarr,:,:,:]
SrcAzimAngle = SrcAzimAngle[ :,0:maxnarr,:,:,:]
RcvrDeclAngle= RcvrDeclAngle[:,0:maxnarr,:,:,:]
RcvrAzimAngle= RcvrAzimAngle[:,0:maxnarr,:,:,:]
NumTopBnc = NumTopBnc[:,0:maxnarr,:,:,:]
NumBotBnc = NumBotBnc[:,0:maxnarr,:,:,:]
Pos = {'freq':freq,'sourcex':sourcex,'sourcey':sourcey,'sourcez':sourcez,'receiver_depths':receiver_depths,'receiver_ranges':receiver_ranges,'receiver_thetas':receiver_thetas}
Arr = {'Narr':Narr,'A':A,'delay':delay,'SrcDeclAngle':SrcDeclAngle,'SrcAzimAngle':SrcAzimAngle,'RcvrDeclAngle':RcvrDeclAngle,'RcvrAzimAngle':RcvrAzimAngle,'NumTopBnc':NumTopBnc,'NumBotBnc':NumBotBnc}
fid.close()
return Arr,Pos