Ejemplo n.º 1
0
void plot_profile(int proflen, float *profile, const char *title,
                  const char *probtxt, const char *foldtxt,
                  int showerr, float *errors, int showid)
{
    int ii;
    float *x, overy, ymin, ymax;
    float errmin = 0.0, errmax = 0.0, offset, avg = 0.0, av[2];

    find_min_max_arr(proflen, profile, &ymin, &ymax);
    if (showerr)
        find_min_max_arr(proflen, errors, &errmin, &errmax);
    overy = 0.1 * (ymax + errmax - ymin - errmin);
    ymax = ymax + overy + errmax;
    ymin = ymin - overy - errmin;
    x = gen_fvect(proflen);
    for (ii = 0; ii < proflen; ii++)
        x[ii] = (float) ii / (float) proflen;
    cpgenv(0.0, 1.00001, ymin, ymax, 0, 0);
    cpgscf(2);
    cpglab("Pulse Phase", "Counts", "");
    if (showid)
        cpgiden();
    cpgslw(5);
    if (showerr) {
        cpgbin(proflen, x, profile, 0);
    } else {
        cpgline(proflen, x, profile);
    }
    cpgslw(1);
    if (showerr) {
        offset = 0.5 / (float) proflen;
        for (ii = 0; ii < proflen; ii++)
            x[ii] += offset;
        cpgerrb(6, proflen, x, profile, errors, 2);
        cpgpt(proflen, x, profile, 5);
    }
    for (ii = 0; ii < proflen; ii++)
        avg += profile[ii];
    avg /= proflen;
    cpgsls(4);
    x[0] = 0.0;
    x[1] = 1.0;
    av[0] = avg;
    av[1] = avg;
    cpgline(2, x, av);
    cpgsls(1);
    cpgsch(1.3);
    cpgmtxt("T", +2.0, 0.5, 0.5, title);
    cpgsch(1.0);
    cpgmtxt("T", +0.8, 0.5, 0.5, foldtxt);
    cpgmtxt("T", -1.5, 0.5, 0.5, probtxt);
    vect_free(x);
}
Ejemplo n.º 2
0
/* horizontal or vertical error bar */
static void _pgerrb (double *t)
{
   SLang_Array_Type *x, *y, *e;
   int dir;

   if (-1 == pop_three_float_vectors (&x, &y, &e))
     return;

   if (-1 != SLang_pop_integer (&dir))
     {
        cpgerrb (dir, (int)x->num_elements,
                 (float*)x->data, (float*)y->data, (float*)e->data,
                 (float) *t);
     }

   free_arrays (x, y, e, NULL);
}
Ejemplo n.º 3
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);
}