int main(int argc, char* argv[]) { int nt, n3, nx, np, i3, ntx, ntp; bool adj,verb,rho; float o1,d1, x0,dx, anti, p0,dp,p1; float *cmp=NULL, *vscan=NULL; sf_file in=NULL, out=NULL; sf_init(argc,argv); in = sf_input ("in"); out = sf_output("out"); if (!sf_histint (in,"n1",&nt)) sf_error("No n1= in input"); if (!sf_histfloat(in,"o1",&o1)) sf_error("No o1= in input"); if (!sf_histfloat(in,"d1",&d1)) sf_error("No d1= in input"); n3 = sf_leftsize(in,2); if (!sf_getbool ("verb",&verb)) verb=false; /* verbosity flag */ if (!sf_getbool ( "adj",&adj )) adj=false; /* adjoint flag */ if (!sf_getbool ( "rho",&rho )) rho=true; /* rho filtering */ if (!sf_getfloat("anti",&anti)) anti=1.; /* antialiasing */ if (adj) { if (!sf_histfloat(in,"o2",&x0)) sf_error("No o2= in input"); if (!sf_histfloat(in,"d2",&dx)) sf_error("No d2= in input"); if (!sf_histint (in,"n2",&nx)) sf_error("No n2= in input"); /* specify slope axis */ if (!sf_getint("np",&np)) sf_error("Need np="); /* number of p values (if adj=y) */ if (!sf_getfloat("dp",&dp)) sf_error("Need dp="); /* p sampling (if adj=y) */ if (!sf_getfloat("p0",&p0)) sf_error("Need p0="); /* p origin (if adj=y) */ sf_putint (out,"n2",np); sf_putfloat(out,"d2",dp); sf_putfloat(out,"o2",p0); } else { /* modeling */ if (!sf_histint (in,"n2",&np)) sf_error("No n2= in input"); if (!sf_histfloat(in,"d2",&dp)) sf_error("No d2= in input"); if (!sf_histfloat(in,"o2",&p0)) sf_error("No o2= in input"); if (!sf_getfloat("x0",&x0)) sf_error("Need x0="); /* offset origin */ if (!sf_getfloat("dx",&dx)) sf_error("Need dx="); /* offset sampling */ if (!sf_getint("nx",&nx)) sf_error ("Need nx="); /* number of offsets */ sf_putint (out,"n2",nx); sf_putfloat(out,"o2",x0); sf_putfloat(out,"d2",dx); } if (!sf_getfloat("p1",&p1)) p1=0.; /* reference slope */ ntx = nt*nx; ntp = nt*np; cmp = sf_floatalloc(ntx); vscan = sf_floatalloc(ntp); slant_init (true, rho, x0, dx, nx, p0, dp, np, o1, d1, nt, p1, anti); for (i3=0; i3 < n3; i3++) { if(verb) sf_warning("i=%d of %d",i3+1,n3); if( adj) { sf_floatread( cmp,ntx,in); } else { sf_floatread(vscan,ntp,in); } slant_lop(adj,false,ntp,ntx,vscan,cmp); if( adj) { sf_floatwrite(vscan,ntp,out); } else { sf_floatwrite( cmp,ntx,out); } } exit(0); }
int main (int argc, char **argv) { bool verb; /* verbosity flag */ int nt; /* number of time samples */ int nx; /* number of offsets */ int np; /* number of slopes */ int nw1, nw2; int nc,ic,i; /* number of CMP gathers, CMP gather counter */ bool adj, inv, par, freq; /* adjoint, inverse, parabolic, domain flag */ int nf1, nf2, nf; /* number of filter size */ float dt,t0; /* time increment, starting time */ float dp,p0; /* slope increment, starting slope */ float x0, dx, ox; /* reference offset, increment, origin */ float *x, *y, *filt; /* input and output */ bool rho; float anti, p1, *w=NULL; sf_file in, out, fil, weight=NULL; sf_init(argc,argv); in = sf_input("in"); out = sf_output("out"); fil = sf_input("filt"); if (!sf_getbool("adj",&adj)) adj=false; /* if y, perform adjoint operation */ if (!sf_getbool("inv",&inv)) inv=false; /* if y, perform inverse operation */ if (!sf_getbool ("verb",&verb)) verb=false; /* verbosity flag */ /* read input file parameters */ if (!sf_histint(in,"n1",&nt)) sf_error("No n1= in input"); if (!sf_histfloat(in,"d1",&dt)) sf_error("No d1= in input"); if (!sf_histfloat(in,"o1",&t0)) t0=0.; if (!sf_histint(fil,"n1",&nf1)) sf_error("No nf1= in filt"); if (!sf_histint(fil,"n2",&nf2)) sf_error("No nf2= in filt"); if (!sf_histint(fil,"n3",&nf)) sf_error("No nf3= in filt"); if (!adj) { if (!sf_histint(in,"n2",&nx)) sf_error("No n2= in input"); if (!sf_histfloat(in,"o2",&ox)) sf_error("No o2= in input"); if (!sf_histfloat(in,"d2",&dx)) sf_error("No d2= in input"); /* specify slope axis */ if (!sf_getint ("np",&np)) sf_error("Need np="); /* number of p values */ if (!sf_getfloat("dp",&dp)) sf_error("Need dp="); /* p sampling */ if (!sf_getfloat("p0",&p0)) sf_error("Need p0="); /* p origin */ } else { if (!sf_histint(in,"n2",&np)) sf_error("No n2= in input"); if (!sf_histfloat(in,"o2",&p0)) sf_error("No o2= in input"); if (!sf_histfloat(in,"d2",&dp)) sf_error("No d2= in input"); /* specify space axis */ if (!sf_getint ("nx",&nx)) sf_error("Need nx="); /* number of x values */ if (!sf_getfloat("dx",&dx)) sf_error("Need dx="); /* x sampling */ if (!sf_getfloat("ox",&ox)) sf_error("Need ox="); /* x origin */ } if (nf1!=nt || nf2!= nx) sf_error("Need nf1==nt && nf2==nx"); nc = sf_leftsize(in,2); if (!sf_getbool("freq",&freq)) freq=true; /* if y, parabolic Radon transform */ if (!sf_getbool("parab",&par)) par=false; /* if y, parabolic Radon transform, only when freq=y */ if (!sf_getfloat("x0",&x0)) x0=1.; /* reference offset */ if (!sf_getbool ( "rho",&rho )) rho=true; /* rho filtering, only when freq=n */ if (!sf_getfloat("anti",&anti)) anti=1.; /* antialiasing, only when freq=n */ if (!sf_getfloat("p1",&p1)) p1=0.; /* reference slope, only when freq=n */ x = sf_floatalloc (nt*np); y = sf_floatalloc (nt*nx); filt = sf_floatalloc (nt*nx*nf); if (NULL != sf_getstring ("weight")) { weight = sf_input("weight"); w = sf_floatalloc(nt*np); if (!sf_histint(in,"n1",&nw1)) sf_error("No n1= in weight"); if (!sf_histint(in,"n2",&nw2)) sf_error("No n2= in weight"); if (nw1 != nt || nw2 != np) sf_error("Need nw1==nt && nw2==np"); } else { weight = NULL; w = NULL; } for (ic = 0; ic < nc; ic++) { /* loop over CMPs */ if(verb) sf_warning("i=%d of %d",ic+1,nc); sf_floatread(filt,nt*nx*nf,fil); if (!adj) { sf_floatread(y,nt*nx,in); nmrt_init (nt,nx,nf,np,dt,t0,dx,ox,x0,dp,p0, par,freq,rho,anti,p1,filt); nmrt_oper (adj, false, nt*np, nt*nx, x, y); if (NULL != weight) { sf_floatread(w,nt*np,weight); for (i=0; i < nt*np; i++) { x[i] *= w[i]; } } sf_putint(out,"n2",np); sf_putfloat(out,"d2",dp); sf_putfloat(out,"o2",p0); sf_putstring(out,"label2","P"); sf_putstring(out,"unit2",""); sf_floatwrite(x,nt*np,out); } else { sf_floatread(x,nt*np,in); if (inv) { if (freq) { radonoper_init (nt,dt,t0,nx,dx,ox, x0,np,dp,p0,par); radonoper_lop (false, false, nt*np, nt*nx, x, y); } else { slant_init (true,rho,x0,dx,nx,p0,dp, np,t0,dt,nt,p1,anti); slant_lop(false,false,nt*np,nt*nx,x,y); } } else { nmrt_init (nt,nx,nf,np,dt,t0,dx,ox,x0,dp,p0, par,freq,rho,anti,p1,filt); nmrt_oper (adj, false, nt*np, nt*nx, x, y); } sf_putint(out,"n2",nx); sf_putfloat(out,"d2",dx); sf_putfloat(out,"o2",ox); sf_putstring(out,"label2","Distance"); sf_putstring(out,"unit2",""); sf_floatwrite(y,nt*nx,out); } } /* loop over CMPs */ exit (0); }