9#include "eris_ifu_debug.h"
10#include "eris_ifu_error.h"
36 const cpl_property *p = NULL;
38 cpl_error_code ret_error = CPL_ERROR_NONE;
42 cpl_msg_debug(
"",
"===== START HEADER =====");
44 cpl_msg_warning(
"",
"Empty header!");
46 for (i = 0; i < cpl_propertylist_get_size(header); i++) {
48 p = cpl_propertylist_get_const(header, i));
50 t = cpl_property_get_type (p);
54 cpl_msg_debug(
"",
"%s: %d", cpl_property_get_name(p),
55 cpl_property_get_bool(p));
58 cpl_msg_debug(
"",
"%s: %d", cpl_property_get_name(p),
59 cpl_property_get_int(p));
62 cpl_msg_debug(
"",
"%s: %12.16g", cpl_property_get_name(p),
63 cpl_property_get_double(p));
66 cpl_msg_debug(
"",
"%s: %12.16f", cpl_property_get_name(p),
67 cpl_property_get_float(p));
70 cpl_msg_debug(
"",
"%s: %s", cpl_property_get_name(p),
71 cpl_property_get_string(p));
78 cpl_msg_debug(
"",
"====== END HEADER ======");
84 ret_error = cpl_error_get_code();
106 const cpl_frame *frame = NULL;
107 cpl_error_code ret_error = CPL_ERROR_NONE;
111 cpl_msg_debug(
"",
"====== START FRAMESET ======");
112 if (frameset == NULL) {
113 cpl_msg_warning(
"",
"Empty frameset!");
115 frame = cpl_frameset_find_const(frameset, NULL);
120 cpl_msg_debug(
"",
"====== END FRAMESET ======");
122 return CPL_ERROR_NONE;
125 while (frame != NULL) {
128 frame = cpl_frameset_find_const(frameset, NULL));
131 cpl_msg_debug(
"",
"====== END FRAMESET ======");
137 ret_error = cpl_error_get_code();
159 cpl_error_code ret_error = CPL_ERROR_NONE;
160 const cpl_parameter *par = NULL;
161 const char* name = NULL;
171 cpl_msg_debug(
"",
"====== START PARAMETERLIST ======");
173 cpl_msg_warning(
"",
"Empty parameterlist!");
175 printf(
"Number of elements in parameter list: %lld\n",
176 cpl_parameterlist_get_size(plist));
177 par = cpl_parameterlist_get_first_const(plist);
178 while (par != NULL) {
179 name = cpl_parameter_get_name(par);
180 switch(cpl_parameter_get_type(par)) {
182 intVal = cpl_parameter_get_bool(par);
183 intDef = cpl_parameter_get_default_bool(par);
184 printf(
"Parameter %s: %d [%d]\n", name, intVal, intDef);
187 intVal = cpl_parameter_get_int(par);
188 intDef = cpl_parameter_get_default_int(par);
189 printf(
"Parameter %s: %d [%d]\n", name, intVal, intDef);
191 case CPL_TYPE_DOUBLE:
192 dblVal = cpl_parameter_get_double(par);
193 dblDef = cpl_parameter_get_default_double(par);
194 printf(
"Parameter %s: %f [%f]\n", name, dblVal, dblDef);
196 case CPL_TYPE_STRING:
197 strVal = cpl_parameter_get_string(par);
198 strDef = cpl_parameter_get_default_string(par);
199 printf(
"Parameter %s: %s [%s]\n", name, strVal, strDef);
205 par = cpl_parameterlist_get_next_const(plist);
208 cpl_msg_debug(
"",
"====== END FRAMESET ======");
214 ret_error = cpl_error_get_code();
236 cpl_error_code ret_error = CPL_ERROR_NONE;
240 cpl_msg_debug(
"",
"====== START PROPERTYLIST ======");
242 cpl_msg_warning(
"",
"Empty frameset!");
245 cpl_propertylist_dump(plist, NULL);
247 cpl_msg_debug(
"",
"====== END PROPERTYLIST ======");
253 ret_error = cpl_error_get_code();
277 const char *tmp = NULL;
279 cpl_error_code ret_error = CPL_ERROR_NONE;
283 cpl_msg_debug(
"",
" ====== START FRAME ======");
285 cpl_msg_warning(
"",
"Empty frame!");
287 tmp = cpl_frame_get_filename(frame);
292 cpl_msg_debug(
"",
" ====== END FRAME ======");
293 return CPL_ERROR_NONE;
296 cpl_msg_debug(
"",
"filename: %s", tmp);
297 cpl_msg_debug(
"",
"tag: %s", cpl_frame_get_tag(frame));
299 i = cpl_frame_get_type(frame);
302 case CPL_FRAME_TYPE_NONE:
303 cpl_msg_debug(
"",
"type: CPL_FRAME_TYPE_NONE (%d)", i);
305 case CPL_FRAME_TYPE_IMAGE:
306 cpl_msg_debug(
"",
"type: CPL_FRAME_TYPE_IMAGE (%d)", i);
308 case CPL_FRAME_TYPE_MATRIX:
309 cpl_msg_debug(
"",
"type: CPL_FRAME_TYPE_MATRIX (%d)", i);
311 case CPL_FRAME_TYPE_TABLE:
312 cpl_msg_debug(
"",
"type: CPL_FRAME_TYPE_TABLE (%d)", i);
314 case CPL_FRAME_TYPE_PAF:
315 cpl_msg_debug(
"",
"type: CPL_FRAME_TYPE_PAF (%d)", i);
317 case CPL_FRAME_TYPE_ANY:
318 cpl_msg_debug(
"",
"type: CPL_FRAME_TYPE_ANY (%d)", i);
321 cpl_msg_debug(
"",
"type: other ERROR (%d)", i);
324 i = cpl_frame_get_group(frame);
327 case CPL_FRAME_GROUP_NONE:
328 cpl_msg_debug(
"",
"group: CPL_FRAME_GROUP_NONE (%d)", i);
330 case CPL_FRAME_GROUP_RAW:
331 cpl_msg_debug(
"",
"group: CPL_FRAME_GROUP_RAW (%d)", i);
333 case CPL_FRAME_GROUP_CALIB:
334 cpl_msg_debug(
"",
"group: CPL_FRAME_GROUP_CALIB (%d)", i);
336 case CPL_FRAME_GROUP_PRODUCT:
337 cpl_msg_debug(
"",
"group: CPL_FRAME_GROUP_PRODUCT (%d)", i);
340 cpl_msg_debug(
"",
"group: other ERROR (%d)", i);
343 i = cpl_frame_get_level(frame);
346 case CPL_FRAME_GROUP_NONE:
347 cpl_msg_debug(
"",
"level: CPL_FRAME_LEVEL_NONE (%d)", i);
349 case CPL_FRAME_GROUP_RAW:
350 cpl_msg_debug(
"",
"level: CPL_FRAME_LEVEL_TEMPORARY (%d)", i);
352 case CPL_FRAME_GROUP_CALIB:
353 cpl_msg_debug(
"",
"level: CPL_FRAME_LEVEL_INTERMEDIATE (%d)", i);
355 case CPL_FRAME_GROUP_PRODUCT:
356 cpl_msg_debug(
"",
"level: CPL_FRAME_LEVEL_FINAL (%d)", i);
359 cpl_msg_debug(
"",
"level: other ERROR (%d)", i);
362 cpl_msg_debug(
"",
" ====== END FRAME ======");
368 ret_error = cpl_error_get_code();
391 cpl_error_code ret_error = CPL_ERROR_NONE;
395 cpl_msg_debug(
"",
"====== START IMAGELIST ======");
396 if (imglist == NULL) {
397 cpl_msg_warning(
"",
"Empty cube!");
399 for (i = 0; i < cpl_imagelist_get_size(imglist); i++) {
404 cpl_msg_debug(
"",
"====== END IMAGELIST ======");
410 ret_error = cpl_error_get_code();
435 cpl_error_code ret_error = CPL_ERROR_NONE;
441 cpl_msg_debug(
"",
" ====== START IMAGE ======");
443 cpl_msg_warning(
"",
"Empty image!");
446 for (y = 1; y <= cpl_image_get_size_y(img); y++) {
447 for (x = 1; x <= cpl_image_get_size_x(img); x++) {
448 sprintf(tmp,
"%f ", cpl_image_get(img, x, y, &gaga));
453 cpl_msg_debug(
"",
"%s", line);
456 cpl_msg_debug(
"",
" ====== END IMAGE ======");
462 ret_error = cpl_error_get_code();
486 cpl_error_code ret_error = CPL_ERROR_NONE;
487 const double *pvec = NULL;
491 cpl_msg_debug(
"",
" ====== START VECTOR ======");
493 cpl_msg_warning(
"",
"Empty vector!");
496 pvec = cpl_vector_get_data_const(vec));
498 size = cpl_vector_get_size(vec);
499 for (x = 0; x < size; x++) {
500 cpl_msg_debug(
"",
"%12.16g ", pvec[x]);
503 cpl_msg_debug(
"",
" ====== END VECTOR ======");
509 ret_error = cpl_error_get_code();
534 const int *pint = NULL;
535 const double *pdouble = NULL;
536 cpl_error_code ret_error = CPL_ERROR_NONE;
542 type = cpl_array_get_type(arr);
543 size = cpl_array_get_size(arr);
547 pint = cpl_array_get_data_int_const(arr);
548 cpl_msg_debug(
"",
" ====== START ARRAY ======");
550 cpl_msg_warning(
"",
"Empty array!");
552 for (x = 0; x < size; x++) {
553 cpl_msg_debug(
"",
"%i", pint[x]);
556 cpl_msg_debug(
"",
" ====== END ARRAY ======");
558 case CPL_TYPE_DOUBLE:
559 pdouble = cpl_array_get_data_double_const(arr);
560 cpl_msg_debug(
"",
" ====== START ARRAY ======");
562 cpl_msg_warning(
"",
"Empty array!");
564 for (x = 0; x < size; x++) {
565 cpl_msg_debug(
"",
"%12.16g", pdouble[x]);
568 cpl_msg_debug(
"",
" ====== END ARRAY ======");
571 cpl_msg_debug(
"",
">>> cpl_type (%d) not supported!", type);
576 cpl_msg_debug(
"",
" ====== START ARRAY ======");
577 cpl_msg_debug(
"",
"Empty array!");
578 cpl_msg_debug(
"",
" ====== END ARRAY ======");
584 ret_error = cpl_error_get_code();
606 cpl_error_code ret_error = CPL_ERROR_NONE;
610 cpl_msg_debug(
"",
" ====== START TABLE ======");
612 cpl_msg_warning(
"",
"Empty table pointer!");
614 cpl_table_dump(table, 0, cpl_table_get_nrow(table), NULL);
616 cpl_msg_debug(
"",
" ====== END TABLE ======");
622 ret_error = cpl_error_get_code();
644 const cpl_vector *vector)
646 cpl_error_code ret_error = CPL_ERROR_NONE;
653 if ((vector != NULL) &&
654 (cpl_msg_get_level() == CPL_MSG_DEBUG))
656 strcpy(pre_final,
"");
658 strcat(pre_final, pre);
660 ostype = getenv(
"OSTYPE");
661 if(strcmp(ostype,
"darwin") == 0) {
662 strcat(pre_final,
"set term x11;");
666 cpl_plot_vector(pre_final, opt, NULL, vector));
672 ret_error = cpl_error_get_code();
695 const cpl_vector *x,
const cpl_vector *y)
697 cpl_error_code ret_error = CPL_ERROR_NONE;
699 cpl_bivector *bi = NULL;
706 if ((x != NULL) && (y != NULL) &&
707 (cpl_msg_get_level() == CPL_MSG_DEBUG))
709 strcpy(pre_final,
"");
711 strcat(pre_final, pre);
713 ostype = getenv(
"OSTYPE");
714 if(strcmp(ostype,
"darwin") == 0) {
715 strcat(pre_final,
"set term x11;");
722#pragma GCC diagnostic push
723#pragma GCC diagnostic ignored "-Wcast-qual"
726 bi = cpl_bivector_wrap_vectors((cpl_vector*)x,
729#pragma GCC diagnostic pop
732 cpl_plot_bivector(pre_final, opt, NULL, bi));
734 cpl_bivector_unwrap_vectors(bi);
740 ret_error = cpl_error_get_code();
765 const cpl_vector *y1,
766 const cpl_vector *y2)
768 cpl_error_code ret_error = CPL_ERROR_NONE;
771 cpl_bivector *plots[nr_plots];
777 if ((x != NULL) && (y1 != NULL) && (y2 != NULL) &&
778 (cpl_msg_get_level() == CPL_MSG_DEBUG))
780 strcpy(pre_final,
"");
782 strcat(pre_final, pre);
784 ostype = getenv(
"OSTYPE");
785 if(strcmp(ostype,
"darwin") == 0) {
786 strcat(pre_final,
"set term x11;");
794#pragma GCC diagnostic push
795#pragma GCC diagnostic ignored "-Wcast-qual"
798 plots[0] = cpl_bivector_wrap_vectors((cpl_vector*)x,
801 plots[1] = cpl_bivector_wrap_vectors((cpl_vector*)x,
805 cpl_plot_bivectors(pre_final,
808 (
const cpl_bivector **) plots,
811#pragma GCC diagnostic pop
815 for (k = 0; k < nr_plots; k++) {
816 cpl_bivector_unwrap_vectors(plots[k]);
824 ret_error = cpl_error_get_code();
846 const cpl_image *img)
848 cpl_error_code ret_error = CPL_ERROR_NONE;
856 (cpl_msg_get_level() == CPL_MSG_DEBUG))
858 strcpy(pre_final,
"");
860 strcat(pre_final, pre);
862 ostype = getenv(
"OSTYPE");
863 if(strcmp(ostype,
"darwin") == 0) {
864 strcat(pre_final,
"set term x11;");
868 cpl_plot_image(pre_final, opt, NULL, img));
874 ret_error = cpl_error_get_code();
#define BRK_WITH_ERROR(code)
Set a new CPL error, and exit the try-block.
#define BRK_IF_ERROR(function)
If function is or returns an error != CPL_ERROR_NONE, then the try-block is exited.
#define RECOVER(void)
Recover the error state which was present during TRY (at the beginning of the try-block).
#define GET_NEW_ERROR(void)
Return new CPL error code.
#define CHECK_ERROR_STATE(void)
Check the CPL error state, and exit the try-block if not CPL_ERROR_NONE.
#define CATCH_MSG()
Displays an error message.
#define TRY
Beginning of a TRY-block.
#define CATCH
End of a TRY-block, beginning of a CATCH-block.
#define BRK_IF_NULL(function)
If function is or returns a NULL pointer, then the try-block is exited.
cpl_error_code eris_ifu_plot_vectors_xy(const char *pre, const char *opt, const cpl_vector *x, const cpl_vector *y)
Plots vector y against vector x.
cpl_error_code eris_ifu_debug_cube(const cpl_imagelist *imglist)
All images contained in imglist are printed for debugging purposes.
cpl_error_code eris_ifu_debug_propertylist(const cpl_propertylist *plist)
All properties contained in plist are printed for debugging purposes.
cpl_error_code eris_ifu_debug_frameset(const cpl_frameset *frameset)
All frames contained in frameset are printed for debugging purposes.
cpl_error_code eris_ifu_debug_array(const cpl_array *arr)
All values contained in arr are printed for debugging purposes.
cpl_error_code eris_ifu_debug_image(const cpl_image *img)
All values contained in img are printed for debugging purposes.
cpl_error_code eris_ifu_plot_vector(const char *pre, const char *opt, const cpl_vector *vector)
Plots a vector only if message level is CPL_MSG_DEBUG.
cpl_error_code eris_ifu_plot_vectors2(const char *pre, const char **opt, const cpl_vector *x, const cpl_vector *y1, const cpl_vector *y2)
Plots 2 vectors against vector x.
cpl_error_code eris_ifu_debug_parameterlist(const cpl_parameterlist *plist)
All parameters contained in plist are printed for debugging purposes.
cpl_error_code eris_ifu_debug_vector(const cpl_vector *vec)
All values contained in vec are printed for debugging purposes.
cpl_error_code eris_ifu_plot_image(const char *pre, const char *opt, const cpl_image *img)
Plots an image only if message level is CPL_MSG_DEBUG.
cpl_error_code eris_ifu_debug_header(const cpl_propertylist *header)
All properties contained in header are printed as pairs of keyword and data for debugging purposes.
cpl_error_code eris_ifu_debug_frame(const cpl_frame *frame)
The CPL_FRAME_TYPE, CPL_FRAME_LEVEL and CPL_FRAME_GROUP of frame are printed for debugging purposes.
cpl_error_code eris_ifu_debug_table(const cpl_table *table)
All values contained in table are printed for debugging purposes.