#include <stdarg.h>
#include <cpl.h>
Go to the source code of this file.
Defines | |
#define | IRPLIB_XSTRINGIFY(TOSTRING) #TOSTRING |
#define | IRPLIB_STRINGIFY(TOSTRING) IRPLIB_XSTRINGIFY(TOSTRING) |
#define | irplib_trace() |
#define | irplib_error_recover(ESTATE,...) |
#define | IRPLIB_UTIL_SET_ROW(table_set_row) |
#define | IRPLIB_UTIL_CHECK(table_check) |
#define | skip_if(CONDITION) |
#define | skip_if_lt(A, B, MSG) |
#define | bug_if(CONDITION) |
#define | error_if(CONDITION, ERROR,...) |
#define | any_if(...) |
#define | end_skip |
#define | irplib_ensure(CONDITION, ec,...) cpl_error_ensure(CONDITION, ec, goto cleanup, __VA_ARGS__) |
Conditional skip to the (unqiue) return point of the function. | |
#define | irplib_check(COMMAND,...) |
Catch an error. | |
Functions | |
cpl_error_code | irplib_dfs_save_image (cpl_frameset *, const cpl_parameterlist *, const cpl_frameset *, const cpl_image *, cpl_type_bpp, const char *, const char *, const cpl_propertylist *, const char *, const char *, const char *) |
Save an image as a DFS-compliant pipeline product. | |
cpl_error_code | irplib_dfs_save_propertylist (cpl_frameset *, const cpl_parameterlist *, const cpl_frameset *, const char *, const char *, const cpl_propertylist *, const char *, const char *, const char *) |
Save a propertylist as a DFS-compliant pipeline product. | |
cpl_error_code | irplib_dfs_save_imagelist (cpl_frameset *, const cpl_parameterlist *, const cpl_frameset *, const cpl_imagelist *, cpl_type_bpp, const char *, const char *, const cpl_propertylist *, const char *, const char *, const char *) |
Save an imagelist as a DFS-compliant pipeline product. | |
cpl_error_code | irplib_dfs_save_table (cpl_frameset *, const cpl_parameterlist *, const cpl_frameset *, const cpl_table *, const cpl_propertylist *, const char *, const char *, const cpl_propertylist *, const char *, const char *, const char *) |
Save a table as a DFS-compliant pipeline product. | |
void | irplib_reset (void) |
Reset IRPLIB state. | |
int | irplib_compare_tags (cpl_frame *, cpl_frame *) |
Comparison function to identify different input frames. | |
const char * | irplib_frameset_find_file (const cpl_frameset *, const char *) |
Find the filename with the given tag in a frame set. | |
const cpl_frame * | irplib_frameset_get_first_from_group (const cpl_frameset *, cpl_frame_group) |
Find the first frame belonging to the given group. | |
cpl_error_code | irplib_apertures_find_max_flux (const cpl_apertures *, int *, int) |
Find the aperture(s) with the greatest flux. | |
int | irplib_isinf (double value) |
portable isinf | |
int | irplib_isnan (double value) |
portable isnan | |
void | irplib_errorstate_warning (unsigned, unsigned, unsigned) |
Dump a single CPL error. | |
cpl_error_code | irplib_dfs_table_convert (cpl_table *, cpl_frameset *, const cpl_frameset *, int, char, const char *, const char *, const cpl_parameterlist *, const char *, const cpl_propertylist *, const cpl_propertylist *, const char *, const char *, const char *, cpl_boolean(*)(cpl_table *, const char *, int, const cpl_frame *, const cpl_parameterlist *), cpl_error_code(*)(cpl_table *, const cpl_frameset *, const cpl_parameterlist *)) |
Create a DFS product with one table from one or more (ASCII) file(s). | |
cpl_error_code | irplib_table_read_from_frameset (cpl_table *, const cpl_frameset *, int, char, const cpl_parameterlist *, cpl_boolean(*)(cpl_table *, const char *, int, const cpl_frame *, const cpl_parameterlist *)) |
Set the rows of a table with data from one or more (ASCII) files. | |
cpl_error_code | irplib_image_split (const cpl_image *, cpl_image *, cpl_image *, cpl_image *, double, cpl_boolean, double, cpl_boolean, double, double, cpl_boolean, cpl_boolean, cpl_boolean) |
Split the values in an image in three according to two thresholds. | |
void | irplib_errorstate_dump_warning (unsigned, unsigned, unsigned) |
Dump a single CPL error at the CPL warning level. | |
void | irplib_errorstate_dump_info (unsigned, unsigned, unsigned) |
Dump a single CPL error at the CPL info level. | |
void | irplib_errorstate_dump_debug (unsigned, unsigned, unsigned) |
Dump a single CPL error at the CPL debug level. | |
cpl_polynomial * | irplib_polynomial_fit_1d_create (const cpl_vector *x_pos, const cpl_vector *values, int degree, double *mse) |
cpl_polynomial * | irplib_polynomial_fit_1d_create_chiq (const cpl_vector *x_pos, const cpl_vector *values, int degree, double *rechiq) |
cpl_error_code | irplib_frameset_sort (const cpl_frameset *self, int *index, double *exptime) |
#define any_if | ( | ... | ) |
cpl_error_ensure(!cpl_error_get_code(), cpl_error_get_code(), \
goto cleanup, __VA_ARGS__)
Definition at line 215 of file xsh_irplib_utils.h.
#define bug_if | ( | CONDITION | ) |
do { \ cpl_error_ensure(!cpl_error_get_code(), cpl_error_get_code(), \ goto cleanup, "Propagating an unexpected error, " \ "please report to " PACKAGE_BUGREPORT); \ cpl_error_ensure(!(CONDITION), CPL_ERROR_UNSPECIFIED, \ goto cleanup, "Internal error, please report to " \ PACKAGE_BUGREPORT); \ } while (0)
Definition at line 182 of file xsh_irplib_utils.h.
#define end_skip |
do { \ cleanup: \ if (cpl_error_get_code()) \ cpl_msg_debug(cpl_func, "Cleanup in " __FILE__ " line %u with " \ "error '%s' at %s", __LINE__, \ cpl_error_get_message(), cpl_error_get_where()); \ else \ cpl_msg_debug(cpl_func, "Cleanup in " __FILE__ " line %u", \ __LINE__); \ } while (0)
Definition at line 226 of file xsh_irplib_utils.h.
Referenced by xsh_detmon_gain(), xsh_detmon_gain_table_create(), xsh_detmon_gain_table_fill_row(), xsh_detmon_lg(), xsh_detmon_lg_core(), xsh_detmon_lg_lamp_stab(), xsh_detmon_lg_lineff(), xsh_detmon_lg_qc_med(), xsh_detmon_lg_qc_ptc(), xsh_detmon_lg_reduce(), xsh_detmon_lg_reduce_all(), xsh_detmon_lg_reduce_dit(), xsh_detmon_lg_reduce_init(), xsh_detmon_lg_reduce_set(), xsh_detmon_lg_rescale(), xsh_detmon_lg_save(), xsh_detmon_lg_split_onoff(), xsh_detmon_lin(), xsh_detmon_lin_table_create(), xsh_detmon_opt_contamination(), xsh_detmon_ronbias(), xsh_detmon_ronbias_histo(), xsh_detmon_ronbias_master(), xsh_detmon_ronbias_random(), xsh_detmon_ronbias_save(), and xsh_ksigma_clip_old().
#define error_if | ( | CONDITION, | |||
ERROR, | |||||
... | ) |
cpl_error_ensure(cpl_error_get_code() == CPL_ERROR_NONE && \ !(CONDITION), ERROR, goto cleanup, __VA_ARGS__)
Definition at line 204 of file xsh_irplib_utils.h.
#define irplib_check | ( | COMMAND, | |||
... | ) |
do { \ cpl_errorstate irplib_check_prestate = cpl_errorstate_get(); \ skip_if(0); \ COMMAND; \ irplib_trace(); \ irplib_ensure(cpl_errorstate_is_equal(irplib_check_prestate), \ cpl_error_get_code(), __VA_ARGS__); \ irplib_trace(); \ } while (0)
Catch an error.
COMMAND | Command to execute and check. This command is expected to set the cpl_error_code in case of failure | |
msg | A printf-style error message. |
This macro is used to catch an error from a function that sets the cpl_error_code
in case of error.
Example:
irplib_check( cpl_object_do_something(object), ("Could not do something"));
If the cpl_error_code
is set before or after calling the function, execution jumps to the cleanup label.
The macro can also be used to check a sequence of commands:
irplib_check( x = cpl_table_get_int(table, "x", 0, NULL); y = cpl_table_get_int(table, "y", 0, NULL); z = cpl_table_get_int(table, "z", 0, NULL), / * Comma here! * / ("Error reading wavelength catalogue"));
Definition at line 287 of file xsh_irplib_utils.h.
Referenced by xsh_detmon_ronbias_master().
#define irplib_ensure | ( | CONDITION, | |||
ec, | |||||
... | ) | cpl_error_ensure(CONDITION, ec, goto cleanup, __VA_ARGS__) |
Conditional skip to the (unqiue) return point of the function.
CONDITION | An error is set if this test condition evaluates to false | |
ec | The CPL error code | |
msg | A printf-style error message. As a matter of user-friendliness the message should mention any value that caused the CONDITION to fail. |
Definition at line 252 of file xsh_irplib_utils.h.
Referenced by xsh_detmon_lg(), xsh_detmon_lg_reduce_all(), and xsh_detmon_lin().
#define irplib_error_recover | ( | ESTATE, | |||
... | ) |
do if (!cpl_errorstate_is_equal(ESTATE)) { \ cpl_msg_warning(cpl_func, __VA_ARGS__); \ cpl_msg_indent_more(); \ cpl_errorstate_dump(ESTATE, CPL_FALSE, irplib_errorstate_warning); \ cpl_msg_indent_less(); \ cpl_errorstate_set(ESTATE); \ } while (0)
Definition at line 55 of file xsh_irplib_utils.h.
#define IRPLIB_STRINGIFY | ( | TOSTRING | ) | IRPLIB_XSTRINGIFY(TOSTRING) |
Definition at line 44 of file xsh_irplib_utils.h.
#define irplib_trace | ( | ) |
do if (cpl_error_get_code()) { \ cpl_msg_debug(cpl_func, __FILE__ " at line %d: ERROR '%s' at %s", \ __LINE__, cpl_error_get_message(), cpl_error_get_where()); \ } else { \ cpl_msg_debug(cpl_func, __FILE__ " at line %d: OK", __LINE__); \ } while (0)
Definition at line 48 of file xsh_irplib_utils.h.
#define IRPLIB_UTIL_CHECK | ( | table_check | ) |
cpl_error_code table_check(cpl_table *, \ const cpl_frameset *, \ const cpl_parameterlist *)
Definition at line 90 of file xsh_irplib_utils.h.
#define IRPLIB_UTIL_SET_ROW | ( | table_set_row | ) |
cpl_boolean table_set_row(cpl_table *, \ const char *, \ int, \ const cpl_frame *, \ const cpl_parameterlist *)
Definition at line 74 of file xsh_irplib_utils.h.
#define IRPLIB_XSTRINGIFY | ( | TOSTRING | ) | #TOSTRING |
Definition at line 43 of file xsh_irplib_utils.h.
#define skip_if | ( | CONDITION | ) |
do { \ cpl_error_ensure(!cpl_error_get_code(), cpl_error_get_code(), \ goto cleanup, "Propagating a pre-existing error"); \ cpl_error_ensure(!(CONDITION), cpl_error_get_code(), \ goto cleanup, "Propagating error");\ } while (0)
Definition at line 144 of file xsh_irplib_utils.h.
Referenced by xsh_detmon_fpn_compute(), xsh_detmon_gain(), xsh_detmon_gain_table_create(), xsh_detmon_gain_table_fill_row(), xsh_detmon_lg(), xsh_detmon_lg_core(), xsh_detmon_lg_lamp_stab(), xsh_detmon_lg_lineff(), xsh_detmon_lg_qc_med(), xsh_detmon_lg_qc_ptc(), xsh_detmon_lg_reduce(), xsh_detmon_lg_reduce_all(), xsh_detmon_lg_reduce_dit(), xsh_detmon_lg_reduce_init(), xsh_detmon_lg_reduce_set(), xsh_detmon_lg_rescale(), xsh_detmon_lg_save(), xsh_detmon_lg_split_onoff(), xsh_detmon_lin(), xsh_detmon_lin_table_create(), xsh_detmon_opt_contamination(), xsh_detmon_ronbias(), xsh_detmon_ronbias_histo(), xsh_detmon_ronbias_master(), xsh_detmon_ronbias_random(), xsh_detmon_ronbias_save(), and xsh_ksigma_clip_old().
#define skip_if_lt | ( | A, | |||
B, | |||||
MSG | ) |
do { \ const double tmpa = (double)(A); \ const double tmpb = (double)(B); \ \ cpl_error_ensure(!cpl_error_get_code(), cpl_error_get_code(), \ goto cleanup, "Propagating a pre-existing error"); \ cpl_error_ensure(tmpa >= tmpb, CPL_ERROR_DATA_NOT_FOUND, \ goto cleanup, "Need at least %g (not %g) %s", \ tmpb, tmpa, MSG); \ } while (0)
Definition at line 162 of file xsh_irplib_utils.h.
cpl_error_code irplib_frameset_sort | ( | const cpl_frameset * | self, | |
int * | index, | |||
double * | exptime | |||
) |
Definition at line 1356 of file xsh_irplib_utils.c.
References frame_get_exptime(), and quicksort().
Referenced by xsh_detmon_lg_reduce_set().
cpl_polynomial* irplib_polynomial_fit_1d_create | ( | const cpl_vector * | x_pos, | |
const cpl_vector * | values, | |||
int | degree, | |||
double * | mse | |||
) |
Definition at line 1278 of file xsh_irplib_utils.c.
References irplib_polynomial_fit_1d_create_common().
Referenced by xsh_detmon_lg_qc_ptc(), and xsh_detmon_lg_reduce_all().
cpl_polynomial* irplib_polynomial_fit_1d_create_chiq | ( | const cpl_vector * | x_pos, | |
const cpl_vector * | values, | |||
int | degree, | |||
double * | rechiq | |||
) |
Definition at line 1269 of file xsh_irplib_utils.c.
References irplib_polynomial_fit_1d_create_common().
Referenced by xsh_detmon_lg_qc_ptc(), and xsh_detmon_lin().