// MOD35 includes #include "granule.h" #include "pixel.h" #include "thresholds.h" #include "stats.h" #include "sst.h" // Standard includes #include //#include //#include //static float DEG2RAD = (3.14159 / 180.0); //static int output_cm_stats = 1; //static PyObject *cm_wrapper(PyObject *self, PyObject *args); //extern "C" void modis_cm_main(char *); //static void *pointer_to_nwp = NULL; //static nwp_params *pointer_to_nwp = NULL; /* Interface: */ int cm_wrapper( float *dlat, float *dlon, float *dsenZ, float *dsolZ, float *dra, float *dse, float *digbp, float *dsst, float *dndvi, float *sfctemp, int *sfct_flag, float *tpw, float *dmodis, unsigned char *dlsm, unsigned char *dnise, unsigned char *deco, int lcol, unsigned char *result, unsigned char *qa ) { // memset(&g_cm, 0, lcol * 6); printf("*********************************\n"); printf("******* RUNNING CLOUDMASK *******\n"); printf("*********************************\n"); // printf("grows: %d | gcols: %d", grows, gcols); // printf("dmodis 0: [%f]\n", dmodis[0]); // printf("dlat 0: [%f] | dlon 0: [%f]\n", dlat[0], dlon[0]); // printf("dsenZ: [%f] | dsolZ: [%f]\n", dsenZ[0], dsolZ[0]); // printf("dra: [%f] | dse: [%f] | digbp: [%f]\n", dra[0], dse[0], digbp[0]); int ni; int nones = 0; int nzeros = 0; int nother = 0; // DEBUG SFCT_FLAG CHECK: // for(ni=0; niproc_250; // if(proc_qkm) { //g_qkm1 = imgr1->qkm_ref1; //g_qkm2 = imgr1->qkm_ref2; //g_qkm_ncol = imgr1->qkm_ncol; // } // Satellite ID sid_terra = 0; sid_aqua = 1; /* TODO: if(imgr1->satid == TERRA) { sid_terra = 1; sid_aqua = 0; } else if (imgr1->satid == AQUA) { sid_terra = 0; sid_aqua = 1; } */ // Assume number pixels is always 1354. neles = 1354; // Number scans in granule // nscans = sizeof(dlat) / sizeof(dlat[0]); nscans = lcol / neles; printf("nscans: %d\n", nscans); // Get angular data from input geolocation data. g_lat = dlat; g_lon = dlon; g_vza = dsenZ; g_sza = dsolZ; g_raz = dra; // Get MODIS land/sea flag (from MODIS geolocation file). g_lsf = dlsm; for(ni=0; ni 10) { printf("g_lsf[%d] = %d\n", ni, g_lsf[ni]); } } // Get surface elevation. g_elev = dse; // ALL THE STUFF FROM OTHER FUNCTIONS: // Get Reynolds SST g_reynSST = dsst; // Get NISE g_nise = dnise; // Get Olson Eco g_eco = deco; // Get NDVI g_ndvibk = dndvi; // ** POINTER TO NWP STUFF *** // // Get SURFACE TEMP g_sfctmp = sfctemp; // Get SFCT FLAG g_sfct_flag = sfct_flag; // Get TPW g_tpw = tpw; // modis_cm_main(imgr1->algData_dir_name); // GPC printf("*********************************\n"); printf("****** CALL MODIS_CM_MAIN *******\n"); printf("*********************************\n"); // FIXME: hardcoded path needs to go before this can be portable modis_cm_main("/data3/nickb/pypre/src/cloudmask/thresholds/"); // GPC printf(" COPYING RESULTS . . . \n"); printf("lcol VALUE: %d\n", lcol); // printf("g_cm[0] = %s\n", g_cm[0]); // return g_cm; printf("g_cm[0][0]: %d\n", g_cm[0][0]); // WRONG - JUST COPYING POINTER // result = &g_cm[0]; // for(b=0; b<6; b++) // { // printf("%d %d\n", lcol, b); // memcpy(&result[lcol*b], &g_cm[b], lcol); // } int idx; for(b=0; b<6; b++) { for(idx=0; idx