int main (int argc, char *argv[]) { int ir, nr, n1,n2,n3, m1, m2, m3, n12, nw, nj1, i3; float *u1, *u2, *p; sf_file in, out, dip; bool verb; allpass ap; sf_init(argc,argv); in = sf_input ("in"); dip = sf_input ("dip"); out = sf_output ("out"); if (SF_FLOAT != sf_gettype(in) || SF_FLOAT != sf_gettype(dip)) sf_error("Need float type"); if (!sf_histint(in,"n1",&n1)) sf_error("Need n1= in input"); if (!sf_histint(in,"n2",&n2)) n2=1; if (!sf_histint(in,"n3",&n3)) n3=1; n12 = n1*n2; nr = sf_leftsize(in,2); if (!sf_histint(dip,"n1",&m1) || m1 != n1) sf_error("Need n1=%d in dip",n1); if (1 != n2 && (!sf_histint(dip,"n2",&m2) || m2 != n2)) sf_error("Need n2=%d in dip",n2); if (1 != n3 && (!sf_histint(dip,"n3",&m3) || m3 != n3)) sf_error("Need n3=%d in dip",n3); if (!sf_getint("order",&nw)) nw=1; /* accuracy */ if (!sf_getbool("verb",&verb)) verb = false; /* verbosity flag */ if (!sf_getint("nj1",&nj1)) nj1=1; /* aliasing */ n3 = 1; for (ir=0; ir < nr; ir++) { if (verb) sf_warning("slice %d of %d", ir+1, nr); u1 = sf_floatalloc(n12); u2 = sf_floatalloc(n12); p = sf_floatalloc(n12); for (i3=0; i3 < n3; i3++) { /* read data */ sf_floatread(u1,n12,in); /* read t-x dip */ sf_floatread(p,n12,dip); ap = allpass_init (nw,nj1,n1,n2,1,p); /* apply */ allpass1(false, false, ap, u1, u2); /* write t-x destruction */ sf_floatwrite(u2,n12,out); } free(u1); free(u2); free(p); } exit (0); }
int main (int argc, char *argv[]) { bool both; int ir, nr, n1,n2,n3,n4, m1, m2, m3, n12, n123, nw, nj1, nj2, i3; float *u1, *u2, *p; sf_file in, out, dip; off_t pos=0; allpass ap; sf_init(argc,argv); in = sf_input ("in"); dip = sf_input ("dip"); out = sf_output ("out"); if (SF_FLOAT != sf_gettype(in) || SF_FLOAT != sf_gettype(dip)) sf_error("Need float type"); if (!sf_histint(in,"n1",&n1)) sf_error("Need n1= in input"); if (!sf_histint(in,"n2",&n2)) n2=1; if (!sf_histint(in,"n3",&n3)) n3=1; n12 = n1*n2; n123 = n12*n3; nr = sf_leftsize(in,3); if (!sf_histint(dip,"n1",&m1) || m1 != n1) sf_error("Need n1=%d in dip",n1); if (1 != n2 && (!sf_histint(dip,"n2",&m2) || m2 != n2)) sf_error("Need n2=%d in dip",n2); if (1 != n3 && (!sf_histint(dip,"n3",&m3) || m3 != n3)) sf_error("Need n3=%d in dip",n3); if (!sf_getbool("both",&both)) both=false; /* if y, compute both left and right predictions */ if (1 == n3) { n4=0; if (both) sf_putint(out,"n3",2); } else { if (!sf_getint("n4",&n4)) n4=2; /* what to compute in 3-D. 0: in-line, 1: cross-line, 2: both */ if (n4 > 2) n4=2; if (2==n4) sf_putint(out,"n4",both? 4:2); if (0 != n4 || both) { sf_unpipe(in,(off_t) n123*sizeof(float)); pos = sf_tell(in); } } if (!sf_getint("order",&nw)) nw=1; /* accuracy */ if (!sf_getint("nj1",&nj1)) nj1=1; /* in-line aliasing */ if (!sf_getint("nj2",&nj2)) nj2=1; /* cross-line aliasing */ for (ir=0; ir < nr; ir++) { if (1 != n4) { /* in-line */ u1 = sf_floatalloc(n12); u2 = sf_floatalloc(n12); p = sf_floatalloc(n12); for (i3=0; i3 < n3; i3++) { /* read data */ sf_floatread(u1,n12,in); /* read t-x dip */ sf_floatread(p,n12,dip); ap = allpass_init (nw,nj1,n1,n2,1,p); /* apply */ allpass1(false, false, ap, u1, u2); /* write t-x destruction */ sf_floatwrite(u2,n12,out); } free(u1); free(u2); free(p); } if (0 != n4) { /* cross-line */ u1 = sf_floatalloc(n123); u2 = sf_floatalloc(n123); p = sf_floatalloc(n123); /* read data */ sf_seek(in,pos,SEEK_SET); sf_floatread(u1,n123,in); /* read t-y dip */ sf_floatread(p,n123,dip); ap = allpass_init(nw,nj2,n1,n2,n3,p); /* apply */ allpass2(false, false, ap, u1, u2); /* write t-y destruction */ sf_floatwrite(u2,n123,out); } if (!both) continue; if (1 != n4) { /* in-line */ u1 = sf_floatalloc(n12); u2 = sf_floatalloc(n12); p = sf_floatalloc(n12); sf_seek(in,pos,SEEK_SET); for (i3=0; i3 < n3; i3++) { /* read data */ sf_floatread(u1,n12,in); /* read t-x dip */ sf_floatread(p,n12,dip); ap = allpass_init (nw,nj1,n1,n2,1,p); /* apply */ allpass1(true, false, ap, u1, u2); /* write t-x destruction */ sf_floatwrite(u2,n12,out); } free(u1); free(u2); free(p); } if (0 != n4) { /* cross-line */ u1 = sf_floatalloc(n123); u2 = sf_floatalloc(n123); p = sf_floatalloc(n123); /* read data */ sf_seek(in,pos,SEEK_SET); sf_floatread(u1,n123,in); /* read t-y dip */ sf_floatread(p,n123,dip); ap = allpass_init(nw,nj2,n1,n2,n3,p); /* apply */ allpass2(true, false, ap, u1, u2); /* write t-y destruction */ sf_floatwrite(u2,n123,out); } } exit (0); }
void dip3(bool left /* left or right prediction */, int dip /* 1 - inline, 2 - crossline */, int niter /* number of nonlinear iterations */, int nw /* filter size */, int nj /* filter stretch for aliasing */, bool verb /* verbosity */, float *u /* input data */, float* p /* output dip */, bool* mask /* input mask for known data */, float pmin, float pmax /* minimum and maximum dip */) /*< estimate local dip >*/ { int i, iter, k; float usum, usum2, pi, lam; allpass ap; ap = allpass_init (nw,nj,n1,n2,n3,p); if (dip == 1) { allpass1 (left, false, ap, u,u2); } else { allpass2 (left, false, ap, u,u2); } for (iter =0; iter < niter; iter++) { if (dip == 1) { allpass1 (left, true, ap, u,u1); } else { allpass2 (left, true, ap, u,u1); } usum = 0.0; for(i=0; i < n; i++) { p0[i] = p[i]; usum += u2[i]*u2[i]; } if (NULL != mask) { for(i=0; i < n; i++) { if (mask[i]) { u1[i] = 0.; u2[i] = 0.; } } } sf_divne (u2, u1, dp, eps); lam = 1.; for (k=0; k < 8; k++) { for(i=0; i < n; i++) { pi = p0[i]+lam*dp[i]; if (pi < pmin) pi=pmin; if (pi > pmax) pi=pmax; p[i] = pi; } if (dip == 1) { allpass1 (left, false, ap, u,u2); } else { allpass2 (left, false, ap, u,u2); } usum2 = 0.; for(i=0; i < n; i++) { usum2 += u2[i]*u2[i]; } if (usum2 < usum) break; lam *= 0.5; } } /* iter */ free(ap); }
int main(int argc, char* argv[]) { int nt, nt2, nx, i1, i2, n12, i, j; bool adj, sm, domod; float dt, dt2, dx, ot, ot2, ox, epst2; float v_1, v_2, v_3, v_4, eps, passthr; float * data, * output, * datat2, * outputt2, * model; sf_file inp, out; /* PWD parameters */ int nw, nj1; float *pp, *pwdata; sf_file dip,outpwdcheck,outdipcheck; /* kirchhoff params */ bool half, verb,normalize,debug; int nh, **fold, apt; float **v, rho, *off; float h0, dh, aal, angle; int ix, ih, nh2; sf_file vel, gather, offset; //MADAGASCAR C API /* initialize */ sf_init(argc,argv); inp = sf_input("in"); out = sf_output("out"); vel = sf_input("vel"); dip = sf_input("dip"); //initialize file with dip /* get dimensions from input */ if (!sf_histint(inp,"n1",&nt)) sf_error("No n1= in inp"); if (!sf_histint(inp,"n2",&nx)) sf_error("No n2= in inp"); if (!sf_histfloat(inp,"d1",&dt)) sf_error("No d1= in inp"); if (!sf_histfloat(inp,"d2",&dx)) sf_error("No d2= in inp"); if (!sf_histfloat(inp,"o1",&ot)) sf_error("No o1= in inp"); if (!sf_histfloat(inp,"o2",&ox)) sf_error("No o2= in inp"); /* get parameters from command line */ /* adjoint flag */ if (!sf_getbool("adj",&adj)) adj=false; /* if perform derivative filtering = PWD */ if (!sf_getbool("sm",&sm)) sm=true; /* if perform modelling via Kirchhoff */ if (!sf_getbool("domod",&domod)) domod=true; /* debug flag */ if (!sf_getbool("debug",&debug)){ debug=false; outpwdcheck = NULL; outdipcheck = NULL; } else { outpwdcheck = sf_output("outpwd"); outdipcheck = sf_output("outdip"); } /* kirchhoff parameters */ //////////////////////////////////////////////////////////////////////////////////////// if (!sf_getbool("normalize",&normalize)) normalize=true; /* normalize for the fold */ if (normalize) { fold = sf_intalloc2(nt,nx); } else { fold = NULL; } if (adj) { if (!sf_histint(inp,"n3",&nh)) sf_error("No n3="); sf_putint(out,"n3",1); } else { if (!sf_getint("nh",&nh)) sf_error("Need nh="); /* number of offsets (for modeling) */ sf_putint(out,"n3",nh); } if (NULL != sf_getstring("gather")) { gather = sf_output("gather"); } else { gather = NULL; } if (!sf_getfloat("antialias",&aal)) aal = 1.0; /* antialiasing */ if (!sf_getint("apt",&apt)) apt = nx; /* integral aperture */ if (!sf_getfloat("angle",&angle)) angle = 90.0; /* angle aperture */ angle = fabsf(tanf(angle*SF_PI/180.0)); if (!sf_getbool("half",&half)) half = true; /* if y, the third axis is half-offset instead of full offset */ if (!sf_getbool("verb",&verb)) verb = true; /* verbosity flag */ if (!sf_getfloat("rho",&rho)) rho = 1.-1./nt; /* Leaky integration constant */ if (NULL != sf_getstring("offset")) { offset = sf_input("offset"); nh2 = sf_filesize(offset); if (nh2 != nh*nx) sf_error("Wrong dimensions in offset"); off = sf_floatalloc(nh2); sf_floatread (off,nh2,offset); sf_fileclose(offset); } else { if (adj) { if (!sf_histfloat(inp,"o3",&h0)) sf_error("No o3="); if (!sf_histfloat(inp,"d3",&dh)) sf_error("No d3="); sf_putfloat(out,"d3",1.); sf_putfloat(out,"o3",0.); } else { if (!sf_getfloat("dh",&dh)) sf_error("Need dh="); /* offset sampling (for modeling) */ if (!sf_getfloat("h0",&h0)) sf_error("Need h0="); /* first offset (for modeling) */ sf_putfloat(out,"d3",dh); sf_putfloat(out,"o3",h0); } if (!half) dh *= 0.5; off = sf_floatalloc(nh*nx); for (ix = 0; ix < nx; ix++) { for (ih = 0; ih < nh; ih++) { off[ih*nx+ix] = h0 + ih*dh; } } offset = NULL; } //////////////////////////////////////////////////////////////////////////////////////// /* path-integral range */ if (!sf_getfloat("v_1",&v_1)) sf_error("No integration range specified"); if (!sf_getfloat("v_2",&v_2)) sf_error("No integration range specified"); if (!sf_getfloat("v_3",&v_3)) sf_error("No integration range specified"); if (!sf_getfloat("v_4",&v_4)) sf_error("No integration range specified"); if (!sf_getfloat("passthr",&passthr)) passthr = 0.001; // threshold for tail elimination if (!sf_getfloat("eps",&eps)) eps = 0.001; // damper for pi if (!sf_getfloat("epst2",&epst2)) epst2 = 0.001; // damper for t2warp /* new axis length */ if (!sf_getint("pad",&nt2)) nt2=nt; /* output time samples */ n12 = nt2*nx; data = sf_floatalloc(nt*nx); model = sf_floatalloc(nt*nx); datat2 = sf_floatalloc(nt2*nx); outputt2 = sf_floatalloc(nt2*nx); output = sf_floatalloc(nt*nx); pwdata = NULL; // allocate dip if (sm){ pp = sf_floatalloc(nt*nx); //allocate space for dip sf_floatread(pp,nt*nx,dip); //read dip pwdata = sf_floatalloc(nt*nx); //allocate space for pwd data if (!sf_getint("order",&nw)) nw=1; /* [1,2,3] accuracy order */ if (nw < 1 || nw > 3) sf_error ("Unsupported nw=%d, choose between 1 and 3",nw); if (!sf_getint("nj1",&nj1)) nj1=1; /* antialiasing */ allpass32d_init(allpass_init(nw, nj1, nt,nx,1, pp)); //initialize all-pass-filter structure } // allocating and reading velocity v = sf_floatalloc2(nt,nx); sf_floatread(v[0],nt*nx,vel); if(!adj) { if(domod){// perform modelling // reading data sf_floatread(model,nt*nx,inp); // modelling via mig2 mig2_lop(false,half,verb,normalize,nt,nx,nh,fold,apt,data,v,rho,model,off,h0,dh,dx,ot,dt,aal,angle); } else {// just read the data sf_warning("modelling is disabled"); sf_floatread(data,nt*nx,inp); } // internal else if (sm){// perform PWD allpass32d_lop(adj,false,nt*nx,nt*nx,data,pwdata); if (debug){ sf_floatwrite(pwdata,nt*nx,outpwdcheck); sf_floatwrite(pp,nt*nx,outdipcheck); } //change the address for(i=0;i<nt*nx;i++){ data[i]=pwdata[i]; } }//PWD flag } else {// adj flag // read data currently 2D sf_floatread(data,nt*nx,inp); }// adj flag // t2warping axis evaluation ot2 = ot*ot; dt2 = ot+(nt-1)*dt; dt2 = (dt2*dt2 - ot2)/(nt2-1); // take in account different output trace length t2warp_init(nt,nt2,nx,ot,dt,ot2,dt2,epst2); sf_warning("t2warp_init(nt,nt2,nx,ot,dt,ot2,dt2,epst2);\n"); // compute pi filter sf_warning("be4 filter"); flatpifilt_init(nt2, nx, dt2, dx, 0.001, v_1, v_2, v_3, v_4, eps); sf_warning("after filter"); sf_warning("pifilt_init(nt2, nx, dt2, dx, v_a, v_b, v_0, beta, eps);\n"); if(adj) { sf_warning("be4 the chain: params %d %d %d %d",nt*nx,nt2*nx,nt2*nx,nt*nx); sf_chain3(t2warp_inv,freqfilt4pi_lop,t2warp,adj,false,nt*nx,nt2*nx,nt2*nx,nt*nx,output,data,outputt2,datat2); sf_warning("running chain"); } else { sf_chain3(t2warp_inv,freqfilt4pi_lop,t2warp,false,false,nt*nx,nt2*nx,nt2*nx,nt*nx,data,output,datat2,outputt2); } if(adj) { if (sm){ sf_warning("performing PWD"); allpass32d_lop(adj,false,nt*nx,nt*nx,pwdata,output); //change the address for (i=0;i<nt*nx;i++){ output[i]=pwdata[i]; } } if (domod) { sf_warning("performing Kirchhoff migration"); mig2_lop(true,half,verb,normalize,nt,nx,nh,fold,apt,output,v,rho,model,off,h0,dh,dx,ot,dt,aal,angle); } else { sf_warning("changing the address"); //change the address for (i=0;i<nt*nx;i++){ model[i]=output[i]; } } } // adj flag sf_warning("done with output"); if (!adj) { // write sf_floatwrite(output,nt*nx,out); } else { // write sf_floatwrite(model,nt*nx,out); } exit(0); }
int main(int argc, char* argv[]) { int nt, nt2, nx, i1, i2, n12, i, j, nx2; bool adj, sm, domod; float dt, dt2, dx, ot, ot2, ox, epst2; float v_1, v_2, v_3, v_4, eps, passthr; float * data, * output, * datat2, * outputt2, * model, * pwdmodel, * outputext, * pwdmodelext; sf_file inp, out; /* PWD parameters */ int nw, nj1; float *pp, *pwdata, *pwdataext; sf_file dip,outpwdcheck,outdipcheck; /* kirchhoff params */ bool half, verb,normalize,debug; int nh, **fold, apt; float **v, rho, *off; float h0, dh, aal, angle; int ix, ih, nh2; sf_file vel, gather, offset; /* regularization weight */ float reg; /* files needed for the extended operator */ float * modelext, * dataext; // diffmod - diffraction image from the previous iteration // dipim - dip distribution in the image sf_file dipim; //diffmod, //MADAGASCAR C API /* initialize */ sf_init(argc,argv); inp = sf_input("in"); out = sf_output("out"); vel = sf_input("vel"); dip = sf_input("dip"); //initialize file with dip dipim = sf_input("dipim"); //initialize file with image dip //diffmod = sf_input("diffmod"); //diffraction model from the previous iteration /* get dimensions from input */ if (!sf_histint(inp,"n1",&nt)) sf_error("No n1= in inp"); if (!sf_histint(inp,"n2",&nx2)) sf_error("No n2= in inp"); // half of the traces - actual data // half of the traces - model penalization nx = (int)(nx2)/2; sf_warning("nx=%d nx2=%d \n",nx,nx2); sf_warning("nx=%d nx2=%d \n",nx,nx2); sf_warning("nx=%d nx2=%d \n",nx,nx2); sf_warning("nx=%d nx2=%d \n",nx,nx2); sf_warning("nx=%d nx2=%d \n",nx,nx2); if (!sf_histfloat(inp,"d1",&dt)) sf_error("No d1= in inp"); if (!sf_histfloat(inp,"d2",&dx)) sf_error("No d2= in inp"); if (!sf_histfloat(inp,"o1",&ot)) sf_error("No o1= in inp"); if (!sf_histfloat(inp,"o2",&ox)) sf_error("No o2= in inp"); /* get parameters from command line */ /* adjoint flag */ if (!sf_getbool("adj",&adj)) adj=false; /* if perform derivative filtering = PWD */ if (!sf_getbool("sm",&sm)) sm=true; /* if perform modelling via Kirchhoff */ if (!sf_getbool("domod",&domod)) domod=true; /* get regularization parameter */ if (!sf_getfloat("reg",®)) reg=0.0; /* debug flag */ if (!sf_getbool("debug",&debug)){ debug=false; outpwdcheck = NULL; outdipcheck = NULL; } else { outpwdcheck = sf_output("outpwd"); outdipcheck = sf_output("outdip"); } /* kirchhoff parameters */ //////////////////////////////////////////////////////////////////////////////////////// if (!sf_getbool("normalize",&normalize)) normalize=true; /* normalize for the fold */ if (normalize) { fold = sf_intalloc2(nt,nx); } else { fold = NULL; } if (adj) { if (!sf_histint(inp,"n3",&nh)) sf_error("No n3="); sf_putint(out,"n3",1); } else { if (!sf_getint("nh",&nh)) sf_error("Need nh="); /* number of offsets (for modeling) */ sf_putint(out,"n3",nh); } if (NULL != sf_getstring("gather")) { gather = sf_output("gather"); } else { gather = NULL; } if (!sf_getfloat("antialias",&aal)) aal = 1.0; /* antialiasing */ if (!sf_getint("apt",&apt)) apt = nx; /* integral aperture */ if (!sf_getfloat("angle",&angle)) angle = 90.0; /* angle aperture */ angle = fabsf(tanf(angle*SF_PI/180.0)); if (!sf_getbool("half",&half)) half = true; /* if y, the third axis is half-offset instead of full offset */ if (!sf_getbool("verb",&verb)) verb = true; /* verbosity flag */ if (!sf_getfloat("rho",&rho)) rho = 1.-1./nt; /* Leaky integration constant */ if (NULL != sf_getstring("offset")) { offset = sf_input("offset"); nh2 = sf_filesize(offset); if (nh2 != nh*nx) sf_error("Wrong dimensions in offset"); off = sf_floatalloc(nh2); sf_floatread (off,nh2,offset); sf_fileclose(offset); } else { if (adj) { if (!sf_histfloat(inp,"o3",&h0)) sf_error("No o3="); if (!sf_histfloat(inp,"d3",&dh)) sf_error("No d3="); sf_putfloat(out,"d3",1.); sf_putfloat(out,"o3",0.); } else { if (!sf_getfloat("dh",&dh)) sf_error("Need dh="); /* offset sampling (for modeling) */ if (!sf_getfloat("h0",&h0)) sf_error("Need h0="); /* first offset (for modeling) */ sf_putfloat(out,"d3",dh); sf_putfloat(out,"o3",h0); } if (!half) dh *= 0.5; off = sf_floatalloc(nh*nx); for (ix = 0; ix < nx; ix++) { for (ih = 0; ih < nh; ih++) { off[ih*nx+ix] = h0 + ih*dh; } } offset = NULL; } //////////////////////////////////////////////////////////////////////////////////////// /* path-integral range */ if (!sf_getfloat("v_1",&v_1)) sf_error("No integration range specified"); if (!sf_getfloat("v_2",&v_2)) sf_error("No integration range specified"); if (!sf_getfloat("v_3",&v_3)) sf_error("No integration range specified"); if (!sf_getfloat("v_4",&v_4)) sf_error("No integration range specified"); if (!sf_getfloat("passthr",&passthr)) passthr = 0.001; // threshold for tail elimination if (!sf_getfloat("eps",&eps)) eps = 0.001; // damper for pi if (!sf_getfloat("epst2",&epst2)) epst2 = 0.001; // damper for t2warp /* new axis length */ if (!sf_getint("pad",&nt2)) nt2=nt; /* output time samples */ n12 = nt2*nx; /*^^^*/ /* extended operator arrays */ dataext = sf_floatalloc(nt*nx); modelext = sf_floatalloc(nt*nx); pwdmodel = sf_floatalloc(nt*nx); pwdmodelext = sf_floatalloc(nt*nx); outputext = sf_floatalloc(nt*nx); /* chain arrays */ data = sf_floatalloc(nt*nx); model = sf_floatalloc(nt*nx); datat2 = sf_floatalloc(nt2*nx); outputt2 = sf_floatalloc(nt2*nx); output = sf_floatalloc(nt*nx); pwdata = NULL; // allocate dip if (sm){ pp = sf_floatalloc(nt*nx); //allocate space for dip sf_floatread(pp,nt*nx,dip); //read dip pwdata = sf_floatalloc(nt*nx); //allocate space for pwd data (modelled with kichhoff operator usually) pwdataext = sf_floatalloc(nt*nx); //allocate space for pwd data if (!sf_getint("order",&nw)) nw=1; /* [1,2,3] accuracy order */ if (nw < 1 || nw > 3) sf_error ("Unsupported nw=%d, choose between 1 and 3",nw); if (!sf_getint("nj1",&nj1)) nj1=1; /* antialiasing */ allpass32d_init(allpass_init(nw, nj1, nt,nx,1, pp)); //initialize all-pass-filter structure } // allocating and reading velocity v = sf_floatalloc2(nt,nx); sf_floatread(v[0],nt*nx,vel); if(!adj) { if(domod){// perform modelling /*^^^*/ // reading data // first we read actual model sf_floatread(model,nt*nx,inp); // here we read diffractivity from the // previous iteration (should be catenated along // the second axis) sf_floatread(modelext,nt*nx,inp); // modelling via mig2 //^^^^^ mig2_lop(false,half,verb,normalize,nt,nx,nh,fold,apt,data,v,rho,model,off,h0,dh,dx,ot,dt,aal,angle); mig2_lop(false,half,verb,normalize,nt,nx,nh,fold,apt,dataext,v,rho,modelext,off,h0,dh,dx,ot,dt,aal,angle); } else {// just read the data sf_warning("modelling is disabled"); sf_floatread(data,nt*nx,inp); //sf_floatread(modelext,nt*nx,inp); } // internal else if (sm){// perform PWD //^^^^^ allpass32d_lop(adj,false,nt*nx,nt*nx,data,pwdata); allpass32d_lop(adj,false,nt*nx,nt*nx,dataext,pwdataext); /*if (debug){ sf_floatwrite(pwdata,nt*nx,outpwdcheck); sf_floatwrite(pp,nt*nx,outdipcheck); }*/ //change the address for(i=0;i<nt*nx;i++){ data[i]=pwdata[i]; dataext[i]=pwdataext[i]; } }//PWD flag } else {// adj flag /*^^^*/ // read data currently 2D sf_floatread(data,nt*nx,inp); // read extended data - zero PWD over reflection sf_floatread(dataext,nt*nx,inp); // since adj PWD applied to zero is zero // lets just put zeroes in the correspoding part of the output /*for (i1=0;i1<nt*nx;i1++) { dataext[i1]=0.0; }*/ }// adj flag // t2warping axis evaluation ot2 = ot*ot; dt2 = ot+(nt-1)*dt; dt2 = (dt2*dt2 - ot2)/(nt2-1); // take in account different output trace length t2warp_init(nt,nt2,nx,ot,dt,ot2,dt2,epst2); sf_warning("t2warp_init(nt,nt2,nx,ot,dt,ot2,dt2,epst2);\n"); // compute pi filter sf_warning("be4 filter"); flatpifilt_init(nt2, nx, dt2, dx, 0.001, v_1, v_2, v_3, v_4, eps); sf_warning("after filter"); sf_warning("pifilt_init(nt2, nx, dt2, dx, v_a, v_b, v_0, beta, eps);\n"); if(adj) { sf_warning("be4 the chain: params %d %d %d %d",nt*nx,nt2*nx,nt2*nx,nt*nx); sf_chain3(t2warp_inv,freqfilt4pi_lop,t2warp,adj,false,nt*nx,nt2*nx,nt2*nx,nt*nx,output,data,outputt2,datat2); //sf_chain3(t2warp_inv,freqfilt4pi_lop,t2warp,adj,false,nt*nx,nt2*nx,nt2*nx,nt*nx,outputext,data,outputt2,datat2); sf_warning("running chain"); } else { sf_chain3(t2warp_inv,freqfilt4pi_lop,t2warp,false,false,nt*nx,nt2*nx,nt2*nx,nt*nx,data,output,datat2,outputt2); sf_chain3(t2warp_inv,freqfilt4pi_lop,t2warp,false,false,nt*nx,nt2*nx,nt2*nx,nt*nx,dataext,outputext,datat2,outputt2); } if(adj) { if (sm){ sf_warning("performing PWD"); //^^^^^ allpass32d_lop(adj,false,nt*nx,nt*nx,pwdata,output); //allpass32d_lop(adj,false,nt*nx,nt*nx,pwdataext,outputext); //change the address for (i=0;i<nt*nx;i++){ output[i]=pwdata[i]; //outputext[i]=pwdataext[i]; } } if (domod) { sf_warning("performing Kirchhoff migration"); //^^^^^ mig2_lop(true,half,verb,normalize,nt,nx,nh,fold,apt,output,v,rho,model,off,h0,dh,dx,ot,dt,aal,angle); //mig2_lop(true,half,verb,normalize,nt,nx,nh,fold,apt,outputext,v,rho,modelext,off,h0,dh,dx,ot,dt,aal,angle); } else { sf_warning("changing the address"); //change the address for (i=0;i<nt*nx;i++){ model[i]=output[i]; } } } // adj flag sf_warning("done with output"); if (sm){ // pp = sf_floatalloc(nt*nx); //allocate space for dip sf_floatread(pp,nt*nx,dipim); //read dipim // we need to re-initialize allpass filter // so that it operates in the image domain allpass32d_init(allpass_init(nw, nj1, nt,nx,1, pp)); //initialize all-pass-filter structure // all other parameters are supposed to be initialized previously if(!adj) { // perform adj pwd in the image domain on the model and diffraction model allpass32d_lop(adj,false,nt*nx,nt*nx,model,pwdmodel); for(j=0;j<nx*nt;j++){ output[j] = output[j] + outputext[j]; outputext[j] = reg*pwdmodel[j]; } } else { allpass32d_lop(adj,false,nt*nx,nt*nx,pwdmodelext,dataext); for(j=0;j<nx*nt;j++){ modelext[j] = model[j]; model[j] = model[j] + reg*pwdmodelext[j]; }//for } } if (!adj) { // write sf_floatwrite(output,nt*nx,out); // write extended output sf_floatwrite(outputext,nt*nx,out); } else { // write sf_floatwrite(model,nt*nx,out); // equivalent to setting reflection component to zero sf_floatwrite(modelext,nt*nx,out); } exit(0); }
int main (int argc, char *argv[]) { bool left; int ir, nr, n1,n2,n3, m1, m2, m3, n12, nw, nj1, nj2, i3; float *u1, *u2, *p; sf_file in, out, dip; allpass ap; sf_init(argc,argv); in = sf_input ("in"); dip = sf_input ("dip"); out = sf_output ("out"); if (SF_FLOAT != sf_gettype(in) || SF_FLOAT != sf_gettype(dip)) sf_error("Need float type"); if (!sf_histint(in,"n1",&n1)) sf_error("Need n1= in input"); if (!sf_histint(in,"n2",&n2)) n2=1; if (!sf_histint(in,"n3",&n3)) n3=1; n12 = n1*n2; nr = sf_leftsize(in,3); if (!sf_getbool("left",&left)) left=true; /* if using left or right side of PWD */ if (!sf_histint(dip,"n1",&m1) || m1 != n1) sf_error("Need n1=%d in dip",n1); if (1 != n2 && (!sf_histint(dip,"n2",&m2) || m2 != n2)) sf_error("Need n2=%d in dip",n2); if (1 != n3 && (!sf_histint(dip,"n3",&m3) || m3 != n3)) sf_error("Need n3=%d in dip",n3); if (!sf_getint("order",&nw)) nw=1; /* accuracy */ if (!sf_getint("nj1",&nj1)) nj1=1; /* in-line aliasing */ if (!sf_getint("nj2",&nj2)) nj2=1; /* cross-line aliasing */ for (ir=0; ir < nr; ir++) { u1 = sf_floatalloc(n12); u2 = sf_floatalloc(n12); p = sf_floatalloc(n12); for (i3=0; i3 < n3; i3++) { /* read data */ sf_floatread(u1,n12,in); /* read t-x dip */ sf_floatread(p,n12,dip); ap = allpass_init (nw,nj1,n1,n2,1,p); /* apply */ if (left) { left1(false, false, ap, u1, u2); } else { right1(false, false, ap, u1, u2); } /* write t-x destruction */ sf_floatwrite(u2,n12,out); } free(u1); free(u2); free(p); } exit (0); }