pswigb.c

来自「su 的源代码库」· C语言 代码 · 共 482 行 · 第 1/2 页

C
482
字号
/* Copyright (c) Colorado School of Mines, 2006.*//* All rights reserved.                       *//* PSWIGB: $Revision: 1.25 $ ; $Date: 2004/12/01 16:36:24 $	*/#include "par.h"#include "psplot.h"/*********************** self documentation **********************/char *sdoc[] = {" 									"," PSWIGB - PostScript WIGgle-trace plot of f(x1,x2) via Bitmap		"," Best for many traces.  Use PSWIGP (Polygon version) for few traces.	"," 									"," pswigb n1= [optional parameters] <binaryfile >postscriptfile		"," 									"," Required Parameters:							"," n1                     number of samples in 1st (fast) dimension	"," 									"," Optional Parameters:							"," d1=1.0                 sampling interval in 1st dimension		"," f1=0.0                 first sample in 1st dimension			"," n2=all                 number of samples in 2nd (slow) dimension	"," d2=1.0                 sampling interval in 2nd dimension		"," f2=0.0                 first sample in 2nd dimension			"," x2=f2,f2+d2,...        array of sampled values in 2nd dimension	"," bias=0.0               data value corresponding to location along axis 2"," perc=100.0             percentile for determining clip		"," clip=(perc percentile) data values < bias+clip and > bias-clip are clipped"," xcur=1.0               wiggle excursion in traces corresponding to clip"," wt=1                   =0 for no wiggle-trace; =1 for wiggle-trace	"," va=1                   =0 for no variable-area; =1 for variable-area fill","                        =2 for variable area, solid/grey fill          ","                        SHADING: 2<= va <=5  va=2 lightgrey, va=5 black", " nbpi=72                number of bits per inch at which to rasterize	"," verbose=1              =1 for info printed on stderr (0 for no info)	"," xbox=1.5               offset in inches of left side of axes box	"," ybox=1.5               offset in inches of bottom side of axes box	"," wbox=6.0               width in inches of axes box			"," hbox=8.0               height in inches of axes box			"," x1beg=x1min            value at which axis 1 begins			"," x1end=x1max            value at which axis 1 ends			"," d1num=0.0              numbered tic interval on axis 1 (0.0 for automatic)"," f1num=x1min            first numbered tic on axis 1 (used if d1num not 0.0)"," n1tic=1                number of tics per numbered tic on axis 1	"," grid1=none             grid lines on axis 1 - none, dot, dash, or solid"," label1=                label on axis 1				"," x2beg=x2min            value at which axis 2 begins			"," x2end=x2max            value at which axis 2 ends			"," d2num=0.0              numbered tic interval on axis 2 (0.0 for automatic)"," f2num=x2min            first numbered tic on axis 2 (used if d2num not 0.0)"," n2tic=1                number of tics per numbered tic on axis 2	"," grid2=none             grid lines on axis 2 - none, dot, dash, or solid"," label2=                label on axis 2				"," labelfont=Helvetica    font name for axes labels			"," labelsize=18           font size for axes labels			"," title=                 title of plot					"," titlefont=Helvetica-Bold font name for title				"," titlesize=24           font size for title				"," titlecolor=black       color of title					"," axescolor=black        color of axes					"," gridcolor=black        color of grid					"," axeswidth=1            width (in points) of axes			"," ticwidth=axeswidth     width (in points) of tic marks		"," gridwidth=axeswidth    width (in points) of grid lines		"," style=seismic          normal (axis 1 horizontal, axis 2 vertical) or	","                        seismic (axis 1 vertical, axis 2 horizontal)	"," interp=0		 no display interpolation			","			 =1 use 8 point sinc interpolation		"," curve=curve1,curve2,...  file(s) containing points to draw curve(s)   "," npair=n1,n2,n2,...            number(s) of pairs in each file         "," curvecolor=black,..    color of curve(s)                              "," curvewidth=axeswidth   width (in points) of curve(s)                  "," 									"," Notes: 								"," The interp option may be useful for high nbpi values, however, it	"," tacitly assumes that the data are purely oscillatory.	Non-oscillatory	"," data will not be represented correctly when this option is set.	"," 									"," The curve file is an ascii file with the points specified as x1 x2	"," pairs, one pair to a line.  A \"vector\" of curve files and curve	"," colors may be specified as curvefile=file1,file2,etc. and 		"," curvecolor=color1,color2,etc, and the number of pairs of values in each"," file as npair=npair1,npair2,... .					","									"," All color specifications may also be made in X Window style Hex format"," example:   axescolor=#255						","									",NULL};/**************** end self doc ********************************//* * * AUTHOR:  Dave Hale, Colorado School of Mines, 05/29/90 * MODIFIED:  Craig Artley, Colorado School of Mines, 08/30/91 *          BoundingBox moved to top of PostScript output * MODIFIED:  Craig Artley, Colorado School of Mines, 12/16/93 *          Added color options (Courtesy of Dave Hale, Advance Geophysical). * Modified: Morten Wendell Pedersen, Aarhus University, 23/3-97 *           Added ticwidth,axeswidth, gridwidth parameters  * MODIFIED:  Brian K. Macy, Phillips Petroleum, 01/14/99 *            Added curve plotting option * MODIFIED:  P. Michaels, Boise State Univeristy  29 December 2000 *            Added solid/grey color scheme for peaks/troughs */int main (int argc, char **argv){	int n1,n2,nbpi,n1tic,n2tic,nfloats,wt,va,bbox[4],		i2,grid1,grid2,style,		n1bits,n2bits,nbpr,i1beg,i1end,if1r,n1r,		b1fz,b1lz,n2in,nz,iz,i,nbytes,verbose,endian=CWPENDIAN, interp;	float labelsize,titlesize,bias,perc,clip,xcur,		d1,f1,d2,f2,*x2,*z,		xbox,ybox,wbox,hbox,		x1beg,x1end,x2beg,x2end,		x1min,x1max,x2min,x2max,		d1num,f1num,d2num,f2num,		*temp,p2beg,p2end,matrix[6],		bscale,boffset,bxcur,bx2;	float axeswidth, ticwidth, gridwidth;	unsigned char *bits;	char *label1="",*label2="",*title="",		*labelfont="Helvetica",*titlefont="Helvetica-Bold",		*styles="seismic",*grid1s="none",*grid2s="none",		*titlecolor="black",*axescolor="black",*gridcolor="black";	FILE *infp=stdin;	float **x1curve=NULL,**x2curve=NULL,*curvewidth=NULL;	int j,curve=0,*npair=NULL,ncurvecolor=0,ncurvewidth=0;	char **curvecolor=NULL,**curvefile=NULL;	FILE *curvefp=NULL;	cwp_Bool is_curve = cwp_false;	/* initialize getpar */	initargs(argc,argv);	requestdoc(1);	/* get parameters describing 1st dimension sampling */	if (!getparint("n1",&n1))		err("Must specify number of samples in 1st dimension!\n");	d1 = 1.0;  getparfloat("d1",&d1);	f1 = 0.0;  getparfloat("f1",&f1);	x1min = (d1>0.0)?f1:f1+(n1-1)*d1;	x1max = (d1<0.0)?f1:f1+(n1-1)*d1;	/* get parameters describing 2nd dimension sampling */	if ((n2=countparval("x2"))==0 && !getparint("n2",&n2)) {			if (efseeko(infp,(off_t) 0,SEEK_END)!=0)				err("must specify n2 if in a pipe!\n");			nfloats =(int) (eftello(infp)/((off_t) sizeof(float)));			efseeko(infp,(off_t) 0,SEEK_SET);			n2 = nfloats/n1;	}	x2 = ealloc1float(n2);	if (!getparfloat("x2",x2)) {		d2 = 1.0;  getparfloat("d2",&d2);		f2 = 0.0;  getparfloat("f2",&f2);		for (i2=0; i2<n2; i2++)			x2[i2] = f2+i2*d2;	}	for (i2=1,x2min=x2max=x2[0]; i2<n2; i2++) {		x2min = MIN(x2min,x2[i2]);		x2max = MAX(x2max,x2[i2]);	}	/* set up curve plotting */	if ((curve=countparval("curve"))!=0) {		curvefile=(char**)ealloc1(curve,sizeof(void*));		getparstringarray("curve",curvefile);		if ((x1curve=(float**)malloc(curve*sizeof(void*)))==NULL)			err("Could not allocate x1curve pointers\n");		if ((x2curve=(float**)malloc(curve*sizeof(void*)))==NULL)			err("Could not allocate x2curve pointers\n");		npair=ealloc1int(curve);		getparint("npair",npair);		is_curve = cwp_true;	} else {		npair=(int *)NULL;		curvefile=(char **)NULL;		x1curve=(float **)NULL;		x2curve=(float **)NULL;		is_curve = cwp_false;	}	if (is_curve) {	if ((ncurvecolor=countparval("curvecolor"))<curve) {		curvecolor=(char**)ealloc1(curve,sizeof(void*));		if (!getparstringarray("curvecolor",curvecolor)) {			curvecolor[0]=(char *)cwp_strdup("black\0");			ncurvecolor=1;		}		for (i=ncurvecolor; i<curve; i++)			curvecolor[i]=(char *)cwp_strdup(curvecolor[ncurvecolor-1]);	} else if (ncurvecolor){		curvecolor=(char**)ealloc1(ncurvecolor,sizeof(void*));		getparstringarray("curvecolor",curvecolor);	}	 for (j=0; j<curve; j++) {		curvefp=efopen(curvefile[j],"r");		x1curve[j]=ealloc1float(npair[j]);		x2curve[j]=ealloc1float(npair[j]);		for (i=0; i<npair[j]; i++) {			fscanf(curvefp,"%f",&x1curve[j][i]);			fscanf(curvefp,"%f",&x2curve[j][i]);		}		efclose(curvefp);	 }	}	/* read binary data to be plotted */	nz = n1*n2;	z = ealloc1float(nz);	if (fread(z,sizeof(float),nz,infp)!=nz)		err("error reading input file!\n");	/* if necessary, subtract bias */	if (getparfloat("bias",&bias) && bias!=0.0)		for (iz=0; iz<nz; iz++)			z[iz] -= bias;	/* if necessary, determine clip from percentile */	if (!getparfloat("clip",&clip)) {		perc = 100.0;  getparfloat("perc",&perc);		temp = ealloc1float(nz);		for (iz=0; iz<nz; iz++)			temp[iz] = fabs(z[iz]);		iz = (nz*perc/100.0);		if (iz<0) iz = 0;		if (iz>nz-1) iz = nz-1;		qkfind(iz,nz,temp);		clip = temp[iz];		free1float(temp);	}	verbose = 1;  getparint("verbose",&verbose);	if (verbose) warn("clip=%g\n",clip);	/* get wiggle-trace-variable-area parameters */	wt = 1;  getparint("wt",&wt);	va = 1;  getparint("va",&va);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?