75 #define PRINT_USAGE(rc) \
76 fprintf(stderr, "Usage: %s [ -l1 lambda1 ] [ -l2 lambda2 ] [ -x1 xpos1 ] " \
77 "[ -x2 xpos2 ] [ -y1 ypos1 ] [ -y2 ypos2 ] [ -i IFU ] [ -s slice ] " \
78 "PIXTABLE_IN PIXTABLE_OUT\n", argv[0]); \
79 cpl_end(); return (rc);
81 int main(
int argc,
char **argv)
83 cpl_init(CPL_INIT_DEFAULT);
93 double x1 = -FLT_MAX, x2 = FLT_MAX,
94 y1 = -FLT_MAX, y2 = FLT_MAX,
95 l1 = -FLT_MAX, l2 = FLT_MAX;
96 unsigned char ifu = 0;
97 unsigned short slice = 0;
101 for (i = 1; i < argc; i++) {
102 if (strncmp(argv[i],
"-x1", 4) == 0) {
110 }
else if (strncmp(argv[i],
"-x2", 4) == 0) {
117 }
else if (strncmp(argv[i],
"-y1", 4) == 0) {
124 }
else if (strncmp(argv[i],
"-y2", 4) == 0) {
131 }
else if (strncmp(argv[i],
"-l1", 4) == 0) {
139 }
else if (strncmp(argv[i],
"-l2", 4) == 0) {
146 }
else if (strncmp(argv[i],
"-i", 3) == 0) {
153 }
else if (strncmp(argv[i],
"-s", 3) == 0) {
156 slice = atoi(argv[i]);
160 }
else if (strncmp(argv[i],
"-", 1) == 0) {
163 if (tiname && toname) {
173 if (!tiname || !toname) {
177 cpl_msg_set_level(CPL_MSG_WARNING);
194 printf(
"MUSE pixel table \"%s\" (%"CPL_SIZE_FORMAT
" rows)\n"
195 " cropping to lambda = %.2f..%.2f Angstrom\n"
196 " xpos = %.3e..%.3e %s\n"
197 " ypos = %.3e..%.3e %s\n",
199 xl, xu, cpl_table_get_column_unit(table->
table, MUSE_PIXTABLE_XPOS),
200 yl, yu, cpl_table_get_column_unit(table->
table, MUSE_PIXTABLE_YPOS));
207 if (ifu >= 1 && ifu <= kMuseNumIFUs) {
208 printf(
" selecting pixels from IFU %02hhu ", ifu);
209 cpl_table_unselect_all(table->
table);
210 const int *origin = cpl_table_get_data_int_const(table->
table,
211 MUSE_PIXTABLE_ORIGIN);
213 for (irow = 0; irow < nrow; irow++) {
215 cpl_table_select_row(table->
table, irow);
218 printf(
"(%d of %d)\n", (
int)cpl_table_count_selected(table->
table), (
int)nrow);
219 cpl_table_erase_selected(table->
table);
221 if (slice >= 1 && slice <= kMuseSlicesPerCCD) {
222 printf(
" selecting pixels from slice %02hu ", slice);
223 cpl_table_unselect_all(table->
table);
224 const int *origin = cpl_table_get_data_int_const(table->
table,
225 MUSE_PIXTABLE_ORIGIN);
227 for (irow = 0; irow < nrow; irow++) {
229 cpl_table_select_row(table->
table, irow);
232 printf(
"(%d of %d)\n", (
int)cpl_table_count_selected(table->
table), (
int)nrow);
233 cpl_table_erase_selected(table->
table);
245 printf(
"MUSE pixel table \"%s\" (%"CPL_SIZE_FORMAT
" rows) saved\n",
muse_pixtable * muse_pixtable_load(const char *aFilename)
Load the table itself and the FITS headers of a MUSE pixel table from a file.
unsigned short muse_pixtable_origin_get_slice(uint32_t aOrigin)
Get the slice number from the encoded 32bit origin number.
#define MUSE_HDR_PT_XLO
FITS header keyword contains the lower limit of the data in x-direction.
cpl_size muse_pixtable_get_nrow(const muse_pixtable *aPixtable)
get the number of rows within the pixel table
#define MUSE_HDR_PT_LHI
FITS header keyword contains the upper limit of the data in spectral direction.
cpl_table * table
The pixel table.
cpl_error_code muse_pixtable_restrict_wavelength(muse_pixtable *aPixtable, double aLow, double aHigh)
Restrict a pixel table to a certain wavelength range.
Structure definition of MUSE pixel table.
#define MUSE_HDR_PT_YLO
FITS header keyword contains the lower limit of the data in y-direction.
#define MUSE_HDR_PT_LLO
FITS header keyword contains the lower limit of the data in spectral direction.
cpl_error_code muse_pixtable_save(muse_pixtable *aPixtable, const char *aFilename)
Save a MUSE pixel table to a file on disk.
unsigned short muse_pixtable_origin_get_ifu(uint32_t aOrigin)
Get the IFU number from the encoded 32bit origin number.
cpl_error_code muse_pixtable_restrict_xpos(muse_pixtable *aPixtable, double aLo, double aHi)
Restrict a pixel table to a certain x coordinate range.
void muse_pixtable_delete(muse_pixtable *aPixtable)
Deallocate memory associated to a pixel table object.
cpl_error_code muse_pixtable_restrict_ypos(muse_pixtable *aPixtable, double aLo, double aHi)
Restrict a pixel table to a certain y coordinate range.
#define MUSE_HDR_PT_YHI
FITS header keyword contains the upper limit of the data in y-direction.
cpl_propertylist * header
The FITS header.
#define MUSE_HDR_PT_XHI
FITS header keyword contains the upper limit of the data in x-ion.