示例#1
0
文件: fixbad.c 项目: 1014511134/src
void fixbad (int niter    /* number of iterations */, 
	     sf_filter aa /* PEF */, 
	     int ny       /* data size */,
	     float *yy    /* in - data, out - deburst */) 
/*< find bad data and restore it >*/
{
    int iy;
    float *rr, *rabs, rbar;
    bool *known;

    rr = sf_floatalloc(ny);
    rabs = sf_floatalloc(ny);
    known = sf_boolalloc(ny);

    sf_helicon_init(aa);
    sf_helicon_lop (false,false,ny,ny,yy,rr); 
    for (iy=0; iy < ny; iy++) 
	rabs[iy] = fabsf (rr[iy]);
    rbar = sf_quantile(ny/2,ny,rabs);
    for (iy=0; iy < ny; iy++) 
	known[iy] = (bool) ((yy[iy] > 0.) && (fabsf(rr[iy]) < 4. * rbar));
    mis2 (niter, ny, yy, aa, known, 0., true);

    free(rr);
    free(rabs);
    free(known);
}
示例#2
0
文件: mis2.c 项目: 1014511134/src
void mis2(int niter         /* number of iterations */, 
	  int nx            /* model size */, 
	  float *xx         /* model */, 
	  sf_filter aa      /* helix filter */, 
	  const bool *known /* mask for known data */,
	  float eps         /* regularization parameter */,
	  bool doprec       /* to apply preconditioning */) 
/*< interpolate >*/
{
    int ix;
    float *dd;

    if (doprec) {                          /*  preconditioned */
	sf_mask_init(known);
	sf_polydiv_init(nx, aa);
	sf_solver_prec(sf_mask_lop, sf_cgstep, sf_polydiv_lop, 
		       nx, nx, nx, xx, xx, niter, eps, "end");
	sf_polydiv_close();
    } else {                               /*  regularized */
	dd = sf_floatalloc(nx);
	for (ix=0; ix < nx; ix++) {
	    dd[ix]=0.;
	}

	sf_helicon_init(aa);
	sf_solver (sf_helicon_lop, sf_cgstep, nx, nx, xx, dd, niter, 
		   "known", known, "x0", xx, "end");
	free(dd);
    }
    sf_cgstep_close();
}
示例#3
0
文件: wilson2.c 项目: 1014511134/src
float wilson2_factor(int niter   /* number of iterations */, 
		    float s0     /* zero-lag auto-correlation */, 
		    sf_filter ss /* input auto-correlation */, 
		    float a0     /* zero-lag filter */,
		    sf_filter aa /* output factor */, 
		    bool verb    /* verbosity flag */,
		    float tol    /* tolerance */)
/*< Factor >*/ 
{
    float g0, *gg;
    int i, iter;
    
    for(i=0; i < n2; i++) {
	au[i] = 0.;
    }

    sf_helicon_init( aa);                      /* multiply polynoms */
    sf_polydiv_init( n2, aa);                  /* divide   polynoms */

    au[n-1] = -a0*a0;
    sf_helicon_lop(false, false, n2, n2, au, bb);
    sf_helicon_lop(true,  false, n2, n2, au, bb);

    au[n-1] += s0;		     
    for(i=0; i < ss->nh; i++) {  /* symmetrize input auto */
	au[n-1+ss->lag[i]] +=  ss->flt[i];        
	au[n-1-ss->lag[i]] +=  ss->flt[i];
    }                   

    g0 = a0;
    gg = sf_floatalloc(aa->nh);
    for(i=0; i < aa->nh; i++) {
	gg[i] = aa->flt[i];
    }

    for(iter=0; iter < niter; iter++) {
	sf_polydiv_lop(false,false, n2, n2, au, bb);  /* bb = S/A */
	sf_polydiv_lop(true, false, n2, n2, cc, bb);  /* cc = S/(AA') */

	/* b = plusside(cc) */
	for(i=0; i < n; i++) {      
	    b[i] = 0.5*(cc[n-1+i] + cc[n-1-i])/a0; 
	}

	sf_helicon_lop( false, false, n, n, b, c);   /* c = A b */
	
	a0 = 2.*(c[0]+g0);      
	for(i=0; i < aa->nh; i++) {              /* put on helix */
	    aa->flt[i] = 2.*(c[aa->lag[i]]+gg[i])/a0;
	}                
    } 
    
    a0 -= g0;
    for(i=0; i < aa->nh; i++) { 
	aa->flt[i] = ((a0+g0)*aa->flt[i]-gg[i])/a0;
    }

    return a0;
}
示例#4
0
文件: signoi.c 项目: housian0724/src
void signoi2_lop (bool adj, bool add, int n1, int n2, 
		 float *data, float *sign)
/*< alternative linear operator >*/
{
    helicon2_init (nd, nn);
    sf_helicon_init (ss); 

    sf_adjnull(adj,add,n1,n2,data,sign);

    helicon2_lop (false, false, n1, n1, data, dd);
    sf_solver_reg(helicon2_lop, sf_cgstep, sf_helicon_lop, 
		  nd, nd, nd, sign, dd, niter, eps, 
		  "verb", verb, "end");
    sf_cgstep_close();

    nn++;
    ss++;
}
示例#5
0
文件: signoi.c 项目: housian0724/src
void signoi_lop (bool adj, bool add, int n1, int n2, 
		 float *data, float *sign)
/*< linear operator >*/
{
    sf_helicon_init (nn);
    sf_polydiv_init (nd, ss); 

    sf_adjnull(adj,add,n1,n2,data,sign);

    sf_helicon_lop (false, false, n1, n1, data, dd);
    sf_solver_prec(sf_helicon_lop, sf_cgstep, sf_polydiv_lop, 
		   nd, nd, nd, sign, dd, niter, eps, 
		   "verb", verb, "end");
    sf_cgstep_close();

    nn++;
    ss++;
}
示例#6
0
void sf_multidivn_init(int nw       /* number of components */, 
		       int ndim     /* number of dimensions */, 
		       int n        /* data size */, 
		       int *ndat    /* data dimensions [ndim] */, 
		       int *nbox    /* smoothing radius [ndim] */,
		       float* den   /* denominator [nw*nd] */,
		       sf_filter aa /* data filter */,
		       bool verb    /* verbosity flag */)
/*< initialize >*/
{
    int n2;

    n2 = n*nw;
    
    sf_trianglen_init(ndim, nbox, ndat);
    sf_repeat_init(n,nw,sf_trianglen_lop);

    sf_conjgrad_init(n2, n2, n, n, 1., 1.e-6, verb, false);
    p = sf_floatalloc (n2);
    sf_weight2_init(nw,n,den);

    prec = (bool) (NULL != aa);
    if (prec) sf_helicon_init(aa);
}
示例#7
0
int main(int argc, char* argv[])
{
    int n[2], w[2], k[2], a[2], l[2], n12, w12, i;
    float *wall, *data, *windwt;
    sf_filter aa;
    sf_file wind, out;

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

    sf_setformat(out,"native_float");

    if (!sf_getint("n1",&n[0])) n[0] = 100;
    if (!sf_getint("n2",&n[1])) n[1] = 30;

    sf_putint(out,"n1",n[0]);
    sf_putint(out,"n2",n[1]);

    if (!sf_getint("w1",&w[0])) w[0] = 17;
    if (!sf_getint("w2",&w[1])) w[1] = 6;

    if (!sf_getint("k1",&k[0])) k[0] = 5;
    if (!sf_getint("k2",&k[1])) k[1] = 11;

    if (!sf_getint("a1",&a[0])) a[0] = 1;
    if (!sf_getint("a2",&a[1])) a[1] = 1;

    if (!sf_getint("lag1",&l[0])) l[0] = 1;
    if (!sf_getint("lag2",&l[1])) l[1] = 1;

    n12 = n[0]*n[1];
    w12 = w[0]*w[1];

    wall = sf_floatalloc(n12);
    data = sf_floatalloc(n12);
    windwt = sf_floatalloc(w12);

    for (i=0; i < n12; i++) {
        wall[i] = 1.;
    }

    aa = sf_allocatehelix (1);
    aa->lag[0] = 1;

    tent (2, w, l, a, windwt);

    if (NULL != sf_getstring("wind")) {
        /* optional output file for window weight */
        wind = sf_output("wind");
        sf_setformat(wind,"native_float");
        sf_putint(wind,"n1",w[0]);
        sf_putint(wind,"n2",w[1]);

        sf_floatwrite (windwt,w12,wind);
        sf_fileclose(wind);
    }

    sf_helicon_init (aa);
    patching (sf_helicon_lop, wall, data, 2, k, n, w, windwt);

    for (i=0; i < n12; i+= n[0]) {
        data[i] = 0.;
    }
    for (i=1; i < n12; i+= n[0]) {
        data[i] = 0.;
    }
    for (i=n[0]-2; i < n12; i+= n[0]) {
        data[i] = 0.;
    }
    for (i=n[0]-1; i < n12; i+= n[0]) {
        data[i] = 0.;
    }

    sf_floatwrite(data,n12,out);


    exit (0);
}