/* --------------------------------------------------------------------------- */ /* Conversion from users' observation sequence to KMTNet Script Input */ /* Developed by Seung-Lee Kim at KASI */ /* --------------------------------------------------------------------------- */ #include #include #include #define MAXCOL 50 #define MAXFIL 50 char version[200] = "Version 1.0 made on March-06-2018\nVersion 1.1 updated on December-21-2018"; void Write_Script(FILE *fp, int loop, int num, char com[MAXCOL][100]) { fprintf(fp, "%-13s %11s %11s %4s %8s %12s %6s %7s %19s %5s", com[0], com[1], com[2], com[3], com[4], com[5], com[6], com[7], com[8], com[9]); if(loop<3) loop = 5; if((num%loop)==1) fprintf(fp, " #%d\n", num); else if((num%loop)==0) fprintf(fp, "\n\n"); else fprintf(fp, "\n"); } int main(int argc, char *argv[]) { int i,j, flagloop, nfil, nrun, copt, tol, cLabel, cRA, cDEC, cObject, cFilter, cExposure, cUTObs, maxCol, eol; float exptime[MAXFIL]; char pID[100], filter[MAXFIL][100], imgtyp[100]; char seqfile[100], setfile[100], outfile[100], field[300], col[MAXCOL][100], prt[MAXCOL][100], tmp[100]; FILE *in, *out; puts(version); if(argc < 3) { printf("Error : %s objects_filename setting_filename flag_loop (option, default : 0)\n", argv[0]); return 0; } flagloop = nfil = nrun = copt = tol = cLabel = cRA = cDEC = cObject = cFilter = cExposure = cUTObs = maxCol = 0; sprintf(seqfile, "%s", argv[1]); sprintf(setfile, "%s", argv[2]); sprintf(outfile, "sc%s", argv[1]); if(argc > 3 ) flagloop = atoi(argv[3]); if( (in = fopen(setfile, "r") ) == NULL) { puts("Script setting file read error"); return 0; } fgets(field, 300, in); sscanf(field, "%s", pID); fgets(field, 300, in); sscanf(field, "%d", &nfil); if(nfil!=0) for(i=0; imaxCol) maxCol = cLabel; fgets(field, 300, in); sscanf(field, "%d", &cRA); if(cRA>maxCol) maxCol = cRA; fgets(field, 300, in); sscanf(field, "%d", &cDEC); if(cDEC>maxCol) maxCol = cDEC; fgets(field, 300, in); sscanf(field, "%d", &copt); fgets(field, 300, in); sscanf(field, "%s", imgtyp); fgets(field, 300, in); sscanf(field, "%d", &cObject); if(cObject>maxCol) maxCol = cObject; fgets(field, 300, in); sscanf(field, "%d", &cFilter); if(cFilter>maxCol) maxCol = cFilter; fgets(field, 300, in); sscanf(field, "%d", &cExposure);if(cExposure>maxCol) maxCol = cExposure; fgets(field, 300, in); sscanf(field, "%d", &cUTObs); if(cUTObs>maxCol) maxCol = cUTObs; fgets(field, 300, in); sscanf(field, "%d", &tol); fclose(in); if(maxCol>MAXCOL) { puts("Column number in the setting file is larger than maximum\n"); return 0; } if( (in = fopen(seqfile, "r") ) == NULL) { puts("Users' sequence file read error"); return 0; } if( (out = fopen(outfile, "w") ) == NULL) { puts("Script file write error"); return 0; } fprintf(out, "# KMTNet Observation script\n"); fprintf(out, "# LABEL RA DEC COPT IMGTYP OBJECT_NAME FILTER EXPTIME UTOBS UTTOL #Comments\n"); fprintf(out, "#------------ ----------- ----------- ---- -------- ------------ ------ ------- ------------------- ----- ---------\n\n"); for(;;) { for(i=0; i 0) fprintf(out, "\n+ostart %d\n", flagloop); fclose(out); fclose(in); return 1; }