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
00057
00058
00061 #define PRINT_USAGE(rc) \
00062 fprintf(stderr, "Usage: %s [ -s startidx ] [ -c count ] PIXTABLE\n", \
00063 argv[0]); \
00064 cpl_end(); return (rc);
00065
00066 int main(int argc, char **argv)
00067 {
00068 cpl_init(CPL_INIT_DEFAULT);
00069 muse_processing_recipeinfo(NULL);
00070
00071 if (argc <= 1) {
00072
00073 PRINT_USAGE(1);
00074 }
00075
00076 char *tname = NULL;
00077 cpl_size start = 0, count = CPL_SIZE_MAX;
00078 int i;
00079
00080
00081 for (i = 1; i < argc; i++) {
00082 if (strncmp(argv[i], "-s", 3) == 0) {
00083
00084 i++;
00085 if (i < argc) {
00086 start = atol(argv[i]);
00087 } else {
00088 PRINT_USAGE(2);
00089 }
00090 } else if (strncmp(argv[i], "-c", 3) == 0) {
00091
00092 i++;
00093 if (i < argc) {
00094 count = atol(argv[i]);
00095 } else {
00096 PRINT_USAGE(3);
00097 }
00098 } else if (strncmp(argv[i], "-", 1) == 0) {
00099 PRINT_USAGE(9);
00100 } else {
00101 tname = argv[i];
00102 break;
00103 }
00104 }
00105
00106 cpl_msg_set_level(CPL_MSG_WARNING);
00107 muse_pixtable *table = muse_pixtable_load_window(tname, start, count);
00108 if (!table) {
00109 PRINT_USAGE(10);
00110 }
00111
00112 if (count == CPL_SIZE_MAX) {
00113 count = muse_pixtable_get_nrow(table);
00114 }
00115
00116 cpl_propertylist *theader = cpl_propertylist_load(tname, 1);
00117 cpl_size nrow = cpl_propertylist_get_long_long(theader, "NAXIS2");
00118 cpl_propertylist_delete(theader);
00119
00120 printf("# MUSE pixel table \"%s\", showing %"CPL_SIZE_FORMAT" rows starting "
00121 "at index %"CPL_SIZE_FORMAT" of %"CPL_SIZE_FORMAT"\n", tname, count,
00122 start, nrow);
00123 cpl_error_code rc = muse_pixtable_dump(table, 0, count, 1);
00124 switch (rc) {
00125 case CPL_ERROR_NONE:
00126 rc = 0;
00127 break;
00128 case CPL_ERROR_BAD_FILE_FORMAT:
00129 fprintf(stderr, "%s: \"%s\" does not seem to contain a MUSE pixel table!\n",
00130 argv[0], tname);
00131 rc = 11;
00132 break;
00133 case CPL_ERROR_ILLEGAL_INPUT:
00134 fprintf(stderr, "%s: Illegal data range given (start index=%"CPL_SIZE_FORMAT
00135 " count=%"CPL_SIZE_FORMAT") for table with %"CPL_SIZE_FORMAT
00136 " rows!\n", argv[0], start, count, muse_pixtable_get_nrow(table));
00137 rc = 12;
00138 break;
00139 default:
00140 rc = 50;
00141 }
00142
00143 muse_pixtable_delete(table);
00144 cpl_end();
00145 return rc;
00146 }
00147