Example #1
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());
}
Example #2
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());
}
Example #3
0
main(int argc, char **argv)
{
	String key;	/* header key word from segy.h		*/
	String type;	/* ... its type				*/
	int index;	/* ... its index in hdr.h		*/
	Value val;	/* ... its value			*/
	void absval(String type, Value *valp);


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


	/* Get key parameter */
	if (!getparstring("key", &key))	key = KEY;

	file2g(stdin);
	file2g(stdout);

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

	while (gettr(&tr)) {
		gethval(&tr, index, &val);
		absval(type, &val);
		puthval(&tr, index, &val);
		puttr(&tr);
	}


	return EXIT_SUCCESS;
}
Example #4
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());

}
Example #5
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;
}
Example #6
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;
}
Example #7
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());
}
Example #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;
}
Example #9
0
int Application::main(int argc, char **argv) {
  app = new App(argc, argv);
  #if !defined(_WIN32)
  //Windows port uses 256x256 icon from resource file
  app->setWindowIcon(QIcon(":/bsnes.png"));
  #endif

  initargs(argc, argv);  //ensure argv[]s are in UTF-8 format
  initPaths(argv[0]);
  locateFile(configFilename = "bsnes.cfg", true);
  locateFile(styleSheetFilename = "style.qss", false);

  string customStylesheet;
  if(customStylesheet.readfile(styleSheetFilename) == true) {
    app->setStyleSheet((const char*)customStylesheet);
  } else {
    app->setStyleSheet(defaultStylesheet);
  }

  config.load(configFilename);
  init();
  snes.init();

  if(argc == 2) {
    //if valid file was specified on the command-line, attempt to load it now
    utility.loadCartridge(argv[1]);
  }

  while(terminate == false) {
    processEvents();
    utility.updateSystemState();
    inputManager.refresh();

    if(config.input.focusPolicy == Configuration::Input::FocusPolicyPauseEmulation) {
      bool inactive = (winMain->window->isActiveWindow() == false);
      if(!autopause && inactive) {
        autopause = true;
        audio.clear();
      } else if(autopause && !inactive) {
        autopause = false;
      }
    } else {
      autopause = false;
    }

    if(cartridge.loaded() && !pause && !autopause) {
      snes.runtoframe();
    } else {
      usleep(20 * 1000);
    }

    supressScreenSaver();
  }

  config.save(configFilename);
  return 0;
}
Example #10
0
main(int argc, char **argv)
{
	initargs(argc, argv);

	warn("%s: Test of warn", __FILE__);
	err("%s: Test of err", __FILE__);

	return EXIT_SUCCESS;
}
Example #11
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());
}
Example #12
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());
}
Example #13
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());
}
Example #14
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());
}
Example #15
0
main(int argc, char **argv)
{
	initargs(argc, argv);
	requestdoc(1);

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

	return EXIT_SUCCESS;
}
Example #16
0
main(int argc, char **argv)
{
	String output;
	bool asciiout = true;


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

	file2g(stdin);


	/* Argument count check */
	if (argc == 1)  err("must specify key(s) as command line arguments");


	/* Set and check output disposition (ascii or binary) */
	if (!getparstring("output", &output))   output = "ascii";
	if ((!STREQ(output, "ascii")) && (!STREQ(output, "binary")))
		err("output parameter=%s, must be ascii or binary", output);
	if (STREQ(output, "binary"))  asciiout = false;


	/* Loop over traces writing selected header field values */
	while (gettr(&tr)) {
		register int i;

		for (i = 1; i < argc; ++i) {
			String key = argv[i];
			Value val;

			/* discard command line parameter strings */
			if (STREQ(key, "output=ascii") ||
			    STREQ(key, "output=binary"))
				continue;

			gethdval(&tr, key, &val);
			if (asciiout) {  /* ascii output */
				printf("%6s=", key);
				printfval(hdtype(key), val);
				putchar('\t');
			} else {  /* binary output */
				float fval = vtof(hdtype(key), val);
				efwrite((char *) &fval, FSIZE, 1, stdout);
			}
		}

		if (asciiout)  printf("\n\n");
	}

	return EXIT_SUCCESS;
}
Example #17
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());
}
Example #18
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());
}
Example #19
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;
}
Example #20
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());
}
Example #21
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;
}
Example #22
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());
}
Example #23
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());
}
Example #24
0
int main(int argc, char *argv[])
{
    SDF *sdfp = NULL;
    FILE *fp = NULL;

    initargs(argc, argv, &sdfp, &fp);

    writeinit(fp);
    writescalars(sdfp, fp);
    writestructs(sdfp, fp);

    fclose(fp);
    SDFclose(sdfp);

    return 0;
}
Example #25
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());
}
Example #26
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());
}
Example #27
0
int main (int argc, char **argv) {

   short verbose;
   double part, wb, vzero, k, twt, t, depth;

   initargs(argc, argv);

   if (!getparshort("verbose" , &verbose)) verbose = 0;
   if (!getpardouble("wb", &wb)) {
      fprintf ( stderr, "Must input water-bottom (wb) parameter --> exiting" );
      return EXIT_FAILURE;
   }
   if (!getpardouble("twt", &twt)) {
      fprintf ( stderr, "Must input Two-Way Time (twt) parameter --> exiting" );
      return EXIT_FAILURE;
   }
   if (!getpardouble("vzero", &vzero)) {
      fprintf ( stderr, "Must input VZERO (vzero) parameter --> exiting" );
      return EXIT_FAILURE;
   }
   if (!getpardouble("depth", &depth)) {
      fprintf ( stderr, "Must input DEPTH (depth) parameter --> exiting" );
      return EXIT_FAILURE;
   }

   if ( verbose ) {
      fprintf ( stderr, "\n" );
      fprintf ( stderr, "Water-Bottm = %f\n", wb );
      fprintf ( stderr, "TWT = %f\n", twt );
      fprintf ( stderr, "VZERO = %f\n", vzero );
      fprintf ( stderr, "DEPTH = %f\n", depth );
      fprintf ( stderr, "\n" );
   }

   t = ( twt * 0.0005 ) - ( wb / vzero );
   part = vzero * exp ( t );
   k = -1.0 * ( vzero / ( depth - part - wb ) );

   printf ( "K = %.15f\n", k );

   k = 0.48;

   fprintf ( stderr, "DEPTH check = %f\n", (vzero/k) * ( exp ( k * t ) - 1 ) + wb );

   return EXIT_SUCCESS;
}
Example #28
0
int Application::main(int &argc, char **argv) {
  app = new App(argc, argv);
  #if !defined(PLATFORM_WIN)
  //Windows port uses 256x256 icon from resource file
  app->setWindowIcon(QIcon(":/bsnes.png"));
  #endif

  initargs(argc, argv);  //ensure argv[]s are in UTF-8 format
  initPaths(argv[0]);
  locateFile(configFilename = "bsnes.cfg", true);
  locateFile(styleSheetFilename = "style.qss", false);

  string customStylesheet;
  if(customStylesheet.readfile(styleSheetFilename) == true) {
    app->setStyleSheet((const char*)customStylesheet);
  } else {
    app->setStyleSheet(defaultStylesheet);
  }

  config().load(configFilename);
  mapper().bind();
  init();
  SNES::system.init(&interface);
  mainWindow->system_loadSpecial_superGameBoy->setVisible(SNES::supergameboy.opened());

  if(argc == 2) {
    //if valid file was specified on the command-line, attempt to load it now
    cartridge.loadNormal(argv[1]);
  }

  timer = new QTimer(this);
  connect(timer, SIGNAL(timeout()), this, SLOT(run()));
  timer->start(0);
  app->exec();

  //QbWindow::close() saves window geometry for next run
  for(unsigned i = 0; i < windowList.size(); i++) {
    windowList[i]->close();
  }

  cartridge.unload();
  config().save(configFilename);
  return 0;
}
Example #29
0
main(int argc, char **argv)
{
    int n1,i1,n2,i2;
    float *trace;
    float tmp;
    float fama,fami;
    FILE *infp=stdin;
    long long l2; 

    /* get parameters */
    initargs(argc,argv);
    askdoc(1);

    if (!getparint("n1",&n1)) err("must specify n1! \n");

    if (!getparint("n2",&n2)) 
      {
      fseek2g(infp,0L,2);
      l2 = ftell2g(infp);
      l2 = l2/sizeof(float)/n1;
      n2 = l2;
      fseek2g(infp,0L,0);
      }
    trace = (float*)malloc(n1*sizeof(float));
    for (i2=0;i2<n2;i2++)
       {
       fread(trace,sizeof(float),n1,infp);
       if (i2==0) 
	  {
	  tmp = trace[0];
	  if ( tmp < 0. ) tmp = - tmp;
	  fama = tmp;
	  fami = tmp;
	  }
       for(i1=0;i1<n1;i1++)  
	{
	tmp = trace[i1]; if(tmp < 0. ) tmp = -tmp;
	if ( fama < tmp ) fama = tmp;
	if ( fami > tmp ) fami = tmp;
	}
       }
    printf("max abs value= %f \n",fama); 
    printf("min abs value= %f \n",fami); 
}
Example #30
0
main(int argc, char **argv)
{

	segytrace tr;

	FILE *infp=stdin, *outfp=stdout;
	int it, nt;
	float *im, tmp1, tmp2, i0;


    	/* get parameters */
    	initargs(argc,argv);
    	askdoc(1);

	if(!getparfloat("i0",&i0)) err("must specify i0");

	/* large file(s) */
	file2g(infp);
	file2g(outfp);
	
        if (!fgettr(infp,&tr))  err("can't get first trace");
	nt = tr.ns;

	im = (float*) emalloc(nt*sizeof(float));

	do {
		im[0] = i0;
		for(it=1;it<nt;it++) {
			tmp1 = 1. - tr.data[it-1];
			tmp2 = 1. + tr.data[it-1];
			if(tmp1==0.) {
				im[it] = im[it-1];
			} else {
				im[it] = tmp2/tmp1*im[it-1];
			}
		}
		for(it=0;it<nt;it++) tr.data[it] = im[it];
		fputtr(outfp,&tr);
	} while(fgettr(infp,&tr));

	return 0;

}