// boxscan.c // Colin Borys, 26 Sept 2003 // // This program computes the parameters for the UIP command "BOX_SCAN". // It takes as input the desired map size and spacing, checks // constraints, and outputs the most appropriate parameters. // // to compile: // gcc -o boxscan boxscan.c -lm #include #include #include int main(int argc, char *argv[]) { float A; // size of X dimension of scan in arcsec float B; // size of Y dimension of scan in arcsec float Bprime; // size of Y dimension of scan in arcsec after applying // constraints float d; // size of spacing float dprime; // size of spacing after applying constraints float z,zprime; // width of the "diamond" float l; // linear distance telescope must travel to complete scan int Nx,Ny; // number of "diamonds" on each axis float rate=20.0; // scan rate (arcsec/sec) float scantime; // time to complete scan (minutes) float sensitivity; int i; // loop variable. if (argc <4) { fprintf(stderr,"Usage:\n"); fprintf(stderr,"%s A B d [v]\n",argv[0]); exit(0); } if (!sscanf(argv[1], "%f",&A)) { fprintf(stderr,"Bad value for A: %s\n",argv[1]); exit(0); } if (!sscanf(argv[2], "%f",&B)) { fprintf(stderr,"Bad value for B: %s\n",argv[2]); exit(0); } if (!sscanf(argv[3], "%f",&d)) { fprintf(stderr,"Bad value for d: %s\n",argv[3]); exit(0); } // rate is an optional entry..default is 20 arcs/sec if (argc==5) if (!sscanf(argv[4], "%f",&rate)) { fprintf(stderr,"Bad value for scan rate: %s\n",argv[3]); exit(0); } z=sqrt(2)*d; // width of diamond Nx=rint(A/z); // number of diamonds in X direction zprime=A/(float)Nx; // recompute width based on integer value dprime=zprime/sqrt(2);// recompute grid spacing Ny=rint(B/zprime); // compute # of diamonds in Y direction if (Nx%2 == Ny%2) Ny--; // one must be odd, the other even.... // Nx and Ny must not have a common factor between them // Therefore test for the first few odd factors. // (There will be no even factors since we've forced one // to be odd). for (i=3;i<=11;i+=2) if ((Nx%i == 0) && (Ny%i == 0)) Ny+=2; // we could test for higher odd factors but in practice the scans // will not have that many diamonds on a side. Bprime=zprime*Ny; // compute actual size of Y direction l=4*Nx*Ny*dprime; // length of scan (arcsec) scantime= l/(60.0*rate); // scan time sensitivity = 1000/sqrt(60.0*scantime/(A*B/(155.2*58.2))); // print out the UIP command and the required integration time printf("BOX_SCAN %8.3f %8.3f %4.1f 45 : %10.2f minutes\n",A,Bprime,rate,scantime); if (scantime>15.0) printf("# WARNING: scantime exceeds 15 minutes\n"); if (rate>40.0) printf("# WARNING: scan rate exceeds 40 arcsec/sec\n"); if (dprime>40.0) printf("# WARNING: grid spacing exceeds 40 arcsec\n"); printf("# INFO: grid spacing is %8.3f\n",dprime); printf("# INFO: Number of diamonds is: [%4i X %4i]\n",Nx,Ny); printf("# INFO: Sensitivity estimate: %10.2f mJy/beam \n",sensitivity); return 1; }