Esempio n. 1
0
/*------------------------------------------------------------*/
void slant_init (bool pull1                     /* pull or push mode */, 
		 bool rho1                      /* use rho filter */,
		 float x01, float dx1, int nx1  /* offset axis */, 
		 float s01, float ds1, int ns1  /* slowness axis */, 
		 float t01, float dt1, int nt1  /* time axis */, 
		 float s11                      /* reference slowness */, 
		 float anti1                    /* antialiasing */) 
/*< initialize >*/
{
    pull = pull1;
    rho = rho1;

    x0 = x01; dx = dx1; nx = nx1;
    s0 = s01; ds = ds1; ns = ns1;
    t0 = t01; dt = dt1; nt = nt1; 
    s1 = s11; 

    sf_aastretch_init (false, nt, t0, dt, nt);
    if (rho) {
	sf_halfint_init (true,2*nt,1.-1./nt);
	tmp  = sf_floatalloc(nt);
    }

    amp  = sf_floatalloc(nt);
    str  = sf_floatalloc(nt);
    tx   = sf_floatalloc(nt);
}
Esempio n. 2
0
int main(int argc, char* argv[])
{
    bool adj, inv;
    int nn,n1,n2,i1,i2;
    float rho, *pp=NULL;
    sf_file in=NULL, out=NULL;

    sf_init(argc,argv);
    in = sf_input("in");
    out = sf_output("out");

    if (!sf_histint(in,"n1",&n1)) sf_error("No n1= in input");
    n2 = sf_leftsize(in,1);

    if (!sf_getbool("adj",&adj)) adj=false;
    /* If y, apply adjoint */
    if (!sf_getbool("inv",&inv)) inv=false;
    /* If y, do differentiation instead of integration */
    if (!sf_getfloat("rho",&rho)) rho = 1.-1./n1;
    /* Leaky integration constant */

    if (inv) {
	sf_warning("%s half-order differentiation",adj? "anticausal":"causal");
    } else {
	sf_warning("%s half-order integration",adj? "anticausal":"causal");
    }

    nn = 2*kiss_fft_next_fast_size((n1+1)/2);
    pp = sf_floatalloc(nn);

    sf_halfint_init (inv, nn, rho);

    for (i2=0; i2 < n2; i2++) {
	sf_floatread (pp,n1,in);
	for (i1=n1; i1 < nn; i1++) {
	    pp[i1]=0.;
	}
	sf_halfint (adj, pp);
	sf_floatwrite (pp,n1,out);
    }

    exit(0);
}
Esempio n. 3
0
void ditime3d_init (float dipo,   float dipd,   int dipn,   // x-dip angle axis 
					float sdipo,  float sdipd,  int sdipn,  // y-dip angle axis 
				    float xio,    float xid,    int xin,    // xi axis in x-direction
				    float sxio,   float sxid,   int sxin,   // xi axis in y-direction
				    float dip0o,  float dip0d,  int dip0n,  // x-refl dip axis
				    float sdip0o, float sdip0d, int sdip0n, // y-refl dip axis
				    float to,     float td,     int tn,     // time axis 
				    bool isAA,                              // antialiasing
				    int invMod) 						 
/*< initialize >*/
{
    int reflSize, diffSize;
    float CONVPARAM;
    float *pTableR, *pTableD;
    int id, ixi, id0, it, sid, sixi, sid0;
    float curDip, a, tan_a, tan_sa, curXi, scurXi, aux_diff, curTime, a0, sa0, tan_a0, tan_sa0, aux_refl, sa;
	float curDip0, scurDip, scurDip0;

	float k2, ke, k0, k1, kM;

    to_   = to;   td_   = td;   tn_   = tn;  

    dipo_ = dipo; dipd_ = dipd; dipn_ = dipn;  
    sdipo_ = sdipo; sdipd_ = sdipd; sdipn_ = sdipn;  

    dip0o_ = dip0o; dip0d_ = dip0d; dip0n_ = dip0n;  
    sdip0o_ = sdip0o; sdip0d_ = sdip0d; sdip0n_ = sdip0n;  
    xio_  = xio; xid_  = xid;  xin_  = xin;  
    sxio_ = sxio; sxid_ = sxid; sxin_ = sxin;  

    tLim_ = to_ + td_ * (tn_ - 1);

    invMod_ = invMod;
    isAA_   = isAA;

    if (isAA_) {
		sf_aastretch_init  (false, tn_, to_, td_, tn_);
		sf_halfint_init (true, 2 * tn_, 1.f - 1.f / tn_);
    } else {
		stretch_init  (tn_, to_, td_, tn_);
	}

	amp = sf_floatalloc (tn_);
    str = sf_floatalloc (tn_);
    tx  = sf_floatalloc (tn_);
    tmp = sf_floatalloc (tn_);

    // shift tables
    reflSize = tn_ * dip0n_ * sdip0n_ * dipn_ * sdipn_;
    diffSize = tn_ * xin_ * dipn_ * sxin_ * sdipn_;

    tableRefl_ = sf_floatalloc (reflSize);
    tableDiff_ = sf_floatalloc (diffSize);
	
    CONVPARAM = SF_PI / 180.f;

    pTableR = tableRefl_;
    pTableD = tableDiff_;

    for (sid = 0; sid < sdipn_; ++sid) { 
		scurDip = sdipo_ + sid * sdipd_;
		sa      = scurDip * CONVPARAM;
		tan_sa  = tan (sa);
	    for (id = 0; id < dipn_; ++id) { 
			curDip = dipo_ + id * dipd_;
			a      = curDip * CONVPARAM;
			tan_a  = tan (a);
	
			// diffraction part
			for (sixi = 0; sixi < sxin_; ++sixi) { 
			    scurXi = sxio_ + sixi * sxid_;
				for (ixi = 0; ixi < xin_; ++ixi) { 
				    curXi = xio_ + ixi * xid_;

					k2 = scurXi * tan_sa + curXi * tan_a;
					ke = scurXi*scurXi + curXi*curXi + 1.f;
	
				    aux_diff = k2 + sqrt (k2 * k2 + ke);
	
				    for (it = 0; it < tn_; ++it, ++pTableD) { 
						curTime = to_ + it * td_;
						*pTableD = curTime * aux_diff;			    
				    }
				}
			}		
				
			// reflection part
			for (sid0 = 0; sid0 < sdip0n_; ++sid0) { 
			    scurDip0 = sdip0o_ + sid0 * sdip0d_;
			    sa0 = scurDip0 * CONVPARAM;
			    tan_sa0 = tan (sa0);	

				k0 = sqrt (1.f + tan_a0*tan_a0 + tan_sa0*tan_sa0);

				for (id0 = 0; id0 < dip0n_; ++id0) { 
				    curDip0 = dip0o_ + id0 * dip0d_;
				    a0 = curDip0 * CONVPARAM;
				    tan_a0 = tan (a0);	
	
					kM = sqrt (1.f + tan_a*tan_a + tan_sa*tan_sa);
					k1 = tan_sa0*tan_sa + tan_a0*tan_a;
			
				    aux_refl = 1.f / (k0 * kM - k1);
		
				    for (it = 0; it < tn_; ++it, ++pTableR) {		
						curTime = to_ + it * td_;
						*pTableR = curTime * aux_refl;		
				    }
				}	
	    	}	

		}
	}

    return;
}
Esempio n. 4
0
File: Mmig2.c Progetto: Seislet/src
int main(int argc, char* argv[])
{
    bool adj, half, verb, normalize;
    int nt, nx, nh, nh2, ix, ih, iy, i, nn, it, **fold, apt;
    float *trace, **image, **v, rho, **stack, *pp, *off;
    float h, x, t, h0, dh, dx, ti, tx, t0, t1, t2, dt, vi, aal, angle;
    sf_file inp, out, vel, gather, offset;

    sf_init (argc,argv);
    inp = sf_input("in");
    vel = sf_input("vel");  
    out = sf_output("out");
       
    if (!sf_getbool("adj",&adj)) adj=true;
    /* adjoint flag (y for migration, n for modeling) */

    if (!sf_getbool("normalize",&normalize)) normalize=true;
    /* normalize for the fold */
 

    if (!sf_histint(inp,"n1",&nt)) sf_error("No n1=");
    if (!sf_histint(inp,"n2",&nx)) sf_error("No n2=");

    if (!sf_histfloat(inp,"o1",&t0)) sf_error("No o1=");
    if (!sf_histfloat(inp,"d1",&dt)) sf_error("No d1=");
    if (!sf_histfloat(inp,"d2",&dx)) sf_error("No d2=");

    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;
    }

    v = sf_floatalloc2(nt,nx);
    sf_floatread(v[0],nt*nx,vel);

    trace = sf_floatalloc(nt);
    image = sf_floatalloc2(nt,nx);
    stack = sf_floatalloc2(nt,nx);

    if (normalize) {
	fold = sf_intalloc2(nt,nx);
    } else {
	fold = NULL;
    }

    nn = 2*kiss_fft_next_fast_size((nt+1)/2);
    pp = sf_floatalloc(nn);

    sf_halfint_init (true, nn, rho);

    if (adj) {
	for (i=0; i < nt*nx; i++) {
	    stack[0][i] = 0.;  
	}
    } else {
	sf_floatread(stack[0],nt*nx,inp); 
    }

    if (NULL != fold) {
	for (i=0; i < nt*nx; i++) {
	    fold[0][i] = 0;  
	}
    }

    for (ih=0; ih < nh; ih++) {
        if (verb) sf_warning("offset %d of %d;",ih+1,nh);

	if (adj) {
	    for (i=0; i < nt*nx; i++) {
		image[0][i] = 0.;
	    }
	} else {
	    for (iy=0; iy < nx; iy++) {
		for (it=0; it < nt; it++) {
		    image[iy][it] = stack[iy][it];
		}
	    }
	}

	if (!adj) {
	    for (iy=0; iy < nx; iy++) {
		for (it=0; it < nt; it++) {
		    pp[it] = image[iy][it];
		}
		for (it=nt; it < nn; it++) {
		    pp[it] = 0.;
		}
		sf_halfint (false, pp);
		for (it=0; it < nt; it++) {
		    image[iy][it] = pp[it];
		}
	    }
	}

	for (iy=0; iy < nx; iy++) { 
	    if (adj) {
		sf_floatread (trace,nt,inp);
		sf_doubint(true, nt,trace);
	    } else {
		for (it=0; it < nt; it++) {
		    trace[it]=0.0f;
		}
	    }

	    h = fabsf(off[ih*nx+iy]);

	    for (ix=0; ix < nx; ix++) { 
	        x = (ix-iy)*dx;
		if (SF_ABS(ix-iy) > apt) continue;

		for (it=0; it < nt; it++) {
		    t = t0 + it*dt;  
		    vi = v[ix][it];

		    if (fabsf(x) > angle*vi*t) continue;

		    /* hypot(a,b) = sqrt(a*a+b*b) */
		    t1 = hypotf(0.5*t,(x-h)/vi);
		    t2 = hypotf(0.5*t,(x+h)/vi);
		    ti = t1+t2;

		    /* tx = |dt/dx| */
		    tx = fabsf(x-h)/(vi*vi*(t1+dt))+
		         fabsf(x+h)/(vi*vi*(t2+dt));

		    pick(adj,ti,fabsf(tx*dx*aal),trace,image[ix],it,nt,dt,t0);
		} 
	    } 

	    if (!adj) {
		sf_doubint(true, nt,trace);
		sf_floatwrite (trace,nt,out);
	    }
	} 

	if (adj) {
	    for (iy=0; iy < nx; iy++) {
		for (it=0; it < nt; it++) {
		    pp[it] = image[iy][it];
		}
		for (it=nt; it < nn; it++) {
		    pp[it] = 0.;
		}
		sf_halfint (true, pp);
		for (it=0; it < nt; it++) {
		    image[iy][it] = pp[it];
		}
	    }

	    if (NULL != gather) sf_floatwrite(image[0],nt*nx,gather);

	    for (iy=0; iy < nx; iy++) {
		for (it=0; it < nt; it++) {
		    stack[iy][it] += image[iy][it];
		    if (NULL != fold && 0.!=image[iy][it]) fold[iy][it]++; 
		}
	    }
	}
    }
    if (verb) sf_warning(".");

    if (NULL != fold) {
	for (i=0; i < nt*nx; i++) {
	    stack[0][i] /= (fold[0][i]+FLT_EPSILON);  
	}
    }
    
    if (adj) sf_floatwrite(stack[0],nt*nx,out); 

    exit(0);
}
Esempio n. 5
0
int main(int argc, char* argv[])
{
    sf_map4 map;
    int it,nt, ix,nx, ip,np, i3,n3;
    bool adj;
    float t0,dt,t, x0,dx,x, p0,dp,p;
    float **cmp, **rad, *trace;
    sf_file in, out;

    sf_init(argc,argv);
    in = sf_input("in");
    out = sf_output("out");

    if (!sf_histint(in,"n1",&nt)) sf_error("No n1=");
    if (!sf_histfloat(in,"o1",&t0)) sf_error("No o1=");
    if (!sf_histfloat(in,"d1",&dt)) sf_error("No d1=");

    n3 = sf_leftsize(in,2);

    if (!sf_getbool("adj",&adj)) adj=false;
    /* adjoint flag */

    if (adj) {
	if (!sf_histint(in,"n2",&nx))   sf_error("No n2=");
	if (!sf_histfloat(in,"o2",&x0)) sf_error("No o2=");
	if (!sf_histfloat(in,"d2",&dx)) sf_error("No d2=");

	if (!sf_getint("np",&np)) sf_error("Need np=");
	if (!sf_getfloat("op",&p0)) sf_error("need p0=");
	if (!sf_getfloat("dp",&dp)) sf_error("need dp=");

	sf_putint(out,"n2",np);
	sf_putfloat(out,"o2",p0);
	sf_putfloat(out,"d2",dp);	
    } else {
	if (!sf_histint(in,"n2",&np))   sf_error("No n2=");
	if (!sf_histfloat(in,"o2",&p0)) sf_error("No o2=");
	if (!sf_histfloat(in,"d2",&dp)) sf_error("No d2=");

	if (!sf_getint("nx",&nx)) sf_error("Need nx=");
	if (!sf_getfloat("ox",&x0)) sf_error("need x0=");
	if (!sf_getfloat("dx",&dx)) sf_error("need dx=");

	sf_putint(out,"n2",nx);
	sf_putfloat(out,"o2",x0);
	sf_putfloat(out,"d2",dx);
    }

    trace = sf_floatalloc(nt);
    cmp = sf_floatalloc2(nt,nx);
    rad = sf_floatalloc2(nt,np);

    /* initialize half-order differentiation */
    sf_halfint_init (true,nt,1.0f-1.0f/nt);

    /* initialize spline interpolation */
    map = sf_stretch4_init (nt, t0, dt, nt, 0.01);
    
    for (i3=0; i3 < n3; i3++) { 
	if( adj) {
	    for (ix=0; ix < nx; ix++) { 
		sf_floatread(trace,nt,in);
		sf_halfint_lop(true,false,nt,nt,cmp[ix],trace);
	    }
	} else {	    
	    sf_floatread(rad[0],nt*np,in);	    
	}

	sf_adjnull(adj,false,nt*np,nt*nx,rad[0],cmp[0]);
	
	for (ip=0; ip < np; ip++) { 
	    p = p0 + ip*dp;
	    for (ix=0; ix < nx; ix++) { 
		x = x0 + ix*dx;
		
		for (it=0; it < nt; it++) {		
		    t = t0 + it*dt;
		    trace[it] = hypotf(t,p*x);
                    /* hypot(a,b)=sqrt(a*a+b*b) */
		}

		sf_stretch4_define(map,trace);
		
		if (adj) {
		    sf_stretch4_apply_adj(true,map,rad[ip],cmp[ix]);
		} else {
		    sf_stretch4_apply    (true,map,rad[ip],cmp[ix]);
		}
	    }
	}

	if( adj) {
	    sf_floatwrite(rad[0],nt*np,out);
	} else {
	    for (ix=0; ix < nx; ix++) {
		sf_halfint_lop(false,false,nt,nt,cmp[ix],trace);
		sf_floatwrite(trace,nt,out);
	    }
	}
    }

    exit(0);
}
Esempio n. 6
0
int main (int argc, char* argv[]) {
    int i, j, n, nn, nt;
    float *trace;
    sf_file data, out;

    bool absoff, filter, kmah, diff, verb;

    sf_init (argc, argv);

    data = sf_input ("in");
    /* Common-shot 2-D data */
    out = sf_output ("out");

    if (!sf_getbool ("verb", &verb)) verb = false;
    /* verbosity flag */

    if (!sf_getbool ("absoff", &absoff)) absoff = false;
    /* y - absolute offset (default - relative to shot axis) */
    if (!sf_getbool ("filter", &filter)) filter = true;
    /* y - antialiasing filter for data */
    if (!sf_getbool ("KMAH", &kmah)) kmah = true;
    /* y - account for phase shifts due to KMAH index */
    if (!sf_getbool ("diff", &diff)) diff = true;
    /* y - apply half-order differentiation */

    /* Data dimensions */
    if (!sf_histint (data, "n1", &nt)) sf_error ("No n1= in data");
    n = sf_leftsize (data, 1);

    /* Next suitable size for the differentiator */
    nn = 2*kiss_fft_next_fast_size ((nt + 1)/2);
    trace = sf_floatalloc (nn*2);

    if (kmah) { /* Make room for phase-shifted traces */
        sf_shiftdim (data, out, 2);
        sf_putint (out, "n2", 2);
        sf_putfloat (out, "o2", 0.0);
        sf_putfloat (out, "d2", 1.0);
        sf_putstring (out, "label1", "");
        sf_putstring (out, "unit1", "");
    }
    sf_putstring (out, "absoff", absoff ? "y" : "n");
    sf_putstring (out, "filter", filter ? "y" : "n");
    sf_putstring (out, "KMAH", kmah ? "y" : "n");

    /* Half-order differentiation object */
    if (diff)
        sf_halfint_init (true, nn, 1.-1./nt);

    for (i = 0; i < n; i++) { /* Loop over traces */
        if (verb && !(i % 10000LU))
            sf_warning ("Processing trace %lu of %lu (%g %%);",
                        i + 1LU, n, 100.0*(float)i/(float)n);
        sf_floatread (trace, nt, data);
        for (j = nt; j < nn; j++) {
            trace[j] = 0.;
        }
        /* Differentiate */
        if (diff)
            sf_halfint (true, trace);
        /* pi/2 phase shift */
        if (kmah)
            sf_cram_trace_hilbert (nt, trace, &trace[nn]);
        /* Causal and anti-causal integration for anti-aliasing filter */
        if (filter) {
            sf_cram_trace_cint (trace, nt);
            sf_cram_trace_acint (trace, nt);
            if (kmah) {
                sf_cram_trace_cint (&trace[nn], nt);
                sf_cram_trace_acint (&trace[nn], nt);
            }
        }
        sf_floatwrite (trace, nt, out);
        if (kmah)
            sf_floatwrite (&trace[nn], nt, out);
    }
    if (verb)
        sf_warning (".");

    free (trace);

    return 0;
}