Exemple #1
0
pulsesequence()
{   
   int	phase1 = (int)(getval("phase")+0.5),
  	prgcycle=(int)(getval("prgcycle")+0.5);


  assign(ct,v17);
  assign(zero,v18);
  assign(zero,v19);

  if (getflag("prgflg") && (satmode[0] == 'y') && (prgcycle > 1.5))
    {
        hlv(ct,v17);
        mod2(ct,v18); dbl(v18,v18);
        if (prgcycle > 2.5)
           {
                hlv(v17,v17);
                hlv(ct,v19); mod2(v19,v19); dbl(v19,v19);
           }
     }

/* CONSTANTS FOR PHASE CALCULATIONS */
    initval( 8.0,v13);
    initval( 32.0,v12);
    initval( 20.0,v11);
    initval( 192.0,v10);

/* CALCULATE PHASECYCLE */
   assign(zero,v14);	/* phase of first pulse */
   mod2(v17,v1);
   dbl(v1,v1);		/* 0202 */
			/* even/odd flag */
   hlv(v17,v2);
   hlv(v2,v3);
   dbl(v3,v3);		/* 0000222244446666 */
			/* phase for transients 3 + 4*n */
			/* 1+4*n = 0 */
   mod2(v2,v2);		/* 0011 */
			/* switch for pairs */
   assign(v13,v4);	/* 8 */
   ifzero(v2);
      incr(v4);
   elsenz(v2);
      decr(v4);
   endif(v2);
   modn(v4,v13,v4);	/* 1177 */
			/* standard phases for even transients */
			/*      1 for 2+4*n, 7 for 4*n         */
   hlv(v13,v8);		/* 4 */
   add(v17,v8,v5);	/* (ct+4) */
   divn(v5,v12,v5);	/* (ct+4)/32 */
   divn(v17,v12,v6);	/* ct/32 */
   sub(v5,v6,v5);	/* ((ct+4)/32-ct/32 */
			/* 00000000 00000000 00000000 00001111 */
   add(v17,v11,v6);	/* (ct+20) */
   divn(v6,v10,v6);	/* (ct+20)/192 */
   sub(v11,v7,v7);	/* 16 */
   add(v17,v7,v7);	/* (ct+16) */
   divn(v7,v10,v7);	/* (ct+16)/192 */
   add(v5,v6,v5);
   sub(v5,v7,v5);	/* ((ct+4)/32-ct/32)+((ct+20)/192-(ct+16)/192) */
                        /* flag for exceptions on even transients */
   dbl(v2,v6);		/* 0022 */
   add(v6,three,v6);	/* 3355 */
   ifzero(v1);		/* for odd transients */
      ifzero(v2);       /* 1+4n:                             */
         assign(zero,v3);             /* 0xxx 0xxx 0xxx 0xxx */
      endif(v2);        /* 3+4n:         xx0x xx2x xx4x xx6x */
   elsenz(v1);		/* for even transients */
      ifzero(v5);	/* normal case:        */
         assign(v4,v3); /*                x1x7 */
      elsenz(v5);	/* exceptions:         */
         assign(v6,v3); /*                x3x5 */
      endif(v5);	/* v3 = phase of first and second pulse */
			/*      in 45 degrees steps:            */
                        /* 01070127 01470167 01070127 01470365  */
                        /* 01070127 01470167 01070127 01470365  */
                        /* 01070127 01470167 01070127 01470365  */
                        /* 01070127 01470167 01070127 01470365  */
                        /* 01070127 01470167 01070127 01470365  */
                        /* 01070127 01470365 01070127 01470365  */
   endif(v1);
   assign(two,v4);	/* v4 = phase of last 90 degrees pulse */
   assign(v1,oph);	/* oph = 0202 */

   assign(zero,v20);
  if (getflag("prgflg") && (satmode[0] == 'y'))
        assign(v14,v20);
  add(oph,v18,oph);
  add(oph,v19,oph);

   if (phase1 == 2) 
	incr(v14); /* States - Habercorn */

/*
      mod2(id2,v9);
      dbl(v9,v9);
*/
	initval(2.0*(double)(((int)(d2*getval("sw1")+0.5)%2)),v9);

      add(v14,v9,v14);
      add(oph,v9,oph);
 
/* BEGIN ACTUAL PULSE SEQUENCE CODE */
   status(A);

   obsstepsize(45.0);
   delay(5.0e-5);
   if (getflag("sspul"))
        steadystate();

   if (satmode[0] == 'y')
     {
        if ((d1-satdly) > 0.02)
                delay(d1-satdly);
        else
                delay(0.02);
        if (getflag("slpsat"))
           {
		if (getflag("prgflg"))
			xmtrphase(v3);
                shaped_satpulse("relaxD",satdly,v20);
                if (getflag("prgflg"))
		{
                   shaped_purge(v14,v20,v18,v19);
		   xmtrphase(zero);
		}
           }
        else
           {
                if (getflag("prgflg"))
			xmtrphase(v3);
                satpulse(satdly,v20,rof1,rof1);
                if (getflag("prgflg"))
		{
                   purge(v14,v20,v18,v19);
		   xmtrphase(zero);
		}
           }
     }
   else
        delay(d1);

   if (getflag("wet"))
     wet4(zero,one);

   status(B);
      xmtrphase(v3);
      rgpulse(pw, v14, rof1, 2.0e-6);
      if (d2 > 0.0)
         delay(d2 - (4.0*pw/PI) - 4.0e-6);
      else
	delay(d2);
      rgpulse(pw, zero, 2.0e-6, rof1);
      xmtrphase(zero);
      rgpulse(pw, v4, rof1, rof2);
   status(C);
} 
Exemple #2
0
void fbdip(int n3, int n4, float ****in, float **dip, int nit, float eta)
/*< omnidirectional dip estimation >*/
{
	int it, i1, j1, j2;
	double  norm, s1, c1;

	for(i1=0; i1<n1*n2; i1++)
		p[0][i1] = p0;

	for (it=0; it<nit; it++)
	{
		for(i1=0; i1<n1*n2; i1++)
		{
			s1 = cimagf(p[0][i1]);
			c1 = crealf(p[0][i1]);
			u1[0][i1] = 0.0;
			u2[0][i1] = 0.0;
			u3[0][i1] = 0.0;
			for(j2=0; j2<n4; j2++)
			for(j1=0; j1<n3; j1++)
			{
				if((j1+j2)%2==0) continue;
				u1[0][i1] += 2.0*in[j2][j1][0][i1]*POW(s1, j1)*POW(c1,j2);
				u2[0][i1] += 2.0*in[j2][j1][0][i1]*j1*POW(s1, j1-1)*POW(c1,j2);
				u3[0][i1] += 2.0*in[j2][j1][0][i1]*POW(s1, j1)*j2*POW(c1,j2-1);
			}
		}

		if(verb)
		{
			for(i1=0, norm=0.0; i1<n1*n2; i1++)
				norm += (u1[0][i1]*u1[0][i1]);
			sf_warning("res1 %d %g", it+1, sqrtf(norm/n1/n2));
		}

		if(use_divn)
		{
			for(i1=0, c1=0.0, s1=0.0; i1<n1*n2; i1++)
			{
				c1 += (u2[0][i1]*u2[0][i1]);
				s1 += (u3[0][i1]*u3[0][i1]);
			}
			c1=sqrtf(c1/(n1*n2));
			s1=sqrtf(s1/(n1*n2));
			for(i1=0; i1<n1*n2; i1++)
			{
				u1[0][i1] /= c1;
				u2[0][i1] /= c1;
			}
			sf_divn(u1[0], u2[0], u4[0]);
			for(i1=0; i1<n1*n2; i1++)
			{
				u1[0][i1] *= c1/s1;
				u3[0][i1] /= s1;
			}
			sf_divn(u1[0], u3[0], u5[0]);
		}else{
			for(i1=0; i1<n1*n2; i1++)
			{
				u4[0][i1] = divn(u1[0][i1], u2[0][i1]);
				u5[0][i1] = divn(u1[0][i1], u3[0][i1]);
			}
		}
		for(i1=0; i1<n1*n2; i1++)
		{
			p[0][i1] -= eta * sf_cmplx(u5[0][i1], u4[0][i1]);
			p[0][i1] = p[0][i1]*r/(cabsf(p[0][i1])+ 1E-15);
		}

	}
	for(i1=0; i1<n1*n2; i1++)
		dip[0][i1] = atan(tan(cargf(p[0][i1])));
}
Exemple #3
0
int main(int argc, char* argv[])
{
    int dim, n[SF_MAX_DIM], rect[SF_MAX_DIM], nd;
    int ns, nt, nm, nx, i, ix, is, it, niter, imax;
    float **slice, *pick0, *pick, *ampl;
    float s0, ds, t, asum, ai, amax, ap, am, num, den, dx;
    char key[6];
    sf_file in, out;

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

    dim = sf_filedims (in,n);
    if (dim < 2) sf_error("Need at least two dimensions");

    nd = 1;
    for (i=0; i < dim; i++) {
	nd *= n[i];
	if (n[i] > 1) {
	    snprintf(key,6,"rect%d",i+1);
	    if (!sf_getint(key,rect+i)) rect[i]=1;
	} else {
	    rect[i]=1;
	}
    }
    nt = n[0];
    ns = n[1];
    nm = nd/ns;
    nx = nm/nt;

    if (!sf_histfloat(in,"o2",&s0)) sf_error("No o2= in input");
    if (!sf_histfloat(in,"d2",&ds)) sf_error("No d2= in input");
    sf_putint(out,"n2",1);

    if (!sf_getint("niter",&niter)) niter=100;
    /* number of iterations */

    for (i=1; i < dim-1; i++) {
	n[i] = n[i+1];
    }
    dim--;

    divn_init(dim,nm,n,rect,niter);

    slice = sf_floatalloc2(nt,ns);

    pick0 = sf_floatalloc(nm);
    pick = sf_floatalloc(nm);
    ampl = sf_floatalloc(nm);

    for (ix = 0; ix < nx; ix++) {
	sf_floatread (slice[0],nt*ns,in);

	/* pick blind maximum */
	for (it = 0; it < nt; it++) {
	    i = ix*nt+it;

	    imax = 0;
	    amax = 0.;
	    for (is = 0; is < ns; is++) {
		t = slice[is][it];
		if (t > amax) {
		    amax = t;
		    imax = is;
		}
	    }

	    /* quadratic interpolation for sub-pixel accuracy */
	    if (imax > 0 && imax < ns-1) {
		am = slice[imax-1][it];
		ap = slice[imax+1][it];
		num = 0.5*(am-ap);
		den = am+ap-2.*amax;
		dx = num*den/(den*den + FLT_EPSILON);
		if (fabsf(dx) >= 1.) dx=0.;

		ampl[i] = amax - 0.5*dx*dx*den;
		pick0[i] = s0+(imax+dx)*ds;
	    } else {
		ampl[i] = amax;
		pick0[i] = s0+imax*ds;
	    }
	}
    }
    
    /* normalize amplitudes */
    asum = 0.;
    for (i = 0; i < nm; i++) {
	ai = ampl[i];
	asum += ai*ai;
    }
    asum = sqrtf (asum/nm);

    for(i=0; i < nm; i++) {
	ampl[i] /= asum;
	pick0[i] *= ampl[i];
    }

    divn(pick0,ampl,pick);

    sf_floatwrite (pick,nm,out);	

    exit (0);
}
Exemple #4
0
void pulsesequence()
{
   double	base,
                corr,
                presat,
                qlvl;
   char         sspul[MAXSTR];


/* LOAD VARIABLES AND CHECK CONDITIONS */
   presat = getval("presat");
   qlvl = getval("qlvl");
   getstr("sspul", sspul);

   base = 180.0 / qlvl;
   initval(2.0 * qlvl, v5);

   if ((rof1 < 9.9e-6) && (ix == 1))
      fprintf(stdout,"Warning:  ROF1 is less than 10 us\n");

/* STEADY-STATE PHASECYCLING */
/* This section determines if the phase calculations trigger off of (SS - SSCTR)
   or off of CT */

   ifzero(ssctr);
      modn(ct, v5, v10);
      divn(ct, v5, v12);
      mod2(ct, v9);
   elsenz(ssctr);
      sub(ssval, ssctr, v14);	/* v14 = 0,...,ss-1 */
      modn(v14, v5, v10);
      divn(v14, v5, v12);
      mod2(v14, v9);
   endif(ssctr);


/* CALCULATE PHASECYCLE */
/* The phasecycle first performs a (2*Q)-step cycle on the third pulse in order
   to select for MQC.  The phasecycle is then adjusted so that the receiver
   goes +- in an alternating fashion.  Second, the 2-step QIS cycle is added
   in.  Third, a 2-step cycle for axial peak suppression is performed on the
   first pulse. */

   assign(v12, v1);
   mod2(v12, v12);		/* v12=quad. image suppression */
   hlv(v1, v1);
   mod2(v1, v1);
   dbl(v1, v1);
   add(v1, v12, v4);
   add(v12, v1, v1);
   assign(v12, v2);
   assign(v12, v3);
   dbl(v9, v9);
   add(v9, v4, v4);
   assign(v4, oph);
   if (phase1 == 2)
      incr(v1);
   if (phase1 == 3)  /* TPPI */
      add(id2, v1, v1);
/* FAD added for phase=1 or phase=2 */
   if ((phase1 == 1) || (phase1 == 2))
   {
      initval(2.0*(double)(d2_index%2),v13);
      add(v1,v13,v1); add(oph,v13,oph);
   }


/* BEGIN ACTUAL PULSE SEQUENCE CODE */
   if (newtrans)
      obsstepsize(base);

   status(A);
   if (sspul[0] == 'y')
   {
      hsdelay(hst + 0.001);
      rgpulse(pw, v1, 1.0e-6, 1.0e-6);
      hsdelay(hst + 0.001);
   }
   if ((d1 - presat) <= hst)
   {
      rcvroff();
      decon();
      hsdelay(presat);
      decoff();
      delay(1.0e-6);
      rcvron();
   }
   else
   {
      hsdelay(d1 - presat);
      decon();
      rcvroff();
      delay(presat);
      decoff();
      delay(1.0e-6);
      rcvron();
   }
   status(B);
      if (newtrans)
         xmtrphase(v10);      /* hardware digital phaseshift */
      rgpulse(pw, v1, rof1, 1.0e-6);
      corr = 1.0e-6 + rof1 + 4.0*pw/3.1416;
      if (d2  > corr)
        delay(d2-corr); 
      rgpulse(pw, v2, rof1, 0.0);
      if (newtrans)
      {
         xmtrphase(zero);       /* resets relative phase to absolute phase */
      }
      else
      {
         phaseshift(-base, v10, OBSch);   /* software small-angle phaseshift */
      }
      rgpulse(pw, v3, 1.0e-6, rof2);
   status(C);
}
Exemple #5
0
void pulsesequence()
{
    double	base,
            qlvl;
    char         sspul[MAXSTR];


    /* LOAD VARIABLES AND CHECK CONDITIONS */
    qlvl = getval("qlvl");
    getstr("sspul", sspul);

    base = 180.0 / qlvl;
    initval(2.0 * qlvl, v5);

    if ((rof1 < 9.9e-6) && (ix == 1))
        fprintf(stdout,"Warning:  ROF1 is less than 10 us\n");


    /* STEADY-STATE PHASECYCLING */
    /* This section determines if the phase calculations trigger off of (SS - SSCTR)
       or off of CT */

    ifzero(ssctr);
    modn(ct, v5, v10);
    divn(ct, v5, v12);
    mod2(ct, v9);
    elsenz(ssctr);
    sub(ssval, ssctr, v14);	/* v14 = 0,...,ss-1 */
    modn(v14, v5, v10);
    divn(v14, v5, v12);
    mod2(v14, v9);
    endif(ssctr);


    /* CALCULATE PHASECYCLE */
    /* The phasecycle first performs a (2*Q)-step cycle on the third pulse in order
       to select for MQC.  The phasecycle is then adjusted so that the receiver
       goes +- in an alternating fashion.  Second, the 2-step QIS cycle is added
       in.  Third, a 2-step cycle for axial peak suppression is performed on the
       first pulse. */

    assign(v12, v1);
    mod2(v12, v12);		/* v12=quad. image suppression */
    hlv(v1, v1);
    mod2(v1, v1);
    dbl(v1, v1);
    add(v1, v12, v4);
    add(v12, v1, v1);
    assign(v12, v2);
    assign(v12, v3);
    dbl(v9, v9);
    add(v9, v4, v4);
    assign(v4, oph);
    if (phase1 == 2)
        incr(v1);
    if (phase1 == 3)
        add(id2, v1, v1);        /* TPPI increment */


    /* BEGIN ACTUAL PULSE SEQUENCE CODE */
    if (newtrans)
        obsstepsize(base);

    status(A);
    if (sspul[A] == 'y')
    {
        rgpulse(200*pw, zero, rof1,0.0e-6);
        rgpulse(200*pw, one, 0.0e-6, rof1);
    }
    if (satmode[A] == 'y')
    {
        obspower(satpwr);
        rgpulse(satdly,zero,rof1,rof1);
        obspower(tpwr);
    }
    status(B);
    if (newtrans)
        xmtrphase(v10);      /* hardware digital phaseshift */
    rgpulse(pw, v1, rof1, 1.0e-6);
    if (satmode[B] == 'y')
    {
        obspower(satpwr);
        if (d2>0.0) rgpulse(d2 -9.4e-6 -rof1 -(4*pw)/3.1416,zero,0.0,0.0);
        obspower(tpwr);
    }
    else
    {
        if (d2>0.0) delay(d2 -1.0e-6 -rof1 -(4*pw)/3.1416);
    }
    rcvroff();
    rgpulse(pw, v2, rof1, 0.0);
    if (newtrans)
    {
        xmtrphase(zero);       /* resets relative phase to absolute phase */
    }
    else
    {
        phaseshift(-base, v10, OBSch);   /* software small-angle phaseshift */
    }
    rgpulse(pw, v3, 1.0e-6, rof2);
    status(C);
}