int main(int argc, char *argv[]) { const char *peak_file1 = "peak1.dat"; const char *prof_file1 = "prof1.dat"; const char *peak_file2 = "peak2.dat"; const char *prof_file2 = "prof2.dat"; satdata_mag *data = NULL; current_data sat1, sat2; peak_workspace *peak_workspace_p; struct timeval tv0, tv1; sat1.n = 0; sat2.n = 0; while (1) { int c; int option_index = 0; static struct option long_options[] = { { "curr_file", required_argument, NULL, 'j' }, { "curr_file2", required_argument, NULL, 'k' }, { "swarm_file", required_argument, NULL, 's' }, { 0, 0, 0, 0 } }; c = getopt_long(argc, argv, "j:k:s:", long_options, &option_index); if (c == -1) break; switch (c) { case 'j': fprintf(stderr, "main: reading %s...", optarg); read_lc(optarg, &sat1); fprintf(stderr, "done (%zu profiles read)\n", sat1.n); break; case 'k': fprintf(stderr, "main: reading %s...", optarg); read_lc(optarg, &sat2); fprintf(stderr, "done (%zu profiles read)\n", sat2.n); break; case 's': fprintf(stderr, "main: reading %s...", optarg); gettimeofday(&tv0, NULL); data = satdata_swarm_read_idx(optarg, 0); gettimeofday(&tv1, NULL); if (!data) exit(1); fprintf(stderr, "done (%zu points read, %g seconds)\n", data->n, time_diff(tv0, tv1)); break; default: print_help(argv); exit(1); break; } } if (sat1.n == 0) { print_help(argv); exit(1); } peak_workspace_p = peak_alloc(NCURR); if (data) { track_workspace *track_p = track_alloc(); fprintf(stderr, "main: separating into tracks..."); track_init(data, NULL, track_p); fprintf(stderr, "done\n"); /* north hemisphere peak finding */ analyze_hemisphere(-3.0, 23.0, peak_file1, prof_file1, data, track_p, &sat1); /* south hemisphere peak finding */ analyze_hemisphere(-23.0, 0.0, peak_file2, prof_file2, data, track_p, &sat1); satdata_mag_free(data); track_free(track_p); } else if (sat2.n > 0) { const char *data_file1 = "data.dat.north"; const char *corr_file1 = "corr.dat.north"; const char *data_file2 = "data.dat.south"; const char *corr_file2 = "corr.dat.south"; fprintf(stderr, "main: searching for northern J peaks in satellite 1..."); find_J_peaks(5.0, 23.0, -100.0, peak_file1, prof_file1, NULL, NULL, &sat1); fprintf(stderr, "done\n"); fprintf(stderr, "main: searching for northern J peaks in satellite 2..."); find_J_peaks(5.0, 23.0, -100.0, peak_file2, prof_file2, NULL, NULL, &sat2); fprintf(stderr, "done\n"); correlateJ(data_file1, corr_file1, &sat1, &sat2); fprintf(stderr, "main: data printed to %s\n", data_file1); fprintf(stderr, "main: correlation data printed to %s\n", corr_file1); fprintf(stderr, "main: searching for northern J peaks in satellite 2..."); find_J_peaks(-23.0, -5.0, -100.0, peak_file1, prof_file1, NULL, NULL, &sat1); fprintf(stderr, "done\n"); fprintf(stderr, "main: searching for northern J peaks in satellite 2..."); find_J_peaks(-23.0, -5.0, -100.0, peak_file2, prof_file2, NULL, NULL, &sat2); fprintf(stderr, "done\n"); correlateJ(data_file2, corr_file2, &sat1, &sat2); fprintf(stderr, "main: data printed to %s\n", data_file2); fprintf(stderr, "main: correlation data printed to %s\n", corr_file2); } peak_free(peak_workspace_p); return 0; } /* main() */
int main(int argc, char **argv){ char *outfile = argv[argc-1]; int opt,twait; struct picture pict; int interlace=PNG_INTERLACE_ADAM7; pict.colormap=NULL; while((opt = getopt(argc, argv, "hugc:z:s:")) != -1) { switch (opt){ case 'h': Help(argv[0]); return 1; break; case 'c': ConvertColorstring(optarg, &pixcolor); break; case 'z': zoom=atoi(optarg); break; case 'u': compression=0; break; case 'g': gray=1; break; case 's': twait=(atoi(optarg)); while(twait>0) { --twait; printf("[lcshot] Waiting for%4d s\r",twait);fflush(stdout); sleep(1); } printf("\n"); break; default: break; } } if ((optind==argc) || (1!=argc-optind)){ Usage(argv[0]); return 1; } read_lc(&pict); printf("[lcshot] Display content grabbed.\n"); printf("[lcshot] Writing %s ...\n",outfile);fflush(stdout); Write_PNG(&pict, outfile, interlace, gray ); if(pict.colormap){ free(pict.colormap->red); free(pict.colormap->green); free(pict.colormap->blue); free(pict.colormap->transp); free(pict.colormap); } free(pict.buffer); printf ("[lcshot] done.\n"); return 0; }