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(); }
void Plotter2::plot() { open(); if ((width > 0.0) && (aspect > 0.0)) { cpgpap(width, aspect); } cpgscr(0, 1.0, 1.0, 1.0); // set background color white cpgscr(1, 0.0, 0.0, 0.0); // set foreground color black for (unsigned int i = 0; i < vInfo.size(); ++i) { Plotter2ViewportInfo vi = vInfo[i]; if (vi.showViewport) { resetAttributes(vi); // setup viewport cpgsvp(vi.vpPosXMin, vi.vpPosXMax, vi.vpPosYMin, vi.vpPosYMax); cpgswin(vi.vpRangeXMin, vi.vpRangeXMax, vi.vpRangeYMin, vi.vpRangeYMax); // background color (default is transparent) if (vi.vpBColor >= 0) { cpgsci(vi.vpBColor); cpgrect(vi.vpRangeXMin, vi.vpRangeXMax, vi.vpRangeYMin, vi.vpRangeYMax); cpgsci(1); // reset foreground colour to the initial one (black) } // data for (unsigned int j = 0; j < vi.vData.size(); ++j) { resetAttributes(vi); Plotter2DataInfo di = vi.vData[j]; std::vector<float> vxdata = di.xData; int ndata = vxdata.size(); float* pxdata = new float[ndata]; float* pydata = new float[ndata]; for (int k = 0; k < ndata; ++k) { pxdata[k] = di.xData[k]; pydata[k] = di.yData[k]; } if (di.drawLine) { cpgsls(di.lineStyle); cpgslw(di.lineWidth); int colorIdx = di.lineColor; if (colorIdx < 0) { colorIdx = (j + 1) % 15 + 1; } cpgsci(colorIdx); cpgline(ndata, pxdata, pydata); } if (di.drawMarker) { cpgsch(di.markerSize); cpgsci(di.markerColor); cpgpt(ndata, pxdata, pydata, di.markerType); } delete [] pxdata; delete [] pydata; } //calculate y-range of xmasks std::vector<float> yrange = vi.getRangeY(); float yexcess = 0.1*(yrange[1] - yrange[0]); float xmaskymin = yrange[0] - yexcess; float xmaskymax = yrange[1] + yexcess; // masks for (unsigned int j = 0; j < vi.vRect.size(); ++j) { resetAttributes(vi); Plotter2RectInfo ri = vi.vRect[j]; cpgsci(ri.color); cpgsfs(ri.fill); cpgslw(ri.width); cpgshs(45.0, ri.hsep, 0.0); float* mxdata = new float[4]; float* mydata = new float[4]; mxdata[0] = ri.xmin; mxdata[1] = ri.xmax; mxdata[2] = ri.xmax; mxdata[3] = ri.xmin; mydata[0] = xmaskymin; mydata[1] = xmaskymin; mydata[2] = xmaskymax; mydata[3] = xmaskymax; cpgpoly(4, mxdata, mydata); } // arrows for (unsigned int j = 0; j < vi.vArro.size(); ++j) { resetAttributes(vi); Plotter2ArrowInfo ai = vi.vArro[j]; cpgsci(ai.color); cpgslw(ai.width); cpgsls(ai.lineStyle); cpgsch(ai.headSize); cpgsah(ai.headFillStyle, ai.headAngle, ai.headVent); cpgarro(ai.xtail, ai.ytail, ai.xhead, ai.yhead); } // arbitrary texts for (unsigned int j = 0; j < vi.vText.size(); ++j) { resetAttributes(vi); Plotter2TextInfo ti = vi.vText[j]; cpgsch(ti.size); cpgsci(ti.color); cpgstbg(ti.bgcolor); cpgptxt(ti.posx, ti.posy, ti.angle, ti.fjust, ti.text.c_str()); } // viewport outline and ticks resetAttributes(vi); cpgbox("BCTS", vi.majorTickIntervalX, vi.nMinorTickWithinMajorTicksX, "BCTSV", vi.majorTickIntervalY, vi.nMinorTickWithinMajorTicksY); // viewport numberings std::string numformatx, numformaty; if (vi.numLocationX == "b") { numformatx = "N"; } else if (vi.numLocationX == "t") { numformatx = "M"; } else if (vi.numLocationX == "") { numformatx = ""; } if (vi.numLocationY == "l") { numformaty = "NV"; } else if (vi.numLocationY == "r") { numformaty = "MV"; } else if (vi.numLocationY == "") { numformaty = ""; } cpgbox(numformatx.c_str(), vi.majorTickIntervalX * vi.nMajorTickWithinTickNumsX, 0, numformaty.c_str(), vi.majorTickIntervalY * vi.nMajorTickWithinTickNumsY, 0); float xpos, ypos; // x-label vi.getWorldCoordByWindowCoord(vi.labelXPosX, vi.labelXPosY, &xpos, &ypos); cpgsch(vi.labelXSize); cpgsci(vi.labelXColor); cpgstbg(vi.labelXBColor); //outside viewports, works ONLY with /xwindow cpgptxt(xpos, ypos, vi.labelXAngle, vi.labelXFJust, vi.labelXString.c_str()); // y-label vi.getWorldCoordByWindowCoord(vi.labelYPosX, vi.labelYPosY, &xpos, &ypos); cpgsch(vi.labelYSize); cpgsci(vi.labelYColor); cpgstbg(vi.labelYBColor); //outside viewports, works ONLY with /xwindow cpgptxt(xpos, ypos, vi.labelYAngle, vi.labelYFJust, vi.labelYString.c_str()); // title vi.getWorldCoordByWindowCoord(vi.titlePosX, vi.titlePosY, &xpos, &ypos); cpgsch(vi.titleSize); cpgsci(vi.titleColor); cpgstbg(vi.titleBColor); //outside viewports, works ONLY with /xwindow cpgptxt(xpos, ypos, vi.titleAngle, vi.titleFJust, vi.titleString.c_str()); } } close(); }
int main(int argc,char *argv[]) { int i; char fname[128]; dSet *data; float freq,bw,chanbw; int nchan,npol; float bpass[4096]; float fx[4096]; float miny,maxy,minx,maxx; float ominy,omaxy,ominx,omaxx; float mx,my,mx2,my2; float binw; char key; char grDev[128]="/xs"; int interactive=1; int noc1=0; int zapChannels[4096]; int nzap=0; int overlay=-1; float overlayVal[MAX_OVERLAY]; char overlayStr[MAX_OVERLAY][128]; char overlayFile[128]; int noverlay=0; fitsfile *fp; data = initialiseDset(); for (i=0;i<argc;i++) { if (strcmp(argv[i],"-f")==0) strcpy(fname,argv[++i]); else if (strcmp(argv[i],"-noc1")==0) noc1=1; else if (strcmp(argv[i],"-g")==0) { strcpy(grDev,argv[++i]); interactive=0; } else if (strcmp(argv[i],"-h")==0) help(); else if (strcmp(argv[i],"-overlay")==0) { strcpy(overlayFile,argv[++i]); overlay=1; } } if (overlay==1) { FILE *fin; char line[1024]; noverlay=0; if (!(fin = fopen(overlayFile,"r"))) printf("Unable to open overlay file >%s<\n",overlayFile); else { while (!feof(fin)) { fgets(overlayStr[noverlay],1024,fin); if (fscanf(fin,"%f",&overlayVal[noverlay])==1) { if (overlayStr[noverlay][strlen(overlayStr[noverlay])-1] == '\n') overlayStr[noverlay][strlen(overlayStr[noverlay])-1]='\0'; noverlay++; } } fclose(fin); } } fp = openFitsFile(fname); loadPrimaryHeader(fp,data); displayHeaderInfo(data); readBandpass(fp,bpass); nchan = data->phead.nchan; freq = data->phead.freq; bw = data->phead.bw; chanbw = data->phead.chanbw; for (i=0;i<nchan;i++) { fx[i] = freq-bw/2+(i+0.5)*chanbw; if (i==noc1) { miny = maxy = bpass[i]; minx = maxx = fx[i]; } else if (i!=0) { if (bpass[i] > maxy) maxy = bpass[i]; if (bpass[i] < miny) miny = bpass[i]; if (fx[i] > maxx) maxx = fx[i]; if (fx[i] < minx) minx = fx[i]; } } ominx = minx; omaxx = maxx; ominy = miny; omaxy = maxy; binw = fx[1]-fx[0]; printf("Complete\n"); cpgbeg(0,grDev,1,1); cpgask(0); do { cpgenv(minx,maxx,miny,maxy,0,1); cpglab("Frequency (MHz)","Amplitude (arbitrary)",fname); cpgbin(nchan-noc1,fx+noc1,bpass+noc1,0); if (overlay==1) { float tx[2],ty[2]; cpgsls(4); cpgsci(2); cpgsch(0.8); for (i=0;i<noverlay;i++) { tx[0] = tx[1] = overlayVal[i]; ty[0] = miny; ty[1] = maxy; if (tx[1] > minx && tx[1] < maxx) { cpgline(2,tx,ty); // cpgtext(tx[1],ty[1]-0.05*(maxy-miny),overlayStr[i]); cpgptxt(tx[1]-0.004*(maxx-minx),ty[0]+0.05*(maxy-miny),90,0.0,overlayStr[i]); } } cpgsci(1); cpgsls(1); cpgsch(1); } if (interactive==1) { cpgcurs(&mx,&my,&key); if (key=='A') { int cc=-1; int i; for (i=0;i<nchan-1;i++) { // if ((bw > 0 && (mx > fx[i]-binw/2 && mx < fx[i]+binw/2)) || // (bw < 0 && (mx > fx[i]+binw/2 && mx < fx[i]-binw/2))) if ((bw > 0 && (mx > fx[i] && mx < fx[i]+binw)) || (bw < 0 && (mx > fx[i] && mx < fx[i]+binw))) { cc = i; break; } } printf("mouse x = %g MHz, mouse y = %g, channel = %d, channel frequency = %g MHz\n",mx,my,cc,fx[cc]); } else if (key=='X') { int cc=-1; int i; printf("Deleting %g %g %g\n",mx,fx[10],binw); for (i=0;i<nchan-1;i++) { // if ((bw > 0 && (mx > fx[i]-binw/2 && mx < fx[i]+binw/2)) || // (bw < 0 && (mx > fx[i]+binw/2 && mx < fx[i]-binw/2))) if ((bw > 0 && (mx > fx[i] && mx < fx[i]+binw)) || (bw < 0 && (mx > fx[i] && mx < fx[i]+binw))) { cc = i; break; } } printf("Want to delete = %d\n",cc); if (cc != -1) { bpass[cc] = 0; omaxy = bpass[noc1]; zapChannels[nzap++] = cc; for (i=noc1;i<nchan;i++) { if (omaxy < bpass[i]) omaxy = bpass[i]; } } } else if (key=='z') { cpgband(2,0,mx,my,&mx2,&my2,&key); if (mx > mx2) {maxx = mx; minx = mx2;} else {maxx = mx2; minx = mx;} if (my > my2) {maxy = my; miny = my2;} else {maxy = my2; miny = my;} } else if (key=='u') { minx = ominx; maxx = omaxx; miny = ominy; maxy = omaxy; } else if (key=='l') // List the channels and frequencies to zap { int i; sortInt(zapChannels,nzap); printf("-------------------------------------------------------\n"); printf("Zap channels with first channel = 0\n\n"); for (i=0;i<nzap;i++) printf("%d ",zapChannels[i]); printf("\n\n"); printf("Zap channels with first channel = 1\n\n"); for (i=0;i<nzap;i++) printf("%d ",zapChannels[i]+1); printf("\n\n"); printf("Zap channels frequencies:\n\n"); for (i=0;i<nzap;i++) printf("%g ",fx[zapChannels[i]]); printf("\n\n"); printf("-------------------------------------------------------\n"); } else if (key=='%') // Enter percentage of the band edges to zap { float percent; int i; printf("Enter band edge percentage to zap "); scanf("%f",&percent); for (i=0;i<nchan;i++) { if (i < nchan*percent/100.0 || i > nchan-(nchan*percent/100.0)) { bpass[i] = 0; zapChannels[nzap++] = i; } } omaxy = bpass[noc1]; for (i=noc1;i<nchan;i++) { if (omaxy < bpass[i]) omaxy = bpass[i]; } // Unzoom minx = ominx; maxx = omaxx; miny = ominy; maxy = omaxy; } } } while (key != 'q' && interactive==1); cpgend(); }
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(); }
/* write text at arbitrary position and angle */ static void _pgptxt (double *x, double *y, double *a, double *j, char *s) { cpgptxt ((float) *x, (float) *y, (float) *a, (float) *j, s); }