/* !C ******************************************************************** !Description: Integer function create_cloud_mask.c Creates the MODIS cloud mask (MOD35). Called from modis_cm_main.c !Input arguments: none Inputs from granule.h, pixel.h !Output arguments: none int return_code successful completion is zero, otherwise non-zero (returned through function call) Output cloud mask and associated products and arrays in ... !Revision History: R. Frey 05/2007 !Team-unique Header: !References and Credits: !END ******************************************************************/ /* Includes */ #include #include #include #include "granule.h" #include "pixel.h" #include "thresholds.h" #include "stats.h" int create_cloud_mask() { /* Declarations */ extern int get_pxldat(STATS *); extern int perform_cloud_tests(); extern void thin_cirrus_tests(); extern void noncloud_obs_tests(); extern void set_confdnc(); extern void set_proc_path(); extern void set_bit(int, unsigned char[]); extern void get_cloud_adj(); extern void save_250m_info(); extern void create_250m_cm(int, int, int, int, STATS *); extern void get_stats(STATS *); extern void prepareMetadata(STATS *); extern void set_qa_flags(int, unsigned char[]); long int idx; long int mem; int return_code; int scan_index; int elem_index; int beg_elem_index; int end_elem_index; int ret_code; int num_tests_performed; int outbyte; int out_indx; int num_cm_bytes = 6; int num_qa_bytes = 10; int num_250m_stats = 4; STATS stats_out = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; /* Initializations */ printf("Executing create_cloud_mask 29\n"); return_code = 0; // Allocate memory for cloud mask output. mem = neles * nscans * sizeof(unsigned char); for (outbyte=0; outbyte= 1) { (void) set_bit(0, pxout.testbits); pxout.qa1km = 1; } else { pxout.qa1km = 0; } /* Set cloud mask QA flags. */ (void) set_qa_flags(num_tests_performed, pxout.qabits); /* Zero out results of the cloud mask if geolocation data are missing. */ if(pxin.bad_geo) { printf("Bad geo-location found at %d %d\n", scan_index, elem_index); pxout.qa1km = 0; for (outbyte=0; outbyte beg_elem_index) (void)create_250m_cm(idx, end_elem_index, elem_index, scan_index, &stats_out); if(proc_qkm) (void)save_250m_info(); //************************************************************************************************* idx++; elem_index++; // printf("\nvalue of cm byte 0 %d\n", pxout.testbits[0]); // printf("value of cm byte 1 %d\n", pxout.testbits[1]); // printf("value of cm byte 2 %d\n", pxout.testbits[2]); // printf("value of cm byte 3 %d\n", pxout.testbits[3]); // printf("value of cm byte 4 %d\n", pxout.testbits[4]); // printf("value of cm byte 5 %d\n", pxout.testbits[5]); } scan_index++; } /* Prepare cloud mask statistics for output metadata. */ (void) prepareMetadata(&stats_out); /* Copy cloud mask and qa info to output arrays. */ for (outbyte=0; outbyte