Exemple #1
0
void fillcircle(float x, float y, int ci){
  float xpts[40], ypts[40];
  for (int i=0;i<40;i++){
    xpts[i]=x+0.01*cos(2.0*M_PI*i/40);
    ypts[i]=y+0.01*sin(2.0*M_PI*i/40);
  }
  cpgsfs(1);
  cpgsci(ci);
  cpgpoly(40,xpts,ypts);
  cpgsfs(2);
  cpgsci(1);
  cpgpoly(40,xpts,ypts);
}
Exemple #2
0
int plotregion::erase(float dx1, float dx2, float dy1, float dy2){
  cpgsfs(1);
  cpgsci(0);
  cpgsvp(0.0,1.0,0.0,1.0);
  cpgswin(0.0,1.0,0.0,1.0);
  cpgrect(xmin-dx1,xmax+dx2,ymin-dy1,ymax+dy2);
  cpgsci(1);
  return (0);
}
Exemple #3
0
int plotregion::erase(){
  cpgsfs(1);
  cpgsci(0);
  cpgsvp(0.0,1.0,0.0,1.0);
  cpgswin(0.0,1.0,0.0,1.0);
  cpgrect(xmin-0.065,xmax,ymin-0.1,ymax+0.025);
  cpgsci(1);
  return (0);
}
Exemple #4
0
void markcatobj(Secat object)
{
  cpgsci(2);
  cpgsfs(2);
  cpgslw(3);
  cpgcirc(object.x,object.y,3.0*object.fwhm);
  cpgsci(1);
  cpgslw(1);
}
Exemple #5
0
void Plotter2::resetAttributes(const Plotter2ViewportInfo& vi) {
    cpgstbg(0); // reset background colour to the initial one (white)
    cpgsci(1);  // reset foreground colour to the initial one (black)
    cpgsls(1);  // reset line style to solid
    cpgslw(1);  // reset line width to 1
    cpgscf(1);  // reset font style to normal
    cpgsch(vi.fontSizeDef);// reset font size
    cpgsfs(1);  // reset fill style (solid)
}
Exemple #6
0
static void demo3()
{
#define TWOPI (2.0*3.14159265)
#define NPOL  6
  
  int i, j, k;
  int n1[] = {3, 4, 5, 5, 6, 8};
  int n2[] = {1, 1, 1, 2, 1, 3};
  float x[10], y[10], y0;
  
  char* lab[] =  {"Fill style 1 (solid)",
		  "Fill style 2 (outline)",
		  "Fill style 3 (hatched)",
		  "Fill style 4 (cross-hatched)"};
  
/* Initialize the viewport and window. */

  cpgbbuf();
  cpgsave();
  cpgpage();
  cpgsvp(0.0, 1.0, 0.0, 1.0);
  cpgwnad(0.0, 10.0, 0.0, 10.0);
  
/* Label the graph. */

  cpgsci(1);
  cpgmtxt("T", -2.0, 0.5, 0.5, 
          "PGPLOT fill area: routines cpgpoly(), cpgcirc(), cpgrect()");
  
/* Draw assorted polygons. */

  for (k=1; k<5; k++) {
    cpgsci(1);
    y0 = 10.0 -2.0*k;
    cpgtext(0.2, y0+0.6, lab[k-1]);
    cpgsfs(k);
    for (i=0; i<NPOL; i++) {
      cpgsci(i+1);
      for (j=0; j<n1[i]; j++) {
	x[j] = i+1 + 0.5*cos(n2[i]*TWOPI*j/n1[i]);
	y[j] = y0 + 0.5*sin(n2[i]*TWOPI*j/n1[i]);
      }
      cpgpoly(n1[i], x, y);
    }
    cpgsci(7);
    cpgshs(0.0, 1.0, 0.0);
    cpgcirc(7.0, y0, 0.5);
    cpgsci(8);
    cpgshs(-45.0, 1.0, 0.0);
    cpgrect(7.8, 9.5, y0-0.5, y0+0.5);
  }
  cpgunsa();
  cpgebuf();
  return;
}
Exemple #7
0
int check::draw(){

  if (on) {
    cpgsci(2);
    cpgsfs(1);
    cpgrect(xmin,xmax,ymin,ymax);
    cpgsci(1);
    cpgsfs(2);
    cpgrect(xmin,xmax,ymin,ymax);
  }
  else{
    cpgsci(0);
    cpgsfs(1);
    cpgrect(xmin,xmax,ymin,ymax);
    cpgsci(1);
    cpgsfs(2);
    cpgrect(xmin,xmax,ymin,ymax);
  }
  cpgtext(x+0.05,y,label);
  return(0);
}
Exemple #8
0
int button::draw(){
cpgsvp(0.0,1.0,0.0,1.0);
cpgswin(0.0,1.0,0.0,1.0);
cpgsfs(2);

float xl, yl;
cpglen(4,label,&xl,&yl);
xmin = x-2.0*0.005; 
xmax = x + xl + 2.0 * 0.005;
ymin = y-2.0*0.005;
ymax = y+0.015 + 2.0 * 0.005;

cpgsci(1);
cpgrect(x-0.005, x+xl+0.005, y-0.005, y+0.015 + 0.005);
cpgrect(x-2.0*0.005, x+xl+2.0*0.005, y-2.0*0.005, y+0.015 + 2.0*0.005);
cpgtext(x,y,label);
 return(0);
}
/*
 * Class:     pulsarhunter_PgplotInterface
 * Method:    pgsfs
 * Signature: (I)V
 */
JNIEXPORT void JNICALL Java_pulsarhunter_PgplotInterface_pgsfs
  (JNIEnv *env, jclass cl, jint v){
	cpgsfs(v);
}
Exemple #10
0
int main(){
	printf("\n====================================================================\n");
	printf("This program is able to simulate the diffusion of heat\n");
	printf("across a metal plate of size %i x %i\n", ENV_SIZE_X, ENV_SIZE_Y);
	printf("====================================================================\n");

	//==========================================================================
	//--------------------------SYSTEM INITIALIZATIONS--------------------------
	//==========================================================================
	
	// initialize random seed
	srand(time(NULL));

	// force print all outputs (remove stdout buffer)
	setbuf(stdout, NULL);

	// initialize pgplot window
	if (!cpgopen("/XWINDOW"))
		errorCase(ERR_PGPLOT);

	cpgpap(0.0, 0.6);						// set window size
	cpgsubp(1,3);						// subdivide window into panels
	// heatmap
	cpgpanl(1,1);
	cpgsvp(0.0, 1.0, 0.0, 1.0);
	cpgswin(0, ENV_SIZE_X, 0, ENV_SIZE_Y);
	// flux plot
	cpgpanl(1,2);
	cpgsvp(0.08, 0.92, 0.08, 0.92);
	cpgswin(LINE_PLOT_X1, LINE_PLOT_X2, FLUX_PLOT_Y1, FLUX_PLOT_Y2);
	cpgbox("ABCINTS", 0.0, 0, "ABCINTS", 0.0, 0);
	cpglab("Time", "Flux", "");
	// heat plot
	cpgpanl(1,3);
	cpgsvp(0.08, 0.92, 0.08, 0.92);
	cpgswin(LINE_PLOT_X1, LINE_PLOT_X2, LINE_PLOT_Y1, LINE_PLOT_Y2);
	cpgbox("ABCINTS", 0.0, 0, "ABCINTS", 0.0, 0);
	cpglab("Time", "Total Heat", "");

	// initialize color table for pgplot display
  	float rl[9] = {-0.5, 0.0, 0.17, 0.33, 0.50, 0.67, 0.83, 1.0, 1.7};
  	float rr[9] = { 0.0, 0.0,  0.0,  0.0,  0.6,  1.0,  1.0, 1.0, 1.0};
  	float rg[9] = { 0.0, 0.0,  0.0,  1.0,  1.0,  1.0,  0.6, 0.0, 1.0};
  	float rb[9] = { 0.0, 0.3,  0.8,  1.0,  0.3,  0.0,  0.0, 0.0, 1.0};
  	cpgctab(rl, rr, rg, rb, 512,  1.0, 0.5);
	cpgscr(10, 0.0, 0.0, 1.0);
	cpgscr(11, 1.0, 0.0, 0.0);
	cpgsfs(3);


	//==========================================================================
	//--------------------------VARIABLE INITIALIZATIONS------------------------
	//==========================================================================

	// generic variables
	int i, j, k;						// counters

	// simulation environment
	float** simEnvEven = allocateArray2D(ENV_SIZE_X, ENV_SIZE_Y);
	float** simEnvOdd = allocateArray2D(ENV_SIZE_X, ENV_SIZE_Y);
	float* simLocal = allocateArray1D(5);

	// mnist handwritten numbers
	float** mnistDatabase = readCSV("mnist_train_100.csv", 100, 785);
	for (i=0; i<100; i++)
		for (j=0; j<785; j++)
			mnistDatabase[i][j] = mnistDatabase[i][j]/255.0;

	// current location and time
	int x,y,z;
	int t, tGlobal;

	// student number
	int studentNumbRaw;
	int studentNumbWorking;
	int studentNumb[7];

	// rates
	float rateDiff = 0.2;
	float delta;

	// flux variables
	float flux;
	float fluxTotal;
	float fluxAverage;
	float fluxHeat;
	float totalHeat;
	int x1, x2, y1, y2;

	// background heat
	float bgHeat;

	// tracking variables
	float totalHeatOld;
	float totalHeatPre;
	float tGlobalOld;
	float fluxOld;

	// pgplot variables
	float* plotImg = allocateArray1D(ENV_SIZE_TOTAL);
	float TR[6] = {0, 0, 1, ENV_SIZE_Y, -1, 0};
	float plotMinBound = 0;
	float plotMaxBound = 1;

	//==========================================================================
	//--------------------------------SETUP-------------------------------------
	//==========================================================================
	
	// ask for student number
	printf("Please enter your student number:\n");
	if (scanf("%i", &studentNumbRaw) == 0)
		errorCase(ERR_INVALID_INPUT);
	studentNumbWorking = studentNumbRaw;
	for (i=0; i<SN_LENGTH; i++){
		studentNumb[6-i] = studentNumbWorking%10;
		studentNumbWorking /= 10;
	}
	printf("\nYour student number is:\n");
	for (i=0; i<SN_LENGTH; i++)
		printf("%i", studentNumb[i]);
	printf("\n\n");

	// set and print diffusion rate based on last digit of student number
	rateDiff = ((((float)(studentNumb[6]))/10.0)*0.19)+0.01;
	printf("Your Diffusion Rate is: \n%f\n\n", rateDiff);

	// set and print background heat added based on last 4 digits of student number
	studentNumbRaw -= 1410000;
	bgHeat = ((float)((studentNumbRaw%97)%10));
	bgHeat += ((float)((studentNumbRaw%101)%8))*10;
	bgHeat /= 100;
	printf("Your Background Heat is: \n%f\n\n", bgHeat*100);

	// set and print domain for calculating flux
	// x1, y1 based on last four digits of student number
	x1 = studentNumbRaw % ENV_SIZE_X;
	y1 = studentNumbRaw % ENV_SIZE_Y;
	// x2, y2 based on last four digits of student number
	x2 = x1 + (studentNumbRaw % (97));
	if (x2 >= ENV_SIZE_X)
		x2 = ENV_SIZE_X - 1;
	y2 = y1 + (studentNumbRaw % (29));
	if (y2 >= ENV_SIZE_Y)
		y2 = ENV_SIZE_Y - 1;
	printf("Your Domain is: \n(%i, %i) X (%i, %i)\n\n", x1, y1, x2, y2);

	// environment initialization:
	// select digits and place into environment
	for (i=0; i<SN_LENGTH; i++){
		if (studentNumb[i] == 0)
			z = 0;
		else if (studentNumb[i] == 1)
			z = 13;
		else if (studentNumb[i] == 2)
			z = 27;
		else if (studentNumb[i] == 3)
			z = 33;
		else if (studentNumb[i] == 4)
			z = 44;
		else if (studentNumb[i] == 5)
			z = 55;
		else if (studentNumb[i] == 6)
			z = 60;
		else if (studentNumb[i] == 7)
			z = 71;
		else if (studentNumb[i] == 8)
			z = 81;
		else
			z = 89;

		for (x=0; x<28; x++)
			for (y=0; y<28; y++) {
				simEnvEven[x+(i*28)+1][y+1] = mnistDatabase[z][y*28+x] + bgHeat;
				if (simEnvEven[x+(i*28)+1][y+1] > 1.0)
					simEnvEven[x+(i*28)+1][y+1] = 1.0;
			}
	}


	//==========================================================================
	//--------------------------ACTUAL CODE-------------------------------------
	//==========================================================================

	// initialize display
	fixBoundaryConditions(simEnvEven);
	copyArray2D(simEnvEven, simEnvOdd, ENV_SIZE_X, ENV_SIZE_Y);
	loadImage(simEnvEven, plotImg);
	cpgpanl(1,1);
	cpgsvp(0.0, 1.0, 0.0, 1.0);
	cpgswin(0, ENV_SIZE_X, 0, ENV_SIZE_Y);
	cpgimag(plotImg, ENV_SIZE_Y, ENV_SIZE_X, 1, ENV_SIZE_Y, 1, ENV_SIZE_X, plotMinBound, plotMaxBound, TR);
	cpgrect(x1, x2, y1, y2);

	// initialize trackers
	tGlobalOld = 0;
	fluxOld = 0;
	totalHeatOld = 0;
	for (x=x1; x<=x2; x++)
		for (y=y1; y<=y2; y++)
			totalHeatOld += simEnvEven[x][y];

	// initial delay to visualize starting matrix
	for (t=0; t<500000000; t++){}
	
	t = 0;
	tGlobal = 0;
	flux = 0;
	fluxAverage = 0;
	fluxTotal = 0;
	while(1){
		flux = 0;
		cpgpanl(1,1);
		cpgsvp(0.0, 1.0, 0.0, 1.0);
		cpgswin(0, ENV_SIZE_X, 0, ENV_SIZE_Y);

		// calculate heat changes using numeric methods
		fixBoundaryConditions(simEnvEven);

		//simEnvEven[50][15] = 100;
		//simEnvEven[60][15] = -10;

		copyArray2D(simEnvEven, simEnvOdd, ENV_SIZE_X, ENV_SIZE_Y);

		for (x=1; x<(ENV_SIZE_X-1); x++)
			for (y=1; y<(ENV_SIZE_Y-1); y++)
				if ((x+y)%2 == 0) {
					delta = rateDiff*(simEnvEven[x][y+1] - 2*simEnvEven[x][y] + simEnvEven[x][y-1]);
					simEnvOdd[x][y] += delta;
					if (INSIDE_BOX)
						flux += delta;
					delta = rateDiff*(simEnvEven[x+1][y] - 2*simEnvEven[x][y] + simEnvEven[x-1][y]);
					simEnvOdd[x][y] += delta;
					if (INSIDE_BOX)
						flux += delta;
				}
		for (x=1; x<(ENV_SIZE_X-1); x++)
			for (y=1; y<(ENV_SIZE_Y-1); y++)
				if ((x+y)%2 == 1) {
					delta = rateDiff*(simEnvOdd[x][y+1] - 2*simEnvOdd[x][y] + simEnvOdd[x][y-1]);
					simEnvOdd[x][y] += delta;
					if (INSIDE_BOX)
						flux += delta;
					delta = rateDiff*(simEnvOdd[x+1][y] - 2*simEnvOdd[x][y] + simEnvOdd[x-1][y]);
					simEnvOdd[x][y] += delta;
					if (INSIDE_BOX)
						flux += delta;
				}
		loadImage(simEnvOdd, plotImg);
		cpgimag(plotImg, ENV_SIZE_Y, ENV_SIZE_X, 1, ENV_SIZE_Y, 1, ENV_SIZE_X, plotMinBound, plotMaxBound, TR);
		cpgrect(x1, x2, y1, y2);
		fluxTotal += flux;
		tGlobal++;

		flux = 0;

		//simEnvOdd[50][15] = 100;
		//simEnvOdd[60][15] = -10;

		fixBoundaryConditions(simEnvOdd);
		
		for (x=1; x<(ENV_SIZE_X-1); x++)
			for (y=1; y<(ENV_SIZE_Y-1); y++)
				if ((x+y)%2 == 1) {
					delta = rateDiff*(simEnvOdd[x][y+1] - 2*simEnvOdd[x][y] + simEnvOdd[x][y-1]);
					simEnvEven[x][y] += delta;
					if (INSIDE_BOX)
						flux += delta;
					delta = rateDiff*(simEnvOdd[x+1][y] - 2*simEnvOdd[x][y] + simEnvOdd[x-1][y]);
					simEnvEven[x][y] += delta;
					if (INSIDE_BOX)
						flux += delta;
				}
		for (x=1; x<(ENV_SIZE_X-1); x++)
			for (y=1; y<(ENV_SIZE_Y-1); y++)
				if ((x+y)%2 == 0) {
					delta = rateDiff*(simEnvEven[x][y+1] - 2*simEnvEven[x][y] + simEnvEven[x][y-1]);
					simEnvEven[x][y] += delta;
					if (INSIDE_BOX)
						flux += delta;
					delta = rateDiff*(simEnvEven[x+1][y] - 2*simEnvEven[x][y] + simEnvEven[x-1][y]);
					simEnvEven[x][y] += delta;
					if (INSIDE_BOX)
						flux += delta;
				}
		loadImage(simEnvEven, plotImg);
		cpgimag(plotImg, ENV_SIZE_Y, ENV_SIZE_X, 1, ENV_SIZE_Y, 1, ENV_SIZE_X, plotMinBound, plotMaxBound, TR);
		cpgrect(x1, x2, y1, y2);
		fluxTotal += flux;
		tGlobal++;



		// flux line plot
		cpgpanl(1,2);
		cpgsvp(0.08, 0.92, 0.08, 0.92);
		cpgswin(LINE_PLOT_X1, LINE_PLOT_X2, FLUX_PLOT_Y1, FLUX_PLOT_Y2);
		cpgmove(tGlobalOld, fluxOld);
		cpgdraw(tGlobal, flux);

		// heat line plot
		totalHeat = 0;
		for (x=x1; x<=x2; x++)
			for (y=y1; y<=y2; y++)
				totalHeat += simEnvEven[x][y];
		cpgpanl(1,3);
		cpgsvp(0.08, 0.92, 0.08, 0.92);
		cpgswin(LINE_PLOT_X1, LINE_PLOT_X2, LINE_PLOT_Y1, LINE_PLOT_Y2);
		cpgmove(tGlobalOld, totalHeatOld);
		cpgdraw(tGlobal, totalHeat);

		// set trackers
		tGlobalOld = tGlobal;
		totalHeatOld = totalHeat;
		fluxOld = flux;

		if (tGlobal%100 == 0) {
			totalHeat = 0;
			for (x=x1; x<=x2; x++)
				for (y=y1; y<=y2; y++)
					totalHeat += simEnvEven[x][y];
			fluxAverage = fluxTotal/tGlobal;
			fluxHeat = totalHeat - totalHeatPre;
			printf("Total Heat: %f \n Current Divergence: %f \n Current Flux:       %f\n\n", totalHeat, flux, fluxHeat);
		}

		totalHeatPre = 0;
		for (x=x1; x<=x2; x++)
			for (y=y1; y<=y2; y++)
				totalHeatPre += simEnvEven[x][y];
	}
}
Exemple #11
0
void Plotter2::plot() {
    open();

    if ((width > 0.0) && (aspect > 0.0)) {
        cpgpap(width, aspect);
    }

    cpgscr(0, 1.0, 1.0, 1.0); // set background color white
    cpgscr(1, 0.0, 0.0, 0.0); // set foreground color black

    for (unsigned int i = 0; i < vInfo.size(); ++i) {
        Plotter2ViewportInfo vi = vInfo[i];

	if (vi.showViewport) {
	    resetAttributes(vi);

	    // setup viewport
            cpgsvp(vi.vpPosXMin, vi.vpPosXMax, vi.vpPosYMin, vi.vpPosYMax);
	    cpgswin(vi.vpRangeXMin, vi.vpRangeXMax, vi.vpRangeYMin, vi.vpRangeYMax);

	    // background color (default is transparent)
	    if (vi.vpBColor >= 0) {
	        cpgsci(vi.vpBColor);
	        cpgrect(vi.vpRangeXMin, vi.vpRangeXMax, vi.vpRangeYMin, vi.vpRangeYMax);
	        cpgsci(1);  // reset foreground colour to the initial one (black)
	    }

	    // data
	    for (unsigned int j = 0; j < vi.vData.size(); ++j) {
	        resetAttributes(vi);

	        Plotter2DataInfo di = vi.vData[j];
	        std::vector<float> vxdata = di.xData;
                int ndata = vxdata.size();
	        float* pxdata = new float[ndata];
	        float* pydata = new float[ndata];
	        for (int k = 0; k < ndata; ++k) {
	            pxdata[k] = di.xData[k];
	            pydata[k] = di.yData[k];
	        }

	        if (di.drawLine) {
  	            cpgsls(di.lineStyle);
	            cpgslw(di.lineWidth);
		    int colorIdx = di.lineColor;
		    if (colorIdx < 0) {
		        colorIdx = (j + 1) % 15 + 1;
		    }
	            cpgsci(colorIdx);
	            cpgline(ndata, pxdata, pydata);
	        }

	        if (di.drawMarker) {
	            cpgsch(di.markerSize);
	            cpgsci(di.markerColor);
	            cpgpt(ndata, pxdata, pydata, di.markerType);
	        }

	        delete [] pxdata;
	        delete [] pydata;
	    }

	    //calculate y-range of xmasks
	    std::vector<float> yrange = vi.getRangeY();
	    float yexcess = 0.1*(yrange[1] - yrange[0]);
	    float xmaskymin = yrange[0] - yexcess;
	    float xmaskymax = yrange[1] + yexcess;

	    // masks
	    for (unsigned int j = 0; j < vi.vRect.size(); ++j) {
	        resetAttributes(vi);

	        Plotter2RectInfo ri = vi.vRect[j];
                cpgsci(ri.color);
	        cpgsfs(ri.fill);
	        cpgslw(ri.width);
	        cpgshs(45.0, ri.hsep, 0.0);
	        float* mxdata = new float[4];
	        float* mydata = new float[4];
	        mxdata[0] = ri.xmin;
	        mxdata[1] = ri.xmax;
	        mxdata[2] = ri.xmax;
	        mxdata[3] = ri.xmin;
	        mydata[0] = xmaskymin;
	        mydata[1] = xmaskymin;
	        mydata[2] = xmaskymax;
	        mydata[3] = xmaskymax;
                cpgpoly(4, mxdata, mydata);
	    }

	    // arrows
	    for (unsigned int j = 0; j < vi.vArro.size(); ++j) {
  	        resetAttributes(vi);

		Plotter2ArrowInfo ai = vi.vArro[j];
		cpgsci(ai.color);
		cpgslw(ai.width);
                cpgsls(ai.lineStyle);
		cpgsch(ai.headSize);
		cpgsah(ai.headFillStyle, ai.headAngle, ai.headVent);
		cpgarro(ai.xtail, ai.ytail, ai.xhead, ai.yhead);
	    }

	    // arbitrary texts
	    for (unsigned int j = 0; j < vi.vText.size(); ++j) {
  	        resetAttributes(vi);

		Plotter2TextInfo ti = vi.vText[j];
		cpgsch(ti.size);
		cpgsci(ti.color);
		cpgstbg(ti.bgcolor);
		cpgptxt(ti.posx, ti.posy, ti.angle, ti.fjust, ti.text.c_str());
	    }

	    // viewport outline and ticks
	    resetAttributes(vi);

            cpgbox("BCTS",  vi.majorTickIntervalX, vi.nMinorTickWithinMajorTicksX, 
	           "BCTSV", vi.majorTickIntervalY, vi.nMinorTickWithinMajorTicksY);

	    // viewport numberings
	    std::string numformatx, numformaty;
	    if (vi.numLocationX == "b") {
	        numformatx = "N";
	    } else if (vi.numLocationX == "t") {
	        numformatx = "M";
	    } else if (vi.numLocationX == "") {
	        numformatx = "";
	    }
	    if (vi.numLocationY == "l") {
	        numformaty = "NV";
	    } else if (vi.numLocationY == "r") {
	        numformaty = "MV";
	    } else if (vi.numLocationY == "") {
	        numformaty = "";
	    }

            cpgbox(numformatx.c_str(), vi.majorTickIntervalX * vi.nMajorTickWithinTickNumsX, 0, 
	           numformaty.c_str(), vi.majorTickIntervalY * vi.nMajorTickWithinTickNumsY, 0);

	    float xpos, ypos;

	    // x-label
	    vi.getWorldCoordByWindowCoord(vi.labelXPosX, vi.labelXPosY, &xpos, &ypos);
	    cpgsch(vi.labelXSize);
            cpgsci(vi.labelXColor);
            cpgstbg(vi.labelXBColor); //outside viewports, works ONLY with /xwindow
            cpgptxt(xpos, ypos, vi.labelXAngle, vi.labelXFJust, vi.labelXString.c_str());

	    // y-label
	    vi.getWorldCoordByWindowCoord(vi.labelYPosX, vi.labelYPosY, &xpos, &ypos);
	    cpgsch(vi.labelYSize);
            cpgsci(vi.labelYColor);
            cpgstbg(vi.labelYBColor); //outside viewports, works ONLY with /xwindow
            cpgptxt(xpos, ypos, vi.labelYAngle, vi.labelYFJust, vi.labelYString.c_str());

	    // title
	    vi.getWorldCoordByWindowCoord(vi.titlePosX, vi.titlePosY, &xpos, &ypos);
	    cpgsch(vi.titleSize);
            cpgsci(vi.titleColor);
            cpgstbg(vi.titleBColor); //outside viewports, works ONLY with /xwindow
            cpgptxt(xpos, ypos, vi.titleAngle, vi.titleFJust, vi.titleString.c_str());
	}

    }

    close();
}
Exemple #12
0
static double plot_fftview(fftview * fv, float maxpow, float charhgt,
                           float vertline, int vertline_color)
/* The return value is offsetf */
{
   int ii;
   double lor, lof, hir, hif, offsetf = 0.0;
   float *freqs;

   cpgsave();
   cpgbbuf();

   /* Set the "Normal" plotting attributes */

   cpgsls(1);
   cpgslw(1);
   cpgsch(charhgt);
   cpgsci(1);
   cpgvstd();

   if (maxpow == 0.0)           /* Autoscale for the maximum value */
      maxpow = 1.1 * fv->maxpow;

   lor = fv->lor;
   lof = lor / T;
   hir = lor + fv->dr * DISPLAYNUM;
   hif = hir / T;
   offsetf = 0.0;

   /* Period Labels */

   if (fv->zoomlevel >= 0 && lof > 1.0) {
      double lop, hip, offsetp = 0.0;
      lop = 1.0 / lof;
      hip = 1.0 / hif;
      offsetp = 0.0;

      if ((lop - hip) / hip < 0.001) {
         int numchar;
         char label[50];

         offsetp = 0.5 * (hip + lop);
         numchar = snprintf(label, 50, "Period - %.15g (s)", offsetp);
         cpgmtxt("T", 2.5, 0.5, 0.5, label);
      } else {
         cpgmtxt("T", 2.5, 0.5, 0.5, "Period (s)");
      }
      cpgswin(lop - offsetp, hip - offsetp, 0.0, maxpow);
      cpgbox("CIMST", 0.0, 0, "", 0.0, 0);
   }

   /* Frequency Labels */

   if ((hif - lof) / hif < 0.001) {
      int numchar;
      char label[50];

      offsetf = 0.5 * (hif + lof);
      numchar = snprintf(label, 50, "Frequency - %.15g (Hz)", offsetf);
      cpgmtxt("B", 2.8, 0.5, 0.5, label);
   } else {
      cpgmtxt("B", 2.8, 0.5, 0.5, "Frequency (Hz)");
   }
   cpgswin(lof - offsetf, hif - offsetf, 0.0, maxpow);

   /* Add zapboxes if required */

   if (numzaplist) {
      double zaplo, zaphi;

      cpgsave();
      cpgsci(15);
      cpgsfs(1);
      for (ii = 0; ii < numzaplist; ii++) {
         zaplo = zaplist[ii].lobin;
         zaphi = zaplist[ii].hibin;
         if ((zaplo < hir && zaplo > lor) || (zaphi < hir && zaphi > lor)) {
            cpgrect(zaplo / T - offsetf, zaphi / T - offsetf, 0.0, 0.95 * maxpow);
         }
      }
      cpgunsa();
   }

   /* Add a background vertical line if requested */

   if (vertline != 0.0 && vertline_color != 0) {
      cpgsave();
      cpgsci(vertline_color);
      cpgmove(vertline / T - offsetf, 0.0);
      cpgdraw(vertline / T - offsetf, maxpow);
      cpgunsa();
   }

   if (fv->zoomlevel >= 0 && lof > 1.0)
      cpgbox("BINST", 0.0, 0, "BCNST", 0.0, 0);
   else
      cpgbox("BCINST", 0.0, 0, "BCNST", 0.0, 0);

   /* Plot the spectrum */

   freqs = gen_fvect(DISPLAYNUM);
   for (ii = 0; ii < DISPLAYNUM; ii++)
      freqs[ii] = fv->rs[ii] / T - offsetf;
   if (fv->zoomlevel > 0) {     /* Magnified power spectrum */
      cpgline(DISPLAYNUM, freqs, fv->powers);
   } else {                     /* Down-sampled power spectrum */
      for (ii = 0; ii < DISPLAYNUM; ii++) {
         cpgmove(freqs[ii], 0.0);
         cpgdraw(freqs[ii], fv->powers[ii]);
      }
   }
   vect_free(freqs);
   cpgmtxt("L", 2.5, 0.5, 0.5, "Normalized Power");
   cpgebuf();
   cpgunsa();
   return offsetf;
}
Exemple #13
0
/* set fill-area style */
static void _pgsfs (int *i)
{
   cpgsfs (*i);
}