FORS Pipeline Reference Manual  4.12.5
fors_utils.h
1 /* $Id: fors_utils.h,v 1.31 2013-07-24 09:56:58 cgarcia Exp $
2  *
3  * This file is part of the FORS Library
4  * Copyright (C) 2002-2010 European Southern Observatory
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 /*
22  * $Author: cgarcia $
23  * $Date: 2013-07-24 09:56:58 $
24  * $Revision: 1.31 $
25  * $Name: not supported by cvs2svn $
26  */
27 
28 #ifndef FORS_UTILS_H
29 #define FORS_UTILS_H
30 
31 #include <fors_setting.h>
32 #include <fors_star.h>
33 
34 #include <cpl.h>
35 
42 #define assure(condition, action, ...) \
43 do if (!(condition)) { \
44  cpl_error_set_message(cpl_func, \
45  cpl_error_get_code() ? \
46  cpl_error_get_code() : \
47  CPL_ERROR_UNSPECIFIED, \
48  __VA_ARGS__); \
49  cleanup; \
50  action; \
51 } while(0)
52 // fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\n");
53 
67 #define cassure(condition, errc, action, ...) \
68 do if (!(condition)) { \
69  cpl_error_set_message( cpl_func, \
70  errc, \
71  __VA_ARGS__); \
72  cleanup; \
73  action; \
74 } while(0)
75 // fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\n");
76 
89 #define cassure_automsg(condition, errc, action) \
90 do if (!(condition)) { \
91  cpl_error_set_message( cpl_func, \
92  errc, \
93  "!("#condition")");\
94  cleanup; \
95  action; \
96 } while(0)
97 // fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\n");
98 
108 #define passure(condition, action) \
109  assure(condition, action, \
110  "Internal error. Please report to %s", PACKAGE_BUGREPORT)
111 
121 #define ppassure(condition, errc, action) \
122  cassure(condition, errc, action, \
123  "Internal error (!(%s)). Please report to %s", \
124  #condition, \
125  PACKAGE_BUGREPORT)
126 
127 #define fors_msg(level, ...) fors_msg_macro(level, cpl_func, __VA_ARGS__)
128 
129 #ifndef M_PI
130 #define M_PI 3.1415926535897932384626433832795
131 #endif
132 
133 #ifndef M_E
134 #define M_E 2.7182818284590452354
135 #endif
136 
137 #define TWOSQRT2LN2 2.35482004503095
138 
139 CPL_BEGIN_DECLS
140 
141 extern const double STDEV_PR_MAD;
142 
143 void fors_print_banner(void);
144 const char * fors_get_license(void);
145 int fors_get_version_binary(void);
146 double fors_rand_gauss(void);
147 
148 double fors_tools_get_kth_double(double *a, int n, int k);
149 float fors_tools_get_kth_float(float *a, int n, int k);
150 float fors_tools_get_median_float( float *a, int n);
151 float fors_tools_get_median_fast_float(float *a, int n) ;
152 double fors_utils_median_corr(int n);
153 
154 void fors_frameset_print(const cpl_frameset *frames);
155 void fors_frame_print(const cpl_frame *f);
156 const char *fors_frame_get_type_string(const cpl_frame *f);
157 const char *fors_frame_get_group_string(const cpl_frame *f);
158 const char *fors_frame_get_level_string(const cpl_frame *f);
159 cpl_frameset *fors_frameset_extract(const cpl_frameset *frames,
160  const char *tag);
161 const char *fors_type_get_string(cpl_type type);
162 void fors_parameterlist_set_defaults(cpl_parameterlist *parlist);
163 
164 #ifdef CPL_IS_NOT_CRAP
165 #else
166 cpl_image *fors_imagelist_collapse_create(const cpl_imagelist *ilist);
167 cpl_image *fors_imagelist_collapse_median_create(const cpl_imagelist *ilist);
168 #endif
169 
170 double fors_angle_diff(const double *a1, const double *a2);
171 
172 void fors_msg_macro(cpl_msg_severity level, const char *fct, const char *format, ...)
173 #ifdef __GNUC__
174 __attribute__((format (printf, 3, 4)))
175 #endif
176 ;
177 #endif
178 
179 CPL_END_DECLS
double fors_rand_gauss(void)
Pseudo-random gaussian distributed number.
Definition: fors_utils.c:181
void fors_print_banner(void)
Issue a banner with the pipeline version.
Definition: fors_utils.c:92
float fors_tools_get_median_fast_float(float *a, int n)
Biased median.
Definition: fors_utils.c:265
void fors_frameset_print(const cpl_frameset *frames)
Print a frame set.
Definition: fors_utils.c:393
const char * fors_type_get_string(cpl_type type)
Textual representation of CPL type.
Definition: fors_utils.c:496
void fors_msg_macro(cpl_msg_severity level, const char *fct, const char *format,...)
Print message.
Definition: fors_utils.c:660
double fors_angle_diff(const double *a1, const double *a2)
Difference between angles.
Definition: fors_utils.c:636
const char * fors_frame_get_type_string(const cpl_frame *f)
Get frame type as a string.
Definition: fors_utils.c:319
double fors_tools_get_kth_double(double *a, int n, int k)
Same as cpl_tools_get_kth_double.
Definition: fors_utils.c:211
cpl_image * fors_imagelist_collapse_create(const cpl_imagelist *ilist)
Workaround for cpl_imagelist_collapse_create.
Definition: fors_utils.c:597
cpl_frameset * fors_frameset_extract(const cpl_frameset *frames, const char *tag)
Extract frames with given tag from frameset.
Definition: fors_utils.c:468
float fors_tools_get_kth_float(float *a, int n, int k)
Same as cpl_tools_get_kth_float.
Definition: fors_utils.c:277
const char * fors_frame_get_group_string(const cpl_frame *f)
Get frame group as a string.
Definition: fors_utils.c:344
int fors_get_version_binary(void)
Get FORS library binary version number.
Definition: fors_utils.c:107
double fors_utils_median_corr(int n)
median stacking correction factor
Definition: fors_utils.c:696
float fors_tools_get_median_float(float *a, int n)
Unbiased median.
Definition: fors_utils.c:250
const char * fors_frame_get_level_string(const cpl_frame *f)
Get frame level as a string.
Definition: fors_utils.c:369
void fors_frame_print(const cpl_frame *f)
Print a frame.
Definition: fors_utils.c:427
void fors_parameterlist_set_defaults(cpl_parameterlist *parlist)
Set unset parameters to default value.
Definition: fors_utils.c:545
const char * fors_get_license(void)
Get the pipeline copyright and license.
Definition: fors_utils.c:65
cpl_image * fors_imagelist_collapse_median_create(const cpl_imagelist *ilist)
Workaround for cpl_imagelist_collapse_median_create.
Definition: fors_utils.c:616