Example #1
0
void wipvfield(float x[], float y[], float r[], float phi[], int npts, float angle, float vent)
{
    register int i;
    int fill;
    float x1, y1, x2, y2;
    double darg;
    LOGICAL error;

    darg = wipgetvar("fill", &error);
    fill = (error == TRUE) ? 1 : NINT(darg);

    cpgbbuf();
    cpgsah(fill, angle, vent);

    for (i = 0; i < npts; i++) {
        x1 = x[i];
        y1 = y[i];
        x2 = x1 + (r[i] * COS(phi[i] * RPDEG));
        y2 = y1 + (r[i] * SIN(phi[i] * RPDEG));
        cpgarro(x1, y1, x2, y2);
    }

    cpgebuf();

    return;
}
Example #2
0
void plotsection(SET *p, GRAPHCONTROL *gr, int mode) {
	float *x = (mode == LAT) ? p->y : p->x;
	float *y = p->d;
	int i;

	float x1, x2, y1, y2;

	/* Check we have data */
	if (p->n ==0) {
		cpgsvp(0.07, 0.52, 0.07, 0.30);
		cpgswin(0.0, 1.0, 0.0, 1.0);
		cpgmtxt("T",-3, 0.5, 0.5, "-- Sem Dados -- ");
		return;
	}

	x1 = x2 = x[0];
	y1 = y2 = y[0];
	for(i=0;i<p->n; i++) {
		if (x[i] < x1) x1 = x[i];
		if (x[i] > x2) x2 = x[i];
		if (y[i] < y1) y1 = y[i];
		if (y[i] > y2) y2 = y[i];
	}

	y2 = (( (int)y2 / 50 ) + 1) * 50.0;

	// Plot
	cpgsvp(0.07, 0.52, 0.07, 0.30);
	cpgswin(x1, x2, y2, 0.0);
	cpgbox("BCNST", 0.0, 0, "BCNST", 0.0, 0);
	cpgsch(0.7);
	cpgmtxt("R", 1.0, 0.0, 0.0, "[L] Trocar Lat/Lon");
	cpgmtxt("B", 3.0, 0.5, 0.5, (mode == LAT) ? "Latitude\\m94" : "Longitude\\m94");
	cpgmtxt("L", 3.0, 0.5, 0.5, "Profundidade (km)");
	(gr->printout) ? cpgsch(1.5) : (p->n > 50) ? cpgsch(FS) : cpgsch(1.0);
	cpgbbuf();

	for(i = 0; i< p->n; i++) {
		if (gr->colormode == COLORDEPTH)
			cpgsci(depthcolor(y[i]));
		else if (gr->colormode == COLORMAG)
			cpgsci(magcolor(p->m[i]));
		cpgpt1(x[i], y[i], 1);
	}
	cpgebuf();



	// Terminate
	cpgsch(FS);
	cpgsci(1);
	cpgslw(1);

	return;
}
Example #3
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;
}
Example #4
0
int dialog::update(){   // Only draws what has changed
  cpgbbuf();
  cpgsvp(0.0,1.0,0.0,1.0);
  cpgswin(0.0,1.0,0.0,1.0);
  for (int i=0;i<nbutton;i++) buttons[i].draw();
  for (int i=0;i<nradio;i++) radios[i].draw();
  for (int i=0;i<ncheck;i++) checks[i].draw();
  for (int i=0;i<nstaticText;i++) staticTexts[i].draw();
  cpgebuf();
  return(0);
}
Example #5
0
int dialog::draw(){

  cpgbbuf();
  cpgsvp(0.0,1.0,0.0,1.0);
  cpgswin(0.0,1.0,0.0,1.0);
  for (int i=0;i<nbutton;i++) buttons[i].draw();
  for (int i=0;i<nradio;i++) radios[i].draw();
  for (int i=0;i<ncheck;i++) checks[i].draw();
  for (int i=0;i<nstaticText;i++) staticTexts[i].draw();
  cpgebuf();
  return(0);
}
Example #6
0
static void demo2()
{
  static int nx = 40, ny = 40;
  int i, j, k, lw, ci, ls;
  float f[1600], fmin, fmax, alev;
  double x, y;
  static float tr[6] = {0.0, 1.0, 0.0, 0.0, 0.0, 1.0};
  
  /* Compute a suitable function. A C array is used to emulate
     a 2D fortran array f(nx,ny). */

  fmin = fmax = 0.0;
  for (j=1; j<=ny; j++) {
    for (i=1; i<=ny; i++) {
      k = (j-1)*nx + (i-1);	/* Fortran convention */
      x = tr[0] + tr[1]*i + tr[2]*j;
      y = tr[3] + tr[4]*i + tr[5]*j;
      f[k] = cos(0.3*sqrt(x*2)-0.13333*y)*cos(0.13333*x)+
	(x-y)/(double)nx;
      if (f[k] < fmin) fmin = f[k];
      if (f[k] > fmax) fmax = f[k];
    }
  }
  
  /* Clear the screen. Set up window and viewport. */
  
  cpgpage();
  cpgsvp(0.05, 0.95, 0.05, 0.95);
  cpgswin(1.0, (float) nx, 1.0, (float) ny);
  cpgbox("bcts", 0.0, 0, "bcts", 0.0, 0);
  cpgmtxt("t", 1.0, 0.0, 0.0, "Contouring using cpgcont()");
  
  /* Draw the map. cpgcont is called once for each contour, using
     different line attributes to distinguish contour levels. */
  
  cpgbbuf();
  for (i=1; i<21; i++) {
    alev = fmin + i*(fmax-fmin)/20.0;
    lw = (i%5 == 0) ? 3 : 1;
    ci = (i < 10)   ? 2 : 3;
    ls = (i < 10)   ? 2 : 1;
    cpgslw(lw);
    cpgsci(ci);
    cpgsls(ls);
    cpgcont(f, nx, ny, 1, nx, 1, ny, &alev, -1, tr);
  }
  cpgslw(1);
  cpgsls(1);
  cpgsci(1);
  cpgebuf();
  return;
}
Example #7
0
/*
 *  LOCATION = 1-4 for bars to quadrant j less 45 deg, eg 1 for +X
 *  Returns 0 on success; 1 on error.
 */
int wiperrorbar(int location, float x[], float y[], float err[], int nxy)
{
    float expsiz;
    LOGICAL error;

    if (nxy < 1) return(1);

    cpgbbuf(); /* Set up buffered output. */

    expsiz = wipgetvar("expand", &error);
    if (error == TRUE) expsiz  = 1.0;
    expsiz /= 10.0;
    cpgerrb(location, nxy, x, y, err, expsiz);

    cpgebuf(); /* Finish up buffered output. */

    return(0);
}
// make a single Aitoff sky projection plot
//   using the data in ravec[field], decvec[field], and value[filter][field],
//   using the min and max data values in valmin[filter] and valmax[filter]
//   with filter=0
void plotOne(double nfields, double *value,
             double *ravec, double *decvec,
             double valmin, double valmax,
             char *label, char *title, char *plotName) {
  int nf;
  double xmin, xmax, ymin, ymax;

  // set up the plot
  openPlot(plotName);
  cpgbbuf();

  cpgpap(PLOTSIZE/0.7,0.7);

  cpgsvp(0.02,0.98,0.02,0.98);

  xmax = M_PI;      xmin = -xmax;
  ymax = 0.67*M_PI; ymin = -ymax;
  ymin -= 0.1*ymax; ymax -= 0.1*ymax;

  setupImplot(0.0, 1.0);
  cpgswin(xmin,xmax,ymin,ymax);

  // make a projected field circle for each field
  cpgsch(1.0);
  for(nf=0; nf<nfields; nf++) {
    projCircle(ravec[nf], decvec[nf], FIELD_RADIUS, 
               (value[nf]-valmin)/(valmax-valmin));
  }
  // the grids and galactic exclusion
  aitoffGrid();
  galaxy(peakL, taperL, taperB);

  cpgslw(2);
  cpgsch(2.0);
  cpgswin(0,1,0,1);
  mywedg(0.21, 0.15, 1.0, 12.0, valmin, valmax, label);
  cpgptxt(0.5,0.95,0.0,0.5,title);
  cpgslw(1);

  cpgebuf();
  closePlot();
}
Example #9
0
int main()

{
  char   text[80];
  int    ci, crval1, crval2, ilat, ilng, j, k, latpole, lonpole, stat[361],
         status;
  float  xr[512], yr[512];
  double lat[181], lng[361], phi[361], theta[361], x[361], y[361];
  struct celprm native, celestial;


  printf(
  "Testing WCSLIB celestial coordinate transformation routines (tcel1.c)\n"
  "---------------------------------------------------------------------\n");

  /* List status return messages. */
  printf("\nList of cel status return values:\n");
  for (status = 1; status <= 6; status++) {
    printf("%4d: %s.\n", status, cel_errmsg[status]);
  }

  printf("\n");


  /* Initialize. */
  celini(&native);

  /* Reference angles for the native graticule (in fact, the defaults). */
  native.ref[0] = 0.0;
  native.ref[1] = 0.0;

  /* Set up Bonne's projection with conformal latitude at +35. */
  strcpy(native.prj.code, "BON");
  native.prj.pv[1] = 35.0;


  /* Celestial graticule. */
  celini(&celestial);
  celestial.prj = native.prj;


  /* PGPLOT initialization. */
  strcpy(text, "/xwindow");
  cpgbeg(0, text, 1, 1);

  /* Define pen colours. */
  cpgscr(0, 0.0f, 0.0f, 0.0f);
  cpgscr(1, 1.0f, 1.0f, 0.0f);
  cpgscr(2, 1.0f, 1.0f, 1.0f);
  cpgscr(3, 0.5f, 0.5f, 0.8f);
  cpgscr(4, 0.8f, 0.5f, 0.5f);
  cpgscr(5, 0.8f, 0.8f, 0.8f);
  cpgscr(6, 0.5f, 0.5f, 0.8f);
  cpgscr(7, 0.8f, 0.5f, 0.5f);
  cpgscr(8, 0.3f, 0.5f, 0.3f);

  /* Define PGPLOT viewport. */
  cpgenv(-180.0f, 180.0f, -90.0f, 140.0f, 1, -2);

  /* Loop over CRVAL2, LONPOLE, and LATPOLE with CRVAL1 incrementing by */
  /* 15 degrees each time (it has an uninteresting effect).             */
  crval1 = -180;
  for (crval2 = -90; crval2 <=  90; crval2 += 30) {
    for (lonpole = -180; lonpole <= 180; lonpole += 30) {
      for (latpole = -1; latpole <= 1; latpole += 2) {
        /* For the celestial graticule, set the celestial coordinates of
         * the reference point of the projection (which for Bonne's
         * projection is at the intersection of the native equator and
         * prime meridian), the native longitude of the celestial pole,
         * and extra information needed to determine the celestial
         * latitude of the native pole.  These correspond to FITS keywords
         * CRVAL1, CRVAL2, LONPOLE, and LATPOLE.
         */
        celestial.ref[0] = (double)crval1;
        celestial.ref[1] = (double)crval2;
        celestial.ref[2] = (double)lonpole;
        celestial.ref[3] = (double)latpole;

        /* Skip invalid values of LONPOLE. */
        if (celset(&celestial)) {
          continue;
        }

        /* Skip redundant values of LATPOLE. */
        if (latpole == 1 && fabs(celestial.ref[3]) < 0.1) {
          continue;
        }

        /* Buffer PGPLOT output. */
        cpgbbuf();
        cpgeras();

        /* Write a descriptive title. */
        sprintf(text, "Bonne's projection (BON) - 15 degree graticule");
        printf("\n%s\n", text);
        cpgtext(-180.0f, -100.0f, text);

        sprintf(text, "centred on celestial coordinates (%7.2f,%6.2f)",
          celestial.ref[0], celestial.ref[1]);
        printf("%s\n", text);
        cpgtext (-180.0f, -110.0f, text);

        sprintf(text, "with north celestial pole at native coordinates "
          "(%7.2f,%7.2f)", celestial.ref[2], celestial.ref[3]);
        printf("%s\n", text);
        cpgtext(-180.0f, -120.0f, text);


        /* Draw the native graticule faintly in the background. */
        cpgsci(8);

        /* Draw native meridians of longitude. */
        for (j = 0, ilat = -90; ilat <= 90; ilat++, j++) {
          lat[j] = (double)ilat;
        }

        for (ilng = -180; ilng <= 180; ilng += 15) {
          lng[0] = (double)ilng;
          if (ilng == -180) lng[0] = -179.99;
          if (ilng ==  180) lng[0] =  179.99;

          /* Dash the longitude of the celestial pole. */
          if ((ilng-lonpole)%360 == 0) {
            cpgsls(2);
            cpgslw(5);
          }

          cels2x(&native, 1, 181, 1, 1, lng, lat, phi, theta, x, y, stat);

          k = 0;
          for (j = 0; j < 181; j++) {
            if (stat[j]) {
              if (k > 1) cpgline(k, xr, yr);
              k = 0;
              continue;
            }

            xr[k] = -x[j];
            yr[k] =  y[j];
            k++;
          }

          cpgline(k, xr, yr);
          cpgsls(1);
          cpgslw(1);
        }

        /* Draw native parallels of latitude. */
        lng[0]   = -179.99;
        lng[360] =  179.99;
        for (j = 1, ilng = -179; ilng < 180; ilng++, j++) {
          lng[j] = (double)ilng;
        }

        for (ilat = -90; ilat <= 90; ilat += 15) {
          lat[0] = (double)ilat;

          cels2x(&native, 361, 1, 1, 1, lng, lat, phi, theta, x, y, stat);

          k = 0;
          for (j = 0; j < 361; j++) {
            if (stat[j]) {
              if (k > 1) cpgline(k, xr, yr);
              k = 0;
              continue;
            }

            xr[k] = -x[j];
            yr[k] =  y[j];
            k++;
          }

          cpgline(k, xr, yr);
        }


        /* Draw a colour-coded celestial coordinate graticule. */
        ci = 1;

        /* Draw celestial meridians of longitude. */
        for (j = 0, ilat = -90; ilat <= 90; ilat++, j++) {
          lat[j] = (double)ilat;
        }

        for (ilng = -180; ilng <= 180; ilng += 15) {
          lng[0] = (double)ilng;

          if (++ci > 7) ci = 2;
          cpgsci(ilng?ci:1);

          /* Dash the reference longitude. */
          if ((ilng-crval1)%360 == 0) {
            cpgsls(2);
            cpgslw(5);
          }

          cels2x(&celestial, 1, 181, 1, 1, lng, lat, phi, theta, x, y, stat);

          k = 0;
          for (j = 0; j < 181; j++) {
            if (stat[j]) {
              if (k > 1) cpgline(k, xr, yr);
              k = 0;
              continue;
            }

            /* Test for discontinuities. */
            if (j > 0) {
              if (fabs(x[j]-x[j-1]) > 4.0 || fabs(y[j]-y[j-1]) > 4.0) {
                if (k > 1) cpgline(k, xr, yr);
                k = 0;
              }
            }

            xr[k] = -x[j];
            yr[k] =  y[j];
            k++;
          }

          cpgline(k, xr, yr);
          cpgsls(1);
          cpgslw(1);
        }

        /* Draw celestial parallels of latitude. */
        for (j = 0, ilng = -180; ilng <= 180; ilng++, j++) {
          lng[j] = (double)ilng;
        }

        ci = 1;
        for (ilat = -90; ilat <= 90; ilat += 15) {
          lat[0] = (double)ilat;

          if (++ci > 7) ci = 2;
          cpgsci(ilat?ci:1);

          /* Dash the reference latitude. */
          if (ilat == crval2) {
            cpgsls(2);
            cpgslw(5);
          }

          cels2x(&celestial, 361, 1, 1, 1, lng, lat, phi, theta, x, y, stat);

          k = 0;
          for (j = 0; j < 361; j++) {
            if (stat[j]) {
              if (k > 1) cpgline(k, xr, yr);
              k = 0;
              continue;
            }

            /* Test for discontinuities. */
            if (j > 0) {
              if (fabs(x[j]-x[j-1]) > 4.0 || fabs(y[j]-y[j-1]) > 4.0) {
                if (k > 1) cpgline(k, xr, yr);
                k = 0;
              }
            }

            xr[k] = -x[j];
            yr[k] =  y[j];
            k++;
          }

          cpgline(k, xr, yr);
          cpgsls(1);
          cpgslw(1);
        }

        /* Flush PGPLOT buffer. */
        cpgebuf();
        printf(" Type <RETURN> for next page: ");
        getc(stdin);

        /* Cycle through celestial longitudes. */
        if ((crval1 += 15) > 180) crval1 = -180;

        /* Skip boring celestial latitudes. */
        if (crval2 == 0) break;
      }

      if (crval2 == 0) break;
    }
  }

  cpgask(0);
  cpgend();

  return 0;
}
Example #10
0
int main()

{
  /* Set up a 2 x 2 lookup table. */
  const int M = 2;
  const int K[] = {K1, K2};
  const int map[] = {0, 1};
  const double crval[] = {0.0, 0.0};

  char text[80];
  int i, j, k, l, l1, l2, l3, lstep, m, stat[NP*NP], status;
  float array[NP][NP], clev[31], v0, v1, w;
  const float scl = 2.0f/(NP-1);
  float ltm[6];
  double x[NP][NP][2], world[NP][NP][2];
  struct tabprm tab;

  printf("Testing WCSLIB coordinate lookup table routines (ttab2.c)\n"
         "---------------------------------------------------------\n");

  /* List status return messages. */
  printf("\nList of tab status return values:\n");
  for (status = 1; status <= 5; status++) {
    printf("%4d: %s.\n", status, tab_errmsg[status]);
  }

  printf("\n");


  /* PGPLOT initialization. */
  strcpy(text, "/xwindow");
  cpgbeg(0, text, 1, 1);
  cpgvstd();
  cpgsch(0.7f);

  /* The viewport is slightly oversized. */
  cpgwnad(-0.65f, 1.65f, -0.65f, 1.65f);

  for (l = 0; l <= 30; l++) {
    clev[l] = 0.2f*(l-10);
  }

  ltm[0] = -scl*(1.0f + (NP-1)/4.0f);
  ltm[1] =  scl;
  ltm[2] =  0.0f;
  ltm[3] = -scl*(1.0f + (NP-1)/4.0f);
  ltm[4] =  0.0f;
  ltm[5] =  scl;


  /* Set up the lookup table. */
  tab.flag = -1;
  if ((status = tabini(1, M, K, &tab))) {
    printf("tabini ERROR %d: %s.\n", status, tab_errmsg[status]);
    return 1;
  }

  tab.M = M;
  for (m = 0; m < tab.M; m++) {
    tab.K[m] = K[m];
    tab.map[m] = map[m];
    tab.crval[m] = crval[m];

    for (k = 0; k < tab.K[m]; k++) {
      tab.index[m][k] = (double)k;
    }
  }

  /* Subdivide the interpolation element. */
  for (i = 0; i < NP; i++) {
    for (j = 0; j < NP; j++) {
      x[i][j][0] = j*(K1-1.0)*scl - 0.5 - crval[0];
      x[i][j][1] = i*(K2-1.0)*scl - 0.5 - crval[1];
    }
  }

  /* The first coordinate element is static. */
  tab.coord[0] = 0.0;
  tab.coord[2] = 0.0;
  tab.coord[4] = 0.0;
  tab.coord[6] = 0.0;

  /* (k1,k2) = (0,0). */
  tab.coord[1] = 0.0;

  /* The second coordinate element varies in three of the corners. */
  for (l3 = 0; l3 <= 100; l3 += 20) {
    /* (k1,k2) = (1,1). */
    tab.coord[7] = 0.01 * l3;

    for (l2 = 0; l2 <= 100; l2 += 20) {
      /* (k1,k2) = (0,1). */
      tab.coord[5] = 0.01 * l2;

      cpgpage();
      for (l1 = 0; l1 <= 100; l1 += 2) {
        /* (k1,k2) = (1,0). */
        tab.coord[3] = 0.01 * l1;

        /* Compute coordinates within the interpolation element. */
        tab.flag = 0;
        if ((status = tabx2s(&tab, NP*NP, 2, (double *)x, (double *)world,
                             stat))) {
          printf("tabx2s ERROR %d: %s.\n", status, tab_errmsg[status]);
        }

        /* Start a new plot. */
        cpgbbuf();
        cpgeras();
        cpgsci(1);
        cpgslw(3);
        cpgbox("BCNST", 0.0f, 0, "BCNSTV", 0.0f, 0);
        cpgmtxt("T", 0.7f, 0.5f, 0.5f, "-TAB coordinates:  "
          "linear interpolation / extrapolation in 2-D");

        /* Draw the boundary of the interpolation element in red. */
        cpgsci(2);
        cpgmove(-0.5f,  0.0f);
        cpgdraw( 1.5f,  0.0f);

        cpgmove( 1.0f, -0.5f);
        cpgdraw( 1.0f,  1.5f);

        cpgmove( 1.5f,  1.0f);
        cpgdraw(-0.5f,  1.0f);

        cpgmove( 0.0f,  1.5f);
        cpgdraw( 0.0f, -0.5f);

        /* Label the value of the coordinate element in each corner. */
        sprintf(text, "%.1f", tab.coord[1]);
        cpgtext(-0.09f, -0.05f, text);
        sprintf(text, "%.2f", tab.coord[3]);
        cpgtext( 1.02f, -0.05f, text);
        sprintf(text, "%.1f", tab.coord[5]);
        cpgtext(-0.13f,  1.02f, text);
        sprintf(text, "%.1f", tab.coord[7]);
        cpgtext( 1.02f,  1.02f, text);

        cpgsci(1);
        /* Contour labelling: bottom. */
        v0 = world[0][0][1];
        v1 = world[0][NP-1][1];
        if (v0 != v1) {
          lstep = (abs((int)((v1-v0)/0.2f)) < 10) ? 20 : 40;
          for (l = -200; l <= 300; l += lstep) {
            w = -0.5f + 2.0f * (l*0.01f - v0) / (v1 - v0);
            if (w < -0.5 || w > 1.5) continue;

            sprintf(text, "%4.1f", l*0.01f);
            cpgptxt(w+0.04f, -0.56f, 0.0f, 1.0f, text);
          }
        }

        /* Contour labelling: left. */
        v0 = world[0][0][1];
        v1 = world[NP-1][0][1];
        if (v0 != v1) {
          lstep = (abs((int)((v1-v0)/0.2f)) < 10) ? 20 : 40;
          for (l = -200; l <= 300; l += lstep) {
            w = -0.5f + 2.0f * (l*0.01f - v0) / (v1 - v0);
            if (w < -0.5 || w > 1.5) continue;

            sprintf(text, "%4.1f", l*0.01f);
            cpgptxt(-0.52f, w-0.02f, 0.0f, 1.0f, text);
          }
        }

        /* Contour labelling: right. */
        v0 = world[0][NP-1][1];
        v1 = world[NP-1][NP-1][1];
        if (v0 != v1) {
          lstep = (abs((int)((v1-v0)/0.2f)) < 10) ? 20 : 40;
          for (l = -200; l <= 300; l += lstep) {
            w = -0.5f + 2.0f * (l*0.01f - v0) / (v1 - v0);
            if (w < -0.5 || w > 1.5) continue;

            sprintf(text, "%.1f", l*0.01f);
            cpgptxt(1.52f, w-0.02f, 0.0f, 0.0f, text);
          }
        }

        /* Contour labelling: top. */
        v0 = world[NP-1][0][1];
        v1 = world[NP-1][NP-1][1];
        if (v0 != v1) {
          lstep = (abs((int)((v1-v0)/0.2f)) < 10) ? 20 : 40;
          for (l = -200; l <= 300; l += lstep) {
            w = -0.5f + 2.0f * (l*0.01f - v0) / (v1 - v0);
            if (w < -0.5 || w > 1.5) continue;

            sprintf(text, "%4.1f", l*0.01f);
            cpgptxt(w+0.04f, 1.52f, 0.0f, 1.0f, text);
          }
        }

        /* Draw contours for the second coordinate element. */
        for (i = 0; i < NP; i++) {
          for (j = 0; j < NP; j++) {
            array[i][j] = world[i][j][1];
          }
        }

        cpgsci(4);
        cpgslw(2);
        cpgcont(array[0], NP, NP, 1, NP, 1, NP, clev, 10, ltm);

        cpgsci(7);
        cpgcont(array[0], NP, NP, 1, NP, 1, NP, clev+10, 1, ltm);

        cpgsci(5);
        cpgcont(array[0], NP, NP, 1, NP, 1, NP, clev+11, 20, ltm);

        cpgebuf();
      }
    }
  }

  cpgend();

  tabfree(&tab);

  return 0;
}
// make six Aitoff sky projection plots
//   using the data in ravec[field], decvec[field], and value[filter][field],
//   using the min and max data values in valmin[filter] and valmax[filter]
//   with filter=0 to NFILTERS-1
void plotSix(double nfields, double **value,
             double *ravec, double *decvec,
             double *valmin, double *valmax,
             int horizontal,
             char *label, char *title, char* plotName, int mask) {

	char str[1024];
	int filt, nf;
	double xmin, xmax, ymin, ymax;

	openPlot(plotName);
	cpgbbuf();

	if(horizontal==1) 
		cpgpap(PLOTSIZE/0.5,0.5); else cpgpap(PLOTSIZE/1.0,1.0);

	cpgsvp(0.02,0.98,0.15,0.95);
	xmax = 0.9*(M_PI);      
	xmin = -xmax;
	ymax = 0.9*(0.6*M_PI);  
	ymin = -ymax;
	ymin -= 0.18*ymax;      
	ymax -= 0.18*ymax;

	setupImplot(0.0, 1.0);

	if(horizontal==1) 
		cpgsubp(3,2); 
	else 
		cpgsubp(2,3);

	cpgsch(3.0); 
	cpgslw(2);

	for(filt=0; filt<NFILTERS; filt++) {
		int thereisdata = 0;
		for(nf=0; nf<nfields; nf++) {
			if (value[filt][nf] != 0.0) {
				thereisdata = 1;
			}
		}
		
		if ( thereisdata ) {
			if(horizontal==1) 
				cpgpanl(hpanelx[filt],hpanely[filt]); 
			else 
				cpgpanl(vpanelx[filt],vpanely[filt]);

			cpgswin(xmin,xmax,ymin,ymax);
			for(nf=0; nf<nfields; nf++) {
				if ( mask == 0 ) {
					if(value[filt][nf] > 0.0)
						projCircle(ravec[nf], decvec[nf], FIELD_RADIUS, (value[filt][nf]-valmin[filt])/(valmax[filt]-valmin[filt]));
				} else if ( mask == 1) {
					if(value[filt][nf] != 0.0)
						projCircle(ravec[nf], decvec[nf], FIELD_RADIUS, (value[filt][nf]-valmin[filt])/(valmax[filt]-valmin[filt]));
				}
			}
			aitoffGrid();
			galaxy(peakL, taperL, taperB);
			sprintf(str,"%s: %s", label, filtername[filt]);
			if(valmax[filt]>valmin[filt])
				mywedg(0.2, 0.15, 1.0, 8.0, valmin[filt], valmax[filt], str);
		}
	}

	cpgsch(1.0);
	cpgsubp(1,1);
	cpgswin(0,1,0,1);
	cpgptxt(0.5,1.02,0.0,0.5,title);
	cpgslw(1);    
	cpgebuf();

	closePlot();
}
Example #12
0
int closure (
  const char ctypeS[9],
  double restfrq,
  double restwav,
  int    naxisj,
  double crpixj,
  double cdeltX,
  double crvalX)

{
  char ptype, sname[32], title[80], units[8], xtype, ylab[80];
  int  nFail = 0, restreq, stat1[NSPEC], stat2[NSPEC], status;
  register int j;
  float  tmp, x[NSPEC], xmin, xmax, y[NSPEC], ymax, ymin;
  double cdeltS, clos[NSPEC], crvalS, dSdX, resid, residmax, spec1[NSPEC],
         spec2[NSPEC];
  struct spcprm spc;


  /* Get keyvalues for the required spectral axis type. */
  if ((status = spcxps(ctypeS, crvalX, restfrq, restwav, &ptype, &xtype,
                       &restreq, &crvalS, &dSdX))) {
    printf("ERROR %d from spcxps() for %s.\n", status, ctypeS);
    return 1;
  }
  cdeltS = cdeltX * dSdX;

  spcini(&spc);

  if (ctypeS[5] == 'G') {
    /* KPNO MARS spectrograph grism parameters. */
    spc.pv[0] = mars[0];
    spc.pv[1] = mars[1];
    spc.pv[2] = mars[2];
    spc.pv[3] = mars[3];
    spc.pv[4] = mars[4];
    spc.pv[5] = mars[5];
    spc.pv[6] = mars[6];
  }

  /* Construct the axis. */
  for (j = 0; j < naxisj; j++) {
    spec1[j] = (j+1 - crpixj)*cdeltS;
  }

  printf("%4s (CRVALk+w) range: %13.6e to %13.6e, step: %13.6e\n", ctypeS,
    crvalS+spec1[0], crvalS+spec1[naxisj-1], cdeltS);


  /* Initialize. */
  spc.flag = 0;
  spc.crval = crvalS;
  spc.restfrq = restfrq;
  spc.restwav = restwav;
  strncpy(spc.type, ctypeS, 4);
  spc.type[4] = '\0';
  strcpy(spc.code, ctypeS+5);

  /* Convert the first to the second. */
  if ((status = spcx2s(&spc, naxisj, 1, 1, spec1, spec2, stat1))) {
    printf("spcx2s ERROR %d: %s.\n", status, spc_errmsg[status]);
  }

  /* Convert the second back to the first. */
  if ((status = spcs2x(&spc, naxisj, 1, 1, spec2, clos, stat2))) {
    printf("spcs2x ERROR %d: %s.\n", status, spc_errmsg[status]);
  }

  residmax = 0.0;

  /* Test closure. */
  for (j = 0; j < naxisj; j++) {
    if (stat1[j]) {
      printf("%s: w =%20.12e -> %s = ???, stat = %d\n", ctypeS, spec1[j],
             spc.type, stat1[j]);
      continue;
    }

    if (stat2[j]) {
      printf("%s: w =%20.12e -> %s =%20.12e -> w = ???, stat = %d\n",
             ctypeS, spec1[j], spc.type, spec2[j], stat2[j]);
      continue;
    }

    resid = fabs((clos[j] - spec1[j])/cdeltS);
    if (resid > residmax) residmax = resid;

    if (resid > tol) {
      nFail++;
      printf("%s: w =%20.12e -> %s =%20.12e ->\n          w =%20.12e,  "
             "resid =%20.12e\n", ctypeS, spec1[j], spc.type, spec2[j],
             clos[j], resid);
    }
  }

  printf("%s: Maximum closure residual = %.1e pixel.\n", ctypeS, residmax);


  /* Draw graph. */
  cpgbbuf();
  cpgeras();

  xmin = (float)(crvalS + spec1[0]);
  xmax = (float)(crvalS + spec1[naxisj-1]);
  ymin = (float)(spec2[0]) - xmin;
  ymax = ymin;
  for (j = 0; j < naxisj; j++) {
    x[j] = (float)(j+1);
    y[j] = (float)(spec2[j] - (crvalS + spec1[j]));
    if (y[j] > ymax) ymax = y[j];
    if (y[j] < ymin) ymin = y[j];
  }

  j = (int)crpixj + 1;
  if (y[j] < 0.0) {
    tmp  = ymin;
    ymin = ymax;
    ymax = tmp;
  }

  cpgask(0);
  cpgenv(1.0f, (float)naxisj, ymin, ymax, 0, -1);

  cpgsci(1);
  cpgbox("ABNTS", 0.0f, 0, "BNTS", 0.0f, 0);
  spctyp(ctypeS, 0x0, 0x0, sname, units, 0x0, 0x0, 0x0);
  sprintf(ylab, "%s - correction [%s]", sname, units);
  sprintf(title, "%s:  CRVALk + w [%s]", ctypeS, units);
  cpglab("Pixel coordinate", ylab, title);

  cpgaxis("N", 0.0f, ymax, (float)naxisj, ymax, xmin, xmax, 0.0f, 0, -0.5f,
    0.0f, 0.5f, -0.5f, 0.0f);

  cpgaxis("N", (float)naxisj, ymin, (float)naxisj, ymax, (float)(ymin/cdeltS),
    (float)(ymax/cdeltS), 0.0f, 0, 0.5f, 0.0f, 0.5f, 0.1f, 0.0f);
  cpgmtxt("R", 2.2f, 0.5f, 0.5f, "Pixel offset");

  cpgline(naxisj, x, y);
  cpgsci(7);
  cpgpt1((float)crpixj, 0.0f, 24);
  cpgebuf();

  printf("Type <RETURN> for next page: ");
  (void)getchar();

  printf("\n");

  return nFail;
}
Example #13
0
void plothistogram(SET *p, float w, int mode, float lm, float hm) {
	float *x = (mode == MAG) ? p->m : p->d;
	int i;
	char t[1024];

	float x1, x2, y1, y2;

	float *bins = NULL;
	float *freq = NULL;
	int nb;

	float a, b;
	float rms = -1;

	cpgsvp(0.63, 0.93, 0.07, 0.30);

	/* Check we have data */
	if (p->n ==0) {
		cpgswin(0.0, 1.0, 0.0, 1.0);
		cpgmtxt("T",-3, 0.5, 0.5, "-- Sem Dados -- ");
		return;
	}

	if (mode == MAG) {
		nb = gomag(x, p->n, w, &bins, &freq);
		rms = linefit(bins, freq, nb, lm, hm, &a, &b);
	} else {
		nb = godep(x, p->n, w, &bins, &freq);
	}

	/*
	 * Plot
	 */

	minmax(x, p->n, &x1, &x2);
	minmax(freq, nb, &y1, &y2);
	cpgswin(x1, x2, y1 - (y2-y1)*0.1, y2 * 1.2);
	cpgbox("BCNST", 0.0, 0, "BCMST", 0.0, 0);

	/*
	 * Labels
	 */
	cpgsch(0.7);
	cpgmtxt("L", 2.2, 0.0, 0.0, "[H] Trocar Mag/Dep");
	cpgmtxt("L", 1.0, 0.0, 0.0, "[B] Ajustar largura do bin");

	if (mode == MAG) {
		cpgmtxt("R", 3.0, 0.5, 0.5, "Log(n) Acumulado");
		cpgmtxt("B", 3.0, 0.5, 0.5, "Magnitude");

	} else {
		cpgmtxt("R", 3.0, 0.5, 0.5, "Log(n)");
		cpgmtxt("B", 3.0, 0.5, 0.5, "Profundidade (km)");
	}
	sprintf(t,"Min: %.1f Max: %.1f",x1,x2);
	if (mode == MAG) {
		cpgmtxt("B", -1.0, 0.05, 0.0,t);
	} else {
		cpgmtxt("T", -2.0, 0.95, 1.0,t);
	}
	cpgsch(FS);

	/*
	 * Plots
	 */
	cpgbin(nb, bins, freq, 1);

	if (mode == MAG) {
		cpgmove(x1, a*x1 + b);
		cpgdraw(x2, a*x2 + b);
		if ( lm >= 0.0 ) {
			float temp;
			
			cpgsci(2);
			cpgsch(1.2);
			temp = fabs((a*x1+b) - (a*x2+b));
			cpgpt1(lm, a*lm+b -temp * 0.06, 30);
			cpgpt1(hm, a*hm+b -temp * 0.06, 30);
			cpgsci(1);
			cpgsch(FS);
		}
	}

	if (mode == MAG) {
		cpgsch(0.7);
		sprintf(t,"f(x)=%.2f\\.x+%.2f",a,b);
		cpgmtxt("T",-2.0, 0.9, 1.0,t);

		sprintf(t,"b=%.2f",fabs(a));
		cpgmtxt("T",-3.2, 0.9, 1.0,t);
		cpgsch(FS);
	}

	cpgbbuf();

	/*
	 * Terminate
	 */
	cpgsci(1);
	cpgslw(1);

	cpgebuf();

	if (bins != NULL) free(bins);
	if (freq != NULL) free(freq);

	bins = NULL;
	freq = NULL;

	return;
}
Example #14
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;
}
void oppositionPlot(void) {
  int i;
  double rasun, decsun, distsun, toporasun, topodecsun, x, y, z;
  double jd, lstm, trueam, alt, ha, phi, longEcliptic, latEcliptic;
  double objra, objdec;
  
  openPlot("opposition");
  cpgpap(PLOTSIZE/0.5,0.5);

  cpgbbuf();

  cpgsubp(2,2);

  cpgpanl(1,1);
  cpgswin(PHIMIN, PHIMAX, AMMIN, AMMAX);
  cpgbox("BCNTS",0.0,0,"BVCNTS",0.0,0);
  cpgmtxt("L",2.0,0.5,0.5,"airmass");
  cpgmtxt("B",2.0,0.5,0.5,"angle from Sun");

  cpgsci(2);
  for(i=0; i<numobs; i++) {

    jd = obs[i].date + 2400000.5;
    lstm = lst(jd,longitude_hrs);

    // get ecliptic coordinates
    slaEqecl(obs[i].ra, obs[i].dec, obs[i].date, &longEcliptic, &latEcliptic);

    if(fabs(latEcliptic) < 10.0/DEG_IN_RADIAN && obs[i].twilight==0) {

      // get position of Sun
      accusun(jd, lstm, latitude_deg, &rasun, &decsun, &distsun,
              &toporasun, &topodecsun, &x, &y, &z);

      // sun-object angle in degrees
      // takes ra in hours, dec in degrees
      objra = adj_time(obs[i].ra*HRS_IN_RADIAN);
      objdec = obs[i].dec*DEG_IN_RADIAN;
      phi = mysubtend(rasun, decsun, objra, objdec)*DEG_IN_RADIAN;
      
      // angle from opposition is 180-phi
      //      FIXRANGE(phi,-180.0,180.0);
      
      //airmass takes ra, dec, in radians, returns true airmass
      airmass(obs[i].date, obs[i].ra, obs[i].dec, &trueam, &alt, &ha);
      
      cpgpt1(phi, trueam, -1);

    }
  }

  cpgsci(1);
  cpgptxt(0.0,3.0,0.0,0.5,"|ecliptic latitude|<10");
  cpgptxt(0.0,2.5,0.0,0.5,"night");

  cpgsci(3);
  cpgmove(-90.0,0.0);
  cpgdraw(-90.0,4.0);
  cpgmove( 90.0,0.0);
  cpgdraw( 90.0,4.0);
  cpgsci(1);


  cpgpanl(1,2);
  cpgswin(PHIMIN, PHIMAX, AMMIN, AMMAX);
  cpgbox("BCNTS",0.0,0,"BVCNTS",0.0,0);
  cpgmtxt("L",2.0,0.5,0.5,"airmass");
  cpgmtxt("B",2.0,0.5,0.5,"angle from Sun");

  cpgsci(2);
  for(i=0; i<numobs; i++) {

    jd = obs[i].date + 2400000.5;
    lstm = lst(jd,longitude_hrs);

    // get ecliptic coordinates
    slaEqecl(obs[i].ra, obs[i].dec, obs[i].date, &longEcliptic, &latEcliptic);

    if(fabs(latEcliptic) >= 10.0/DEG_IN_RADIAN  && obs[i].twilight==0 ) {

      // get position of Sun
      accusun(jd, lstm, latitude_deg, &rasun, &decsun, &distsun,
              &toporasun, &topodecsun, &x, &y, &z);

      // sun-object angle in degrees
      phi = mysubtend(rasun, decsun, obs[i].ra*HRS_IN_RADIAN, obs[i].dec*DEG_IN_RADIAN)*DEG_IN_RADIAN;
      
      // angle from opposition is 180-phi
      FIXRANGE(phi,-180.0,180.0);
      
      airmass(obs[i].date, obs[i].ra, obs[i].dec, &trueam, &alt, &ha);
      
      cpgpt1(phi, trueam, -1);

    }
  }

  cpgsci(1);
  cpgptxt(0.0,3.0,0.0,0.5,"|ecliptic latitude|>10");
  cpgptxt(0.0,2.5,0.0,0.5,"night");

  cpgsci(3);
  cpgmove(-90.0,0.0);
  cpgdraw(-90.0,4.0);
  cpgmove( 90.0,0.0);
  cpgdraw( 90.0,4.0);
  cpgsci(1);


  cpgpanl(2,1);
  cpgswin(PHIMIN, PHIMAX, AMMIN, AMMAX);
  cpgbox("BCNTS",0.0,0,"BVCNTS",0.0,0);
  cpgmtxt("L",2.0,0.5,0.5,"airmass");
  cpgmtxt("B",2.0,0.5,0.5,"angle from Sun");

  cpgsci(2);
  for(i=0; i<numobs; i++) {

    jd = obs[i].date + 2400000.5;
    lstm = lst(jd,longitude_hrs);

    // get ecliptic coordinates
    slaEqecl(obs[i].ra, obs[i].dec, obs[i].date, &longEcliptic, &latEcliptic);

    if(fabs(latEcliptic) < 10.0/DEG_IN_RADIAN  && obs[i].twilight==1) {

      // get position of Sun
      accusun(jd, lstm, latitude_deg, &rasun, &decsun, &distsun,
              &toporasun, &topodecsun, &x, &y, &z);

      // sun-object angle in degrees
      // takes ra in hours, dec in degrees
      objra = adj_time(obs[i].ra*HRS_IN_RADIAN);
      objdec = obs[i].dec*DEG_IN_RADIAN;
      phi = mysubtend(rasun, decsun, objra, objdec)*DEG_IN_RADIAN;
      
      // angle from opposition is 180-phi
      //      FIXRANGE(phi,-180.0,180.0);
      
      //airmass takes ra, dec, in radians, returns true airmass
      airmass(obs[i].date, obs[i].ra, obs[i].dec, &trueam, &alt, &ha);
      
      cpgpt1(phi, trueam, -1);

    }
  }

  cpgsci(1);
  cpgptxt(0.0,3.0,0.0,0.5,"|ecliptic latitude|<10");
  cpgptxt(0.0,2.5,0.0,0.5,"twilight");

  cpgsci(3);
  cpgmove(-90.0,0.0);
  cpgdraw(-90.0,4.0);
  cpgmove( 90.0,0.0);
  cpgdraw( 90.0,4.0);
  cpgsci(1);


  cpgpanl(2,2);
  cpgswin(PHIMIN, PHIMAX, AMMIN, AMMAX);
  cpgbox("BCNTS",0.0,0,"BVCNTS",0.0,0);
  cpgmtxt("L",2.0,0.5,0.5,"airmass");
  cpgmtxt("B",2.0,0.5,0.5,"angle from Sun");

  cpgsci(2);
  for(i=0; i<numobs; i++) {

    jd = obs[i].date + 2400000.5;
    lstm = lst(jd,longitude_hrs);

    // get ecliptic coordinates
    slaEqecl(obs[i].ra, obs[i].dec, obs[i].date, &longEcliptic, &latEcliptic);

    if(fabs(latEcliptic) >= 10.0/DEG_IN_RADIAN  && obs[i].twilight==1) {

      // get position of Sun
      accusun(jd, lstm, latitude_deg, &rasun, &decsun, &distsun,
              &toporasun, &topodecsun, &x, &y, &z);

      // sun-object angle in degrees
      phi = mysubtend(rasun, decsun, obs[i].ra*HRS_IN_RADIAN, obs[i].dec*DEG_IN_RADIAN)*DEG_IN_RADIAN;
      
      // angle from opposition is 180-phi
      FIXRANGE(phi,-180.0,180.0);
      
      airmass(obs[i].date, obs[i].ra, obs[i].dec, &trueam, &alt, &ha);
      
      cpgpt1(phi, trueam, -1);

    }
  }

  cpgsci(1);
  cpgptxt(0.0,3.0,0.0,0.5,"|ecliptic latitude|>10");
  cpgptxt(0.0,2.5,0.0,0.5,"twilight");

  cpgsci(3);
  cpgmove(-90.0,0.0);
  cpgdraw(-90.0,4.0);
  cpgmove( 90.0,0.0);
  cpgdraw( 90.0,4.0);
  cpgsci(1);


  cpgebuf();
  closePlot();
}
Example #16
0
void plot(GRAPHCONTROL *gr, SET *p) {
	char t[1024];

	cpgsch(FS);
	cpgsci(1);

	cpgsvp(0.07, 0.93, 0.35, 0.9);
	cpgeras();
	cpgswin(gr->xmin, gr->xmax, gr->ymin, gr->ymax);
	cpgbox("BCNST", 0.0, 0, "BCNST", 0.0, 0);

	cpgbbuf();

	cpgsch(0.8);
	float yp = 3.4;

	sprintf(t,"[n] Ano: %d/%d", p->y1, p->y2);
	cpgmtxt("T", yp, 0.0, 0.0, t);

	sprintf(t,"[m] Magnitude: %.2f/%.2f", p->m1, p->m2);
	cpgmtxt("T", yp, 0.25, 0.0, t);

	sprintf(t,"[s/0] Selecionar Regiao");
	(p->region) ? cpgsci(ON) : cpgsci(OFF);
	cpgmtxt("T", yp, 0.6, 0.0, t);
	cpgsci(1);

	cpgmtxt("T", yp, 0.85, 0.0, "[=] Salvar Print-out");


	yp -= 1.2;

	sprintf(t,"N: %ld",p->n);
	cpgmtxt("T", yp, 0.0, 0.0, t);

	sprintf(t,"[p] Profundidade(p): %.1f/%.1f",p->d1, p->d2);
	cpgmtxt("T", yp, 0.25, 0.0, t);

	sprintf(t,"Longitude: %.2f/%.2f",p->lon1, p->lon2);
	cpgmtxt("T", yp, 0.6, 0.0, t);

        cpgmtxt("T", yp, 0.85, 0.0, "[J] Definir intervalo");

	yp -= 1.2;

	sprintf(t,"Latitude: %.2f/%.2f", p->lat1, p->lat2);
	cpgmtxt("T", yp, 0.6, 0.0, t);

	sprintf(t,"[w] Zoom para todo o mapa");
	cpgmtxt("T", yp, 0.25, 0.0, t);
        
        cpgmtxt("T", yp, 0.85, 0.0, "    de ajuste");
        
	sprintf(t,"[c] Cor: %s", (gr->colormode == COLORDEPTH) ? "Profundidade" : (gr->colormode == COLORMAG) ? "Magnitude" : "Neutra");
	cpgmtxt("R", 1.0, 1.0, 1.0, t);


	(gr->hascontinents) ? cpgsci(ON) : cpgsci(OFF);
	sprintf(t,"[1] Continentes");
	cpgmtxt("R", 1.0, 0.25, 0.0, t);
	cpgsci(1);

	(gr->hasplates) ? cpgsci(ON) : cpgsci(OFF);
	sprintf(t,"[2] Placas");
	cpgmtxt("R", 1.0, 0.0, 0.0, t);
	cpgsci(1);

	// Legenda cores
	cpgsci(1);
	cpgsch(FS);

		/* Graphs */
	int i;
	if (gr->haspoints && p->n > 0) {

		int symbol = 17;
		(p->n > 50) ?  cpgsch(0.4) : cpgsch(FS);

		if (gr->colormode == COLORDEPTH)
			for(i = 0; i< p->n; i++) {
				cpgsci(depthcolor(p->d[i]));
				cpgpt1(p->x[i], p->y[i], symbol);
			}
		else if (gr->colormode == COLORMAG)
			for(i = 0; i< p->n; i++) {
				cpgsci(magcolor(p->m[i]));
				cpgpt1(p->x[i], p->y[i], symbol);
			}
		else
			cpgpt(p->n, p->x, p->y, symbol);

		cpgsci(1);
		cpgsch(FS);
	}

	if (gr->hascontinents >= 1) {
		cpgsci(1);
		cpgslw(2);
		for(i=0; i < ncontinentes; i++) {
			if (continentes[i][0] == -999 && continentes[i][1] == 999 ) {
				i++;
				cpgmove(continentes[i][0], continentes[i][1]);
				continue;
			}
			cpgdraw(continentes[i][0], continentes[i][1]);
		}

		if (gr->hascontinents >=2) {
			cpgslw(1);
			cpgsci(15);
			for(i=0; i < nborders; i++) {
				if (borders[i][0] == -999 && borders[i][1] == 999 ) {
					i++;
					cpgmove(borders[i][0], borders[i][1]);
					continue;
				}
				cpgdraw(borders[i][0], borders[i][1]);
			}
		}
	}

	if (gr->hasplates == 1) {
		cpgsci(3);
		cpgslw(3);
		for(i=0; i < nplates; i++) {
			if (plates[i][0] == -999 && plates[i][1] == 999 ) {
				i++;
				cpgmove(plates[i][0], plates[i][1]);
				continue;
			}
			if (fabs(plates[i][0] - plates[i-1][0]) > 180) {
				cpgmove(plates[i][0], plates[i][1]);
			}
			cpgdraw(plates[i][0], plates[i][1]);
		}
	}

	if (gr->colormode == COLORMAG)
		scalemag();
	else if (gr->colormode == COLORDEPTH)
		scaledep();

	cpgsci(1);
	cpgslw(1);

	cpgebuf();

	cpgsvp(0.07, 0.93, 0.35, 0.9);
	cpgswin(gr->xmin, gr->xmax, gr->ymin, gr->ymax);

	return;
}
Example #17
0
static int plot_dataview(dataview * dv, float minval, float maxval, float charhgt)
/* The return value is offsetn */
{
   int ii, lon, hin, offsetn = 0, tmpn;
   double lot, hit, offsett = 0.0;
   float ns[MAXDISPNUM], hiavg[MAXDISPNUM], loavg[MAXDISPNUM];
   float scalemin = 0.0, scalemax = 0.0, dscale;

   cpgsave();
   cpgbbuf();

   /* Set the "Normal" plotting attributes */

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

   /* Autoscale for the maximum value */
   if (maxval > 0.5 * LARGENUM)
      scalemax = dv->maxval;
   else
      scalemax = maxval;
   /* Autoscale for the minimum value */
   if (minval < 0.5 * SMALLNUM)
      scalemin = dv->minval;
   else
      scalemin = minval;
   dscale = 0.1 * (scalemax - scalemin);
   if (maxval > 0.5 * LARGENUM)
      maxval = scalemax + dscale;
   if (minval < 0.5 * SMALLNUM)
      minval = scalemin - dscale;

   lon = dv->lon;
   lot = lon * idata.dt;
   hin = lon + dv->numsamps;
   hit = hin * idata.dt;

   /* Time Labels (top of box) */

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

      offsett = 0.5 * (hit + lot);
      numchar = snprintf(label, 50, "Time - %.15g (s)", offsett);
      cpgmtxt("T", 2.5, 0.5, 0.5, label);
   } else {
      cpgmtxt("T", 2.5, 0.5, 0.5, "Time (s)");
   }
   cpgswin(lot - offsett, hit - offsett, minval, maxval);
   cpgbox("CMST", 0.0, 0, "", 0.0, 0);

   /* Sample number labels */

   if (lon > 10000000 || (double) (hin - lon) / (double) hin < 0.001) {
      int numchar;
      char label[50];

      offsetn = (lon / 10000) * 10000;
      numchar = snprintf(label, 50, "Sample - %d", offsetn);
      cpgmtxt("B", 2.8, 0.5, 0.5, label);
   } else {
      cpgmtxt("B", 2.8, 0.5, 0.5, "Sample");
   }
   cpgswin(lon - offsetn, hin - offsetn, minval, maxval);
   cpgbox("BNST", 0.0, 0, "BCNST", 0.0, 0);

   /* Plot the rawdata if required */

   tmpn = lon - offsetn;
   if (plotstats == 0 || plotstats == 2) {
      if (dv->zoomlevel > 0) {
         for (ii = 0; ii < dv->dispnum; ii++)
            ns[ii] = tmpn + ii;
         cpgbin(dv->dispnum, ns, dv->vals, 0);
      } else {                  /* Plot the min/max values */
         for (ii = 0; ii < dv->numchunks; ii++, tmpn += dv->chunklen) {
            cpgmove((float) tmpn, dv->mins[ii]);
            cpgdraw((float) tmpn, dv->maxs[ii]);
         }
      }
   }

   /* Plot the other statistics if requested */

   if (plotstats == 0 || plotstats == 1) {
      tmpn = lon - offsetn;
      for (ii = 0; ii < dv->numchunks; ii++, tmpn += dv->chunklen) {
         ns[ii] = tmpn;
         hiavg[ii] = dv->avgmeds[ii] + dv->stds[ii];
         loavg[ii] = dv->avgmeds[ii] - dv->stds[ii];
      }
      if (dv->numchunks > 512) {
         if (plotstats == 1) {
            cpgline(dv->numchunks, ns, dv->mins);
            cpgline(dv->numchunks, ns, dv->maxs);
         }
         cpgsci(AVGMED_COLOR);
         cpgline(dv->numchunks, ns, dv->avgmeds);
         if (usemedian)
            cpgmtxt("T", -1.4, 0.02, 0.0, "Median");
         else
            cpgmtxt("T", -1.4, 0.02, 0.0, "Average");
         cpgsci(STDDEV_COLOR);
         cpgline(dv->numchunks, ns, hiavg);
         cpgline(dv->numchunks, ns, loavg);
         cpgmtxt("T", -2.6, 0.02, 0.0, "+/- 1 Std Dev");
      } else {
         if (plotstats == 1) {
            cpgbin(dv->numchunks, ns, dv->mins, 0);
            cpgbin(dv->numchunks, ns, dv->maxs, 0);
         }
         cpgsci(AVGMED_COLOR);
         cpgbin(dv->numchunks, ns, dv->avgmeds, 0);
         if (usemedian)
            cpgmtxt("T", -1.4, 0.02, 0.0, "Median");
         else
            cpgmtxt("T", -1.4, 0.02, 0.0, "Average");
         cpgsci(STDDEV_COLOR);
         cpgbin(dv->numchunks, ns, hiavg, 0);
         cpgbin(dv->numchunks, ns, loavg, 0);
         cpgmtxt("T", -2.6, 0.02, 0.0, "+/- 1 Std Dev");
      }
   }
   cpgsci(1);
   cpgmtxt("L", 2.5, 0.5, 0.5, "Sample Value");
   cpgebuf();
   cpgunsa();
   return offsetn;
}
Example #18
0
static void _pgebuf (void)
{
   cpgebuf ();
}