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; }
JNIEXPORT void JNICALL Java_pulsarhunter_PgplotInterface_pgtext (JNIEnv *env, jclass cl, jstring text, jfloat x, jfloat y){ char *textStr = (char*)(*env)->GetStringUTFChars(env,text,NULL); jint strlen = (*env)->GetStringUTFLength(env,text); cpgtext(x,y,textStr); (*env)->ReleaseStringUTFChars(env,text,textStr); }
void scaledep() { int i, d; char t[24]; cpgsci(1); cpgmtxt("T",1.0,0.0,0.0,"Prof.:"); cpgsvp(0.12, 0.25, 0.912, 0.922); cpgswin(0.0,700.0, 0.0, 2.0); cpgsch(0.4); for(i=1.0;i<700.0;i+=10.0) { cpgsci(depthcolor((float)i)); cpgpt1(i,1.0,16); } cpgsci(1); d = 0; cpgsci(depthcolor((float)d)); sprintf(t,"%.1d",d); cpgtext(d-25.0,2.8,t); d = 15; cpgsci(depthcolor((float)d)); sprintf(t,"%.1d",d); cpgtext(d-35.0,-1.8,t); d = 35; cpgsci(depthcolor((float)d)); sprintf(t,"%.1d",d); cpgtext(d-20.0,2.8,t); d = 70; cpgsci(depthcolor((float)d)); sprintf(t,"%.1d",d); cpgtext(d-25,-1.8,t); d = 120; cpgsci(depthcolor((float)d)); sprintf(t,"%.1d",d); cpgtext(d-50,2.8,t); d = 300; cpgsci(depthcolor((float)d)); sprintf(t,"%.1d",d); cpgtext(d-50,2.8,t); cpgsch(FS); cpgsci(1); return; }
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); }
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); }
void scalemag() { int i; char t[24]; cpgsci(1); cpgmtxt("T",1.0,0.0,0.0,"Mag.:"); cpgsvp(0.12, 0.25, 0.912, 0.922); cpgswin(0.0, 11.0, 0.0, 2.0); cpgsch(0.4); for(i=0.0;i<10.0;i++) { cpgsci(magcolor((float)i)); sprintf(t,"%.1d",i); cpgtext(i+1-0.12,2.8,t); cpgpt1(i+1,1.0,16); } cpgsch(FS); cpgsci(1); return; }
void rfifind_plot(int numchan, int numint, int ptsperint, float timesigma, float freqsigma, float inttrigfrac, float chantrigfrac, float **dataavg, float **datastd, float **datapow, int *userchan, int numuserchan, int *userints, int numuserints, infodata * idata, unsigned char **bytemask, mask * oldmask, mask * newmask, rfi * rfivect, int numrfi, int rfixwin, int rfips, int xwin) /* Make the beautiful multi-page rfifind plots */ { int ii, jj, ct, loops = 1; float *freqs, *chans, *times, *ints; float *avg_chan_avg, *std_chan_avg, *pow_chan_avg; float *avg_chan_med, *std_chan_med, *pow_chan_med; float *avg_chan_std, *std_chan_std, *pow_chan_std; float *avg_int_avg, *std_int_avg, *pow_int_avg; float *avg_int_med, *std_int_med, *pow_int_med; float *avg_int_std, *std_int_std, *pow_int_std; float dataavg_avg, datastd_avg, datapow_avg; float dataavg_med, datastd_med, datapow_med; float dataavg_std, datastd_std, datapow_std; float avg_reject, std_reject, pow_reject; double inttim, T, lof, hif; inttim = ptsperint * idata->dt; T = inttim * numint; lof = idata->freq - 0.5 * idata->chan_wid; hif = lof + idata->freqband; avg_chan_avg = gen_fvect(numchan); std_chan_avg = gen_fvect(numchan); pow_chan_avg = gen_fvect(numchan); avg_int_avg = gen_fvect(numint); std_int_avg = gen_fvect(numint); pow_int_avg = gen_fvect(numint); avg_chan_med = gen_fvect(numchan); std_chan_med = gen_fvect(numchan); pow_chan_med = gen_fvect(numchan); avg_int_med = gen_fvect(numint); std_int_med = gen_fvect(numint); pow_int_med = gen_fvect(numint); avg_chan_std = gen_fvect(numchan); std_chan_std = gen_fvect(numchan); pow_chan_std = gen_fvect(numchan); avg_int_std = gen_fvect(numint); std_int_std = gen_fvect(numint); pow_int_std = gen_fvect(numint); chans = gen_fvect(numchan); freqs = gen_fvect(numchan); for (ii = 0; ii < numchan; ii++) { chans[ii] = ii; freqs[ii] = idata->freq + ii * idata->chan_wid; } ints = gen_fvect(numint); times = gen_fvect(numint); for (ii = 0; ii < numint; ii++) { ints[ii] = ii; times[ii] = 0.0 + ii * inttim; } /* Calculate the statistics of the full set */ ct = numchan * numint; calc_avgmedstd(dataavg[0], ct, 0.8, 1, &dataavg_avg, &dataavg_med, &dataavg_std); calc_avgmedstd(datastd[0], ct, 0.8, 1, &datastd_avg, &datastd_med, &datastd_std); calc_avgmedstd(datapow[0], ct, 0.5, 1, &datapow_avg, &datapow_med, &datapow_std); avg_reject = timesigma * dataavg_std; std_reject = timesigma * datastd_std; pow_reject = power_for_sigma(freqsigma, 1, ptsperint / 2); /* Calculate the channel/integration statistics vectors */ for (ii = 0; ii < numint; ii++) { calc_avgmedstd(dataavg[0] + ii * numchan, numchan, 0.8, 1, avg_int_avg + ii, avg_int_med + ii, avg_int_std + ii); calc_avgmedstd(datastd[0] + ii * numchan, numchan, 0.8, 1, std_int_avg + ii, std_int_med + ii, std_int_std + ii); calc_avgmedstd(datapow[0] + ii * numchan, numchan, 0.5, 1, pow_int_avg + ii, pow_int_med + ii, pow_int_std + ii); } for (ii = 0; ii < numchan; ii++) { calc_avgmedstd(dataavg[0] + ii, numint, 0.8, numchan, avg_chan_avg + ii, avg_chan_med + ii, avg_chan_std + ii); calc_avgmedstd(datastd[0] + ii, numint, 0.8, numchan, std_chan_avg + ii, std_chan_med + ii, std_chan_std + ii); calc_avgmedstd(datapow[0] + ii, numint, 0.5, numchan, pow_chan_avg + ii, pow_chan_med + ii, pow_chan_std + ii); /* fprintf(stderr, "%12.7g %12.7g %12.7g %12.7g %12.7g %12.7g %12.7g %12.7g %12.7g \n", avg_chan_avg[ii], avg_chan_med[ii], avg_chan_std[ii], std_chan_avg[ii], std_chan_med[ii], std_chan_std[ii], pow_chan_avg[ii], pow_chan_med[ii], pow_chan_std[ii]); */ } /* Generate the byte mask */ /* Set the channels/intervals picked by the user */ if (numuserints) for (ii = 0; ii < numuserints; ii++) if (userints[ii] >= 0 && userints[ii] < numint) for (jj = 0; jj < numchan; jj++) bytemask[userints[ii]][jj] |= USERINTS; if (numuserchan) for (ii = 0; ii < numuserchan; ii++) if (userchan[ii] >= 0 && userchan[ii] < numchan) for (jj = 0; jj < numint; jj++) bytemask[jj][userchan[ii]] |= USERCHAN; /* Compare each point in an interval (or channel) with */ /* the interval's (or channel's) median and the overall */ /* standard deviation. If the channel/integration */ /* medians are more than sigma different than the global */ /* value, set them to the global. */ { float int_med, chan_med; for (ii = 0; ii < numint; ii++) { for (jj = 0; jj < numchan; jj++) { { /* Powers */ if (datapow[ii][jj] > pow_reject) if (!(bytemask[ii][jj] & PADDING)) bytemask[ii][jj] |= BAD_POW; } { /* Averages */ if (fabs(avg_int_med[ii] - dataavg_med) > timesigma * dataavg_std) int_med = dataavg_med; else int_med = avg_int_med[ii]; if (fabs(avg_chan_med[jj] - dataavg_med) > timesigma * dataavg_std) chan_med = dataavg_med; else chan_med = avg_chan_med[jj]; if (fabs(dataavg[ii][jj] - int_med) > avg_reject || fabs(dataavg[ii][jj] - chan_med) > avg_reject) if (!(bytemask[ii][jj] & PADDING)) bytemask[ii][jj] |= BAD_AVG; } { /* Standard Deviations */ if (fabs(std_int_med[ii] - datastd_med) > timesigma * datastd_std) int_med = datastd_med; else int_med = std_int_med[ii]; if (fabs(std_chan_med[jj] - datastd_med) > timesigma * datastd_std) chan_med = datastd_med; else chan_med = std_chan_med[jj]; if (fabs(datastd[ii][jj] - int_med) > std_reject || fabs(datastd[ii][jj] - chan_med) > std_reject) if (!(bytemask[ii][jj] & PADDING)) bytemask[ii][jj] |= BAD_STD; } } } } /* Step over the intervals and channels and count how many are set "bad". */ /* For a given interval, if the number of bad channels is greater than */ /* chantrigfrac*numchan then reject the whole interval. */ /* For a given channel, if the number of bad intervals is greater than */ /* inttrigfrac*numint then reject the whole channel. */ { int badnum, trignum; /* Loop over the intervals */ trignum = (int) (numchan * chantrigfrac); for (ii = 0; ii < numint; ii++) { if (!(bytemask[ii][0] & USERINTS)) { badnum = 0; for (jj = 0; jj < numchan; jj++) if (bytemask[ii][jj] & BADDATA) badnum++; if (badnum > trignum) { userints[numuserints++] = ii; for (jj = 0; jj < numchan; jj++) bytemask[ii][jj] |= USERINTS; } } } /* Loop over the channels */ trignum = (int) (numint * inttrigfrac); for (ii = 0; ii < numchan; ii++) { if (!(bytemask[0][ii] & USERCHAN)) { badnum = 0; for (jj = 0; jj < numint; jj++) if (bytemask[jj][ii] & BADDATA) badnum++; if (badnum > trignum) { userchan[numuserchan++] = ii; for (jj = 0; jj < numint; jj++) bytemask[jj][ii] |= USERCHAN; } } } } /* Generate the New Mask */ fill_mask(timesigma, freqsigma, idata->mjd_i + idata->mjd_f, ptsperint * idata->dt, idata->freq, idata->chan_wid, numchan, numint, ptsperint, numuserchan, userchan, numuserints, userints, bytemask, newmask); /* Place the oldmask over the newmask for plotting purposes */ if (oldmask->numchan) set_oldmask_bits(oldmask, bytemask); /* * Now plot the results */ if (xwin) loops = 2; for (ct = 0; ct < loops; ct++) { /* PS/XWIN Plot Loop */ float min, max, tr[6], locut, hicut; float left, right, top, bottom; float xl, xh, yl, yh; float tt, ft, th, fh; /* thin and fat thicknesses and heights */ float lm, rm, tm, bm; /* LRTB margins */ float xarr[2], yarr[2]; char outdev[100]; int ii, mincol, maxcol, numcol; /*Set the PGPLOT device to an X-Window */ if (ct == 1) strcpy(outdev, "/XWIN"); else sprintf(outdev, "%s.ps/CPS", idata->name); /* Open and prep our device */ cpgopen(outdev); cpgpap(10.25, 8.5 / 11.0); cpgpage(); cpgiden(); cpgsch(0.7); cpgqcir(&mincol, &maxcol); numcol = maxcol - mincol + 1; for (ii = mincol; ii <= maxcol; ii++) { float color; color = (float) (maxcol - ii) / (float) numcol; cpgscr(ii, color, color, color); } /* Set thicknesses and margins */ lm = 0.04; rm = 0.04; bm = 0.08; tm = 0.05; ft = 3.0; /* This sets fat thickness = 3 x thin thickness */ tt = 0.92 / (6.0 + 4.0 * ft); ft *= tt; fh = 0.55; th = tt * 11.0 / 8.5; { /* Powers Histogram */ float *theo, *hist, *hpows, *tpows, maxhist = 0.0, maxtheo = 0.0; int numhist = 40, numtheo = 200, bin, numpows; double dtheo, dhist, spacing; /* Calculate the predicted distribution of max powers */ numpows = numint * numchan; find_min_max_arr(numpows, datapow[0], &min, &max); min = (min < 5.0) ? log10(5.0 * 0.95) : log10(min * 0.95); max = log10(max * 1.05); dhist = (max - min) / numhist; theo = gen_fvect(numtheo); tpows = gen_fvect(numtheo); hist = gen_fvect(numhist); hpows = gen_fvect(numhist); for (ii = 0; ii < numhist; ii++) { hist[ii] = 0.0; hpows[ii] = min + ii * dhist; } for (ii = 0; ii < numpows; ii++) { bin = (*(datapow[0] + ii) == 0.0) ? 0 : (log10(*(datapow[0] + ii)) - min) / dhist; if (bin < 0) bin = 0; if (bin >= numhist) bin = numhist; hist[bin] += 1.0; } for (ii = 0; ii < numhist; ii++) if (hist[ii] > maxhist) maxhist = hist[ii]; maxhist *= 1.1; dtheo = (max - min) / (double) (numtheo - 1); for (ii = 0; ii < numtheo; ii++) { tpows[ii] = min + ii * dtheo; theo[ii] = single_power_pdf(pow(10.0, tpows[ii]), ptsperint / 2) * numpows; spacing = (pow(10.0, tpows[ii] + dhist) - pow(10.0, tpows[ii])); theo[ii] *= spacing; if (theo[ii] > maxtheo) maxtheo = theo[ii]; } maxtheo *= 1.1; if (maxtheo > maxhist) maxhist = maxtheo; left = lm; right = lm + ft + tt; bottom = 0.80; top = 0.96; cpgsvp(left, right, bottom, top); xl = min; xh = max; yl = 0.0; yh = maxhist; cpgswin(xl, xh, yl, yh); cpgmtxt("L", 1.1, 0.5, 0.5, "Number"); cpgmtxt("B", 2.1, 0.5, 0.5, "Max Power"); cpgbin(numhist, hpows, hist, 0); cpgscr(maxcol, 0.5, 0.5, 0.5); cpgsci(maxcol); /* Grey */ cpgline(numtheo, tpows, theo); xarr[0] = log10(power_for_sigma(freqsigma, 1, ptsperint / 2)); xarr[1] = xarr[0]; yarr[0] = yl; yarr[1] = yh; cpgsls(4); /* Dotted line */ cpgscr(maxcol, 1.0, 0.0, 0.0); cpgsci(maxcol); /* Red */ cpgline(2, xarr, yarr); cpgsls(1); /* Solid line */ cpgsci(1); /* Default color */ cpgbox("BCLNST", 0.0, 0, "BC", 0.0, 0); vect_free(hist); vect_free(theo); vect_free(tpows); vect_free(hpows); } /* Maximum Powers */ left = lm; right = lm + ft; bottom = bm; top = bm + fh; xl = 0.0; xh = numchan; yl = 0.0; yh = T; cpgsvp(left, right, bottom, top); cpgswin(xl, xh, yl, yh); cpgscr(maxcol, 1.0, 0.0, 0.0); /* Red */ locut = 0.0; hicut = pow_reject; tr[2] = tr[4] = 0.0; tr[1] = (xh - xl) / numchan; tr[0] = xl - (tr[1] / 2); tr[5] = (yh - yl) / numint; tr[3] = yl - (tr[5] / 2); cpgimag(datapow[0], numchan, numint, 1, numchan, 1, numint, locut, hicut, tr); cpgswin(xl, xh, yl, yh); cpgbox("BNST", 0.0, 0, "BNST", 0.0, 0); cpgmtxt("B", 2.6, 0.5, 0.5, "Channel"); cpgmtxt("L", 2.1, 0.5, 0.5, "Time (s)"); xl = lof; xh = hif; yl = 0.0; yh = numint; cpgswin(xl, xh, yl, yh); cpgbox("CST", 0.0, 0, "CST", 0.0, 0); /* Max Power Label */ left = lm + ft; right = lm + ft + tt; bottom = bm + fh; top = bm + fh + th; cpgsvp(left, right, bottom, top); cpgswin(0.0, 1.0, 0.0, 1.0); cpgscr(maxcol, 1.0, 0.0, 0.0); cpgsci(maxcol); /* Red */ cpgptxt(0.5, 0.7, 0.0, 0.5, "Max"); cpgptxt(0.5, 0.3, 0.0, 0.5, "Power"); cpgsci(1); /* Default color */ /* Max Power versus Time */ left = lm + ft; right = lm + ft + tt; bottom = bm; top = bm + fh; cpgsvp(left, right, bottom, top); find_min_max_arr(numint, pow_int_med, &min, &max); xl = 0.0; xh = 1.5 * pow_reject; yl = 0.0; yh = T; cpgswin(xl, xh, yl, yh); cpgbox("BCST", 0.0, 0, "BST", 0.0, 0); cpgscr(maxcol, 1.0, 0.0, 0.0); cpgsci(maxcol); /* Red */ yarr[0] = yl; yarr[1] = yh; xarr[0] = xarr[1] = datapow_med; cpgline(2, xarr, yarr); cpgsls(4); /* Dotted line */ xarr[0] = xarr[1] = pow_reject; cpgline(2, xarr, yarr); cpgsls(1); /* Solid line */ cpgsci(1); /* Default color */ cpgline(numint, pow_int_med, times); yl = 0.0; yh = numint; cpgswin(xl, xh, yl, yh); cpgbox("", 0.0, 0, "CMST", 0.0, 0); /* cpgmtxt("R", 2.3, 0.5, 0.5, "Interval Number"); */ /* Max Power versus Channel */ left = lm; right = lm + ft; bottom = bm + fh; top = bm + fh + th; cpgsvp(left, right, bottom, top); find_min_max_arr(numchan, pow_chan_med, &min, &max); xl = 0.0; xh = numchan; yl = 0.0; yh = 1.5 * pow_reject; cpgswin(xl, xh, yl, yh); cpgbox("BST", 0.0, 0, "BCST", 0.0, 0); cpgscr(maxcol, 1.0, 0.0, 0.0); cpgsci(maxcol); /* Red */ xarr[0] = xl; xarr[1] = xh; yarr[0] = yarr[1] = datapow_med; cpgline(2, xarr, yarr); cpgsls(4); /* Dotted line */ yarr[0] = yarr[1] = pow_reject; cpgline(2, xarr, yarr); cpgsls(1); /* Solid line */ cpgsci(1); /* Default color */ cpgline(numchan, chans, pow_chan_med); xl = lof; xh = hif; cpgswin(xl, xh, yl, yh); cpgbox("CMST", 0.0, 0, "", 0.0, 0); cpgmtxt("T", 1.8, 0.5, 0.5, "Frequency (MHz)"); /* Standard Deviations */ left = lm + ft + 2.0 * tt; right = lm + 2.0 * ft + 2.0 * tt; bottom = bm; top = bm + fh; xl = 0.0; xh = numchan; yl = 0.0; yh = T; cpgsvp(left, right, bottom, top); cpgswin(xl, xh, yl, yh); cpgscr(mincol, 0.7, 1.0, 0.7); /* Light Green */ cpgscr(maxcol, 0.3, 1.0, 0.3); /* Dark Green */ locut = datastd_med - timesigma * datastd_std; hicut = datastd_med + timesigma * datastd_std; tr[2] = tr[4] = 0.0; tr[1] = (xh - xl) / numchan; tr[0] = xl - (tr[1] / 2); tr[5] = (yh - yl) / numint; tr[3] = yl - (tr[5] / 2); cpgimag(datastd[0], numchan, numint, 1, numchan, 1, numint, locut, hicut, tr); cpgswin(xl, xh, yl, yh); cpgbox("BNST", 0.0, 0, "BNST", 0.0, 0); cpgmtxt("B", 2.6, 0.5, 0.5, "Channel"); xl = lof; xh = hif; yl = 0.0; yh = numint; cpgswin(xl, xh, yl, yh); cpgbox("CST", 0.0, 0, "CST", 0.0, 0); /* Data Sigma Label */ left = lm + 2.0 * ft + 2.0 * tt; right = lm + 2.0 * ft + 3.0 * tt; bottom = bm + fh; top = bm + fh + th; cpgsvp(left, right, bottom, top); cpgswin(0.0, 1.0, 0.0, 1.0); cpgscr(maxcol, 0.0, 1.0, 0.0); cpgsci(maxcol); /* Green */ cpgptxt(0.5, 0.7, 0.0, 0.5, "Data"); cpgptxt(0.5, 0.3, 0.0, 0.5, "Sigma"); cpgsci(1); /* Default color */ /* Data Sigma versus Time */ left = lm + 2.0 * ft + 2.0 * tt; right = lm + 2.0 * ft + 3.0 * tt; bottom = bm; top = bm + fh; cpgsvp(left, right, bottom, top); xl = datastd_med - 2.0 * std_reject; xh = datastd_med + 2.0 * std_reject; yl = 0.0; yh = T; cpgswin(xl, xh, yl, yh); cpgbox("BCST", 0.0, 0, "BST", 0.0, 0); cpgscr(maxcol, 0.0, 1.0, 0.0); cpgsci(maxcol); /* Green */ yarr[0] = yl; yarr[1] = yh; xarr[0] = xarr[1] = datastd_med; cpgline(2, xarr, yarr); cpgsls(4); /* Dotted line */ xarr[0] = xarr[1] = datastd_med + std_reject; cpgline(2, xarr, yarr); xarr[0] = xarr[1] = datastd_med - std_reject; cpgline(2, xarr, yarr); cpgsls(1); /* Solid line */ cpgsci(1); /* Default color */ cpgline(numint, std_int_med, times); yl = 0.0; yh = numint; cpgswin(xl, xh, yl, yh); cpgbox("", 0.0, 0, "CMST", 0.0, 0); /* cpgmtxt("R", 2.3, 0.5, 0.5, "Interval Number"); */ /* Data Sigma versus Channel */ left = lm + ft + 2.0 * tt; right = lm + 2.0 * ft + 2.0 * tt; bottom = bm + fh; top = bm + fh + th; cpgsvp(left, right, bottom, top); xl = 0.0; xh = numchan; yl = datastd_med - 2.0 * std_reject; yh = datastd_med + 2.0 * std_reject; cpgswin(xl, xh, yl, yh); cpgbox("BST", 0.0, 0, "BCST", 0.0, 0); cpgscr(maxcol, 0.0, 1.0, 0.0); cpgsci(maxcol); /* Green */ xarr[0] = xl; xarr[1] = xh; yarr[0] = yarr[1] = datastd_med; cpgline(2, xarr, yarr); cpgsls(4); /* Dotted line */ yarr[0] = yarr[1] = datastd_med + std_reject; cpgline(2, xarr, yarr); yarr[0] = yarr[1] = datastd_med - std_reject; cpgline(2, xarr, yarr); cpgsls(1); /* Solid line */ cpgsci(1); /* Default color */ cpgline(numchan, chans, std_chan_med); xl = lof; xh = hif; cpgswin(xl, xh, yl, yh); cpgbox("CMST", 0.0, 0, "", 0.0, 0); cpgmtxt("T", 1.8, 0.5, 0.5, "Frequency (MHz)"); /* Data Mean */ left = lm + 2.0 * ft + 4.0 * tt; right = lm + 3.0 * ft + 4.0 * tt; bottom = bm; top = bm + fh; xl = 0.0; xh = numchan; yl = 0.0; yh = T; cpgsvp(left, right, bottom, top); cpgswin(xl, xh, yl, yh); cpgscr(mincol, 0.7, 0.7, 1.0); /* Light Blue */ cpgscr(maxcol, 0.3, 0.3, 1.0); /* Dark Blue */ locut = dataavg_med - timesigma * dataavg_std; hicut = dataavg_med + timesigma * dataavg_std; tr[2] = tr[4] = 0.0; tr[1] = (xh - xl) / numchan; tr[0] = xl - (tr[1] / 2); tr[5] = (yh - yl) / numint; tr[3] = yl - (tr[5] / 2); cpgimag(dataavg[0], numchan, numint, 1, numchan, 1, numint, locut, hicut, tr); cpgswin(xl, xh, yl, yh); cpgbox("BNST", 0.0, 0, "BNST", 0.0, 0); cpgmtxt("B", 2.6, 0.5, 0.5, "Channel"); xl = lof; xh = hif; yl = 0.0; yh = numint; cpgswin(xl, xh, yl, yh); cpgbox("CST", 0.0, 0, "CST", 0.0, 0); /* Data Mean Label */ left = lm + 3.0 * ft + 4.0 * tt; right = lm + 3.0 * ft + 5.0 * tt; bottom = bm + fh; top = bm + fh + th; cpgsvp(left, right, bottom, top); cpgswin(0.0, 1.0, 0.0, 1.0); cpgscr(maxcol, 0.0, 0.0, 1.0); cpgsci(maxcol); /* Blue */ cpgptxt(0.5, 0.7, 0.0, 0.5, "Data"); cpgptxt(0.5, 0.3, 0.0, 0.5, "Mean"); cpgsci(1); /* Default color */ /* Data Mean versus Time */ left = lm + 3.0 * ft + 4.0 * tt; right = lm + 3.0 * ft + 5.0 * tt; bottom = bm; top = bm + fh; cpgsvp(left, right, bottom, top); xl = dataavg_med - 2.0 * avg_reject; xh = dataavg_med + 2.0 * avg_reject; yl = 0.0; yh = T; cpgswin(xl, xh, yl, yh); cpgbox("BCST", 0.0, 0, "BST", 0.0, 0); cpgscr(maxcol, 0.0, 0.0, 1.0); cpgsci(maxcol); /* Blue */ yarr[0] = yl; yarr[1] = yh; xarr[0] = xarr[1] = dataavg_med; cpgline(2, xarr, yarr); cpgsls(4); /* Dotted line */ xarr[0] = xarr[1] = dataavg_med + avg_reject; cpgline(2, xarr, yarr); xarr[0] = xarr[1] = dataavg_med - avg_reject; cpgline(2, xarr, yarr); cpgsls(1); /* Solid line */ cpgsci(1); /* Default color */ cpgline(numint, avg_int_med, times); yl = 0.0; yh = numint; cpgswin(xl, xh, yl, yh); cpgbox("", 0.0, 0, "CMST", 0.0, 0); /* Data Mean versus Channel */ left = lm + 2.0 * ft + 4.0 * tt; right = lm + 3.0 * ft + 4.0 * tt; bottom = bm + fh; top = bm + fh + th; cpgsvp(left, right, bottom, top); xl = 0.0; xh = numchan; yl = dataavg_med - 2.0 * avg_reject; yh = dataavg_med + 2.0 * avg_reject; cpgswin(xl, xh, yl, yh); cpgbox("BST", 0.0, 0, "BCST", 0.0, 0); cpgscr(maxcol, 0.0, 0.0, 1.0); cpgsci(maxcol); /* Blue */ xarr[0] = xl; xarr[1] = xh; yarr[0] = yarr[1] = dataavg_med; cpgline(2, xarr, yarr); cpgsls(4); /* Dotted line */ yarr[0] = yarr[1] = dataavg_med + avg_reject; cpgline(2, xarr, yarr); yarr[0] = yarr[1] = dataavg_med - avg_reject; cpgline(2, xarr, yarr); cpgsls(1); /* Solid line */ cpgsci(1); /* Default color */ cpgline(numchan, chans, avg_chan_med); xl = lof; xh = hif; cpgswin(xl, xh, yl, yh); cpgbox("CMST", 0.0, 0, "", 0.0, 0); cpgmtxt("T", 1.8, 0.5, 0.5, "Frequency (MHz)"); { /* Add the Data Info area */ char out[200], out2[100]; float dy = 0.025; cpgsvp(0.0, 1.0, 0.0, 1.0); cpgswin(0.0, 1.0, 0.0, 1.0); left = lm + ft + 1.5 * tt; top = 1.0 - tm; cpgsch(1.0); sprintf(out, "%-s", idata->name); cpgptxt(0.5, 1.0 - 0.5 * tm, 0.0, 0.5, out); cpgsch(0.8); sprintf(out, "Object:"); cpgtext(left + 0.0, top - 0 * dy, out); sprintf(out, "%-s", idata->object); cpgtext(left + 0.1, top - 0 * dy, out); sprintf(out, "Telescope:"); cpgtext(left + 0.0, top - 1 * dy, out); sprintf(out, "%-s", idata->telescope); cpgtext(left + 0.1, top - 1 * dy, out); sprintf(out, "Instrument:"); cpgtext(left + 0.0, top - 2 * dy, out); sprintf(out, "%-s", idata->instrument); cpgtext(left + 0.1, top - 2 * dy, out); ra_dec_to_string(out2, idata->ra_h, idata->ra_m, idata->ra_s); sprintf(out, "RA\\dJ2000\\u"); cpgtext(left + 0.0, top - 3 * dy, out); sprintf(out, "= %-s", out2); cpgtext(left + 0.08, top - 3 * dy, out); ra_dec_to_string(out2, idata->dec_d, idata->dec_m, idata->dec_s); sprintf(out, "DEC\\dJ2000\\u"); cpgtext(left + 0.0, top - 4 * dy, out); sprintf(out, "= %-s", out2); cpgtext(left + 0.08, top - 4 * dy, out); sprintf(out, "Epoch\\dtopo\\u"); cpgtext(left + 0.0, top - 5 * dy, out); sprintf(out, "= %-.11f", idata->mjd_i + idata->mjd_f); cpgtext(left + 0.08, top - 5 * dy, out); sprintf(out, "T\\dsample\\u (s)"); cpgtext(left + 0.0, top - 6 * dy, out); sprintf(out, "= %g", idata->dt); cpgtext(left + 0.08, top - 6 * dy, out); sprintf(out, "T\\dtotal\\u (s)"); cpgtext(left + 0.0, top - 7 * dy, out); sprintf(out, "= %g", T); cpgtext(left + 0.08, top - 7 * dy, out); left = lm + ft + 7.8 * tt; sprintf(out, "Num channels"); cpgtext(left + 0.0, top - 0 * dy, out); sprintf(out, "= %-d", numchan); cpgtext(left + 0.12, top - 0 * dy, out); sprintf(out, "Pts per int"); cpgtext(left + 0.19, top - 0 * dy, out); sprintf(out, "= %-d", ptsperint); cpgtext(left + 0.29, top - 0 * dy, out); sprintf(out, "Num intervals"); cpgtext(left + 0.0, top - 1 * dy, out); sprintf(out, "= %-d", numint); cpgtext(left + 0.12, top - 1 * dy, out); sprintf(out, "Time per int"); cpgtext(left + 0.19, top - 1 * dy, out); sprintf(out, "= %-g", inttim); cpgtext(left + 0.29, top - 1 * dy, out); sprintf(out, "Power:"); cpgtext(left + 0.0, top - 2 * dy, out); sprintf(out, "median"); cpgtext(left + 0.06, top - 2 * dy, out); sprintf(out, "= %-.3f", datapow_med); cpgtext(left + 0.12, top - 2 * dy, out); sprintf(out, "\\gs"); cpgtext(left + 0.21, top - 2 * dy, out); sprintf(out, "= %-.3g", datapow_std); cpgtext(left + 0.245, top - 2 * dy, out); find_min_max_arr(numint * numchan, datapow[0], &min, &max); sprintf(out, "min"); cpgtext(left + 0.06, top - 3 * dy, out); sprintf(out, "= %-.3f", min); cpgtext(left + 0.12, top - 3 * dy, out); sprintf(out, "max"); cpgtext(left + 0.21, top - 3 * dy, out); sprintf(out, "= %-.3f", max); cpgtext(left + 0.245, top - 3 * dy, out); sprintf(out, "Sigma:"); cpgtext(left + 0.0, top - 4 * dy, out); sprintf(out, "median"); cpgtext(left + 0.06, top - 4 * dy, out); sprintf(out, "= %-.3f", datastd_med); cpgtext(left + 0.12, top - 4 * dy, out); sprintf(out, "\\gs"); cpgtext(left + 0.21, top - 4 * dy, out); sprintf(out, "= %-.3g", datastd_std); cpgtext(left + 0.245, top - 4 * dy, out); find_min_max_arr(numint * numchan, datastd[0], &min, &max); sprintf(out, "min"); cpgtext(left + 0.06, top - 5 * dy, out); sprintf(out, "= %-.3f", min); cpgtext(left + 0.12, top - 5 * dy, out); sprintf(out, "max"); cpgtext(left + 0.21, top - 5 * dy, out); sprintf(out, "= %-.3f", max); cpgtext(left + 0.245, top - 5 * dy, out); sprintf(out, "Mean:"); cpgtext(left + 0.0, top - 6 * dy, out); sprintf(out, "median"); cpgtext(left + 0.06, top - 6 * dy, out); sprintf(out, "= %-.3f", dataavg_med); cpgtext(left + 0.12, top - 6 * dy, out); sprintf(out, "\\gs"); cpgtext(left + 0.21, top - 6 * dy, out); sprintf(out, "= %-.3g", dataavg_std); cpgtext(left + 0.245, top - 6 * dy, out); find_min_max_arr(numint * numchan, dataavg[0], &min, &max); sprintf(out, "min"); cpgtext(left + 0.06, top - 7 * dy, out); sprintf(out, "= %-.3f", min); cpgtext(left + 0.12, top - 7 * dy, out); sprintf(out, "max"); cpgtext(left + 0.21, top - 7 * dy, out); sprintf(out, "= %-.3f", max); cpgtext(left + 0.245, top - 7 * dy, out); } { /* Plot the Mask */ unsigned char byte; char temp[200]; float **plotmask, rr, gg, bb, page; plotmask = gen_fmatrix(numint, numchan); for (ii = 0; ii < numint; ii++) { for (jj = 0; jj < numchan; jj++) { byte = bytemask[ii][jj]; plotmask[ii][jj] = 0.0; if (byte & PADDING) plotmask[ii][jj] = 1.0; if (byte & OLDMASK) plotmask[ii][jj] = 2.0; if (byte & USERZAP) plotmask[ii][jj] = 3.0; if (byte & BAD_POW) plotmask[ii][jj] = 4.0; else if (byte & BAD_AVG) plotmask[ii][jj] = 5.0; else if (byte & BAD_STD) plotmask[ii][jj] = 6.0; } } /* Set the colors */ numcol = 7; maxcol = mincol + numcol - 1; cpgscir(mincol, maxcol); cpgqcr(0, &rr, &gg, &bb); cpgscr(mincol + 0, rr, gg, bb); /* GOODDATA = background */ cpgscr(mincol + 1, 0.7, 0.7, 0.7); /* PADDING = light grey */ cpgscr(mincol + 2, 0.3, 0.3, 0.3); /* OLDMASK = dark grey */ cpgqcr(1, &rr, &gg, &bb); cpgscr(mincol + 3, rr, gg, bb); /* USERZAP = foreground */ cpgscr(mincol + 4, 1.0, 0.0, 0.0); /* BAD+POW = red */ cpgscr(mincol + 5, 0.0, 0.0, 1.0); /* BAD+AVG = blue */ cpgscr(mincol + 6, 0.0, 1.0, 0.0); /* BAD+STD = green */ /* Prep the image */ for (page = 0; page <= 1; page++) { xl = 0.0; xh = numchan; yl = 0.0; yh = T; locut = 0.0; hicut = 6.0; tr[2] = tr[4] = 0.0; tr[1] = (xh - xl) / numchan; tr[0] = xl - (tr[1] / 2); tr[5] = (yh - yl) / numint; tr[3] = yl - (tr[5] / 2); if (page == 0) { left = lm + 3.0 * ft + 6.0 * tt; right = lm + 4.0 * ft + 6.0 * tt; bottom = bm; top = bm + fh; } else { cpgpage(); cpgiden(); left = 0.06; right = 0.94; bottom = 0.06; top = 0.88; } cpgsvp(left, right, bottom, top); cpgswin(xl, xh, yl, yh); cpgimag(plotmask[0], numchan, numint, 1, numchan, 1, numint, locut, hicut, tr); cpgswin(xl, xh, yl, yh); cpgbox("BNST", 0.0, 0, "BNST", 0.0, 0); cpgmtxt("B", 2.6, 0.5, 0.5, "Channel"); if (page) cpgmtxt("L", 2.1, 0.5, 0.5, "Time (s)"); xl = lof; xh = hif; yl = 0.0; yh = numint; cpgswin(xl, xh, yl, yh); cpgbox("CMST", 0.0, 0, "CMST", 0.0, 0); cpgmtxt("T", 1.8, 0.5, 0.5, "Frequency (MHz)"); cpgmtxt("R", 2.3, 0.5, 0.5, "Interval Number"); /* Add the Labels */ cpgsvp(0.0, 1.0, 0.0, 1.0); cpgswin(0.0, 1.0, 0.0, 1.0); cpgsch(0.8); if (page == 0) { cpgsci(mincol + 1); cpgptxt(left, top + 0.1, 0.0, 0.0, "Padding"); cpgsci(mincol + 2); cpgptxt(left, top + 0.08, 0.0, 0.0, "Old Mask"); cpgsci(mincol + 3); cpgptxt(left, top + 0.06, 0.0, 0.0, "User Zap"); cpgsci(mincol + 4); cpgptxt(right, top + 0.1, 0.0, 1.0, "Power"); cpgsci(mincol + 6); cpgptxt(right, top + 0.08, 0.0, 1.0, "Sigma"); cpgsci(mincol + 5); cpgptxt(right, top + 0.06, 0.0, 1.0, "Mean"); cpgsci(1); } else { cpgsci(mincol + 1); cpgptxt(1.0 / 12.0, 0.955, 0.0, 0.5, "Padding"); cpgsci(mincol + 2); cpgptxt(3.0 / 12.0, 0.955, 0.0, 0.5, "Old Mask"); cpgsci(mincol + 3); cpgptxt(5.0 / 12.0, 0.955, 0.0, 0.5, "User Zap"); cpgsci(mincol + 4); cpgptxt(7.0 / 12.0, 0.955, 0.0, 0.5, "Max Power"); cpgsci(mincol + 6); cpgptxt(9.0 / 12.0, 0.955, 0.0, 0.5, "Data Sigma"); cpgsci(mincol + 5); cpgptxt(11.0 / 12.0, 0.955, 0.0, 0.5, "Data Mean"); cpgsci(1); cpgsch(0.9); sprintf(temp, "Recommended Mask for '%-s'", idata->name); cpgptxt(0.5, 0.985, 0.0, 0.5, temp); } } vect_free(plotmask[0]); vect_free(plotmask); } if (ct == 0) printf("There are %d RFI instances.\n\n", numrfi); if ((ct == 0 && rfips) || (ct == 1 && rfixwin)) { /* Plot the RFI instances */ int maxcol, mincol, numperpage = 25, numtoplot; float dy = 0.035, top = 0.95, rr, gg, bb; char temp[200]; qsort(rfivect, numrfi, sizeof(rfi), compare_rfi_freq); /* qsort(rfivect, numrfi, sizeof(rfi), compare_rfi_sigma); */ for (ii = 0; ii <= (numrfi - 1) / numperpage; ii++) { cpgpage(); cpgiden(); cpgsvp(0.0, 1.0, 0.0, 1.0); cpgswin(0.0, 1.0, 0.0, 1.0); cpgsch(0.8); sprintf(temp, "%-s", idata->name); cpgtext(0.05, 0.985, temp); cpgsch(0.6); sprintf(temp, "Freq (Hz)"); cpgptxt(0.03, 0.96, 0.0, 0.0, temp); sprintf(temp, "Period (ms)"); cpgptxt(0.12, 0.96, 0.0, 0.0, temp); sprintf(temp, "Sigma"); cpgptxt(0.21, 0.96, 0.0, 0.0, temp); sprintf(temp, "Number"); cpgptxt(0.27, 0.96, 0.0, 0.0, temp); cpgsvp(0.33, 0.64, top - dy, top); cpgswin(lof, hif, 0.0, 1.0); cpgbox("CIMST", 0.0, 0, "", 0.0, 0); cpgmtxt("T", 2.5, 0.5, 0.5, "Frequency (MHz)"); cpgsvp(0.65, 0.96, top - dy, top); cpgswin(0.0, T, 0.0, 1.0); cpgbox("CIMST", 0.0, 0, "", 0.0, 0); cpgmtxt("T", 2.5, 0.5, 0.5, "Time (s)"); cpgqcir(&mincol, &maxcol); maxcol = mincol + 1; cpgscir(mincol, maxcol); cpgqcr(0, &rr, &gg, &bb); cpgscr(mincol, rr, gg, bb); /* background */ cpgqcr(1, &rr, &gg, &bb); /* cpgscr(maxcol, rr, gg, bb); foreground */ cpgscr(maxcol, 0.5, 0.5, 0.5); /* grey */ if (ii == (numrfi - 1) / numperpage) numtoplot = numrfi % numperpage; else numtoplot = numperpage; for (jj = 0; jj < numtoplot; jj++) plot_rfi(rfivect + ii * numperpage + jj, top - jj * dy, numint, numchan, T, lof, hif); cpgsvp(0.33, 0.64, top - jj * dy, top - (jj - 1) * dy); cpgswin(0.0, numchan, 0.0, 1.0); cpgbox("BINST", 0.0, 0, "", 0.0, 0); cpgmtxt("B", 2.5, 0.5, 0.5, "Channel"); cpgsvp(0.65, 0.96, top - jj * dy, top - (jj - 1) * dy); cpgswin(0.0, numint, 0.0, 1.0); cpgbox("BINST", 0.0, 0, "", 0.0, 0); cpgmtxt("B", 2.5, 0.5, 0.5, "Interval"); } } cpgclos(); } /* Plot for loop */ /* Free our arrays */ vect_free(freqs); vect_free(chans); vect_free(times); vect_free(ints); vect_free(avg_chan_avg); vect_free(std_chan_avg); vect_free(pow_chan_avg); vect_free(avg_int_avg); vect_free(std_int_avg); vect_free(pow_int_avg); vect_free(avg_chan_med); vect_free(std_chan_med); vect_free(pow_chan_med); vect_free(avg_int_med); vect_free(std_int_med); vect_free(pow_int_med); vect_free(avg_chan_std); vect_free(std_chan_std); vect_free(pow_chan_std); vect_free(avg_int_std); vect_free(std_int_std); vect_free(pow_int_std); }
int main (int argc, char *argv[]) { int ntimglobal=0; // number of time samples in original int ngulp_original=0; // number of time samples to look at at once int nskipstart=0; // number skipped at start int nrejects; //ZAPPER int zapswitch = 0; //ZAPPER double tsamp_orig=0; //gsearch setup & defaults float Gsigmacut=6.0; float delta, tstart; vector<Gpulse> * Giant = new vector<Gpulse>[MAXFILES]; bool Gsearched=false; int i,ntim,headersize[MAXFILES],noff=0,gulp; float *time_series[MAXFILES],sum=0.0,sumsq=0.0,mean,meansq,sigma; int MAXMARKERS = 1024; int nfiles = 0; FILE *inputfile[MAXFILES]; char filename[MAXFILES][256]; int spectra=0; int powerspectra=0; double dmoffirstfile; char *killfile; bool dokill=false; bool ssigned=true; bool fsigned=false; int topfold=-1; int topgiant=-1; int toppeak=-1; //?!? sarah added this bool askdevice=false; char devicename[200]; if (argc<2 || help_required(argv[1])) { helpmenu(); // fprintf(stderr,"Usage: giant filenames\n\t(e.g.>> giant *.tim)\n\n\t-s N\tskip N samples\n\t-n N\tread N samples\n\t-S read spectra instead of amplitudes\n-i interpret signed chars as unsigned\n\t-z make a zap list of bad time samples\n"); exit(0); } print_version(argv[0],argv[1]); i=1; while (i<argc) { if (file_exists(argv[i])) { inputfile[nfiles]=open_file(argv[i],"r"); strcpy(filename[nfiles],argv[i]); nfiles++; } if (strings_equal(argv[i],"-s")) sscanf(argv[++i],"%d",&nskipstart); if (strings_equal(argv[i],"-S")) spectra=1; if (strings_equal(argv[i],"-i")) ssigned=false; if (strings_equal(argv[i],"-f")) fsigned=true; if (strings_equal(argv[i],"-n")) sscanf(argv[++i],"%d",&ngulp_original); if (strings_equal(argv[i],"-c")) sscanf(argv[++i],"%f",&Gsigmacut); if (strings_equal(argv[i],"-z")) zapswitch=1; if (strings_equal(argv[i],"-g")) {askdevice=true;sscanf(argv[++i],"%s",&devicename);} if (strings_equal(argv[i],"-k")) {killfile=(char*)malloc(strlen(argv[++i])+1); strcpy(killfile,argv[i]);dokill=true;} if (nfiles>MAXFILES) error_message("too many open files"); i++; } int ntimglobal_smallest=0, nsamp; for (i=0; i<nfiles; i++) { if (spectra){ int npf; double rate; time_series[i]=Creadspec(filename[i],&npf,&rate); tsamp = 1.0/(rate); //normalise(npf,time_series[i]); nsamp = ntimglobal = ntimglobal_smallest = npf; } else { if ((headersize[i]=read_header(inputfile[i]))) { if (! fsigned){ if (isign > 0) { ssigned=false; fprintf(stderr,"using signed header variable to set UNSIGNED\n"); } if (isign < 0) { ssigned=true; fprintf(stderr,"using signed header variable to set SIGNED\n"); } } if (i==0) dmoffirstfile = refdm; if (nbits!=8 && nbits!=32) error_message("giant currently only works for 8- or 32-bit data"); nsamp = nsamples(filename[i],headersize[i],nbits,nifs,nchans); if (i == 0) { ntimglobal_smallest=nsamp; } else { ntimglobal= nsamp; if (ntimglobal < ntimglobal_smallest) ntimglobal_smallest = ntimglobal; } // Space for data (time_series) time_series[i]=(float *) malloc((nsamp+2)*sizeof(float)); if (time_series[i]==NULL){ fprintf(stderr,"Error mallocing %d floats of %d size\n",nsamp, sizeof(float)); exit(-1); } tsamp_orig = tsamp; // Skip data fprintf(stderr,"Skipping %d bytes\n",nskipstart*nbits/8); fseek(inputfile[i],nskipstart*nbits/8,SEEK_CUR); } // each file } // spectra or not } // for (i...) puti(ntimglobal_smallest); if (ngulp_original==0) ngulp_original=ntimglobal_smallest; // ****** SAM'S ZAP SWITCH ****** // Sam Bates 2009 // Integrated into new giant by SBS // Switch to make a .killtchan file for time samples > 3.5 sigma // SARAHZAP tag means addition was added later by Sarah // ****************************** int ngulp=ngulp_original; // int nrejects_max=ngulp_original/100; int * mown = new int[ngulp_original]; int nstart=0; if (zapswitch){ float dummy; int NActuallyRead; char *buffer; buffer = new char[ngulp*nbits/8]; for (i=0; i<nfiles; i++){ NActuallyRead = fread(buffer,nbits/8,ngulp,inputfile[i]); if (nbits==32){ memcpy(time_series[i],buffer,sizeof(float)*ngulp); } else { for (int j=0;j<NActuallyRead;j++){ if (ssigned) time_series[i][j]=(float)buffer[j]; if (!ssigned) time_series[i][j]=(float)((unsigned char)buffer[j]); } } puti(ngulp); find_baseline(ngulp,time_series[i],10.0/tsamp,5.0); mowlawn(ngulp,time_series[i],5,256); } printf("%f\n",dummy); printf("Bad time samples found...\n"); exit(0); } int pgpID; if (askdevice){ pgpID = cpgbeg(0,devicename,1,1); } else { pgpID = cpgbeg(0,"/xs",1,1); } cpgsch(0.5); cpgtext(0.6,0.0,"Press 'h' over the main window for help and full options list."); cpgsch(1.0); /* create the dialog */ dialog * d = new dialog(); /* add the "action" buttons */ int QUIT = d->addbutton(0.02,0.95,"Quit"); int POWER = d->addbutton(0.07,0.85,"POWER"); int SMHRM = d->addbutton(0.075,0.80,"SMHRM"); int FFT = d->addbutton(0.02,0.85,"FFT"); int PLOT = d->addbutton(0.02,0.80,"Plot"); int NEXT = d->addbutton(0.02,0.75,"Next"); int ZAPPEAK = d->addbutton(0.075,0.75,"ZapPeak"); int RESET = d->addbutton(0.02,0.70,"Reset"); int GLOBALRESET = d->addbutton(0.02,0.65,"Global Reset"); int HALVEPLOT = d->addbutton(0.02,0.60,"Halve Plot"); int BASELINE = d->addbutton(0.02,0.50,"Baseline"); int ZAPCOMMON = d->addbutton(0.02,0.45,"Zap Common"); int SUBTRACTMEAN = d->addbutton(0.02,0.40,"ZAP Mean"); int BSCRUNCH = d->addbutton(0.02,0.35,"Bscrunch"); int NORMALISE = d->addbutton(0.02,0.30,"Normalise"); int HISTOGRAM = d->addbutton(0.02,0.25,"Histogram"); int GSEARCH = d->addbutton(0.02,0.20,"Find Giants"); int MOWLAWN = d->addbutton(0.08,0.70,"LAWN"); int SEEFIL = d->addbutton(0.02,0.15,"View Band"); int FWRITE = d->addbutton(0.02,0.05,"Write File"); /* add the plot regions */ d->addplotregion(0.2,0.99,0.98,0.99); float deltay = 0.9/(float)nfiles; for (i=0; i<nfiles; i++) d->addplotregion(0.2,0.99,0.95-deltay*(float)(i+1),0.95-deltay*(float)i); d->draw(); float x,y; char ans; int button=-1; int plotno=-1; int NPIXELS = 1024; float * xaxis = new float[NPIXELS]; float * ymaxes = new float[NPIXELS]; float * ymins = new float[NPIXELS]; int scrunch=1; int nmarkers=0; int * markers= new int[MAXMARKERS]; int nfileptr=nskipstart; int nplot=ngulp_original; nstart=0; //COMMENTED IN ZAPPER VERSION: MAY CAUSE CONFLICTS IN THIS VER. ngulp=ngulp_original; //COMMENTED IN ZAPPER VERSION: MAY CAUSE CONFLICTS IN THIS VER. double trialperiod; int doperiod=-1; double xperiod; bool zoneplot=false; int ngates=0; float xgate=0.0; button=NEXT; if (spectra) button = PLOT; while (button!=QUIT){ // Plot the zone // Entire file is white if (button!=NEXT)button=d->manage(&x,&y,&ans,&plotno); if (ans=='h'){ buttonexplain(); continue; } // printf("manage x %f y %f plotno %d\n",x,y,plotno); if (button==BASELINE) { for (i=0; i<nfiles; i++){ find_baseline(ngulp,time_series[i],10.0/tsamp,5.0); } button = PLOT; zoneplot=false; plotno = -1; } if (button==FWRITE) { // reread first header and close it. Sets globals. fclose(inputfile[0]); inputfile[0]=open_file(argv[1],"r"); headersize[0]=read_header(inputfile[0]); output = open_file("giant.tim","w"); nobits=32; nbands=1; dedisperse_header(); fprintf(stderr,"Opened file, writing data\n"); fwrite(time_series[0],sizeof(float),ngulp,output); fclose(output); button = -1; zoneplot=false; plotno =-1; } if (button==BSCRUNCH) { for (i=0; i<nfiles; i++){ bscrunch(ngulp,time_series[i]); } tsamp*=2; scrunch*=2; ngulp/=2; nplot/=2; button = PLOT; zoneplot=false; Gsearched=false; plotno = -1; } if (button==FFT) { for (i=0; i<nfiles; i++){ ngulp = ngulp_original; find_fft(&ngulp,time_series[i]); // Zap DC spike time_series[i][0]=0.0; time_series[i][1]=0.0; } spectra = 1; nplot = ngulp; button = PLOT; Gsearched=false; plotno = -1; } if (button==POWER) { for (i=0; i<nfiles; i++){ find_formspec(ngulp,time_series[i]); } ngulp/=2; powerspectra = 1; nplot = ngulp; button = PLOT; plotno = -1; } if (button==SMHRM) { nfiles = 6; for (i=1; i<nfiles; i++){ time_series[i]=(float *) malloc((ngulp+2)*sizeof(float)); if (time_series[i]==NULL){ fprintf(stderr,"Error allocating memory\n"); exit(-1); } } for (i=1;i<nfiles;i++) memcpy(time_series[i],time_series[0], (ngulp+2)*sizeof(float)); d->nplotregion=1; float deltay = 0.9/(float)nfiles; for (i=0; i<nfiles; i++) d->addplotregion(0.2,0.99,0.95-deltay*(float)(i+1), 0.95-deltay*(float)i); cpgeras(); d->draw(); float * workspace = new float[ngulp]; // Set up space for data, now actually sumhrm int one=1; newoldsumhrm_(&time_series[0][1],workspace,&ngulp,&one, // newoldsumhrm_(&time_series[0][0],workspace,&ngulp,&one, time_series[1],time_series[2],time_series[3], time_series[4],time_series[5]); /* newnewsumhrm_(time_series[0],&ngulp,&one, time_series[1],time_series[2],time_series[3], time_series[4],time_series[5]);*/ for (int iff=2;iff<6;iff++){ for (int i=0;i<ngulp;i++){ time_series[iff][i]/=sqrt(pow(2.0,(float)(iff-1))); } } delete [] workspace; button = PLOT; plotno = -1; } if (button==NORMALISE) { for (i=0; i<nfiles; i++){ normalise(ngulp,time_series[i],5.0); } button = PLOT; Gsearched=false; plotno = -1; } if (button==HISTOGRAM) { float pdfs[nfiles][MAXSIGMA]; // create pdfs for each beam for (int i=0;i<nfiles;i++) formpdf(pdfs[i],MAXSIGMA,ngulp,time_series[i]); for (int i=0;i<nfiles;i++){ for (int j=0;j<MAXSIGMA; j++){ fprintf(stderr, "pdfs[%d][%2d]=%8.0f %f \%\n", i, j+1, pdfs[i][j], 100*pdfs[i][j]/ngulp); } } button = PLOT; plotno = -1; } if (button==HALVEPLOT) { nplot/=2; button = PLOT; zoneplot=true; Gsearched=false; plotno = -1; } if (button==GLOBALRESET) { plotno = -1; nstart = 0; scrunch=1; tsamp = tsamp_orig; nplot=ngulp_original; ngulp=ngulp_original; button=PLOT; // Skip to end of skipped data for (i=0; i<nfiles; i++){ fseek(inputfile[i],-(nfileptr-nskipstart)*nbits/8,SEEK_CUR); Giant[i].clear(); } nfileptr=nskipstart; zoneplot=false; Gsearched=false; doperiod=-1; button=NEXT; } if (button==SUBTRACTMEAN && nfiles>1) { plotno = -1; nstart = 0; nplot=ngulp_original; ngulp=ngulp_original; button=PLOT; // Skip to end of skipped data for (int jj=0;jj<ngulp;jj++){ float sum; sum=0.0; for (i=1;i<nfiles;i++){ sum+=time_series[i][jj]; } time_series[0][jj]-=sum/(float(nfiles-1)); } Gsearched=false; } if (button==ZAPCOMMON && nfiles>1) { plotno = -1; nstart = 0; nplot=ngulp_original; ngulp=ngulp_original; button=PLOT; float pdfs[nfiles][MAXSIGMA]; // create pdfs for each beam for (int i=0;i<nfiles;i++) formpdf(pdfs[i],MAXSIGMA,ngulp,time_series[i]); // for each point in each beam, mask if improbable float thresh = 3.0; int nbeammax = 5; zap_improbables(pdfs,time_series,nfiles,ngulp,MAXSIGMA,thresh,nbeammax); // Skip to end of skipped data //for (int jj=0;jj<ngulp;jj++){ // float sum; // sum=0.0; // for (i=1;i<nfiles;i++){ // sum+=time_series[i][jj]; // } // time_series[0][jj]-=sum/(float(nfiles-1)); //} //Gsearched=false; } if (button==NEXT) { ngulp=ngulp_original; nstart=0; nplot=ngulp_original; // Read the data int NActuallyRead; // unsigned char *buffer; char *buffer; buffer = new char[ngulp*nbits/8]; //buffer = new char[ngulp*nbits/8]; for (i=0; i<nfiles; i++) { // NActuallyRead = fread(time_series[i],sizeof(float),ngulp,inputfile[i]); NActuallyRead = fread(buffer,nbits/8,ngulp,inputfile[i]); if (nbits==32){ memcpy(time_series[i],buffer,sizeof(float)*ngulp); } else { for (int j=0;j<NActuallyRead;j++){ if (ssigned) time_series[i][j]=(float)buffer[j]; if (!ssigned) time_series[i][j]=(float)((unsigned char)buffer[j]); } } puti(ngulp); if (NActuallyRead!=ngulp){ fprintf(stderr,"Could not read %d floats from file\n",ngulp); ngulp = NActuallyRead; } if(nfiles==1){ // Add fake pulsar here.... // for (int ii=0;ii<ngulp;ii++) time_series[i][ii]+= 10.0*pow(sin(float(ii*2.0*M_PI/60.0)),250.0); } //normalise(ngulp,time_series[i]); } nfileptr+=ngulp; button = PLOT; plotno= -1; zoneplot=true; } if (button==RESET) { button = plotno = -1; nstart=0; nplot=ngulp; button=PLOT; zoneplot=true; Gsearched=false; if (ans=='p'){ doperiod=-1; } } if (plotno>0){ /* if (ans=='p'){ // hit p on a plot to type in a period d->plotregions[plotno].reset(); //plot the thing; fprintf(stderr,"Please enter a period in seconds: "); cin>>trialperiod; xperiod = x; doperiod=plotno; button=PLOT; }*/ if (ans=='p'){ // hit p on a plot to type in a period d->plotregions[plotno].reset(); //plot the thing; fprintf(stderr,"Please enter a period in seconds: "); cin>>trialperiod; xperiod = (double)x; doperiod=plotno; button=PLOT; } if (ans=='m'){ // subtract 0.0000005 seconds from period d->plotregions[plotno].reset(); trialperiod-=0.0000005; fprintf(stderr,"Trial period is now %lf\n",trialperiod); doperiod=plotno; button=PLOT; } if (ans=='/'){ // add 0.0000005 seconds to period d->plotregions[plotno].reset(); trialperiod+=0.0000005; fprintf(stderr,"Trial period is now %lf\n",trialperiod); doperiod=plotno; button=PLOT; } if (ans==','){ // subtract 0.000005 seconds from period d->plotregions[plotno].reset(); trialperiod-=0.000005; fprintf(stderr,"Trial period is now %lf\n",trialperiod); doperiod=plotno; button=PLOT; } if (ans=='.'){ // add 0.000005 seconds to period d->plotregions[plotno].reset(); trialperiod+=0.000005; fprintf(stderr,"Trial period is now %lf\n",trialperiod); doperiod=plotno; button=PLOT; } if (ans=='<'){ // subtract 0.001 seconds from period d->plotregions[plotno].reset(); trialperiod-=0.001; fprintf(stderr,"Trial period is now %lf\n",trialperiod); doperiod=plotno; button=PLOT; } if (ans=='>'){ // add 0.001 seconds to period d->plotregions[plotno].reset(); trialperiod+=0.001; fprintf(stderr,"Trial period is now %lf\n",trialperiod); doperiod=plotno; button=PLOT; } if (ans=='X'){ // right click two points on a plot to calculate and plot a period d->plotregions[plotno].reset(); cpgsci(3); cpgmove(x,-1000); cpgdraw(x,1000); if (ngates==0){ xgate=x; ngates++; } else { min_means_min(&x,&xgate); printf("Period from %f to %f is %f\n",x,xgate,xgate-x); doperiod=plotno; xperiod = (double)x; trialperiod=(double)(xgate-x); ngates=0; button=PLOT; } } if (ans=='D'){ markers[nmarkers]=(int)(x/NPIXELS)*nplot+nstart+nfileptr-ngulp; nmarkers++; zoneplot=true; } if (ans=='A'){ d->plotregions[plotno].reset(); cpgsci(2); cpgmove(x,-1000); cpgdraw(x,1000); if (ngates==0){ xgate=x; ngates++; } else { min_means_min(&x,&xgate); // printf("x %f xgate %f tstart %f\n",x,xgate,tstart); nstart=(int)((x-tstart)/delta)+nstart; nplot=(int)((xgate-x)/delta); //if (nplot<NPIXELS) nplot=NPIXELS; ngates=0; button=PLOT; zoneplot=true; // printf("nplot %d nstart %d\n",nplot,nstart); } } if (ans=='z'){ if (NPIXELS>nplot) { nstart+=(int)x; }else nstart=(int)(x/(float)NPIXELS*nplot)+nstart; printf("nstart %d\n",nstart); nplot/=4; printf("nplot %d\n",nplot); nstart-=nplot/2; printf("nstart %d\n",nstart); //if (nplot<NPIXELS){nplot=NPIXELS;} button=PLOT; zoneplot=true; } }
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; }
int radio::draw(){ if (on) fillcircle(x,y,2); else fillcircle(x,y,0); cpgsci(1); cpgtext(x+0.02,y-0.005,label); return(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; }
void doPlot(pulsar *psr,int npsr,float *scale,int nScale,char *grDev,int plotUs,float fontSize,float centreMJD,int ptStyle,float ptSize,int error,float minyv,float maxyv,float minxv,float maxxv,int nOverlay,float labelsize,float fracX) { int i,j,fitFlag=2,exitFlag=0,scale1=0,scale2,count[MAX_PSR],p,xautoscale=0,k,graphics=1; int yautoscale=0,plotpre=1; int ps,pe,pi; int time=0; char xstr[1000],ystr[1000]; float px[2],py[2],pye1[2],pye2[2]; float x[MAX_PSR][MAX_OBSN],y[MAX_PSR][MAX_OBSN],yerr1[MAX_PSR][MAX_OBSN],yerr2[MAX_PSR][MAX_OBSN],tmax,tmin,tmaxy1,tminy1,tmaxy2,tminy2; float sminy[MAX_PSR],smaxy[MAX_PSR]; float minx[MAX_PSR],maxx[MAX_PSR],miny[MAX_PSR],maxy[MAX_PSR],plotx1,plotx2,ploty1,ploty2,mean; float fx[2],fy[2]; float mouseX,mouseY; char key; // float widthPap=0.0,aspectPap=0.618; float widthPap=0.0,aspectPap=1; float xx[MAX_OBSN],yy[MAX_OBSN],yyerr1[MAX_OBSN],yyerr2[MAX_OBSN]; int num=0,colour; /* Obtain a graphical PGPLOT window */ cpgbeg(0,grDev,1,1); // cpgpap(widthPap,aspectPap); cpgsch(fontSize); cpgscf(2); cpgslw(2); cpgask(0); for (p=0;p<npsr;p++) { scale2 = psr[p].nobs; /* sprintf(xstr,"MJD-%.1Lf",psr[0].param[param_pepoch].val[0]); */ if (centreMJD == -1) sprintf(xstr,"Year"); else sprintf(xstr,"MJD-%.1f",centreMJD); sprintf(ystr,"Residual (\\gmsec)"); count[p]=0; printf("points = %d\n",psr[p].nobs); for (i=0;i<psr[p].nobs;i++) { if (psr[p].obsn[i].deleted == 0 && (psr[p].param[param_start].paramSet[0]!=1 || psr[p].param[param_start].fitFlag[0]!=1 || psr[p].param[param_start].val[0] < psr[p].obsn[i].bat) && (psr[p].param[param_finish].paramSet[0]!=1 || psr[p].param[param_finish].fitFlag[0]!=1 || psr[p].param[param_finish].val[0] > psr[p].obsn[i].bat)) { /* x[p][count[p]] = (double)(psr[p].obsn[i].bat-psr[0].param[param_pepoch].val[0]); */ if (centreMJD == -1) x[p][count[p]] = calcYr(psr[p].obsn[i].bat); else x[p][count[p]] = (double)(psr[p].obsn[i].bat-centreMJD); y[p][count[p]] = (double)psr[p].obsn[i].residual*1.0e6; if (nScale>0) y[p][count[p]] *= scale[p]; count[p]++; } } /* Remove mean from the residuals and calculate error bars */ mean = findMean(y[p],psr,p,scale1,count[p]); count[p]=0; for (i=0;i<psr[p].nobs;i++) { if (psr[p].obsn[i].deleted==0 && (psr[p].param[param_start].paramSet[0]!=1 || psr[p].param[param_start].fitFlag[0]!=1 || psr[p].param[param_start].val[0] < psr[p].obsn[i].bat) && (psr[p].param[param_finish].paramSet[0]!=1 || psr[p].param[param_finish].fitFlag[0]!=1 || psr[p].param[param_finish].val[0] > psr[p].obsn[i].bat)) { psr[p].obsn[i].residual-=mean/1.0e6; y[p][count[p]]-=mean; yerr1[p][count[p]] = y[p][count[p]]-(float)psr[p].obsn[i].toaErr; yerr2[p][count[p]] = y[p][count[p]]+(float)psr[p].obsn[i].toaErr; count[p]++; } } /* Get scaling for graph */ if (minxv == maxxv) { minx[p] = findMin(x[p],psr,p,scale1,count[p]); maxx[p] = findMax(x[p],psr,p,scale1,count[p]); } else { minx[p] = minxv; maxx[p] = maxxv; } if (minyv == maxyv){ miny[p] = findMin(y[p],psr,p,scale1,count[p]); maxy[p] = findMax(y[p],psr,p,scale1,count[p]); } else { miny[p] = minyv; maxy[p] = maxyv; } sminy[p] = miny[p]/1e6; smaxy[p] = maxy[p]/1e6; } for (p=0;p<npsr;p++) { for (i=0;i<count[p];i++) { y[p][i] = (y[p][i]-miny[p])/(maxy[p]-miny[p]); yerr1[p][i] = (yerr1[p][i]-miny[p])/(maxy[p]-miny[p]); yerr2[p][i] = (yerr2[p][i]-miny[p])/(maxy[p]-miny[p]); } // maxy[p] = 1.0; // miny[p] = 0.0; } tmin = findMinVal(minx,npsr); tmax = findMaxVal(maxx,npsr); tminy2 = 0.0; //findMinVal(miny,npsr); tmaxy2 = 1.0; //findMaxVal(maxy,npsr); plotx1 = tmin-(tmax-tmin)*0.1; plotx2 = tmax+(tmax-tmin)*0.1; // ploty1 = tminy2-(tmaxy2-tminy2)*0.1; // ploty2 = tmaxy2+(tmaxy2-tminy2)*0.1; ploty1 = 0.1; ploty2 = 0.9; for (p=0;p<npsr;p++) { for (i=0;i<count[p];i++) { y[p][i]=(p)+ploty1+y[p][i]*(ploty2-ploty1); yerr1[p][i]=(p)+ploty1+yerr1[p][i]*(ploty2-ploty1); yerr2[p][i]=(p)+ploty1+yerr2[p][i]*(ploty2-ploty1); } } printf("ytick = %g\n",ploty2-ploty1); /* cpgenv(plotx1,plotx2,ploty1,ploty2+(ploty2-ploty1)*(npsr-1),0,0); */ // cpgenv(plotx1,plotx2,0,npsr+1,0,-1); if (labelsize!=-1) cpgsch(labelsize); cpgsvp(fracX,1.0,0.1,1.0); cpgswin(0,1,0,npsr); cpgbox("ABC",0.0,0,"C",0.0,0); cpgsch(fontSize); char str[1000]; for (p=0;p<npsr;p++) { cpgsch(fontSize); // cpgtext(tmax+(tmax-tmin)*0.05,p+1.5-0.5,psr[p].name); cpgtext(0,p+0.6,psr[p].name); // cpgsch(fontSize); if (plotUs==0) { sprintf(str,"%.2f",(double)((smaxy[p]-sminy[p])*psr[p].param[param_f].val[0])); cpgtext(0,p+0.4,str); // cpgtext(tmax+(tmax-tmin)*0.05,p+1.1-0.5,str); } else { sprintf(str,"%.2f\\gms",(double)((smaxy[p]-sminy[p])/1e-6)); // cpgtext(tmax+(tmax-tmin)*0.05,p+1.1-0.5,str); cpgtext(0,p+0.1,str); } cpgsch(1); px[0] = 0; // px[1] = tmax; //+(tmax-tmin)*0.03; px[1] = 1; py[0] = p; py[1] = p; cpgline(2,px,py); } if (labelsize!=-1) cpgsch(labelsize); cpgsvp(0.1,fracX,0.1,1.0); cpgswin(plotx1,plotx2,0,npsr); cpgbox("ATNSBC",0.0,0,"B",0.0,0); cpglab(xstr,"",""); cpgsch(fontSize); for (p=0;p<npsr;p++) { cpgsls(1); px[0] = plotx1; // px[1] = tmax; //+(tmax-tmin)*0.03; px[1] = plotx2; py[0] = p; py[1] = p; cpgline(2,px,py); cpgsls(4); px[0] = tmin; px[1] = tmax+(tmax-tmin)*0.03; py[0]=py[1] =(p)+ploty1+(-miny[p]/(maxy[p]-miny[p]))*(ploty2-ploty1); // py[0]=py[1] = (p)+ploty1; // py[0] = py[1] = (0-miny[p])/(maxy[p]-miny[p])/(ploty2-ploty1)+p; cpgline(2,px,py); px[0] = plotx1+0.005*(plotx2-plotx1); py[0] = p; pye1[0] = p + 5/(ploty2-ploty1); pye2[0] = p - 5/(ploty2-ploty1); cpgsls(1); cpgsch(3); // cpgerry(1,px,pye1,pye2,1); cpgsch(1); for (colour=0;colour<5;colour++) { num=0; for (i=0;i<count[p];i++) { if ((colour==0 && psr[p].obsn[i].freq<=500) || (colour==1 && psr[p].obsn[i].freq>500 && psr[p].obsn[i].freq<=1000) || (colour==2 && psr[p].obsn[i].freq>1000 && psr[p].obsn[i].freq<=1500) || (colour==3 && psr[p].obsn[i].freq>1500 && psr[p].obsn[i].freq<=3300) || (colour==4 && psr[p].obsn[i].freq>3300)) { xx[num]=x[p][i]; yy[num]=y[p][i]; yyerr1[num]=yerr1[p][i]; yyerr2[num]=yerr2[p][i]; // printf("plotting: %g\n",yy[num]); num++; } } cpgsci(colour+1); cpgsch(ptSize); cpgpt(num,xx,yy,ptStyle); if (error==1) cpgerry(num,xx,yyerr1,yyerr2,1); cpgsch(fontSize); // Plot arrow giving one period fx[0] = fx[1] = tmin-(tmax-tmin)*0.05; // fy[0] = (p+1)+0.5-(float)(1.0/psr[p].param[param_f].val[0])/2.0/(ploty2-ploty1); // fy[1] = (p+1)+0.5+(float)(1.0/psr[p].param[param_f].val[0])/2.0/(ploty2-ploty1); // fy[0] = (-(float)(1.0/psr[p].param[param_f].val[0])/2.0/1.0e6 - miny[p])/(maxy[p]-miny[p])/(ploty2-ploty1) + (p+1)+0.5; // fy[1] = ((float)(1.0/psr[p].param[param_f].val[0])/2.0/1.0e6 - miny[p])/(maxy[p]-miny[p])/(ploty2-ploty1) + (p+1)+0.5; fy[0] = (p+1)+0.5+(float)(1.0/psr[p].param[param_f].val[0])/2.0/(maxy[p]-miny[p])*1e6; fy[1] = (p+1)+0.5-(float)(1.0/psr[p].param[param_f].val[0])/2.0/(maxy[p]-miny[p])*1e6; if (fy[0] > (p+1)+1) fy[0] = (p+1)+1; if (fy[1] < (p+1)) fy[1] = (p+1); // cpgsls(1); cpgline(2,fx,fy); cpgsls(1); } cpgsci(1); } cpgend(); }
int main(int argc, char *argv[]) { float *x=NULL,*y=NULL,minx,maxx,miny,maxy,cx, *oparams=NULL,*nparams=NULL; float *rx=NULL,*ry=NULL,*w=NULL,*wparams=NULL,*wx=NULL,*wy=NULL,*ww=NULL; float *y_sault_fit=NULL, *x_fit=NULL, *y_new_fit=NULL, *y_reynolds_fit=NULL; float *y_stevens_fit=NULL,*y_whole_fit=NULL,*y_old_fit=NULL; int i,j,n=0,n_fit=100,new_fit_order=2,whole_fit_order=5,nr=0,nw=0; /* float extra_x[NEXTRA]={ 93, 95 }, extra_y[NEXTRA] = { 0.1223, 0.1168 }; */ float extra_x[NEXTRA]= { 93, 95 }, extra_y[NEXTRA] = { 0.1116, 0.1056 }; float extra_u[NEXTRA]= { 0.01356, 0.01399 }; float fitp_sault[NFIT_SAULT]= { -202.6259, 149.7321, -36.4943, 2.9372 }; float fitp_reynolds[NFIT_REYNOLDS]= { -30.7667, 26.4908, -7.0977, 0.605334 }; float fitp_stevens[NFIT_STEVENS]= { -1.237160, 2.005317, -0.400622 }; float fitp_old[NFIT_OLD]= { -23.839, 19.569, -4.8168, 0.35836 }; float *ratio_reynolds_fit=NULL,*ratio_stevens_fit=NULL,*ratio_sault_fit=NULL; float *ratio_new_fit=NULL; float vpx1, vpx2, vpy1, vpy2, vpy3, lx, ly, dly; char fitlabel[BUFSIZE]; /* Generate the cm fit points. */ for (cx=1.0; cx<10.0; cx+=0.1) { nr++; rx = realloc(rx, nr * sizeof(float)); ry = realloc(ry, nr * sizeof(float)); rx[nr-1] = log10f(cx * 1000); ry[nr-1] = 0.0; for (i=0; i<NFIT_REYNOLDS; i++) { ry[nr-1] += fitp_reynolds[i] * powf(rx[n-1], (float)i); } } /* Generate the 15mm fit points. */ for (cx=10.0; cx<=24.0; cx+=0.128) { n++; x = realloc(x, n * sizeof(float)); y = realloc(y, n * sizeof(float)); w = realloc(w, n * sizeof(float)); x[n-1] = log10f(cx * 1000); y[n-1] = 0.0; for (i=0; i<NFIT_REYNOLDS; i++) { y[n-1] += fitp_sault[i] * powf(x[n-1], (float)i); } w[n-1] = 1.0/0.1; } /* Do the fit. */ linfit_order(NFIT_SAULT, n, x, y, w, &oparams); for (i=0; i<NFIT_SAULT; i++) { printf("i = %d c[i] = %.4f\n", i, oparams[i]); } /* Add the 3mm flux points. */ for (i=0; i<NEXTRA; i++) { n++; x = realloc(x, n * sizeof(float)); y = realloc(y, n * sizeof(float)); w = realloc(w, n * sizeof(float)); x[n-1] = log10f(extra_x[i] * 1000); y[n-1] = log10f(extra_y[i]); w[n-1] = 1/extra_u[i]; } /* Do another fit. */ linfit_order(new_fit_order, n, x, y, w, &nparams); for (i=0; i<new_fit_order; i++) { printf("i = %d nc[i] = %.4f\n", i, nparams[i]); } /* Generate the whole range fit points. */ minx=log10f(900); maxx=log10f(100000); miny=-2; maxy=log10f(20); x_fit = malloc(n_fit * sizeof(float)); for (i=0; i<n_fit; i++) { x_fit[i] = minx + i * ((maxx - minx)/(float)n_fit); nw++; wx = realloc(wx, nw * sizeof(float)); wy = realloc(wy, nw * sizeof(float)); ww = realloc(ww, nw * sizeof(float)); wx[nw-1] = x_fit[i]; wy[nw-1] = 0.0; ww[nw-1] = 1; if (x_fit[i] < log10f(11143)) { /* Use the Reynolds fit. */ for (j=0; j<NFIT_REYNOLDS; j++) { wy[nw-1] += fitp_reynolds[j] * powf(x_fit[i], (float)j); } } else { /* Use the new fit. */ for (j=0; j<new_fit_order; j++) { wy[nw-1] += nparams[j] * powf(x_fit[i], (float)j); } } } /* Do a whole-range fit. */ linfit_order(whole_fit_order, nw, wx, wy, ww, &wparams); for (i=0; i<whole_fit_order; i++) { printf("i = %d wc[i] = %.4f\n", i, wparams[i]); } // minmax(n, x, &minx, &maxx); // minmax(n, y, &miny, &maxy); y_sault_fit = malloc(n_fit * sizeof(float)); y_reynolds_fit = malloc(n_fit * sizeof(float)); y_stevens_fit = malloc(n_fit * sizeof(float)); y_new_fit = malloc(n_fit * sizeof(float)); y_whole_fit = malloc(n_fit * sizeof(float)); y_old_fit = malloc(n_fit * sizeof(float)); ratio_reynolds_fit = malloc(n_fit * sizeof(float)); ratio_stevens_fit = malloc(n_fit * sizeof(float)); ratio_sault_fit = malloc(n_fit * sizeof(float)); ratio_new_fit = malloc(n_fit * sizeof(float)); /* minx=log10f(50); */ minx=log10f(1000); /* maxx=log10f(500000); */ maxx=log10f(110000); for (i=0; i<n_fit; i++) { x_fit[i] = minx + i * ((maxx - minx)/(float)n_fit); y_sault_fit[i] = 0.0; y_reynolds_fit[i] = 0.0; y_new_fit[i] = 0.0; y_stevens_fit[i] = 0.0; y_whole_fit[i] = 0.0; y_old_fit[i] = 0.0; for (j=0; j<NFIT_SAULT; j++) { y_sault_fit[i] += fitp_sault[j] * powf(x_fit[i], (float)j); } for (j=0; j<NFIT_REYNOLDS; j++) { y_reynolds_fit[i] += fitp_reynolds[j] * powf(x_fit[i], (float)j); } for (j=0; j<NFIT_STEVENS; j++) { y_stevens_fit[i] += fitp_stevens[j] * powf(x_fit[i], (float)j); } for (j=0; j<new_fit_order; j++) { y_new_fit[i] += nparams[j] * powf(x_fit[i], (float)j); } for (j=0; j<whole_fit_order; j++) { y_whole_fit[i] += wparams[j] * powf(x_fit[i], (float)j); } for (j=0; j<NFIT_OLD; j++) { y_old_fit[i] += fitp_old[j] * powf(x_fit[i], (float)j); } ratio_reynolds_fit[i] = powf(10, (y_reynolds_fit[i] - y_whole_fit[i])); ratio_stevens_fit[i] = powf(10, (y_stevens_fit[i] - y_whole_fit[i])); ratio_sault_fit[i] = powf(10, (y_sault_fit[i] - y_whole_fit[i])); ratio_new_fit[i] = powf(10, (y_new_fit[i] - y_whole_fit[i])); } /* cpgopen("11/xs"); */ cpgopen("1934-638_models.ps/cps"); /* cpgopen("1934-638_models.png/png"); */ cpgqvp(0, &vpx1, &vpx2, &vpy1, &vpy2); vpy3 = vpy1 + (vpy2 - vpy1) / 5.0; /* cpgsvp(vpx1, vpx2, vpy3, vpy2); */ cpgswin(minx, maxx, miny, maxy); lx = minx + (maxx - minx) / 9.0; ly = miny + (maxy - miny) / 3.0; dly = (maxy - miny) / 20.0; cpgsch(1.0); cpgbox("BCLNTS",0,0,"BCLNTS",0,0); cpglab("Frequency (MHz)", "Flux Density (Jy)", "1934-638 Model Comparison"); cpgsch(0.8); cpgpt(n, x, y, 4); /* cpgpt(nw, wx, wy, 4); */ cpgsci(2); /* cpgpt(nr, rx, ry, 4); */ cpgline(n_fit, x_fit, y_sault_fit); strcpy(fitlabel, "Sault: "); fitstring(fitp_sault, NFIT_SAULT, fitlabel); cpgtext(lx, ly, fitlabel); cpgsci(3); cpgline(n_fit, x_fit, y_new_fit); strcpy(fitlabel, "Stevens (linear): "); fitstring(nparams, new_fit_order, fitlabel); ly -= dly; cpgtext(lx, ly, fitlabel); cpgsci(4); cpgline(n_fit, x_fit, y_reynolds_fit); strcpy(fitlabel, "Reynolds: "); fitstring(fitp_reynolds, NFIT_REYNOLDS, fitlabel); ly -= dly; cpgtext(lx, ly, fitlabel); cpgsci(5); cpgline(n_fit, x_fit, y_stevens_fit); strcpy(fitlabel, "Stevens (Miriad): "); fitstring(fitp_stevens, NFIT_STEVENS, fitlabel); ly -= dly; cpgtext(lx, ly, fitlabel); cpgsci(6); cpgline(n_fit, x_fit, y_old_fit); strcpy(fitlabel, "Pre-1994: "); fitstring(fitp_old, NFIT_OLD, fitlabel); ly -= dly; cpgtext(lx, ly, fitlabel); /* cpgsci(6); */ /* cpgline(n_fit, x_fit, y_whole_fit); */ /* strcpy(fitlabel, "Stevens (New): "); */ /* fitstring(wparams, whole_fit_order, fitlabel); */ /* ly -= dly; */ /* cpgtext(lx, ly, fitlabel); */ /* cpgsvp(vpx1, vpx2, vpy1, vpy3); */ /* cpgsci(1); */ /* cpgswin(minx, maxx, 0.9, 1.1); */ /* cpgsch(1.0); */ /* cpgbox("BCLNTS",0,0,"BCMTS",0,0); */ /* cpglab("Frequency (MHz)", "Model Ratio", ""); */ /* cpgsci(2); */ /* cpgline(n_fit, x_fit, ratio_sault_fit); */ /* cpgsci(3); */ /* cpgline(n_fit, x_fit, ratio_new_fit); */ /* cpgsci(4); */ /* cpgline(n_fit, x_fit, ratio_reynolds_fit); */ /* cpgsci(5); */ /* cpgline(n_fit, x_fit, ratio_stevens_fit); */ cpgclos(); exit(0); }
static void _pgtext (double *x, double *y, char *s) { cpgtext ((float) *x, (float) *y, s); }