IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

sample_pstamp_request: stampmaker.c

File stampmaker.c, 2.2 KB (added by ndeacon, 16 years ago)
Line 
1#include <stdio.h>
2#include <stdlib.h>
3#include <math.h>
4#include <time.h>
5
6/*gcc stampmaker.c -o stampmaker*/
7
8/*Takes a list of decimal degree positions and produces output tabels to be turned into FITS tables for the Pan-STARRS postage stamp server - Niall Deacon*/
9
10/*The required input filter format is inputfile name filtername. The output file will be the name you give it + unix timestamp + filter*/
11
12/*The required input file format is "idno ra dec"*/
13
14int main(int argc, char *argv[])
15{
16 int count,idno,filecount;
17 double ra,dec;
18 long t1;
19 FILE *input,*output;
20 char scanner[500],inname[50],outname[50],outname1[53];
21 count=0;
22 if(argc!=4)
23 {
24 printf("Poorly formatted input\n");
25 exit(0);
26 }
27 if((input = fopen(argv[1],"r"))!=NULL)
28 {
29 time(&t1);
30 filecount=1;
31 sprintf(outname,"%s%ld%s%d",argv[2],t1,argv[3],filecount);
32 sprintf(outname1,"%s%ld%s%d.tab",argv[2],t1,argv[3],filecount);
33 printf("Output file is %s\n",outname1);
34 printf("Job name is %s\n",outname);
35 output=fopen(outname1,"w");
36 fprintf(output,"#%s\n# REQ_NAME EXTVER\n%s 1\n# ID | ROI Specification | JOB Specification | Images of interest specification\n# ROWNUM CENTER_X CENTER_Y WIDTH HEIGHT COORD_MASK JOB_TYPE OPTION_MASK PROJECT REQ_TYPE IMG_TYPE ID TESS_ID COMPONENT DATA_GROUP REQFILT MJD_MIN MJD_MAX | COMMENT\n",outname1,outname);
37 while(fgets(scanner,500,input)!=NULL)
38 {
39 sscanf(scanner,"%d %lf %lf",&idno,&ra,&dec);
40 fprintf(output,"%5.5d %lf %lf 100 100 2 stamp 1 gpc1 bycoord chip null null null null %s 0 0 |search by coords (make the server work)\n",idno,ra,dec,argv[3]);
41 count++;
42 if(((count%1000)==0)&&(count>1))
43 {
44 /*Start new output file*/
45 filecount++;
46 fclose(output);
47 sprintf(outname,"%s%ld%s%d",argv[2],t1,argv[3],filecount);
48 sprintf(outname1,"%s%ld%s%d.tab",argv[2],t1,argv[3],filecount);
49 printf("New output file is %s\n",outname1);
50 printf("New job name is %s\n",outname);
51 output=fopen(outname1,"w");
52 }
53 }
54 fclose(output);
55 }
56 else
57 {
58 printf("Input file not found\n");
59 exit(0);
60 }
61}