fors_utils.h

00001 /* $Id: fors_utils.h,v 1.29 2010/09/14 07:49:30 cizzo Exp $
00002  *
00003  * This file is part of the FORS Library
00004  * Copyright (C) 2002-2010 European Southern Observatory
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00019  */
00020 
00021 /*
00022  * $Author: cizzo $
00023  * $Date: 2010/09/14 07:49:30 $
00024  * $Revision: 1.29 $
00025  * $Name: fors-4_8_6 $
00026  */
00027 
00028 #ifndef FORS_UTILS_H
00029 #define FORS_UTILS_H
00030 
00031 #include <fors_setting.h>
00032 #include <fors_star.h>
00033 
00034 #include <cpl.h>
00035 
00042 #define assure(condition, action, ...)                      \
00043 do if (!(condition)) {                                      \
00044     cpl_error_set_message(cpl_func,                         \
00045               cpl_error_get_code() ?            \
00046               cpl_error_get_code() :            \
00047                           CPL_ERROR_UNSPECIFIED,            \
00048                           __VA_ARGS__);                     \
00049     cleanup;                                                \
00050     action;                                                 \
00051 } while(0)
00052 //    fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\n");
00053 
00067 #define cassure(condition, errc, action, ...)               \
00068 do if (!(condition)) {                                      \
00069     cpl_error_set_message(                  cpl_func,       \
00070                                             errc,           \
00071                                             __VA_ARGS__);   \
00072     cleanup;                                                \
00073     action;                                                 \
00074 } while(0)
00075 //    fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\n");
00076 
00089 #define cassure_automsg(condition, errc, action)            \
00090 do if (!(condition)) {                                      \
00091     cpl_error_set_message(                  cpl_func,       \
00092                                             errc,           \
00093                                             "!("#condition")");\
00094     cleanup;                                                \
00095     action;                                                 \
00096 } while(0)
00097 //    fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\n");
00098 
00108 #define passure(condition, action)                                     \
00109     assure(condition, action,                                          \
00110        "Internal error. Please report to %s", PACKAGE_BUGREPORT)
00111 
00121 #define ppassure(condition, errc, action)                              \
00122     cassure(condition, errc, action,                                   \
00123        "Internal error (!(%s)). Please report to %s", \
00124        #condition, \
00125        PACKAGE_BUGREPORT)
00126 
00127 #define fors_msg(level, ...) fors_msg_macro(level, cpl_func, __VA_ARGS__)
00128 
00129 #ifndef M_PI 
00130 #define M_PI 3.1415926535897932384626433832795
00131 #endif
00132 
00133 #ifndef M_E
00134 #define M_E  2.7182818284590452354
00135 #endif
00136 
00137 #define TWOSQRT2LN2 2.35482004503095
00138 
00139 extern const char *const fors_license;
00140 extern const double STDEV_PR_MAD;
00141 
00142 int fors_get_version_binary(void);
00143 double fors_rand_gauss(void);
00144 
00145 double fors_tools_get_kth_double(double *a, int n, int k);
00146 float fors_tools_get_kth_float(float *a, int n, int k);
00147 float fors_tools_get_median_float( float *a, int n);
00148 float fors_tools_get_median_fast_float(float *a, int n)  ;
00149 double fors_utils_median_corr(int n);
00150 
00151 void fors_frameset_print(const cpl_frameset *frames);
00152 void fors_frame_print(const cpl_frame *f);
00153 const char *fors_frame_get_type_string(const cpl_frame *f);
00154 const char *fors_frame_get_group_string(const cpl_frame *f);
00155 const char *fors_frame_get_level_string(const cpl_frame *f);
00156 cpl_frameset *fors_frameset_extract(const cpl_frameset *frames,
00157                     const char *tag);
00158 const char *fors_type_get_string(cpl_type type);
00159 void fors_parameterlist_set_defaults(cpl_parameterlist *parlist);
00160 
00161 #ifdef CPL_IS_NOT_CRAP
00162 #else
00163 cpl_image *fors_imagelist_collapse_create(const cpl_imagelist *ilist);
00164 cpl_image *fors_imagelist_collapse_median_create(const cpl_imagelist *ilist);
00165 #endif
00166 
00167 double fors_angle_diff(const double *a1, const double *a2);
00168 
00169 void fors_msg_macro(cpl_msg_severity level, const char *fct, const char *format, ...)
00170 #ifdef __GNUC__
00171 __attribute__((format (printf, 3, 4)))
00172 #endif
00173 ;
00174 #endif

Generated on Fri Mar 4 09:46:01 2011 for FORS Pipeline Reference Manual by  doxygen 1.4.7