/*-------------------------------------------------------------------------------------------- File name: SMOKE2AREA.c Purpose: Read Goes East McIDAS AREA file as template and creat one for Smoke AOD Adapted from AOD2AREA.c which was written By Zedong Zhang on 2/18/2004 Edited by Laura Kowal to work for SMOKE data April 2008 Modified: By J.Yang in May 2008 Usage: SMOKE2AREA Notes: The Smoke binary data values are as following: Smoke AOD: > 0. (Maximum is 1.517, we use 1.6 for scaling) Cloud: -1. No fire: -2. Nonsmoke aerosols: -3. No data: -9999. In McIDAS AREA file the brightnesss values are as following: no data: 0 cloud: 1 no fire: 2 nonsmoke aerosol: 3 Smoke AOD: 10-255 Last Modified: 05/20/2008 --------------------------------------------------------------------------------------------*/ #include #include #include #define WORD unsigned int #define BYTE unsigned char #define SHORT unsigned short #define MX 2126 #define MY 880 #define DX 2 #define DY 14 #define Image_WEST_X 2130 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: SMOKE2AREA SMOKE_file\n"); } int searchSlash(char *s) { int i,p; p=0; for(i=0;i1300) x=0; // data[i][822-j] = data[i][822-j] / 1000000; //if((data[i][822-j]>0) && ((i % 10) == 0) ) //{ // printf("data value = %f\n", data[i][822-j]); //} if(data[i][MY-j-DY]<0) { if(data[i][MY-j-DY] == -1.0) { imagedata = 1; } else if (data[i][MY-j-DY] == -2.0) { imagedata = 2; // if((i % 10) == 0) // { // printf("-2 value = %f, count value is %d\n", data[i][822-j], imagedata); // } } else if (data[i][MY-j-DY] == -3.0) { imagedata = 3; } else { imagedata = 0; /* for debug if((i % 50) == 0) { printf("Other negative value = %f, count value is %d\n", data[i][822-j], imagedata); } */ } } else if (data[i][MY-j-DY]>1.6) { imagedata= 255; } else { // plus 0.5 for round the value to the nearest integer imagedata=(BYTE)(x*data[i][MY-j] + minCnt + 0.5); /* for debug if((i % 50) == 0) { printf("Smoke data value = %f, count value is %d\n", data[i][822-j], imagedata); } */ } fwrite(&imagedata,sizeof(BYTE),1,fp); } // fseek(fp,121*sizeof(BYTE), SEEK_CUR); // for(i=0;i<121;i++) // fwrite(&zero,sizeof(BYTE),1,fp); } // for(j=822;j<883;j++) // for(i=0;i<2128;i++) // fwrite(&zero,sizeof(BYTE),1,fp); for(j=MY;j