/**************************************************** slice_response_example.c Author: Michael P. Owen 8/07/2007, MERS Laboratory, Brigham Young University Description: Sample code to illustrate usage of QuikSCAT slice spatial response functions found in "slice_response_code.h". This code counts the number of cells in a random slice response function that are greater than -70dB and finds the average latitude and longitude perturbation of the slice. ****************************************************/ #include #include /* used to get random integers */ int main(int argc,char *argv[]) { int pulse_polarization = 0; float pulse_antenna_angle = 0; float pulse_orbit_time = 0; float center_lat, center_lon = 0; int slice_number = 0; int i = 0; int cell_count = 0; float lat_sum = 0, lon_sum = 0; /* get random location, polarization, antenna angle and orbit time*/ center_lat = (float) (rand()%180); center_lon = (float) ((rand()%360)-180); pulse_polarization = (rand()%2); pulse_antenna_angle = (float) (rand()%360); pulse_orbit_time = (float) (rand()%6061); printf("Center latitude: %f\n", center_lat); printf("Center longitude: %f\n", center_lon); printf("Polarization: %d\n", pulse_polarization); printf("Antenna angle: %f\n", pulse_antenna_angle); printf("Orbit time: %f\n", pulse_orbit_time); /* load data files and allocate memory arrays*/ loadresponse(); /* get the interpolated response and latitude and longitude vectors for the random pulse*/ interpolate_slice(pulse_antenna_angle, pulse_orbit_time, pulse_polarization, center_lat, center_lon ); /* get a random slice number between 0 and 7 to use */ slice_number = (rand()%8); printf("Slice number (1-8): %d\n", slice_number+1); for(i = 0; i < mmm*nnn; i++){/* index the entire response arrays in order in memory */ /* accumulate the delta lat and lon for the pulse*/ lat_sum += pulse_del_lat[i]; lon_sum += pulse_del_lon[i]; /* count slice response cells greater than -70dB */ if(pulse_response[i + mmm*nnn*slice_number] > -70) cell_count++; } printf("Average delta latitude: %f\n", lat_sum/((float)mmm*nnn)); printf("Average delta longitude: %f\n", lon_sum/((float)mmm*nnn)); printf("Slice response cells > -70dB: %d\n", cell_count); /* Free all allocated global vars */ free(Vdel_lat); free(Vdel_lon); free(Vresponse); free(Vpoints); free(Hdel_lat); free(Hdel_lon); free(Hresponse); free(Hpoints); free(pulse_del_lat); free(pulse_del_lon); free(pulse_points); }