00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <muse.h>
00023 #include <string.h>
00024
00025
00051
00052
00055 #define PRINT_USAGE(rc) \
00056 fprintf(stderr, "Usage: %s [ -s sigma ] [ -q ] GEOMETRY_TABLE FIXED_TABLE\n",\
00057 argv[0]); \
00058 cpl_end(); return (rc);
00059
00060 int main(int argc, char **argv)
00061 {
00062 cpl_init(CPL_INIT_DEFAULT);
00063 muse_processing_recipeinfo(NULL);
00064 cpl_errorstate state = cpl_errorstate_get();
00065
00066 if (argc <= 2) {
00067
00068 PRINT_USAGE(1);
00069 }
00070
00071
00072 char *tiname = NULL,
00073 *toname = NULL;
00074 double sigma = 3.;
00075 cpl_boolean qc = CPL_FALSE;
00076 int i;
00077 for (i = 1; i < argc; i++) {
00078 if (strncmp(argv[i], "-s", 3) == 0) {
00079 i++;
00080 if (i < argc) {
00081 sigma = atof(argv[i]);
00082 } else {
00083 PRINT_USAGE(2);
00084 }
00085 } else if (strncmp(argv[i], "-q", 3) == 0) {
00086 qc = CPL_TRUE;
00087 } else if (strncmp(argv[i], "-", 1) == 0) {
00088 PRINT_USAGE(9);
00089 } else {
00090 if (tiname && toname) {
00091 break;
00092 }
00093 if (!tiname) {
00094 tiname = argv[i];
00095 } else {
00096 toname = argv[i];
00097 }
00098 }
00099 }
00100 if (!tiname || !toname) {
00101 PRINT_USAGE(1);
00102 }
00103 cpl_msg_set_level(CPL_MSG_DEBUG);
00104
00105 muse_geo_table *gt = muse_geo_table_new(1, 1.);
00106 cpl_table_delete(gt->table);
00107 gt->table = cpl_table_load(tiname, 1, 1);
00108 if (!gt->table) {
00109 muse_geo_table_delete(gt);
00110 PRINT_USAGE(10);
00111 }
00112
00113
00114 cpl_propertylist *pheader = cpl_propertylist_load(tiname, 0);
00115 cpl_error_code rc = muse_geo_correct_slices(gt, pheader, sigma);
00116 if (qc) {
00117 muse_geo_qc_global(gt, pheader);
00118 }
00119 cpl_table_save(gt->table, pheader, NULL, toname, CPL_IO_CREATE);
00120 cpl_propertylist_delete(pheader);
00121 muse_geo_table_delete(gt);
00122
00123 if (rc != CPL_ERROR_NONE) {
00124 cpl_msg_error(__func__, "Fixing the table failed: %s",
00125 cpl_error_get_message());
00126 } else if (!cpl_errorstate_is_equal(state)) {
00127 cpl_msg_error(__func__, "An error occurred, unrelated to fixing the table: %s",
00128 cpl_error_get_message());
00129 rc = 50;
00130 }
00131 cpl_memory_dump();
00132 cpl_end();
00133 return rc;
00134 }
00135