9#include "eris_ifu_debug.h"
10#include "eris_ifu_error.h"
49 const cpl_property *p = NULL;
51 cpl_error_code ret_error = CPL_ERROR_NONE;
55 cpl_msg_debug(
"",
"===== START HEADER =====");
57 cpl_msg_warning(
"",
"Empty header!");
59 for (i = 0; i < cpl_propertylist_get_size(header); i++) {
61 p = cpl_propertylist_get_const(header, i));
63 t = cpl_property_get_type (p);
67 cpl_msg_debug(
"",
"%s: %d", cpl_property_get_name(p),
68 cpl_property_get_bool(p));
71 cpl_msg_debug(
"",
"%s: %d", cpl_property_get_name(p),
72 cpl_property_get_int(p));
75 cpl_msg_debug(
"",
"%s: %12.16g", cpl_property_get_name(p),
76 cpl_property_get_double(p));
79 cpl_msg_debug(
"",
"%s: %12.16f", cpl_property_get_name(p),
80 cpl_property_get_float(p));
83 cpl_msg_debug(
"",
"%s: %s", cpl_property_get_name(p),
84 cpl_property_get_string(p));
91 cpl_msg_debug(
"",
"====== END HEADER ======");
97 ret_error = cpl_error_get_code();
120 const cpl_frame *frame = NULL;
121 cpl_error_code ret_error = CPL_ERROR_NONE;
125 cpl_msg_debug(
"",
"====== START FRAMESET ======");
126 if (frameset == NULL) {
127 cpl_msg_warning(
"",
"Empty frameset!");
129 frame = cpl_frameset_find_const(frameset, NULL);
134 cpl_msg_debug(
"",
"====== END FRAMESET ======");
136 return CPL_ERROR_NONE;
139 while (frame != NULL) {
142 frame = cpl_frameset_find_const(frameset, NULL));
145 cpl_msg_debug(
"",
"====== END FRAMESET ======");
151 ret_error = cpl_error_get_code();
176 cpl_error_code ret_error = CPL_ERROR_NONE;
177 const cpl_parameter *par = NULL;
178 const char* name = NULL;
188 cpl_msg_debug(
"",
"====== START PARAMETERLIST ======");
190 cpl_msg_warning(
"",
"Empty parameterlist!");
192 printf(
"Number of elements in parameter list: %lld\n",
193 cpl_parameterlist_get_size(plist));
194 par = cpl_parameterlist_get_first_const(plist);
195 while (par != NULL) {
196 name = cpl_parameter_get_name(par);
197 switch(cpl_parameter_get_type(par)) {
199 intVal = cpl_parameter_get_bool(par);
200 intDef = cpl_parameter_get_default_bool(par);
201 printf(
"Parameter %s: %d [%d]\n", name, intVal, intDef);
204 intVal = cpl_parameter_get_int(par);
205 intDef = cpl_parameter_get_default_int(par);
206 printf(
"Parameter %s: %d [%d]\n", name, intVal, intDef);
208 case CPL_TYPE_DOUBLE:
209 dblVal = cpl_parameter_get_double(par);
210 dblDef = cpl_parameter_get_default_double(par);
211 printf(
"Parameter %s: %f [%f]\n", name, dblVal, dblDef);
213 case CPL_TYPE_STRING:
214 strVal = cpl_parameter_get_string(par);
215 strDef = cpl_parameter_get_default_string(par);
216 printf(
"Parameter %s: %s [%s]\n", name, strVal, strDef);
222 par = cpl_parameterlist_get_next_const(plist);
225 cpl_msg_debug(
"",
"====== END PARAMETERLIST ======");
231 ret_error = cpl_error_get_code();
252 cpl_error_code ret_error = CPL_ERROR_NONE;
256 cpl_msg_debug(
"",
"====== START PROPERTYLIST ======");
258 cpl_msg_warning(
"",
"Empty propertylist!");
261 cpl_propertylist_dump(plist, NULL);
263 cpl_msg_debug(
"",
"====== END PROPERTYLIST ======");
269 ret_error = cpl_error_get_code();
291 const char *tmp = NULL;
293 cpl_error_code ret_error = CPL_ERROR_NONE;
297 cpl_msg_debug(
"",
" ====== START FRAME ======");
299 cpl_msg_warning(
"",
"Empty frame!");
301 tmp = cpl_frame_get_filename(frame);
306 cpl_msg_debug(
"",
" ====== END FRAME ======");
307 return CPL_ERROR_NONE;
310 cpl_msg_debug(
"",
"filename: %s", tmp);
311 cpl_msg_debug(
"",
"tag: %s", cpl_frame_get_tag(frame));
313 i = cpl_frame_get_type(frame);
316 case CPL_FRAME_TYPE_NONE:
317 cpl_msg_debug(
"",
"type: CPL_FRAME_TYPE_NONE (%d)", i);
319 case CPL_FRAME_TYPE_IMAGE:
320 cpl_msg_debug(
"",
"type: CPL_FRAME_TYPE_IMAGE (%d)", i);
322 case CPL_FRAME_TYPE_MATRIX:
323 cpl_msg_debug(
"",
"type: CPL_FRAME_TYPE_MATRIX (%d)", i);
325 case CPL_FRAME_TYPE_TABLE:
326 cpl_msg_debug(
"",
"type: CPL_FRAME_TYPE_TABLE (%d)", i);
328 case CPL_FRAME_TYPE_PAF:
329 cpl_msg_debug(
"",
"type: CPL_FRAME_TYPE_PAF (%d)", i);
331 case CPL_FRAME_TYPE_ANY:
332 cpl_msg_debug(
"",
"type: CPL_FRAME_TYPE_ANY (%d)", i);
335 cpl_msg_debug(
"",
"type: other ERROR (%d)", i);
338 i = cpl_frame_get_group(frame);
341 case CPL_FRAME_GROUP_NONE:
342 cpl_msg_debug(
"",
"group: CPL_FRAME_GROUP_NONE (%d)", i);
344 case CPL_FRAME_GROUP_RAW:
345 cpl_msg_debug(
"",
"group: CPL_FRAME_GROUP_RAW (%d)", i);
347 case CPL_FRAME_GROUP_CALIB:
348 cpl_msg_debug(
"",
"group: CPL_FRAME_GROUP_CALIB (%d)", i);
350 case CPL_FRAME_GROUP_PRODUCT:
351 cpl_msg_debug(
"",
"group: CPL_FRAME_GROUP_PRODUCT (%d)", i);
354 cpl_msg_debug(
"",
"group: other ERROR (%d)", i);
357 i = cpl_frame_get_level(frame);
360 case CPL_FRAME_GROUP_NONE:
361 cpl_msg_debug(
"",
"level: CPL_FRAME_LEVEL_NONE (%d)", i);
363 case CPL_FRAME_GROUP_RAW:
364 cpl_msg_debug(
"",
"level: CPL_FRAME_LEVEL_TEMPORARY (%d)", i);
366 case CPL_FRAME_GROUP_CALIB:
367 cpl_msg_debug(
"",
"level: CPL_FRAME_LEVEL_INTERMEDIATE (%d)", i);
369 case CPL_FRAME_GROUP_PRODUCT:
370 cpl_msg_debug(
"",
"level: CPL_FRAME_LEVEL_FINAL (%d)", i);
373 cpl_msg_debug(
"",
"level: other ERROR (%d)", i);
376 cpl_msg_debug(
"",
" ====== END FRAME ======");
382 ret_error = cpl_error_get_code();
407 cpl_error_code ret_error = CPL_ERROR_NONE;
411 cpl_msg_debug(
"",
"====== START IMAGELIST ======");
412 if (imglist == NULL) {
413 cpl_msg_warning(
"",
"Empty cube!");
415 for (i = 0; i < cpl_imagelist_get_size(imglist); i++) {
420 cpl_msg_debug(
"",
"====== END IMAGELIST ======");
426 ret_error = cpl_error_get_code();
454 cpl_error_code ret_error = CPL_ERROR_NONE;
460 cpl_msg_debug(
"",
" ====== START IMAGE ======");
462 cpl_msg_warning(
"",
"Empty image!");
465 for (y = 1; y <= cpl_image_get_size_y(img); y++) {
466 for (x = 1; x <= cpl_image_get_size_x(img); x++) {
467 sprintf(tmp,
"%f ", cpl_image_get(img, x, y, &gaga));
472 cpl_msg_debug(
"",
"%s", line);
475 cpl_msg_debug(
"",
" ====== END IMAGE ======");
481 ret_error = cpl_error_get_code();
504 cpl_error_code ret_error = CPL_ERROR_NONE;
505 const double *pvec = NULL;
509 cpl_msg_debug(
"",
" ====== START VECTOR ======");
511 cpl_msg_warning(
"",
"Empty vector!");
514 pvec = cpl_vector_get_data_const(vec));
516 size = cpl_vector_get_size(vec);
517 for (x = 0; x < size; x++) {
518 cpl_msg_debug(
"",
"%12.16g ", pvec[x]);
521 cpl_msg_debug(
"",
" ====== END VECTOR ======");
527 ret_error = cpl_error_get_code();
553 const int *pint = NULL;
554 const double *pdouble = NULL;
555 cpl_error_code ret_error = CPL_ERROR_NONE;
561 type = cpl_array_get_type(arr);
562 size = cpl_array_get_size(arr);
566 pint = cpl_array_get_data_int_const(arr);
567 cpl_msg_debug(
"",
" ====== START ARRAY ======");
569 cpl_msg_warning(
"",
"Empty array!");
571 for (x = 0; x < size; x++) {
572 cpl_msg_debug(
"",
"%i", pint[x]);
575 cpl_msg_debug(
"",
" ====== END ARRAY ======");
577 case CPL_TYPE_DOUBLE:
578 pdouble = cpl_array_get_data_double_const(arr);
579 cpl_msg_debug(
"",
" ====== START ARRAY ======");
581 cpl_msg_warning(
"",
"Empty array!");
583 for (x = 0; x < size; x++) {
584 cpl_msg_debug(
"",
"%12.16g", pdouble[x]);
587 cpl_msg_debug(
"",
" ====== END ARRAY ======");
590 cpl_msg_debug(
"",
">>> cpl_type (%d) not supported!", type);
595 cpl_msg_debug(
"",
" ====== START ARRAY ======");
596 cpl_msg_debug(
"",
"Empty array!");
597 cpl_msg_debug(
"",
" ====== END ARRAY ======");
603 ret_error = cpl_error_get_code();
624 cpl_error_code ret_error = CPL_ERROR_NONE;
628 cpl_msg_debug(
"",
" ====== START TABLE ======");
630 cpl_msg_warning(
"",
"Empty table pointer!");
632 cpl_table_dump(table, 0, cpl_table_get_nrow(table), NULL);
634 cpl_msg_debug(
"",
" ====== END TABLE ======");
640 ret_error = cpl_error_get_code();
666 const cpl_vector *vector)
668 cpl_error_code ret_error = CPL_ERROR_NONE;
675 if ((vector != NULL) &&
676 (cpl_msg_get_level() == CPL_MSG_DEBUG))
678 strcpy(pre_final,
"");
680 strcat(pre_final, pre);
682 ostype = getenv(
"OSTYPE");
683 if(strcmp(ostype,
"darwin") == 0) {
684 strcat(pre_final,
"set term x11;");
688 cpl_plot_vector(pre_final, opt, NULL, vector));
694 ret_error = cpl_error_get_code();
721 const cpl_vector *x,
const cpl_vector *y)
723 cpl_error_code ret_error = CPL_ERROR_NONE;
725 cpl_bivector *bi = NULL;
732 if ((x != NULL) && (y != NULL) &&
733 (cpl_msg_get_level() == CPL_MSG_DEBUG))
735 strcpy(pre_final,
"");
737 strcat(pre_final, pre);
739 ostype = getenv(
"OSTYPE");
740 if(strcmp(ostype,
"darwin") == 0) {
741 strcat(pre_final,
"set term x11;");
748#pragma GCC diagnostic push
749#pragma GCC diagnostic ignored "-Wcast-qual"
752 bi = cpl_bivector_wrap_vectors((cpl_vector*)x,
755#pragma GCC diagnostic pop
758 cpl_plot_bivector(pre_final, opt, NULL, bi));
760 cpl_bivector_unwrap_vectors(bi);
766 ret_error = cpl_error_get_code();
795 const cpl_vector *y1,
796 const cpl_vector *y2)
798 cpl_error_code ret_error = CPL_ERROR_NONE;
801 cpl_bivector *plots[nr_plots];
807 if ((x != NULL) && (y1 != NULL) && (y2 != NULL) &&
808 (cpl_msg_get_level() == CPL_MSG_DEBUG))
810 strcpy(pre_final,
"");
812 strcat(pre_final, pre);
814 ostype = getenv(
"OSTYPE");
815 if(strcmp(ostype,
"darwin") == 0) {
816 strcat(pre_final,
"set term x11;");
824#pragma GCC diagnostic push
825#pragma GCC diagnostic ignored "-Wcast-qual"
828 plots[0] = cpl_bivector_wrap_vectors((cpl_vector*)x,
831 plots[1] = cpl_bivector_wrap_vectors((cpl_vector*)x,
835 cpl_plot_bivectors(pre_final,
838 (
const cpl_bivector **) plots,
841#pragma GCC diagnostic pop
845 for (k = 0; k < nr_plots; k++) {
846 cpl_bivector_unwrap_vectors(plots[k]);
854 ret_error = cpl_error_get_code();
879 const cpl_image *img)
881 cpl_error_code ret_error = CPL_ERROR_NONE;
889 (cpl_msg_get_level() == CPL_MSG_DEBUG))
891 strcpy(pre_final,
"");
893 strcat(pre_final, pre);
895 ostype = getenv(
"OSTYPE");
896 if(strcmp(ostype,
"darwin") == 0) {
897 strcat(pre_final,
"set term x11;");
901 cpl_plot_image(pre_final, opt, NULL, img));
907 ret_error = cpl_error_get_code();
cpl_error_code eris_ifu_plot_vectors_xy(const char *pre, const char *opt, const cpl_vector *x, const cpl_vector *y)
Plot vector y against vector x for debugging.
cpl_error_code eris_ifu_debug_cube(const cpl_imagelist *imglist)
Print all images in an imagelist for debugging.
cpl_error_code eris_ifu_debug_propertylist(const cpl_propertylist *plist)
Print all properties in a propertylist for debugging.
cpl_error_code eris_ifu_debug_frameset(const cpl_frameset *frameset)
Print all frames in a frameset for debugging.
cpl_error_code eris_ifu_debug_array(const cpl_array *arr)
Print all values in an array for debugging.
cpl_error_code eris_ifu_debug_image(const cpl_image *img)
Print all pixel values in an image for debugging.
cpl_error_code eris_ifu_plot_vector(const char *pre, const char *opt, const cpl_vector *vector)
Plot a vector for debugging.
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)
Plot two y-vectors against an x-vector for debugging.
cpl_error_code eris_ifu_debug_parameterlist(const cpl_parameterlist *plist)
Print all parameters in a parameterlist for debugging.
cpl_error_code eris_ifu_debug_vector(const cpl_vector *vec)
Print all values in a vector for debugging.
cpl_error_code eris_ifu_plot_image(const char *pre, const char *opt, const cpl_image *img)
Plot an image for debugging.
cpl_error_code eris_ifu_debug_header(const cpl_propertylist *header)
Print all properties in a propertylist for debugging.
cpl_error_code eris_ifu_debug_frame(const cpl_frame *frame)
Print frame information for debugging.
cpl_error_code eris_ifu_debug_table(const cpl_table *table)
Print all values in a table for debugging.
#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.