Пример #1
0
int main(int argc, char **argv)
{
	int i;

	char *srcfile;
	char *datfile;
	float b,e,k,a;
	int nv; float *v;

	/* Initialize */
	initargs(argc, argv);
	requestdoc(1);

	/* Get parameters */
	if (!getparstring("src", &srcfile)) err("must specify src= source file");
	if (!getparstring("dat", &datfile)) err("must specify dat= data file");
	if (!getparfloat("b", &b)) b=-INFINITY;
	if (!getparfloat("e", &e)) e=INFINITY;
	if (!getparfloat("k", &k)) k=0.01;
	if (!getparfloat("a", &a)) a=0;
	if ((nv=countparval("v"))) {
		v=malloc(nv*sizeof(float));
		getparfloat("v",v);
	}

	/* Print out parameters */
	printf("src=%s dat=%s b=%f e=%f k=%f a=%f v=",srcfile,datfile,b,e,k,a);
	for (i=0;i<nv;i++) printf("%f,",v[i]);
	printf("\n");

	return 0;
}
Пример #2
0
int
main(int argc, char **argv)
{
	int ns;		/* samples on output traces	*/


	/* Initialize */
	initargs(argc, argv);
	requestdoc(1);


        /* Get info from first trace */ 
        if (!fvgettr(stdin, &tr))  err("can't get first trace"); 
        if (!getparint("ns", &ns)) ns = tr.ns;
        checkpars();


	/* Loop over the traces */
	do {
		int nt = tr.ns;
				
		if (nt < ns) /* pad with zeros */
                	memset((void *)(tr.data + nt), 0, (ns-nt)*FSIZE);
		tr.ns = ns;
		puttr(&tr);
	} while (fvgettr(stdin, &tr));
	
	return(CWP_Exit());
}
Пример #3
0
int
main(int argc, char **argv)
{
	FILE *fp;
	int fd,j=0,verbose;

	initargs(argc,argv);
	requestdoc(1);

	if(!getparint("fd",&fd)) fd=-1;
	if(!getparint("verbose",&verbose)) verbose=0; 
	warn("File descriptor passed to suget = %d",fd);
	if( (fp = (FILE *) fdopen(fd,"r"))==NULL) err("Bad file descriptor");
	warn("About to read first trace");
	if(!fgettr(fp,&tr)) err("Can't get first trace");

	do{
		if(verbose>0){
			warn("read trace %d",j);
			j++;
		}

		puttr(&tr);

	} while(fgettr(fp,&tr));

	return(CWP_Exit());
}
Пример #4
0
int
main(int argc, char **argv)
{

	/* Initialize */
	initargs(argc, argv);
	requestdoc(1);


	while (gettr(&tr)) {
		tr.f1 = 0.0;
		tr.d1 = 0.0;
		tr.f2 = 0.0;
		tr.d2 = 0.0;
		tr.ungpow = 0.0;
		tr.unscale = 0.0;
		tr.ntr = 0;
		tr.mark = 0;

		puttr(&tr);
	}


	return(CWP_Exit());
}
Пример #5
0
int
main(int argc, char **argv)
{
	float *f;
	int n1;
	void *wpc1;
	int i;

	initargs(argc,argv);
	requestdoc(1);

	wpc1 = wpc1Read(stdin);

	n1 = wpc1Numsmp(wpc1);

	if(n1< 0) fprintf(stderr, "Inconsistent data, n=%d\n", n1);

	f = alloc1float(n1);
	
	i = 0;
	while(i >= 0 /*TRUE*/){
	    if(!wpc1Uncompress(wpc1, f)){
	    	fprintf(stderr, "Inconsistent data, trace # %d\n", i);
		break;
	    }

	    i++;
	    fwrite(f, sizeof(float), n1, stdout);
	    if((wpc1 = wpc1Read(stdin)) == NULL) break; 
	}
	return EXIT_SUCCESS;
}
Пример #6
0
int 
main(int argc, char **argv)
{
	/* Segy data constans */
	int ntr=0;		/* number of traces			*/
	char *outpar=NULL;	/* name of file holding output		*/
	FILE *outparfp=stdout;	/* ... its file pointer			*/

	initargs(argc, argv);
   	requestdoc(1);
	
	/* Get information from the first header */
	if (!gettr(&tr)) err("can't get first trace");
	if (!getparstring("outpar", &outpar))	outpar = "/dev/stdout" ;
	
	outparfp = efopen(outpar, "w");

        checkpars();
	/* Loop over traces getting a count */
	do {
		++ntr;
	} while(gettr(&tr));

	fprintf(outparfp, "%d", ntr);

	return(CWP_Exit());

}
Пример #7
0
int
main(int argc, char **argv)
{
	cwp_String key1,  key2;	/* x and y key header words	*/
	Value  val1,  val2;	/* ... their values		*/
	cwp_String type1, type2;/* ... their types		*/
	int index1, index2;	/* ... their indices in hdr.h	*/
	float x, y;		/* temps to hold current x & y 	*/
	cwp_String outpar;	/* name of par file		*/
	register int npairs;	/* number of pairs found	*/


	/* Hook up getpars */
	initargs(argc, argv);
	requestdoc(1);


	/* Prevent byte codes from spilling to screen */
	if (isatty(STDOUT)) err("must redirect or pipe binary output");


	/* Get parameters */
	if (!getparstring("key1", &key1))	key1 = "sx";
	if (!getparstring("key2", &key2))	key2 = "gx";

	type1 = hdtype(key1);
	type2 = hdtype(key2);

	index1 = getindex(key1);
	index2 = getindex(key2);


	/* Loop over traces */
	npairs = 0;
	while(gettr(&tr)) {

		gethval(&tr, index1, &val1);
		gethval(&tr, index2, &val2);

		x = vtof(type1, val1);
		y = vtof(type2, val2);

		efwrite(&x, FSIZE, 1, stdout);
		efwrite(&y, FSIZE, 1, stdout);

		++npairs;
	}


	/* Make parfile if needed */
	if (getparstring("outpar", &outpar))
		fprintf(efopen(outpar, "w"),
			"n=%d label1=%s label2=%s\n",
			npairs, key1, key2);

	return(CWP_Exit());
}
Пример #8
0
int
main(int argc, char **argv)
{
	int i, j, n;
	float *f,  max, step, rstep;
	float fhist[1024], dev, rdev, ent, error; 
	int hist[1024];
	 
	initargs(argc, argv);
	requestdoc(1);

	MUSTGETPARINT("n",&n);

	f = alloc1float(n);

	fread(f,sizeof(float),n,stdin);
	
	for(i=0;i<1024;i++) hist[i] = 0;

	for(i=0,rdev=0.;i<n;i++)
	   rdev += f[i]*f[i]; 
	rdev = rdev/n;
	rdev = sqrt(rdev);

	if(!getparfloat("dev",&dev)) dev = rdev;

	fprintf(stderr,"dev=%f\n", dev);

	step = dev*3.464*.01;

	rstep = 1./step;

	error = 0.;
	for(i=0;i<n;i++){
	    max = f[i]*rstep;
	    error += (NINT(max)*step - f[i])*(NINT(max)*step - f[i]);
	    hist[NINT(max)+512] ++;
	}

	error = error/n;
	error = sqrt(error);
	error = error/rdev;

	ent = 0.;
	for(j=0;j<1024;j++){
		fhist[j] = ((float) hist[j])/((float) n);
		if(hist[j])
		    ent += fhist[j]*log(fhist[j])/log(2.);
	}
	ent = -ent;

fprintf(stderr,"entropy of the signal is=%f, average error=%f\n",ent, error);

	fwrite(fhist,sizeof(float),1024,stdout);

	return EXIT_SUCCESS;
}
Пример #9
0
int
main(int argc, char **argv)
{

	int i;			/* counter			*/
	int itr=0;		/* trace counter		*/
	int verbose;		/* =0 silent,  =1 chatty	*/
	int interp;		/* =1 interpolate to get NaN	*/
				/* and Inf replacement values	*/
			
	float value;		/* value to set NaN and Infs to */

	/* Initialize */
   	initargs(argc,argv);
   	requestdoc(1);

	/* Get info from first trace */
	if(!gettr(&tr) ) err("Can't get first trace \n");

	/* Get parameters */
	if(!getparint("verbose",&verbose))	verbose = 1;
	if(!getparint("interp",&interp))	interp = 0;
	if(!getparfloat("value",&value))	value = 0.0;
        checkpars();

	/* Loop over traces */
	do{
		++itr;
      		for(i=0; i<tr.ns; ++i){
		    if(!isfinite(tr.data[i])) {
		       if (verbose)
	                warn("found NaN trace = %d  sample = %d", itr, i);

			if (interp) { /* interpolate nearest neighbors */
				      /* for NaN replacement value     */
				if (i==0 && isfinite(tr.data[i+1])) { 
					tr.data[i]=tr.data[i+1];
				} else if(i==tr.ns-1 && isfinite(tr.data[i-2])) {
					tr.data[i]= tr.data[i-2];
				} else if( isfinite(tr.data[i-1]) &&
						isfinite(tr.data[i+1]) ) {
					tr.data[i]=(tr.data[i-1]+tr.data[i+1])/2.0;
				}
			}
				
			/* use user defined NaNs replacement value */
            	       	tr.data[i] = value;
			}
		    }

      		puttr(&tr);
	} while(gettr(&tr));

	return(CWP_Exit());
}
Пример #10
0
int
main(int argc, char **argv)
{
	float fz[BUFSIZ];
	int iz=0,jz,nz=0;
	unsigned int z[BUFSIZ];
	char line[BUFSIZ],*lp, *outpar;
	FILE *infp=stdin,*outfp=stdout, *outparfp;

	unsigned int *uz = &(z[0]);

	/* Hook up getpar */
	initargs(argc, argv);
	requestdoc(1);

	/* Prevent floats from dumping on screen */
	switch(filestat(STDOUT)) {
	case BADFILETYPE:
		warn("stdout is illegal filetype");
		pagedoc();
	break;
	case TTY:
		warn("stdout can't be tty");
		pagedoc();
	break;
	default: /* rest are OK */
	break;
	}


	/* Get parameters and do set up */
	if (!getparstring("outpar", &outpar))  outpar = "/dev/tty" ;
	outparfp = efopen(outpar, "w");

	while (fgets(line,BUFSIZ,infp)!=NULL) {

		/* set pointer to beginning of line */
		lp = line;

		/* read hex digits from input line */
		for(iz=0;sscanf(lp,"%2x",&uz[iz])==1;iz++,nz++,lp+=2);

		/* convert to floats */
		for(jz=0;jz<iz;jz++)
			fz[jz] = 255-z[jz];

		/* write floats */
		fwrite(fz,sizeof(float),iz,outfp);
	}

	/* Make par file */
	fprintf(outparfp, "total number of values=%d\n",nz);

	return(CWP_Exit());
}
Пример #11
0
int
main(int argc, char **argv)
{
	int nt;				/* number of samples on input */
	int ntout;			/* number of samples on output */
	int it;				/* counter */
	int istart;			/* beginning sample */
	int izero;			/* - istart */
	int norm;			/* user defined normalization value */
	int sym;			/* symmetric plot? */
	float scale;			/* scale factor computed from norm */
	float *temp=NULL;		/* temporary array */
	float dt;			/* time sampling interval (sec) */

	/* hook up getpar */
	initargs(argc, argv);
	requestdoc(1);

	/* get information from the first header */
	if (!gettr(&tr)) err("can't get first trace");
	nt = tr.ns;
	dt = tr.dt/1000000.0;

	/* get parameters */
	if (!getparint("ntout",&ntout)) ntout=101;
	if (!getparint("norm",&norm)) norm = 1;
	if (!getparint("sym",&sym)) sym = 1;
        checkpars();
	
	/* allocate workspace */
	temp = ealloc1float(ntout);
	
	/* index of first sample */
	if (sym == 0) istart = 0;
	else istart = -(ntout-1)/2;

	/* index of sample at time zero */
	izero = -istart;
	
	/* loop over traces */
	do {
		xcor(nt,0,tr.data,nt,0,tr.data,ntout,istart,temp);
		if (norm) {
			scale = 1.0/(temp[izero]==0.0?1.0:temp[izero]);
			for (it=0; it<ntout; ++it)  temp[it] *= scale;
		}
		memcpy((void *) tr.data, (const void *) temp, ntout*FSIZE);
		tr.ns = ntout;
		tr.f1 = -dt*ntout/2.0;
		tr.delrt = 0;
		puttr(&tr);
	} while(gettr(&tr));

	return(CWP_Exit());
}
Пример #12
0
main(int argc, char **argv)
{
	initargs(argc, argv);
	requestdoc(1);

 	while (gettr(&tr)) {
 		tr.offset = abs(tr.offset);
 		puttr(&tr);
 	}

	return EXIT_SUCCESS;
}
Пример #13
0
int
main(int argc, char **argv)
{
	double sx, sy, gx, gy, factor;
	float mx, my;
        short unit;                                                           
	int degree;
	cwp_String outpar;
	register int npairs;


	/* Initialize */
	initargs(argc, argv);
	requestdoc(1);

	if (!getparint("degree", &degree)) degree=0;

	npairs = 0;
	while (gettr(&tr)) {

		sx = tr.sx;
		sy = tr.sy;
		gx = tr.gx;
		gy = tr.gy;

                unit = tr.counit;
		
		/* If tr.scalco not set, use 1 as the value */
		factor = (!tr.scalco) ? 1 : tr.scalco;
		
                /* factor < 0 means divide; factor > 0 means to multiply */
                if (factor < 0) factor = -1/factor;

                /* if necessary, convert from seconds to degrees */
                if (unit == 2 && degree == 1) factor /= 3600;

                mx = (float) (0.5*(sx + gx) * factor);
                my = (float) (0.5*(sy + gy) * factor);

		efwrite(&mx, FSIZE, 1, stdout);
		efwrite(&my, FSIZE, 1, stdout);

		++npairs;
	}


	/* Make parfile if needed */
	if (getparstring("outpar", &outpar))
		fprintf(efopen(outpar, "w"), "n=%d\n", npairs);

	return(CWP_Exit());
}
Пример #14
0
int main( int argc, char *argv[] )
{
	/* binning */
	float xc;
	float yc;
	double cdpcx;
	double cdpcy;
	float dbx;
	float dby;
	float deg;
	float degr;
	int dirx;
	int diry;
	int nx;
	int ny;
	float xe;
	float ye;
	int ix;
	int iy;

	initargs(argc, argv);
   	requestdoc(1);

	/* binning stuff */
	if(!getparfloat("xc",&xc)) xc=1;
	if(!getparfloat("yc",&yc)) yc=1;
	if(!getparfloat("dbx",&dbx)) dbx=20;
	if(!getparfloat("dby",&dby)) dby=20;
	if(!getparfloat("deg",&deg)) deg=0;
	degr = 3.141592653/180 * deg;
	if(!getparint("dirx",&dirx)) dirx=1;
	if(!getparint("diry",&diry)) diry=1;
	MUSTGETPARINT("nx", &nx);
	MUSTGETPARINT("ny", &ny);

	/* edge of bin# 1,1 */
	xe = xc - dirx*dbx/2.0*cos(degr) - diry*dby/2.0*sin(degr);
	ye = yc - diry*dby/2.0*cos(degr) + dirx*dbx/2.0*sin(degr);

	/* compute bin centre coordinates */
	for(ix=1;ix<=nx; ix++) {
		for(iy=1;iy<=ny;iy++) { 
			cdpcx= xc + dirx*(ix-1)*dbx*cos(degr) +
                        	diry*(iy-1)*dby*sin(degr);
			cdpcy= yc + diry*(iy-1)*dby*cos(degr) -
                        	dirx*(ix-1)*dbx*sin(degr);
			fprintf(stdout," %d %f %f\n",
				ix*1000+iy,cdpcx,cdpcy);
			}
	}
	return EXIT_SUCCESS;
}
Пример #15
0
int
main(int argc, char **argv)
{
	int itmin;		/* smallest sample (zero-based)	to plot	*/
	int itmax;		/* largest sample (zero-based) to plot	*/
	int nt;			/* number of samples			*/
	int count;		/* number of traces to plot		*/
	register int itr;	/* trace counter			*/
	cwp_Bool plotall;	/* plot all the traces			*/


	/* Initialize */
	initargs(argc, argv);
	requestdoc(1);


	/* Set number of traces to plot */
	plotall = cwp_false;
	if (!getparint("count", &count)) plotall = cwp_true;


	/* Loop over traces */
	for (itr = 0; (plotall || itr < count) && gettr(&tr); itr++) {

		nt = (int) tr.ns;	/* Cast from unsigned */
		if (itr == 0) {	/* Awkward to do a gettr outside loop */
			if (!getparint("itmin", &itmin))	itmin = 0;
			if (!getparint("itmax", &itmax))	itmax = nt - 1;
			if (itmin >= nt - 1 || itmin < 0) {
				err("itmin=%d, require 0 < itmin < %d",
							itmin, nt - 1);
			}
			if (itmax >= nt) {
				itmax = nt - 1;
			}
			if (itmax < 0) {
				err("itmax=%d, require itmax > 0", itmax);
			}
			if (itmin > itmax) {
				itmin = itmax;
			}
		}

		printheader(&tr);

		tabplot(&tr, itmin, itmax);

	}


	return(CWP_Exit());
}
Пример #16
0
int
main(int argc, char **argv)
{
	int nt;				/* number of time samples	*/
	int ntr;			/* number of traces		*/
	int itr;			/* trace counter		*/
	int nspk;			/* number of spikes		*/
	int it1;			/* time of 1st spike		*/
	int ix1;			/* position of 1st spike	*/
	int it2;			/* time of 2nd spike		*/
	int ix2;			/* position of 2nd spike	*/
	int ix3;			/* position of 3rd spike	*/
	int it3;			/* time of 3rd spike		*/
	int ix4;			/* position of 4th spike	*/
	int it4;			/* time of 4th spike		*/
	float dt;			/* time sampling interval	*/
	float offset;			/* offset			*/


	/* Initialize */
	initargs(argc, argv);
	requestdoc(0); /* stdin not used */


	nt = 64;	getparint("nt", &nt);
	CHECK_NT("nt",nt);				tr.ns = nt;
	ntr = 32;	getparint("ntr", &ntr);
	dt = 0.004;	getparfloat("dt", &dt);		tr.dt = dt*1000000;
	offset = 400;	getparfloat("offset", &offset);	tr.offset = offset;
	nspk = 4;	getparint("nspk", &nspk);
	ix1 = ntr/4;	getparint("ix1", &ix1); 
	it1 = nt/4;	getparint("it1", &it1);
	ix2 = ntr/4;	getparint("ix2", &ix2);
	it2 = 3*nt/4;	getparint("it2", &it2);
	ix3 = 3*ntr/4;	getparint("ix3", &ix3);
	it3 = nt/4;	getparint("it3", &it3);
	ix4 = 3*ntr/4;	getparint("ix4", &ix4);
	it4 = 3*nt/4;	getparint("it4", &it4);

	for (itr = 0; itr < ntr; itr++) {
		memset( (void *) tr.data, 0, nt * FSIZE);
		if (itr == ix1-1) tr.data[it1-1] = 1.0;  
		if (nspk > 1 && itr == ix2-1) tr.data[it2-1] = 1.0;
		if (nspk > 2 && itr == ix3-1) tr.data[it3-1] = 1.0;
		if (nspk > 3 && itr == ix4-1) tr.data[it4-1] = 1.0;
		tr.tracl = itr + 1;
		puttr(&tr);
	}


	return(CWP_Exit());
}
Пример #17
0
int main( int argc, char *argv[] )
{
	/* Segy data constans */
	int nt;                 /* number of time samples               */
        int ntr=0;              /* number of traces                     */
	
	float *filter;
	int fnl,fnr;
	int fnp;
	int fld;
	int fm;
        float dt;               /* sample interval in secs              */
	float prw;		/* pre-withening */
	
	initargs(argc, argv);
   	requestdoc(1);
	
        /* get information from the first header */
        if (!gettr(&tr)) err("can't get first trace");
        nt = tr.ns;

        if (!getparfloat("dt", &dt)) dt = ((double) tr.dt)/1000000.0;
        if (!dt) {
                dt = .002;
                warn("dt not set, assumed to be .002");
        }
	
	if(!getparint ("fnl", &fnl)) fnl=15;
	fnr=fnl;
	if(!getparint ("fnp", &fnp)) fnp=fnr+fnl+fnr/2;
	if(!getparfloat ("prw", &prw)) prw=1.0;
		
	if(fnl!=0) {
		fld=0; fm=0; fnr=fnl;
		filter = ealloc1float(fnp);
		SG_smoothing_filter(fnp,fnl,fnr,fld,fm,filter); 
/*		rwa_smoothing_filter(1,fnl,fnr,filter); */ 
	} else {
		filter= NULL;
	}
	
	do {
		do_minphdec(tr.data,nt,filter,fnl,fnr,prw);
		
		tr.ns=nt;
		ntr++;		
		puttr(&tr);
	} while(gettr(&tr));
	
   return EXIT_SUCCESS;
}
Пример #18
0
int
main(int argc, char **argv)
{
	char *outpar;		/* name of file holding output parfile	*/
	FILE *outparfp;		/* ... its file pointer			*/
	int n1;			/* number of floats per line		*/
	size_t n1read;		/* number of items read			*/
	size_t n2 = 0;		/* number of lines in input file 	*/
	float *z;		/* binary floats			*/

	/* Hook up getpar */
	initargs(argc, argv);
	requestdoc(1);

	/* Get parameters and do set up */
	if (!getparstring("outpar", &outpar))	outpar = "/dev/tty" ;
	outparfp = efopen(outpar, "w");
	MUSTGETPARINT("n1",&n1);

	z = ealloc1float(n1);

	/* Loop over data converting to ascii */
	while ((n1read = efread(z, FSIZE, n1, stdin))) {
		register int i1;

		if (n1read != n1)
			err("out of data in forming line #%d", n2+1);
		for (i1 = 0; i1 < n1; ++i1)
/* z2xyz.c:70: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘size_t’ */
/* 			printf("%d %d %11.4e \n",n2,i1,z[i1]); */
#if __WORDSIZE == 64
			printf("%lu %d %11.4e \n",n2,i1,z[i1]);
#else
			printf("%u %d %11.4e \n",n2,i1,z[i1]);
#endif
		++n2;
	}


	/* Make par file */
/* z2xyz.c:76: warning: format ‘%d’ expects type ‘int’, but argument 3 has type ‘size_t’ */
/* 	fprintf(outparfp, "n2=%d\n", n2); */
#if __WORDSIZE == 64
	fprintf(outparfp, "n2=%lu\n", n2);
#else
	fprintf(outparfp, "n2=%u\n", n2);
#endif

	return(CWP_Exit());
}
Пример #19
0
int
main(int argc, char **argv)
{
	int nt,nshot,noff;
        int ishot,ioff,it;
        float dt,dshot,doff,sx,gx,offset,cmp;

	/* Initialize */
	initargs(argc, argv);
	requestdoc(0); /* stdin not used */

	nt = 100;	getparint("nt", &nt);
	CHECK_NT("nt",nt);				tr.ns = nt;
	nshot = 10;	getparint("nshot", &nshot);
	noff  = 24;	getparint("noff", &noff);
	dt = 0.004;	getparfloat("dt", &dt);		tr.dt = dt*1000000;
	dshot = 10;	getparfloat("dshot", &dshot);
	doff = 20;	getparfloat("doff", &doff);

	for (ishot = 0; ishot < nshot; ishot++) {
          sx = ishot*dshot;
	  for (ioff = 0; ioff < noff; ioff++) {
                offset = (ioff+1)*doff;
                gx = sx + offset; 
                cmp = (sx + gx)/2.;
		memset( (void *) tr.data, 0, nt * FSIZE);
                for (it = 0; it < nt/4; it++) {
		  tr.data[it] = sx;  
                }
                for (it = nt/4; it < nt/2; it++) {
		  tr.data[it] = gx;  
                }
                for (it = nt/2; it < 3*nt/4; it++) {
		  tr.data[it] = offset;  
                }
                for (it = 3*nt/4; it < nt; it++) {
		  tr.data[it] = cmp;  
                }
		tr.sx = sx;
		tr.gx = gx;
		tr.offset = offset;
		tr.cdp = cmp;
		tr.tracl = ishot*nshot + ioff + 1;
		puttr(&tr);
          }
        }


	return(CWP_Exit());
}
Пример #20
0
int
main (int argc, char **argv)
{
	int n1,n2,i2;
	float f1,f2,d1,d2,*x;
	char *label2="Trace",label[256];
	FILE *infp=stdin,*outfp=stdout;

	/* hook up getpar to handle the parameters */
	initargs(argc,argv);
	requestdoc(0);

	/* get optional parameters */
	if (!getparint("n1",&n1)) {
		if (efseeko(infp,(off_t) 0,SEEK_END)==-1)
			err("input file size is unknown; specify n1!\n");
		if ((n1=((int) (eftello(infp)/((off_t) sizeof(float)))))<=0)
			err("input file size is unknown; specify n1!\n");
		efseeko(infp,(off_t) 0,SEEK_SET);
	}

	if (!getparfloat("d1",&d1)) d1 = 1.0;
	if (!getparfloat("f1",&f1)) f1 = d1;
	if (!getparint("n2",&n2)) n2 = -1;
	if (!getparfloat("d2",&d2)) d2 = 1.0;
	if (!getparfloat("f2",&f2)) f2 = d2;
	getparstring("label2",&label2);

	/* allocate space */
	x = ealloc1float(n1);

	/* loop over 2nd dimension */
	for (i2=0; i2<n2 || n2<0; i2++) {

		/* read input array, watching for end of file */
		if (efread(x,sizeof(float),n1,infp)!=n1) break;
			
		/* make plot label */
		sprintf(label,"%s %0.4g",label2,f2+i2*d2);

		/* plot the array */
		prp1d(outfp,label,n1,d1,f1,x);
	}
	
	return(CWP_Exit());
}
Пример #21
0
int
main(int argc, char **argv)
{
	int j,nt,flag,ntout;
	float *buf,*ttn,dt,dtout=0.0,tmin,tmax;

	/* Initialize */
	initargs(argc, argv);
	requestdoc(1);

	/* Get information from the first header */
	if (!gettr(&tr)) err("can't get first trace");
	nt = tr.ns;
	dt = (float) tr.dt/1000000.0;

	if (!getparfloat("tmin", &tmin)) tmin=0.1*nt*dt;
	if (!getparint("flag", &flag)) flag=1;
	if(flag==1) {
		dtout=tmin*2.*dt;
		tmax=nt*dt;
		ntout=1+tmax*tmax/dtout; CHECK_NT("ntout",ntout);
		ttn=ealloc1float(ntout);
		for(j=0;j<ntout;j++) ttn[j]=sqrt(j*dtout);
	}else{
		if (!getparfloat("dt", &dt)) dtout=0.004;
		ntout=1+sqrt(nt*dt)/dtout; CHECK_NT("ntout",ntout);
		ttn=ealloc1float(ntout);
		for(j=0;j<ntout;j++) ttn[j]=j*j*dtout*dtout;
	}
	buf = ealloc1float(nt);

	fprintf(stderr,"sutsq: ntin=%d dtin=%f ntout=%d dtout=%f\n",
		nt,dt,ntout,dtout);

	/* Main loop over traces */
	do {
		for(j=0;j<nt;j++) buf[j]=tr.data[j];
		tr.ns = ntout;
		tr.dt = dtout*1000000.;			
		ints8r(nt,dt,0.,buf,0.0,0.0,
			ntout,ttn,tr.data);
		puttr(&tr);
	} while (gettr(&tr));
	
	return(CWP_Exit());
}
Пример #22
0
int main( int argc, char *argv[] )
{
	int n1;		/* number of x y values */
	int stinc;	/* x increment  */
	int f;		/* filter length */
	int m;		/* filter method flag */
	float *x;	/* array of x index values */
	float *y; 	/* array of y values */

        /* Initialize */
        initargs(argc, argv);
        requestdoc(1);

    
	MUSTGETPARINT("n1",&n1);
	if( !getparint("stinc",&stinc)) stinc=1;
	if( !getparint("f",&f)) f=5;
	if( !getparint("m",&m)) m=1;
	
	/* allocate arrays */
	x = ealloc1float(n1);
	y = ealloc1float(n1);
	
	/* Read data into the arrays */
	{ int i;
		for(i=0;i<n1;i++) {
			fscanf(stdin," %f %f\n",&x[i],&y[i]);
		}
	}
	/* smooth */
	sm_st(x,y,n1,f,stinc,m);
	
	/* Write out */
	{ int i;
		for(i=0;i<n1;i++) {
			fprintf(stdout," %10.3f %10.3f\n",x[i],y[i]);
		}
	}
	
	free1float(x);
	free1float(y);
   	return EXIT_SUCCESS;
}
Пример #23
0
int main(int argc, char **argv)
{
  int i, npars;
  int parnum=100;
  char *name[100];
  char *asciival[100];

  /* Initialize */
  initargs(argc, argv);
  requestdoc(1);

  /* Get parameters */
  npars = getargtbl(name, asciival, parnum);

  /* Print out parameters */
  for (i=0; i<npars; i++) {
    printf("i=%d key=%s value=%s\n",i,name[i],asciival[i]);
  }

  return 0;
}
Пример #24
0
main(int argc, char **argv)
{
	String key;
	String type;
	int index;
	double a, c, b, d, i, j;
	int itr = 0;
	Value val;
	FILE *infp=stdin, *outfp=stdout; 


	/* Initialize */
	initargs(argc, argv);
	requestdoc(1);


	/* Get parameters */
	if (!getparstring("key", &key))	 key = "cdp";
	if (!getpardouble("a"  , &a))	 a = 0;
	if (!getpardouble("b"  , &b))	 b = 0;
	if (!getpardouble("c"  , &c))	 c = 0;
	if (!getpardouble("d"  , &d))	 d = 0;
	if (!getpardouble("j"  , &j))	 j = ULONG_MAX;

	type = hdtype(key);
	index = getindex(key);

	file2g(infp);
	file2g(outfp);

	while (gettr(&tr)) {
		i = (double) itr++ + d;
		setval(type, &val, a, b, c, i, j);
		puthval(&tr, index, &val);
		puttr(&tr);
	}


	return EXIT_SUCCESS;
}
Пример #25
0
int
main(int argc, char **argv)
{
	int itmin;		/* first sample to zero out		*/
	int itmax;		/* last sample to zero out	 	*/
	float value;		/* value to set within window		*/
	int nt;			/* time samples per trace in input data	*/

	/* Initialize */
	initargs(argc, argv);
	requestdoc(1);

	/* Get information from first trace */
	if (!gettr(&tr)) err("can't get first trace");
	nt = tr.ns;

	/* Get params from user */
	MUSTGETPARINT("itmax", &itmax);
	if (!getparint("itmin", &itmin))	itmin = 0;
	if (!getparfloat("value", &value))	value = 0.0;

	/* Error checking */
	if (itmax > nt)    err("itmax = %d, must be < nt", itmax);
	if (itmin < 0)     err("itmin = %d, must not be negative", itmin);
	if (itmax < itmin) err("itmax < itmin, not allowed");

	/* Main loop over traces */
	do { 
		register int i;
		for (i = itmin; i <= itmax; ++i)  tr.data[i] = value;
		
		puttr(&tr);
	} while(gettr(&tr));


	return(CWP_Exit());
}
Пример #26
0
/* the main program */
int main (int argc, char **argv)
{
	double vp1,vp2,vs1,vs2,rho1,rho2;
	double eps1,eps2,delta1,delta2;
	double gamma1,gamma2,azimuth;
	float fangle,langle,dangle,angle;
	double *coeff,p=0;
	double sangle,cangle,sazi,cazi;
	float anglef,dummy;
	FILE *outparfp=NULL, *coeffp=NULL;
	int ibin,modei,modet,rort,iangle,iscale,index;
	char *outparfile=NULL,*coeffile=NULL;
	Stiff2D *spar1, *spar2;
	double **a,*rcond,*z;
	int *ipvt;

	/* allocate space for stiffness elements */
	spar1=(Stiff2D*)emalloc(sizeof(Stiff2D));
	spar2=(Stiff2D*)emalloc(sizeof(Stiff2D));

	/* allocate space for matrix system */
	a = alloc2double(6,6);
	coeff = alloc1double(6);
	ipvt=alloc1int(6);
	z = alloc1double(6);
	rcond=alloc1double(6);

	/* hook up getpar to handle the parameters */
	initargs(argc,argv);
	requestdoc(0);

	if (!getparint("ibin",&ibin)) ibin = 1;
	if (!getparint("modei",&modei)) modei = 0;
	if (!getparint("modet",&modet)) modet = 0;
	if (!getparint("rort",&rort)) rort = 1;
        if (!getparint("iscale",&iscale)) iscale = 0;
	if (!getparint("test",&test)) test = 1;
	if (!getparint("info",&info)) info = 0;

	if(modei != 0 && modei !=1 && modei !=2){
		fprintf(stderr," \n ERROR wrong incidence mode \n");
		return (-1);	/* wrong mode */
	}

	if(modet != 0 && modet !=1 && modet !=2){
		fprintf(stderr," \n ERROR wrong scattering mode \n");
		return (-1);	/* wrong mode */
	}

        if(rort != 0 && rort !=1){
                fprintf(stderr," ERROR wrong rort parameter \n");
                return (-1);    /* wrong mode */
        }

        if(iscale != 0 && iscale !=1 && iscale !=2 && iscale!=3 ){
                fprintf(stderr," ERROR wrong iscale parameter \n");
                return (-1);    /* wrong mode */
        }


	if (!getparfloat("fangle",&fangle)) fangle = 0.0;
	if (!getparfloat("langle",&langle)) langle = 45.0;
	if (!getparfloat("dangle",&dangle)) dangle = 1.0;

	if (!getpardouble("azimuth",&azimuth)) azimuth = 0.;
	if (!getpardouble("vp1",&vp1)) vp1 = 2.0;
	if (!getpardouble("vp2",&vp2)) vp2 = 2.0;
	if (!getpardouble("vs1",&vs1)) vs1 = 1.0;
	if (!getpardouble("vs2",&vs2)) vs2 = 1.0;
	if (!getpardouble("rho1",&rho1)) rho1 = 2.7;
	if (!getpardouble("rho2",&rho2)) rho2 = 2.7;

	if (!getpardouble("eps1",&eps1)) eps1 = 0.;
	if (!getpardouble("eps2",&eps2)) eps2 = 0.;

	if (!getpardouble("delta1",&delta1)) delta1 = 0.;
	if (!getpardouble("delta2",&delta2)) delta2 = 0.;
	if (!getpardouble("gamma1",&gamma1)) gamma1 = 0.;
	if (!getpardouble("gamma2",&gamma2)) gamma2 = 0.;

	if (getparstring("outparfile",&outparfile)) {
                 outparfp = efopen(outparfile,"w");
        } else {
                 outparfp = efopen("outpar","w");
        }

	if (getparstring("coeffile",&coeffile)) {
                 coeffp = efopen(coeffile,"w");
        } else {
                 coeffp = efopen("coeff.data","w");
        }


	/******   some debugging information ******************/
	if(info){
		ddprint(azimuth);
		ddprint(vp1); ddprint(vs1); ddprint(rho1);
		ddprint(eps1); ddprint(delta1); ddprint(gamma1);

		ddprint(vp2); ddprint(vs2); ddprint(rho2);
		ddprint(eps2); ddprint(delta2); ddprint(gamma2);
	}


	/* convert into rad */
	azimuth=azimuth*PI /180.;
	sazi=sin(azimuth);
	cazi=cos(azimuth);

	/******   convertion into cij's ************************/
	if (!thom2stiffTI(vp1,vs1,eps1,delta1,gamma1,PI/2.,spar1,1) ){
		fprintf(stderr," \n ERROR in thom2stiffTI (1) \n");
		return (-1);
	}

	if (!thom2stiffTI(vp2,vs2,eps2,delta2,gamma2,PI/2.,spar2,1) ){
		fprintf(stderr,"\n ERROR in thom2stiffTI (2) \n");
		return (-1);
	}

	/*****    more debugging output ************************/
	
	if(info){
		diprint(modei);
		diprint(modet);
		diprint(rort);
		ddprint(spar1->a1111);
		ddprint(spar1->a3333);
		ddprint(spar1->a1133);
		ddprint(spar1->a1313);
		ddprint(spar1->a2323);
		ddprint(spar1->a1212);

		ddprint(spar2->a1111);
		ddprint(spar2->a3333);
		ddprint(spar2->a1133);
		ddprint(spar2->a1313);
		ddprint(spar2->a2323);
		ddprint(spar2->a1212);
	}

	/********  find generated wave type-index     ************/
	/* reflect_P (0) reflect_S (1) transm_P (2) transm_S (3) */

	if(modet == 0 && rort==1)
		index = 0;
	else if(modet == 1 && rort==1)
		index = 1;
	else if(modet == 2 && rort==1)
		index = 2;
	else if(modet == 0 && rort==0)
		index = 3;
	else if(modet == 1 && rort==0)
		index = 4;
	else if(modet == 2 && rort==0)
		index = 5;
	else {
		fprintf(stderr,"\n ERROR wrong (index) \n ");
		return (-1);
	}


	/***************** LOOP OVER ANGLES ************************/
	for(angle=fangle,iangle=0;angle<=langle;angle+=dangle){
		
		if(info) ddprint(angle);
	
		sangle=(double) angle*PI/180;
		cangle=cos(sangle);
		sangle=sin(sangle);


		/* get horizontal slowness */
		if(p_hor3DTIH(spar1,modei,sangle,cangle,sazi,cazi,&p)!=1){
			fprintf(stderr,"\n ERROR in p_hor3DTIH \n ");
			return (-1);
		}

		/* compute reflection/transmission coefficient */
		if(graebner3D(spar1,spar2,rho1,rho2,modei,modet,rort,
		   sazi,cazi,p,coeff,a,ipvt,z,rcond)!=1){
			fprintf(stderr,"\n ERROR in p_hor3DTIH \n ");
			return (-1);
		}

		++iangle;

                if(iscale==0)
                     anglef=(float) angle;
                else if(iscale==1)
                     anglef=(float) angle*PI/180.;
                else if(iscale==2)
                     anglef=(float) p;
                else if(iscale==3) 
                     anglef=(float) sangle*sangle;
                  
                dummy= (float)coeff[index];
                  

                /* Binary output for x_t */
                if(ibin==1){

                        fwrite(&anglef,sizeof(float),1,coeffp);
                        fwrite(&dummy,sizeof(float),1,coeffp);

                /* ASCII output  */
                } else if(ibin==0){

                        fprintf(coeffp,"%f      %f\n",anglef,dummy);
		}
	}

	/*********  No of output pairs for plotting ********/
	if(ibin) fprintf(outparfp,"%i\n",iangle);

	return 1;
}
Пример #27
0
int
main(int argc, char **argv)
{
	int nz;		/* numer of depth samples */
	int iz;		/* counter */
	int nt;		/* number of time samples */

	int nzpar;	/* number of getparred depth values for velocities */
	int nvpar;	/* number of getparred velocity values */
	int izpar;	/* counter */

	int verbose;	/* verbose flag, =0 silent, =1 chatty */

	float dz=0.0;	/* depth sampling interval */
	float fz=0.0;	/* first depth value */
	float dt=0.0;	/* time sampling interval for velocities */
	float ft=0.0;	/* first time value */
	float z=0.0;	/* depth values for times */
	float vmin=0.0;	/* minimum velocity */
	float vmax=0.0;	/* maximum velocity */

	float *zpar=NULL;	/* values of z getparred */
	float *vpar=NULL;	/* values of v getparred */
	float *vz=NULL;		/* v(z) velocity as a function of z */
	float *zt=NULL;		/* z(t) depth as a function of t */
	float *temp=NULL;	/* temporary storage array */
	char *vfile="";		/* name of the velocity file */

	/* hook up getpar */
	initargs(argc,argv);
	requestdoc(1);

	/* get time sampling from first header */
	if (!gettr(&tr)) err("can't get first trace");
	nz = tr.ns;

	/* get depth sampling */
	if (!getparfloat("dz",&dz)) dz = ((float) tr.d1);

	/* determine velocity function v(t) */
	vz = ealloc1float(nz);
	if (!getparstring("vfile",&vfile)) {
		nzpar = countparval("z");
		if (nzpar==0) nzpar = 1;
		zpar = ealloc1float(nzpar);
		if (!getparfloat("z",zpar)) zpar[0] = 0.0;
		nvpar = countparval("v");
		if (nvpar==0) nvpar = 1;
		if (nvpar!=nzpar)err("number of t and v values must be equal");
		vpar = ealloc1float(nvpar);
		if (!getparfloat("v",vpar)) vpar[0] = 1500.0;
		for (izpar=1; izpar<nzpar; ++izpar)
			if (zpar[izpar]<=zpar[izpar-1])
				err("zpar must increase monotonically");
		for (iz=0,z=0.0; iz<nz; ++iz,z+=dz)
			intlin(nzpar,zpar,vpar,vpar[0],vpar[nzpar-1],
				1,&z,&vz[iz]);
	} else { /* read from a file */
		if (fread(vz,sizeof(float),nz,fopen(vfile,"r"))!=nz)
			err("cannot read %d velocities from file %s",nz,vfile);
	}

	/* determine minimum and maximum velocities */
	for (iz=1,vmin=vmax=vz[0]; iz<nz; ++iz) {
		if (vz[iz]<vmin) vmin = vz[iz];
		if (vz[iz]>vmax) vmax = vz[iz];
	}

	/* get parameters */
	if (!getparfloat("dt",&dt)) dt = 2.0*dz/vmin;
	if (!getparfloat("ft",&ft)) ft = 2.0*ft/vz[0];
	if (!getparint("nt",&nt)) nt = 1+(nz-1)*dz*2.0/(dt*vmax);
	if (!getparint("verbose",&verbose)) verbose = 0;
	CHECK_NT("nt",nt);

	/* if requested, print time sampling, etc */
	if (verbose) {
		warn("Input:");
		warn("\tnumber of depth samples = %d",nz);
		warn("\tdepth sampling interval = %g",dz);
		warn("\tfirst depth sample = %g",fz);
		warn("Output:");
		warn("\tnumber of time samples = %d",nt);
		warn("\ttime sampling interval = %g",dt);
		warn("\tfirst time sample = %g",ft);
	}

	/* allocate workspace */
	zt = ealloc1float(nt);
	temp = ealloc1float(nz);

	/* make z(t) function */
	makezt(nz,dz,fz,vz,nt,dt,ft,zt);
	
	/* loop over traces */
	do {
		/* update header fields */
		tr.trid = TREAL;
		tr.ns = nt;
		tr.dt = dt*1000000.0;
		tr.f1 = ft;
		tr.d1 = 0.0;

		/* resample */
		memcpy((void *) temp, (const void *) tr.data,nz*sizeof(float));
		ints8r(nz,dz,fz,temp,0.0,0.0,nt,zt,tr.data);

		/* put this trace before getting another */
		puttr(&tr);

	} while(gettr(&tr));

	return(CWP_Exit());
}
Пример #28
0
int      main(int argc, char **argv)
{

   int i;  
   int j;  
   int bins;
   float min;
   float max;
   float bin;

   int* histogram;
    
   /* Initialize */
   initargs(argc, argv);
   requestdoc(1);

   /* Get info from first trace */
   if( !gettr(&tr) ){
      err("Can't get first trace \n");
   }

   /* Get parameters */
   if( !getparfloat("min", &min) ){
      err("min must be specified\n");
   }

   if( !getparfloat("max", &max) ){
      err("max must be specified\n");
   }

   if( !getparint("bins", &bins) ){
      err("bins must be specified\n");
   }

   bin = (max-min) / bins;

   histogram=emalloc( bins*sizeof(int) );

   /* Loop over traces */
   do{
      for( i=0; i<tr.ns; i++ ){

         j = (tr.data[i] - min) / bin;
         j = j < 0 ? 0 : j;
         j = j > bins-1 ? bins-1 : j;

         histogram[j]++;

      }

   }while( gettr(&tr) );

   for( i=0; i<bins; i++ ){

      printf( "%15f " ,min+i*bin    );
      printf( "%15d " ,histogram[i] );
      printf( "\n" );
   } 

   return (EXIT_SUCCESS);
}
Пример #29
0
int
main(int argc, char **argv)
{
	float ungpow;
	int nt;
	cwp_Bool isone, istwo;
	float f_one = 1.0;
	float f_two = 2.0;

	/* Initialize */
	initargs(argc, argv);
	requestdoc(1);


	/* Get info from first trace */
	if (!gettr(&tr)) err("can't get first trace");
	if (tr.trid != CHARPACK) err("Not char packed traces");
	nt = tr.ns;
	ungpow = tr.ungpow;
	isone = CLOSETO(ungpow, f_one);
	istwo = CLOSETO(ungpow, f_two);


	/* Main loop over segy traces */
	do {
		/* Point input char trace at the trace data and unpack.
		   Since the floats take more room than the chars,
		   we load in from back end.
		
		   Note that the segy field tr.data is declared as
		   floats, so we need to invent a pointer for the
		   char array which is actually there.
		*/

		register int i;
		register float val;
		register signed char *itr = (signed char *) tr.data;

		if (istwo) {
			for (i = nt-1; i >= 0; --i) { 
				val = (float) itr[i];
				val *= tr.unscale;
				tr.data[i] = val * ABS(val);
			}
		} else if (isone) {
			for (i = nt-1; i >= 0; --i) { 
				val = (float) itr[i];
				val *= tr.unscale;
				tr.data[i] = val;
			}
		} else {
			for (i = nt-1; i >= 0; --i) { 
				val = (float) itr[i];
				val *= tr.unscale;
				tr.data[i] = (val >= 0.0) ?
					pow(val, ungpow) : -pow(-val, ungpow);
			}
		}


		/* Mark as seismic data and remove now unnecessary fields */
		tr.trid = 1;
		tr.ungpow = 0.0;
		tr.unscale = 0.0;


		/* Write out restored (unpacked) segy */
		puttr(&tr);


	} while (gettr(&tr));


	return(CWP_Exit());
}
Пример #30
0
int
main(int argc, char **argv)
{
	int nx,nz,ix,iz,verbose;
	float tmp;
	float **c11,**c13,**c33,**c44,**vp,**vs,**rho,**eps, **delta;

	/* input files */
	char *c11_file, *c13_file, *c33_file, *c44_file;
	FILE *c11fp, *c13fp, *c33fp, *c44fp;

	/* output files */
	char *vp_file,*vs_file,*rho_file,*eps_file,*delta_file;
	FILE *vpfp,*vsfp,*rhofp,*epsfp,*deltafp;

	/* hook up getpar */
	initargs(argc, argv);
	requestdoc(1);

	/* get required parameters */
	MUSTGETPARINT("nx",  &nx );
	MUSTGETPARINT("nz",  &nz );

	/* get parameters */
	if (!getparstring("rho_file", &rho_file))       rho_file="rho.bin";
	if (!getparstring("c11_file", &c11_file))   	c11_file="c11.bin";
	if (!getparstring("c13_file", &c13_file))   	c13_file="c13.bin";
	if (!getparstring("c33_file", &c33_file))   	c33_file="c33.bin";
	if (!getparstring("c44_file", &c44_file))   	c44_file="c44.bin";
	if (!getparstring("vp_file", &vp_file))       	vp_file="vp.bin";
	if (!getparstring("vs_file", &vs_file))       	vs_file="vs.bin";
	if (!getparstring("eps_file", &eps_file))     	eps_file="eps.bin";
	if (!getparstring("delta_file", &delta_file)) 	delta_file="delta.bin";
	if (!getparint("verbose", &verbose))        	verbose = 1;
	

        checkpars();

	/* allocate space */
	rho	= alloc2float(nz,nx);
	c11	= alloc2float(nz,nx);
	c13	= alloc2float(nz,nx);
	c33	= alloc2float(nz,nx);
	c44	= alloc2float(nz,nx);
	vp	= alloc2float(nz,nx);
	vs	= alloc2float(nz,nx);
	eps	= alloc2float(nz,nx);
	delta   = alloc2float(nz,nx);



	/* read mandatory input files */
	rhofp = efopen(rho_file,"r");
	if (efread(*rho, sizeof(float), nz*nx, rhofp)!=nz*nx)
	  err("error reading rho_file=%s!\n",rho_file);

	c11fp = efopen(c11_file,"r");
	if (efread(*c11, sizeof(float), nz*nx, c11fp)!=nz*nx)
	  err("error reading c11_file=%s!\n",c11_file);

	c13fp = efopen(c13_file,"r");
	if (efread(*c13, sizeof(float), nz*nx, c13fp)!=nz*nx)
	  err("error reading c13_file=%s!\n",c13_file);

	c33fp = efopen(c33_file,"r");
	if (efread(*c33, sizeof(float), nz*nx, c33fp)!=nz*nx)
	  err("error reading c33_file=%s!\n",c33_file);

	c44fp = efopen(c44_file,"r");
	if (efread(*c44, sizeof(float), nz*nx, c44fp)!=nz*nx)
	  err("error reading c44_file=%s!\n",c44_file);

	fclose(rhofp);
	fclose(c11fp);
	fclose(c13fp);
	fclose(c33fp);
	fclose(c44fp);


	/* open output file: */
	vpfp = fopen(vp_file,"w");
	vsfp = fopen(vs_file,"w");
	epsfp = fopen(eps_file,"w");
	deltafp = fopen(delta_file,"w");


	/* loop over gridpoints and do calculations */
	for(ix=0; ix<nx; ++ix){
	      for(iz=0; iz<nz; ++iz){
		vp[ix][iz] = sqrt(c33[ix][iz]/rho[ix][iz]);
		vs[ix][iz] = sqrt(c44[ix][iz]/rho[ix][iz]);
		eps[ix][iz] = (c11[ix][iz]-c33[ix][iz])/(2*c33[ix][iz]);
		tmp = (c13[ix][iz]+c44[ix][iz])*(c13[ix][iz]+c44[ix][iz]);
		tmp = tmp - (c33[ix][iz]-c44[ix][iz])*(c33[ix][iz]-c44[ix][iz]);
		delta[ix][iz] = tmp/(2*c33[ix][iz]*(c33[ix][iz]-c44[ix][iz]));
	      }
	}

	/* write the output files to disk */
	efwrite(*vp,sizeof(float),nz*nx,vpfp);
	efwrite(*vs,sizeof(float),nz*nx,vsfp);
	efwrite(*eps,sizeof(float),nz*nx,epsfp);
	efwrite(*delta,sizeof(float),nz*nx,deltafp);
		if(verbose){
	  warn("Output file for vp : %s ",vp_file);
	  warn("Output file for vs : %s ",vs_file);
	  warn("Output file for epsilon : %s ",eps_file);
	  warn("Output file for delta : %s ",delta_file);
	}


	/* free workspace */
	free2float(vp);
	free2float(vs);
	free2float(rho);
	free2float(eps);
	free2float(delta);
	free2float(c11);
	free2float(c13);
	free2float(c33);
	free2float(c44);

	return(CWP_Exit());	
}