-
Notifications
You must be signed in to change notification settings - Fork 172
/
Mwexmig.c
246 lines (199 loc) · 7.95 KB
/
Mwexmig.c
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
/* 3-D modeling/migration with extended SSF */
/*
Copyright (C) 2009 Colorado School of Mines
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <rsf.h>
#ifdef _OPENMP
#include <omp.h>
#include "omputil.h"
#endif
#include "wex.h"
#include "wexeic.h"
#include "wextap.h"
#include "wexssr.h"
#include "wexslo.h"
#include "wexutl.h"
/*^*/
int main (int argc, char *argv[])
{
bool verb; /* verbosity */
float eps; /* dip filter constant */
bool eic; /* output cic or eic cube */
bool drv; /* output derivative */
bool new; /* output phase-shifted gathers */
int nrmax; /* number of reference velocities */
float dtmax; /* time error */
int pmx,pmy; /* padding in the k domain */
int tmx,tmy; /* boundary taper size */
int nhx, nhy, nhz, nht, nc;
int nhx2,nhy2,nhz2,nht2;
float dht=0, oht;
sf_axis amx,amy,az;
sf_axis alx,aly;
sf_axis aw,ae,aa,ac;
/* I/O files */
sf_file Fs=NULL; /* slowness file S(nlx,nly,nz ) */
sf_file Fc=NULL; /* CIP coordinates */
sf_file Fd=NULL; /* Surface data file D(nmx,nmy,nw) */
sf_file Fm=NULL; /* Output image r(nmx,nmy,nmz) */
sf_file Fe=NULL; /* Output CIP gathers */
sf_file Fws=NULL; /* source wavefield */
sf_file Fts=NULL; /* temporary wavefield */
sf_file Ftr=NULL; /* temporary wavefield */
int ompnth=1;
wexcub3d cub; /* wavefield hypercube */
wexcip3d cip; /* CIP gathers */
wextap3d tap; /* tapering */
wexssr3d ssr; /* SSR operator */
wexslo3d slo; /* slowness */
wexop3d weop;
float dsmax;
/*------------------------------------------------------------*/
sf_init(argc,argv);
/* OMP parameters */
#ifdef _OPENMP
ompnth=omp_init();
#endif
if (!sf_getbool( "feic",&eic )) eic = false; /* extended I.C. flag */
if (!sf_getbool( "fdrv",&drv )) drv = false; /* image derivative flag */
if (!sf_getbool( "fnew",&new )) new = false; /* phase-shift flag */
if (!sf_getbool( "verb",&verb )) verb = false; /* verbosity flag */
if (!sf_getfloat( "eps",&eps )) eps = 0.01; /* stability parameter */
if (!sf_getint( "nrmax",&nrmax )) nrmax = 1; /* maximum references */
if (!sf_getfloat("dtmax",&dtmax )) dtmax = 0.004; /* max time error */
if (!sf_getint( "pmx",&pmx )) pmx = 0; /* padding on x */
if (!sf_getint( "pmy",&pmy )) pmy = 0; /* padding on y */
if (!sf_getint( "tmx",&tmx )) tmx = 0; /* taper on x */
if (!sf_getint( "tmy",&tmy )) tmy = 0; /* taper on y */
ae = sf_maxa(1,0,1);
nhx=nhy=nhz=nht=nc=nhx2=nhy2=nhz2=nht2=0;
oht = 0.0;
/*------------------------------------------------------------*/
/* slowness */
Fs = sf_input("slo");
alx = sf_iaxa(Fs,1); sf_setlabel(alx,"lx");
aly = sf_iaxa(Fs,2); sf_setlabel(aly,"ly");
az = sf_iaxa(Fs,3); sf_setlabel(az, "z");
/*------------------------------------------------------------*/
/* source wavelet */
Fws = sf_input ( "swfl");
amx = sf_iaxa(Fws,1); sf_setlabel(amx,"mx");
amy = sf_iaxa(Fws,2); sf_setlabel(amy,"my");
aw = sf_iaxa(Fws,3); sf_setlabel(aw ,"w" );
/*------------------------------------------------------------*/
Fts = sf_tmpfile(NULL); sf_settype(Fts,SF_COMPLEX);
Ftr = sf_tmpfile(NULL); sf_settype(Ftr,SF_COMPLEX);
/*------------------------------------------------------------*/
cub = wex_cube(verb,
amx,amy,az,
alx,aly,
aw,
ae,
eps,
ompnth);
dsmax = dtmax/cub->az.d;
/*------------------------------------------------------------*/
/* init structures */
tap = wextap_init(cub->amx.n,
cub->amy.n,
1,
SF_MIN(tmx,cub->amx.n-1), /* tmx */
SF_MIN(tmy,cub->amy.n-1), /* tmy */
0,
true,true,false);
slo = wexslo_init(cub,Fs,nrmax,dsmax);
ssr = wexssr_init(cub,slo,pmx,pmy,tmx,tmy,dsmax);
weop = wex_init(cub);
/*------------------------------------------------------------*/
/* For migration, output image or CIPs */
sf_warning("migration ....");
Fd = sf_input( "in");
if (SF_COMPLEX !=sf_gettype(Fd)) sf_error("Need complex data");
// Output file and set axis
Fm = sf_output("out"); sf_settype(Fm,SF_COMPLEX);
sf_oaxa(Fm,amx,1);
sf_oaxa(Fm,amy,2);
sf_oaxa(Fm,az, 3);
if(eic){
/* CIP coordinates */
Fc = sf_input ("cc" );
ac = sf_iaxa(Fc,2); sf_setlabel(ac,"cc"); sf_setunit(ac,"");
nc = sf_n(ac);
Fe = sf_output("cip"); sf_settype(Fe,SF_COMPLEX);
if(! sf_getint("nhx",&nhx)) nhx=0; /* number of lags on the x axis */
if(! sf_getint("nhy",&nhy)) nhy=0; /* number of lags on the y axis */
if(! sf_getint("nhz",&nhz)) nhz=0; /* number of lags on the z axis */
if(! sf_getint("nht",&nht)) nht=0; /* number of lags on the t axis */
if(! sf_getfloat("dht",&dht)) sf_error("need dht");
oht = -nht*dht;
nhx2=2*nhx+1;
nhy2=2*nhy+1;
nhz2=2*nhz+1;
nht2=2*nht+1;
aa=sf_maxa(nhx2,-nhx*cub->amx.d,cub->amx.d);
sf_setlabel(aa,"hx"); sf_setunit(aa,"");
if(verb) sf_raxa(aa);
sf_oaxa(Fe,aa,1);
aa=sf_maxa(nhy2,-nhy*cub->amy.d,cub->amy.d);
sf_setlabel(aa,"hy"); sf_setunit(aa,"");
if(verb) sf_raxa(aa);
sf_oaxa(Fe,aa,2);
aa=sf_maxa(nhz2,-nhz*cub->az.d,cub->az.d);
sf_setlabel(aa,"hz"); sf_setunit(aa,"");
if(verb) sf_raxa(aa);
sf_oaxa(Fe,aa,3);
aa=sf_maxa(nht2,-nht*dht,dht);
sf_setlabel(aa,"ht"); sf_setunit(aa,"s");
if(verb) sf_raxa(aa);
sf_oaxa(Fe,aa,4);
sf_oaxa(Fe,ac,5);
}
/* source wavefield extrapolation */
wex(weop,cub,ssr,tap,slo,1,Fws,Fts,true);
/* receiver wavefield extrapolation */
wex(weop,cub,ssr,tap,slo,-1,Fd,Ftr,true);
/* initialize CIP gathers */
cip = wexcip_init(cub,nhx,nhy,nhz,nht,nhx2,nhy2,nhz2,nht2,nc,dht,oht,Fc,eic);
/* construct image */
wexcip_for(cub,cip,Fts,Ftr,Fm,0,0,0);
/* construct CIP gathers */
if(eic){
if(drv)
wexcip_for_drv(cub,cip,Fts,Ftr,Fe);
else if(new)
wexcip_for_new(cub,cip,Fts,Ftr,Fe);
else
wexcip_for(cub,cip,Fts,Ftr,Fe,eic,0,0);
}
/*------------------------------------------------------------*/
/* close structures */
wex_close(weop);
wexslo_close(slo);
wexssr_close(cub,ssr);
wextap2D_close(tap);
if(eic) wexcip_close(cip,eic);
/*------------------------------------------------------------*/
/*------------------------------------------------------------*/
/* close files */
if (Fs!=NULL) sf_fileclose(Fs);
if (Fc!=NULL) sf_fileclose(Fc);
if (Fd!=NULL) sf_fileclose(Fd);
if (Fm!=NULL) sf_fileclose(Fm);
if (Fe!=NULL) sf_fileclose(Fe);
if (Fws!=NULL) sf_fileclose(Fws);
if (Fts!=NULL) sf_tmpfileclose(Fts);
if (Ftr!=NULL) sf_tmpfileclose(Ftr);
/*------------------------------------------------------------*/
exit (0);
}