/* put SMOKE_AREA to McIDAS Dataset*/ /* By Zedong Zhang 3/04/2004 */ /* checkAREA.c Edited by Laura Kowal to work for SMOKE data February 2009*/ /* */ #include #include #include #define WORD unsigned int #define BYTE unsigned char #define SHORT unsigned short #define MX 2126 #define MY 880 struct Directoryblock { WORD relp; //1. relative position of the image object in the ADDE dataset WORD imgtype; //2. image type=4 WORD sennum; //3. SSEC sensor source number WORD yyyddd; //4. nominal year and Julian day of the image, yyyddd WORD hhmm; //5. nominal time of the image, hhmmss WORD lineC; //6. upper-left image line coordinate WORD eleC; //7. upper-left image element coordinate WORD res1; //8. reserved;:w WORD numline; //9. number of line in the image WORD numdata; //10. number of data points per line WORD numbyte; //11. number of bytes per data point WORD lineresol;//12. line resolution WORD eleres; //13. element resolution WORD numband; //14. number of spectral bands; WORD lenprefix;//15. length of the line prefix WORD projnum; //16. SSEC file creation project number WORD filedate; //17. file creation year and Julian day, yyyddd WORD filetime; //18. file creation time, hhmmss WORD bandmap; //19. spectral band map WORD ID; //20. image ID number char res2[16]; //21-24. resrved for sensor-specific data char memo[32]; //25-32. memo field; 32 ASCII characters WORD res3; //33. reserved WORD datablock;//34. byte offset to the start of the data block WORD navblock; //35. byte offset to the start of the navigation block WORD valcode; //36. validity code; char PDL[32]; //37-44. Program Date Load; used for pre-GOES-8 satellites WORD band8; //45. source of band 8; used for GOES AA processing WORD imgdate; //46. actual image start year and Julian day, yyyddd WORD imgtime; //47. actual image start time, hhmmss; in milliseconds for POES data WORD imgscan; //48. actual image start scan WORD lendoc; //49. length of the prefix documentation WORD lencali; //50. length of the prefix calibration WORD lenband; //51. length of the prefix band list char stype[4]; //52. source type; satellite-specific (ASCII) char ctype[4]; //53. calibration type; satellite-specific (ASCII) char res4[24]; //54-59. reserved WORD supblock; //60. byte offset to the supplemental block WORD numsup; //61. number of bytes in the supplemental block char res5[4]; //62. reserved WORD caliblock;//63. byte offset to the start of the calibration block WORD numcom; //64. number of comment cards }dheader; /*void usage(void) { printf("Usage: AOD2AREA AOD_file\n"); } */ int main(int argc,char *argv[]) { FILE *fp,*fo; WORD i, j, p; WORD yyyddd,hhmm, minyyy,minhh; char areaname[120],fn[100],cnum[3],command[200]; fp=fopen("/data/SMOKE/work/SMOKE_AREA","rb"); if(fp==NULL) { printf("Error: SMOKE_AREA doesn't exist!\n"); exit(1); } if(fread(&dheader,sizeof(dheader),1,fp)!=1) { printf("Error: Failed to read SMOKE file!\n"); fclose(fp); exit(1); } fclose(fp); // passing in startAREArange on command line int startAREA; startAREA= atoi(argv[1]); /* Compute offset from start area. Assumes first area is at time 10:15Z */ int areaOffset; int areanum; hhmm=dheader.hhmm; areaOffset = 2*(hhmm/10000 - 10) + (hhmm%10000)/3000 ; /* check that areanum is within limits */ if (startAREA < 4296 | startAREA > 4399 | areaOffset < 0 | areaOffset > 26){ printf("ERROR COMPUTED ILLEGAL areanum %d\n", startAREA); printf("startAREA=%d\n", startAREA); printf("areaOffset=%d\n", areaOffset); printf("quitting\n"); exit(1); } areanum = startAREA + areaOffset ; if (areanum < 4296 | areanum > 4399 | areaOffset < 0 | areaOffset > 26){ areanum = areanum - 104; } /* Copy the smoke product to computed area file*/ sprintf( areaname, "/data/SMOKE/SMOKE-DATASET/AREA%4.4d",areanum); strcpy(command,"cp /data/SMOKE/work/SMOKE_AREA "); strcat(command,areaname); printf("%s\n",command); system(command); printf("\tScan %s\n",cnum); if((fo=fopen("/home/oper/new_SMOKE/AREAnumber", "w")) == NULL) { printf("cannnot open file\n"); } fprintf(fo, "%s",cnum); fclose(fo); exit(0); }