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 PIXTABLE_IN IFU SLICE PIXTABLE_OUT\n", argv[0]); \
00057 cpl_end(); return (rc);
00058
00059 int main(int argc, char **argv)
00060 {
00061 cpl_init(CPL_INIT_DEFAULT);
00062 muse_processing_recipeinfo(NULL);
00063 cpl_errorstate prestate = cpl_errorstate_get();
00064
00065 if (argc != 5) {
00066
00067 PRINT_USAGE(1);
00068 }
00069
00070 char *tiname = NULL,
00071 *toname = NULL;
00072 unsigned char ifu = 0;
00073 unsigned short slice = 0;
00074 int i;
00075
00076
00077 for (i = 1; i < argc; i++) {
00078 if (tiname && toname) {
00079 break;
00080 }
00081 if (!tiname) {
00082 tiname = argv[i];
00083 } else if (!ifu) {
00084 ifu = atoi(argv[i]);
00085 } else if (!slice) {
00086 slice = atoi(argv[i]);
00087 } else {
00088 toname = argv[i];
00089 }
00090 }
00091 if (ifu == 0 || ifu > kMuseNumIFUs) {
00092 printf("Illegal IFU number %hhu given\n", ifu);
00093 PRINT_USAGE(2);
00094 }
00095 if (slice == 0 || slice > kMuseSlicesPerCCD) {
00096 printf("Illegal slice number %hu given\n", slice);
00097 PRINT_USAGE(3);
00098 }
00099
00100 muse_pixtable *table = muse_pixtable_load(tiname);
00101 if (!table) {
00102 PRINT_USAGE(10);
00103 }
00104 cpl_size nrow = muse_pixtable_get_nrow(table);
00105 printf("Loaded pixel table \"%s\" with %"CPL_SIZE_FORMAT" rows\n",
00106 tiname, nrow);
00107
00108 cpl_error_code rc = muse_pixtable_erase_ifu_slice(table, ifu, slice);
00109 cpl_size nrow2 = muse_pixtable_get_nrow(table);
00110 if (rc == CPL_ERROR_NONE) {
00111 printf("Erased slice %hu of IFU %hhu (%"CPL_SIZE_FORMAT" pixels removed)\n",
00112 slice, ifu, nrow - nrow2);
00113 } else {
00114 printf("Error while erasing slice %hu of IFU %hhu: %s\n", slice, ifu,
00115 cpl_error_get_message());
00116 }
00117
00118 muse_pixtable_save(table, toname);
00119 printf("MUSE pixel table \"%s\" (%"CPL_SIZE_FORMAT" rows) saved\n", toname,
00120 nrow2);
00121 muse_pixtable_delete(table);
00122 rc = cpl_errorstate_is_equal(prestate) ? 0 : 50;
00123 if (rc) {
00124 cpl_errorstate_dump(prestate, CPL_FALSE, muse_cplerrorstate_dump_some);
00125 }
00126 cpl_end();
00127 return rc;
00128 }
00129