Skip to content

Commit ee5eb59

Browse files
committed
Merge branch 'master' of https://github.com/ahay/src
2 parents 24681cb + b6b2e31 commit ee5eb59

File tree

2 files changed

+229
-1
lines changed

2 files changed

+229
-1
lines changed

user/fomels/Mpsmig2.c

Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
/* 2-D prestack Kirchhoff time migration with antialiasing.
2+
The axes in the input and output are {time,midpoint,offset}
3+
The axes in the offset are {1,midpoint,offset}
4+
*/
5+
/*
6+
Copyright (C) 2010 University of Texas at Austin
7+
8+
This program is free software; you can redistribute it and/or modify
9+
it under the terms of the GNU General Public License as published by
10+
the Free Software Foundation; either version 2 of the License, or
11+
(at your option) any later version.
12+
13+
This program is distributed in the hope that it will be useful,
14+
but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
GNU General Public License for more details.
17+
18+
You should have received a copy of the GNU General Public License
19+
along with this program; if not, write to the Free Software
20+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21+
*/
22+
#include <rsf.h>
23+
24+
static void pick(bool adj, float ti, float deltat,
25+
float *trace, float *out, int i,
26+
int nt, float dt, float t0)
27+
/* pick a traveltime sample from a trace */
28+
{
29+
int it, itm, itp;
30+
float ft, tm, tp, ftm, ftp, imp;
31+
32+
ft = (ti-t0)/dt; it = floorf(ft); ft -= it;
33+
if ( it < 0 || it >= nt-1) return;
34+
35+
tm = ti-deltat-dt;
36+
ftm = (tm-t0)/dt; itm = floorf(ftm); ftm -= itm;
37+
if (itm < 0) return;
38+
39+
tp = ti+deltat+dt;
40+
ftp = (tp-t0)/dt; itp = floorf(ftp); ftp -= itp;
41+
if (itp >= nt-1) return;
42+
43+
imp = dt/(dt+tp-tm);
44+
imp *= imp;
45+
46+
if (adj) {
47+
out[i] += imp*(
48+
2.*(1.-ft)*trace[it] + 2.*ft*trace[it+1] -
49+
(1.-ftm)*trace[itm] - ftm*trace[itm+1] -
50+
(1.-ftp)*trace[itp] - ftp*trace[itp+1]);
51+
} else {
52+
trace[it] += 2.*(1-ft)*imp*out[i];
53+
trace[it+1] += 2.*ft*imp*out[i];
54+
trace[itm] -= (1.-ftm)*imp*out[i];
55+
trace[itm+1] -= ftm*imp*out[i];
56+
trace[itp] -= (1.-ftp)*imp*out[i];
57+
trace[itp+1] -= ftp*imp*out[i];
58+
}
59+
}
60+
61+
int main(int argc, char* argv[])
62+
{
63+
bool adj, half, verb;
64+
int nt, nx, nh, nh2, ix, ih, iy, i, nn, it, apt;
65+
float *trace, **image, **v, rho, *pp, *off;
66+
float h, x, t, h0, dh, dx, ti, tx, t0, t1, t2, dt, vi, aal, angle;
67+
sf_file inp, out, vel, offset;
68+
69+
sf_init (argc,argv);
70+
inp = sf_input("in");
71+
vel = sf_input("vel");
72+
out = sf_output("out");
73+
74+
if (!sf_getbool("adj",&adj)) adj=true;
75+
/* adjoint flag (y for migration, n for modeling) */
76+
77+
if (!sf_histint(inp,"n1",&nt)) sf_error("No n1=");
78+
if (!sf_histint(inp,"n2",&nx)) sf_error("No n2=");
79+
80+
if (!sf_histfloat(inp,"o1",&t0)) sf_error("No o1=");
81+
if (!sf_histfloat(inp,"d1",&dt)) sf_error("No d1=");
82+
if (!sf_histfloat(inp,"d2",&dx)) sf_error("No d2=");
83+
84+
if (!sf_histint(inp,"n3",&nh)) sf_error("No n3=");
85+
86+
if (!sf_getfloat("antialias",&aal)) aal = 1.0;
87+
/* antialiasing */
88+
89+
if (!sf_getint("apt",&apt)) apt = nx;
90+
/* integral aperture */
91+
92+
if (!sf_getfloat("angle",&angle)) angle = 90.0;
93+
/* angle aperture */
94+
95+
angle = fabsf(tanf(angle*SF_PI/180.0));
96+
97+
if (!sf_getbool("half",&half)) half = true;
98+
/* if y, the third axis is half-offset instead of full offset */
99+
100+
if (!sf_getbool("verb",&verb)) verb = true;
101+
/* verbosity flag */
102+
103+
if (!sf_getfloat("rho",&rho)) rho = 1.-1./nt;
104+
/* Leaky integration constant */
105+
106+
if (NULL != sf_getstring("offset")) {
107+
offset = sf_input("offset");
108+
nh2 = sf_filesize(offset);
109+
110+
if (nh2 != nh*nx) sf_error("Wrong dimensions in offset");
111+
112+
off = sf_floatalloc(nh2);
113+
sf_floatread (off,nh2,offset);
114+
sf_fileclose(offset);
115+
} else {
116+
if (!sf_histfloat(inp,"o3",&h0)) sf_error("No o3=");
117+
if (!sf_histfloat(inp,"d3",&dh)) sf_error("No d3=");
118+
119+
if (!half) dh *= 0.5;
120+
121+
off = sf_floatalloc(nh*nx);
122+
for (ix = 0; ix < nx; ix++) {
123+
for (ih = 0; ih < nh; ih++) {
124+
off[ih*nx+ix] = h0 + ih*dh;
125+
}
126+
}
127+
offset = NULL;
128+
}
129+
130+
v = sf_floatalloc2(nt,nx);
131+
sf_floatread(v[0],nt*nx,vel);
132+
133+
trace = sf_floatalloc(nt);
134+
image = sf_floatalloc2(nt,nx);
135+
136+
nn = 2*kiss_fft_next_fast_size((nt+1)/2);
137+
pp = sf_floatalloc(nn);
138+
139+
sf_halfint_init (true, nn, rho);
140+
141+
for (ih=0; ih < nh; ih++) {
142+
if (verb) sf_warning("offset %d of %d;",ih+1,nh);
143+
144+
if (adj) {
145+
for (i=0; i < nt*nx; i++) {
146+
image[0][i] = 0.;
147+
}
148+
} else {
149+
sf_floatread(image[0],nt*nx,inp);
150+
}
151+
152+
if (!adj) {
153+
for (iy=0; iy < nx; iy++) {
154+
for (it=0; it < nt; it++) {
155+
pp[it] = image[iy][it];
156+
}
157+
for (it=nt; it < nn; it++) {
158+
pp[it] = 0.;
159+
}
160+
sf_halfint (false, pp);
161+
for (it=0; it < nt; it++) {
162+
image[iy][it] = pp[it];
163+
}
164+
}
165+
}
166+
167+
for (iy=0; iy < nx; iy++) {
168+
if (adj) {
169+
sf_floatread (trace,nt,inp);
170+
sf_doubint(true, nt,trace);
171+
} else {
172+
for (it=0; it < nt; it++) {
173+
trace[it]=0.0f;
174+
}
175+
}
176+
177+
h = fabsf(off[ih*nx+iy]);
178+
179+
for (ix=0; ix < nx; ix++) {
180+
x = (ix-iy)*dx;
181+
if (SF_ABS(ix-iy) > apt) continue;
182+
183+
for (it=0; it < nt; it++) {
184+
t = t0 + it*dt;
185+
vi = v[ix][it];
186+
187+
if (fabsf(x) > angle*vi*t) continue;
188+
189+
/* hypot(a,b) = sqrt(a*a+b*b) */
190+
t1 = hypotf(0.5*t,(x-h)/vi);
191+
t2 = hypotf(0.5*t,(x+h)/vi);
192+
ti = t1+t2;
193+
194+
/* tx = |dt/dx| */
195+
tx = fabsf(x-h)/(vi*vi*(t1+dt))+
196+
fabsf(x+h)/(vi*vi*(t2+dt));
197+
198+
pick(adj,ti,fabsf(tx*dx*aal),trace,image[ix],it,nt,dt,t0);
199+
}
200+
}
201+
202+
if (!adj) {
203+
sf_doubint(true, nt,trace);
204+
sf_floatwrite (trace,nt,out);
205+
}
206+
}
207+
208+
if (adj) {
209+
for (iy=0; iy < nx; iy++) {
210+
for (it=0; it < nt; it++) {
211+
pp[it] = image[iy][it];
212+
}
213+
for (it=nt; it < nn; it++) {
214+
pp[it] = 0.;
215+
}
216+
sf_halfint (true, pp);
217+
for (it=0; it < nt; it++) {
218+
image[iy][it] = pp[it];
219+
}
220+
}
221+
222+
sf_floatwrite(image[0],nt*nx,out);
223+
}
224+
}
225+
if (verb) sf_warning(".");
226+
227+
exit(0);
228+
}

user/fomels/SConstruct

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ imray interf interp2 interpt iphase kdsort kdtree kron label legacy
1515
lfftexp0 llpf localskew locov lpf lrmig0 lsfit max2 median mffit mig3
1616
miss3 morph nconv nnint nnshape nnshapet nsmooth nsmooth1 ocparcel
1717
octentwt ofilp ofsemb ortho patch pchain pchain1 phaserot pick pick2
18-
pick3 plane poly polyfit regr rdiv rect1 reshape riesz rsin sc
18+
pick3 plane poly polyfit psmig2 regr rdiv rect1 reshape riesz rsin sc
1919
seislet1 semblance semblancew shape shapeagc shapefill shearer shift1
2020
sh1 sh2 similarity similarity2 simenv slschain2d smoothderw smoothreg
2121
smspray stfchain stfchain2 stcontrib stltft stpf stphase stream

0 commit comments

Comments
 (0)