25 #define PRINT_USAGE(rc) \
26 fprintf(stderr, "Usage: %s INFILE OUTFILE\n", argv[0]); \
27 cpl_end(); return (rc);
34 int main(
int argc,
char **argv)
36 cpl_init(CPL_INIT_DEFAULT);
43 cpl_table *table = cpl_table_load(argv[1], 3, 0);
47 int nrow = cpl_table_get_nrow(table);
48 cpl_msg_info(__func__,
"read %d columns from \"%s\"", nrow, argv[1]);
51 cpl_table_add_scalar(table,
"xdet", 1);
52 cpl_table_add_scalar(table,
"ydet", 1);
54 cpl_table_new_column(table,
"euro3d", CPL_TYPE_INT);
55 int n, nhot = 0, ndark = 0, ntrap = 0;
56 for (n = 0; n < nrow; n++) {
58 char type = cpl_table_get_string(table,
"type", n)[0];
61 cpl_table_set(table,
"euro3d", n, EURO3D_HOTPIXEL);
65 cpl_table_set(table,
"euro3d", n, EURO3D_DARKPIXEL);
69 cpl_table_set(table,
"euro3d", n, EURO3D_MUSE_TRAP);
75 cpl_table_dump(table, 0, 100000, stdout);
78 cpl_msg_info(__func__,
"%d hot, %d dark, and %d trap pixel%s",
79 nhot, ndark, ntrap, nhot+ndark+ntrap != 1 ?
"s" :
"");
83 image->
data = cpl_image_load(argv[1], CPL_TYPE_INT, 0, 1);
84 int nx = cpl_image_get_size_x(image->
data),
85 ny = cpl_image_get_size_y(image->
data);
87 image->
dq = cpl_image_new(nx, ny, CPL_TYPE_INT);
89 for (n = 0; n < nrow; n++) {
90 int i = cpl_table_get_int(table,
"xdet", n, NULL),
91 j = cpl_table_get_int(table,
"ydet", n, NULL),
92 dq = cpl_table_get_int(table,
"euro3d", n, NULL),
93 err, val = cpl_image_get(image->
dq, i, j, &err);
94 cpl_image_set(image->
dq, i, j, dq | val);
98 image->
header = cpl_propertylist_load(argv[1], 1);
100 cpl_image_save(trimmed->
dq, argv[2], CPL_TYPE_INT, NULL, CPL_IO_CREATE);
101 cpl_msg_info(__func__,
"saved to \"%s\"", argv[2]);
104 cpl_table_delete(table);
void muse_image_delete(muse_image *aImage)
Deallocate memory associated to a muse_image object.
cpl_image * data
the data extension
Structure definition of MUSE three extension FITS file.
cpl_propertylist * header
the FITS header
cpl_image * dq
the data quality extension
muse_image * muse_image_new(void)
Allocate memory for a new muse_image object.
muse_image * muse_quadrants_trim_image(muse_image *aImage)
Trim the input image of pre- and over-scan regions of all quadrants.