FORS Pipeline Reference Manual  4.12.5
fors_utils.c
1 /* $Id: fors_utils.c,v 1.32 2013-10-09 15:58:42 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-10-09 15:58:42 $
24  * $Revision: 1.32 $
25  * $Name: not supported by cvs2svn $
26  */
27 
28 #ifdef HAVE_CONFIG_H
29 #include <config.h>
30 #endif
31 
32 #include <fors_utils.h>
33 
34 #include <fors_pfits.h>
35 
36 #include <math.h>
37 #include <stdbool.h>
38 
39 /*----------------------------------------------------------------------------*/
43 /*----------------------------------------------------------------------------*/
44 
47 /* Required CPL version */
48 #define REQ_CPL_MAJOR 4
49 #define REQ_CPL_MINOR 0
50 #define REQ_CPL_MICRO 0
51 
52 const double STDEV_PR_MAD = 1/0.6744897; /* standard deviations per median
53  absolute deviation,
54  assuming a normal distribution */
55 
56 /*----------------------------------------------------------------------------*/
64 /*----------------------------------------------------------------------------*/
65 const char * fors_get_license(void)
66 {
67  const char *const fors_license =
68  "This file is currently part of the FORS Instrument Pipeline\n"
69  "Copyright (C) 2002-2011 European Southern Observatory\n"
70  "\n"
71  "This program is free software; you can redistribute it and/or modify\n"
72  "it under the terms of the GNU General Public License as published by\n"
73  "the Free Software Foundation; either version 2 of the License, or\n"
74  "(at your option) any later version.\n"
75  "\n"
76  "This program is distributed in the hope that it will be useful,\n"
77  "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
78  "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
79  "GNU General Public License for more details.\n"
80  "\n"
81  "You should have received a copy of the GNU General Public License\n"
82  "along with this program; if not, write to the Free Software Foundation,\n"
83  "Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA\n";
84  return fors_license ;
85 }
86 
87 /*----------------------------------------------------------------------------*/
91 /*----------------------------------------------------------------------------*/
93 {
94  cpl_msg_info(__func__, "*****************************************");
95  cpl_msg_info(__func__, "Welcome to FORS Pipeline release %s",
96  PACKAGE_VERSION);
97  cpl_msg_info(__func__, "*****************************************");
98 }
99 
100 /*----------------------------------------------------------------------------*/
105 /*----------------------------------------------------------------------------*/
106 int
108 {
109  /*
110  This is a good opportunity to verify that the compile time
111  and runtime CPL versions are recent enough, and consistent
112  */
113 
114 #ifdef CPL_VERSION_CODE
115 #if CPL_VERSION_CODE >= CPL_VERSION(REQ_CPL_MAJOR, REQ_CPL_MINOR, REQ_CPL_MICRO)
116  cpl_msg_debug(cpl_func,
117  "Compile time CPL version code was %d. "
118  "Required is version %d.%d.%d, code %d",
119  CPL_VERSION_CODE, REQ_CPL_MAJOR, REQ_CPL_MINOR, REQ_CPL_MICRO,
120  CPL_VERSION(REQ_CPL_MAJOR, REQ_CPL_MINOR, REQ_CPL_MICRO));
121 #else
122 #error CPL version too old
123 #endif
124 #else /* ifdef CPL_VERSION_CODE */
125 #error CPL_VERSION_CODE not defined. CPL version too old
126 #endif
127 
128  if (cpl_version_get_major() < REQ_CPL_MAJOR ||
129  (cpl_version_get_major() == REQ_CPL_MAJOR &&
130  (int) cpl_version_get_minor() < REQ_CPL_MINOR) ||
131 
132  (cpl_version_get_major() == REQ_CPL_MAJOR &&
133  cpl_version_get_minor() == REQ_CPL_MINOR &&
134  (int) cpl_version_get_micro() < REQ_CPL_MICRO)
135  ) {
136  /* cast suppresses warning about comparing unsigned with 0 */
137 
138  cpl_msg_warning(cpl_func,
139  "Runtime CPL version %s (%d.%d.%d) "
140  "is not supported. "
141  "Please update to CPL version %d.%d.%d or later",
142  cpl_version_get_version(),
143  cpl_version_get_major(),
144  cpl_version_get_minor(),
145  cpl_version_get_micro(),
146  REQ_CPL_MAJOR,
147  REQ_CPL_MINOR,
148  REQ_CPL_MICRO);
149  }
150  else {
151  cpl_msg_debug(cpl_func,
152  "Runtime CPL version %s (%d.%d.%d) detected, "
153  "%d.%d.%d or later required",
154  cpl_version_get_version(),
155  cpl_version_get_major(),
156  cpl_version_get_minor(),
157  cpl_version_get_micro(),
158  REQ_CPL_MAJOR,
159  REQ_CPL_MINOR,
160  REQ_CPL_MICRO);
161  }
162 
163  /* Fixme: Test that compile and runtime versions compare equal.
164  This requires CPL to provide the major/minor/micro version numbers
165  as preprocessor symbols, not just a code. */
166 
167  /* As defined in config.h */
168  return FORS_BINARY_VERSION;
169 }
170 
171 
172 /*----------------------------------------------------------------------------*/
180 /*----------------------------------------------------------------------------*/
181 double fors_rand_gauss(void)
182 {
183  static double V1, V2, S;
184  static int phase = 0;
185  double X;
186 
187  if(phase == 0) {
188  do {
189  double U1 = (double)rand() / RAND_MAX;
190  double U2 = (double)rand() / RAND_MAX;
191 
192  V1 = 2 * U1 - 1;
193  V2 = 2 * U2 - 1;
194  S = V1 * V1 + V2 * V2;
195  } while(S >= 1 || S == 0);
196 
197  X = V1 * sqrt(-2 * log(S) / S);
198  } else
199  X = V2 * sqrt(-2 * log(S) / S);
200 
201  phase = 1 - phase;
202 
203  return X;
204 }
205 
206 /*----------------------------------------------------------------------------*/
210 /*----------------------------------------------------------------------------*/
212  double * a,
213  int n,
214  int k)
215 {
216  double x ;
217  int i, j, l, m ;
218 
219  cpl_ensure(a, CPL_ERROR_NULL_INPUT, 0.00) ;
220 
221  l=0 ; m=n-1 ;
222  while (l<m) {
223  x=a[k] ;
224  i=l ;
225  j=m ;
226  do {
227  while (a[i]<x) i++ ;
228  while (x<a[j]) j-- ;
229  if (i<=j) {
230  //CPL_DOUBLE_SWAP(a[i],a[j]) ;
231  double temp = a[i];
232  a[i] = a[j];
233  a[j] = temp;
234  i++ ; j-- ;
235  }
236  } while (i<=j) ;
237  if (j<k) l=i ;
238  if (k<i) m=j ;
239  }
240  return a[k] ;
241 }
242 
243 #undef cleanup
244 #define cleanup
245 /*----------------------------------------------------------------------------*/
249 /*----------------------------------------------------------------------------*/
250 float fors_tools_get_median_float(float *a, int n)
251 {
252  return (n % 2 == 0) ?
253  (fors_tools_get_kth_float(a, n, (n-1)/2) +
254  fors_tools_get_kth_float(a, n, (n/2))) / 2.0
255  : fors_tools_get_kth_float(a, n, n/2);
256 }
257 
258 #undef cleanup
259 #define cleanup
260 /*----------------------------------------------------------------------------*/
264 /*----------------------------------------------------------------------------*/
265 float fors_tools_get_median_fast_float(float *a, int n)
266 {
267  return fors_tools_get_kth_float(a, n, n/2);
268 }
269 
270 #undef cleanup
271 #define cleanup
272 /*----------------------------------------------------------------------------*/
276 /*----------------------------------------------------------------------------*/
278  float * a,
279  int n,
280  int k)
281 {
282  float x ;
283  int i, j, l, m ;
284 
285  cpl_ensure(a, CPL_ERROR_NULL_INPUT, 0.00) ;
286 
287  l=0 ; m=n-1 ;
288  while (l<m) {
289  x=a[k] ;
290  i=l ;
291  j=m ;
292  do {
293  while (a[i]<x) i++ ;
294  while (x<a[j]) j-- ;
295  if (i<=j) {
296  //CPL_FLOAT_SWAP(a[i],a[j]) ;
297  float temp = a[i];
298  a[i] = a[j];
299  a[j] = temp;
300  i++ ; j-- ;
301  }
302  } while (i<=j) ;
303  if (j<k) l=i ;
304  if (k<i) m=j ;
305  }
306  return a[k] ;
307 }
308 
309 #undef cleanup
310 #define cleanup
311 /*----------------------------------------------------------------------------*/
317 /*----------------------------------------------------------------------------*/
318 const char *
319 fors_frame_get_type_string(const cpl_frame *f)
320 {
321  assure( f != NULL, return NULL, "Null frame" );
322 
323  switch (cpl_frame_get_type(f)) {
324  case CPL_FRAME_TYPE_NONE: return "NONE"; break;
325  case CPL_FRAME_TYPE_IMAGE: return "IMAGE"; break;
326  case CPL_FRAME_TYPE_MATRIX: return "MATRIX"; break;
327  case CPL_FRAME_TYPE_TABLE: return "TABLE"; break;
328  default:
329  return "unrecognized frame type";
330  break;
331  }
332 }
333 
334 #undef cleanup
335 #define cleanup
336 /*----------------------------------------------------------------------------*/
342 /*----------------------------------------------------------------------------*/
343 const char *
344 fors_frame_get_group_string(const cpl_frame *f)
345 {
346  assure( f != NULL, return NULL, "Null frame" );
347 
348  switch (cpl_frame_get_group(f)) {
349  case CPL_FRAME_GROUP_NONE: return "NONE"; break;
350  case CPL_FRAME_GROUP_RAW: return CPL_FRAME_GROUP_RAW_ID; break;
351  case CPL_FRAME_GROUP_CALIB: return CPL_FRAME_GROUP_CALIB_ID; break;
352  case CPL_FRAME_GROUP_PRODUCT: return CPL_FRAME_GROUP_PRODUCT_ID; break;
353  default:
354  return "unrecognized frame group";
355  break;
356  }
357 }
358 
359 #undef cleanup
360 #define cleanup
361 /*----------------------------------------------------------------------------*/
367 /*----------------------------------------------------------------------------*/
368 const char *
369 fors_frame_get_level_string(const cpl_frame *f)
370 {
371  assure( f != NULL, return NULL, "Null frame" );
372 
373  switch (cpl_frame_get_level(f)) {
374  case CPL_FRAME_LEVEL_NONE: return "NONE"; break;
375  case CPL_FRAME_LEVEL_TEMPORARY: return "TEMPORARY"; break;
376  case CPL_FRAME_LEVEL_INTERMEDIATE:return "INTERMEDIATE"; break;
377  case CPL_FRAME_LEVEL_FINAL: return "FINAL"; break;
378  default:
379  return "unrecognized frame level";
380  break;
381  }
382 }
383 
384 /*----------------------------------------------------------------------------*/
391 /*----------------------------------------------------------------------------*/
392 void
393 fors_frameset_print(const cpl_frameset *frames)
394 {
395  /* Two special cases: a NULL frame set and an empty frame set */
396 
397  if (frames == NULL) {
398  cpl_msg_info(cpl_func, "NULL");
399  }
400  else {
401  const cpl_frame *f = NULL;
402  f = cpl_frameset_get_first_const(frames);
403 
404  if (f == NULL) {
405  cpl_msg_info(cpl_func, "[Empty frame set]");
406  }
407  else {
408  while(f != NULL) {
409  fors_frame_print(f);
410  f = cpl_frameset_get_next_const(frames);
411  }
412  }
413  }
414 
415  return;
416 }
417 
418 /*----------------------------------------------------------------------------*/
425 /*----------------------------------------------------------------------------*/
426 void
427 fors_frame_print(const cpl_frame *f)
428 {
429  if (f == NULL) {
430  cpl_msg_info(cpl_func, "NULL");
431  }
432  else {
433  const char *filename = cpl_frame_get_filename(f);
434  const char *tag = cpl_frame_get_tag(f);
435 
436  if (filename == NULL) {
437  filename = "NULL";
438  }
439  if (tag == NULL) {
440  tag = "NULL";
441  }
442 
443  cpl_msg_info(cpl_func, "%-7s %-20s %s",
445  tag,
446  filename);
447 
448  cpl_msg_debug(cpl_func, "type \t= %s", fors_frame_get_type_string(f));
449  cpl_msg_debug(cpl_func, "group \t= %s", fors_frame_get_group_string(f));
450  cpl_msg_debug(cpl_func, "level \t= %s", fors_frame_get_level_string(f));
451  }
452 
453  return;
454 }
455 
456 
457 #undef cleanup
458 #define cleanup
459 /*----------------------------------------------------------------------------*/
466 /*----------------------------------------------------------------------------*/
467 cpl_frameset *
468 fors_frameset_extract(const cpl_frameset *frames,
469  const char *tag)
470 {
471  cpl_frameset *subset = NULL;
472  const cpl_frame *f;
473 
474  assure( frames != NULL, return NULL, "Null frameset" );
475  assure( tag != NULL, return NULL, "Null tag" );
476 
477  subset = cpl_frameset_new();
478 
479  for (f = cpl_frameset_find_const(frames, tag);
480  f != NULL;
481  f = cpl_frameset_find_const(frames, NULL)) {
482 
483  cpl_frameset_insert(subset, cpl_frame_duplicate(f));
484  }
485 
486  return subset;
487 }
488 
489 /*----------------------------------------------------------------------------*/
495 /*----------------------------------------------------------------------------*/
496 const char *fors_type_get_string(cpl_type t)
497 {
498  /* Note that CPL_TYPE_STRING is shorthand
499  for CPL_TYPE_CHAR | CPL_TYPE_FLAG_ARRAY . */
500 
501  if (!(t & CPL_TYPE_FLAG_ARRAY))
502  switch(t & (~CPL_TYPE_FLAG_ARRAY)) {
503  case CPL_TYPE_CHAR: return "char"; break;
504  case CPL_TYPE_UCHAR: return "uchar"; break;
505  case CPL_TYPE_BOOL: return "boolean"; break;
506  case CPL_TYPE_INT: return "int"; break;
507  case CPL_TYPE_UINT: return "uint"; break;
508  case CPL_TYPE_LONG: return "long"; break;
509  case CPL_TYPE_ULONG: return "ulong"; break;
510  case CPL_TYPE_FLOAT: return "float"; break;
511  case CPL_TYPE_DOUBLE: return "double"; break;
512  case CPL_TYPE_POINTER: return "pointer"; break;
513  case CPL_TYPE_INVALID: return "invalid"; break;
514  default:
515  return "unrecognized type";
516  }
517  else
518  switch(t & (~CPL_TYPE_FLAG_ARRAY)) {
519  case CPL_TYPE_CHAR: return "string (char array)"; break;
520  case CPL_TYPE_UCHAR: return "uchar array"; break;
521  case CPL_TYPE_BOOL: return "boolean array"; break;
522  case CPL_TYPE_INT: return "int array"; break;
523  case CPL_TYPE_UINT: return "uint array"; break;
524  case CPL_TYPE_LONG: return "long array"; break;
525  case CPL_TYPE_ULONG: return "ulong array"; break;
526  case CPL_TYPE_FLOAT: return "float array"; break;
527  case CPL_TYPE_DOUBLE: return "double array"; break;
528  case CPL_TYPE_POINTER: return "pointer array"; break;
529  case CPL_TYPE_INVALID: return "invalid (array)"; break;
530  default:
531  return "unrecognized type";
532  }
533 }
534 
535 /*----------------------------------------------------------------------------*/
543 /*----------------------------------------------------------------------------*/
544 void
545 fors_parameterlist_set_defaults(cpl_parameterlist *parlist)
546 {
547  cpl_parameter *p = NULL;
548  bool parameter_is_set;
549 
550  p = cpl_parameterlist_get_first(parlist);
551  while (p != NULL) {
552 
553  /* EsoRex bug: (well, it's an undocumented-feature
554  that EsoRex, unlike Gasgano, reads the default flag):
555  */
556  parameter_is_set = cpl_parameter_get_default_flag(p);
557 
558  if (!parameter_is_set) {
559  cpl_type ptype = cpl_parameter_get_type(p);
560  switch (ptype) {
561  case CPL_TYPE_BOOL:
562  cpl_parameter_set_bool(p, cpl_parameter_get_default_bool(p));
563  break;
564  case CPL_TYPE_INT:
565  cpl_parameter_set_int(p, cpl_parameter_get_default_int(p));
566  break;
567  case CPL_TYPE_DOUBLE:
568  cpl_parameter_set_double(p, cpl_parameter_get_default_double(p));
569  break;
570  case CPL_TYPE_STRING:
571  cpl_parameter_set_string(p, cpl_parameter_get_default_string(p));
572  break;
573  default:
574  assure( false, return, "Unknown type of parameter '%s'",
575  cpl_parameter_get_name(p));
576  }
577  }
578  p = cpl_parameterlist_get_next(parlist);
579  }
580 
581  return;
582 }
583 
584 #ifdef CPL_IS_NOT_CRAP
585 #else
586 
597 cpl_image *fors_imagelist_collapse_create(const cpl_imagelist *ilist)
598 {
599  cpl_image *result = cpl_imagelist_collapse_create(ilist);
600 
601  if (result != NULL && cpl_image_count_rejected(result) == 0) {
602  cpl_image_accept_all(result);
603  }
604 
605  return result;
606 }
607 
608 
616 cpl_image *fors_imagelist_collapse_median_create(const cpl_imagelist *ilist)
617 {
618  cpl_image *result = cpl_imagelist_collapse_median_create(ilist);
619 
620  if (result != NULL && cpl_image_count_rejected(result) == 0) {
621  cpl_image_accept_all(result);
622  }
623 
624  return result;
625 }
626 #endif
627 
628 #undef cleanup
629 #define cleanup
630 
636 double fors_angle_diff(const double *a1, const double *a2)
637 {
638  assure( a1 != NULL, return -1, NULL );
639  assure( a2 != NULL, return -1, NULL );
640 
641  double d = *a1 - *a2;
642 
643  while (d < -M_PI) d += 2*M_PI;
644  while (d > M_PI) d -= 2*M_PI;
645 
646  return fabs(d);
647 }
648 
649 #define MAX_MESSAGE_LENGTH 1024
650 #undef cleanup
651 #define cleanup
652 
660 void fors_msg_macro(cpl_msg_severity level, const char *fct, const char *format, ...)
661 {
662  char message[MAX_MESSAGE_LENGTH];
663  va_list al;
664 
665  va_start(al, format);
666  vsnprintf(message, MAX_MESSAGE_LENGTH - 1, format, al);
667  va_end(al);
668 
669  message[MAX_MESSAGE_LENGTH - 1] = '\0';
670 
671  switch(level) {
672  case CPL_MSG_DEBUG: cpl_msg_debug (fct, "%s", message); break;
673  case CPL_MSG_INFO: cpl_msg_info (fct, "%s", message); break;
674  case CPL_MSG_WARNING: cpl_msg_warning(fct, "%s", message); break;
675  case CPL_MSG_ERROR: cpl_msg_error (fct, "%s", message); break;
676  default:
677  cpl_msg_error(fct, "Unknown message level: %d", level);
678  cpl_msg_error(fct, "%s", message);
679  break;
680  }
681  return;
682 }
683 
684 
685 #undef cleanup
686 #define cleanup
687 
697 {
698  assure( n > 0, return -1, "Illegal number: %d", n);
699 
700  const double c[] = {
701  /* Format: n, corr(n), error
702  Numbers computed by numerical experiment
703  (i.e. generate n normal distributed numbers,
704  get the median (if n is even, mean of middle elements),
705  measure the median error and median's error error)
706  */
707  1, 0.999892, 0.000405,
708  2, 0.999868, 0.000413,
709  3, 1.159685, 0.000467,
710  4, 1.091738, 0.000431,
711  5, 1.197186, 0.000473,
712  6, 1.134358, 0.000454,
713  7, 1.213364, 0.000481,
714  8, 1.159116, 0.000466,
715  9, 1.223264, 0.000487,
716  10, 1.176252, 0.000468,
717  11, 1.228136, 0.000491,
718  12, 1.187431, 0.000476,
719  13, 1.231643, 0.000498,
720  14, 1.195670, 0.000488,
721  15, 1.235724, 0.000491,
722  16, 1.201223, 0.000482,
723  17, 1.237393, 0.000487,
724  18, 1.207451, 0.000487,
725  19, 1.239745, 0.000502,
726  20, 1.212639, 0.000490,
727  21, 1.241837, 0.000498,
728  22, 1.216330, 0.000492,
729  23, 1.244426, 0.000508,
730  24, 1.221290, 0.000493,
731  25, 1.246456, 0.000507,
732  26, 1.224591, 0.000498,
733  27, 1.248254, 0.000500,
734  28, 1.227300, 0.000498,
735  29, 1.248467, 0.000503,
736  30, 1.229101, 0.000485,
737  31, 1.248270, 0.000498,
738  32, 1.231945, 0.000493,
739  33, 1.249087, 0.000509,
740  34, 1.231960, 0.000486,
741  35, 1.249525, 0.000500,
742  36, 1.231679, 0.000496,
743  37, 1.249156, 0.000510,
744  38, 1.233630, 0.000494,
745  39, 1.249173, 0.000483,
746  40, 1.233669, 0.000492,
747  41, 1.248756, 0.000510,
748  42, 1.235170, 0.000493,
749  43, 1.248498, 0.000497,
750  44, 1.235864, 0.000501,
751  45, 1.248986, 0.000487,
752  46, 1.236148, 0.000495,
753  47, 1.248720, 0.000507,
754  48, 1.236461, 0.000499,
755  49, 1.248677, 0.000500,
756  50, 1.236832, 0.000499,
757  51, 1.249143, 0.000510,
758  52, 1.237251, 0.000497,
759  53, 1.248619, 0.000510,
760  54, 1.237826, 0.000490,
761  55, 1.249292, 0.000499,
762  56, 1.238721, 0.000492,
763  57, 1.248719, 0.000502,
764  58, 1.238830, 0.000482,
765  59, 1.248869, 0.000491,
766  60, 1.239892, 0.000501,
767  61, 1.248980, 0.000505,
768  62, 1.239435, 0.000506,
769  63, 1.249534, 0.000506,
770  64, 1.240748, 0.000507,
771  65, 1.249158, 0.000501,
772  66, 1.240053, 0.000503,
773  67, 1.248843, 0.000500,
774  68, 1.241417, 0.000499,
775  69, 1.249386, 0.000506,
776  70, 1.241106, 0.000499,
777  71, 1.249540, 0.000509,
778  72, 1.240998, 0.000491,
779  73, 1.250202, 0.000502,
780  74, 1.241989, 0.000491,
781  75, 1.249485, 0.000497,
782  76, 1.242218, 0.000503,
783  77, 1.249733, 0.000506,
784  78, 1.240815, 0.000517,
785  79, 1.250652, 0.000494,
786  80, 1.241356, 0.000501,
787  81, 1.250115, 0.000511,
788  82, 1.241610, 0.000506,
789  83, 1.249751, 0.000504,
790  84, 1.242905, 0.000485,
791  85, 1.249906, 0.000512,
792  86, 1.243211, 0.000502,
793  87, 1.250671, 0.000503,
794  88, 1.242750, 0.000489,
795  89, 1.249779, 0.000502,
796  90, 1.243191, 0.000507,
797  91, 1.250325, 0.000494,
798  92, 1.243411, 0.000493,
799  93, 1.250774, 0.000508,
800  94, 1.244007, 0.000492,
801  95, 1.249777, 0.000503,
802  96, 1.243910, 0.000507,
803  97, 1.250147, 0.000503,
804  98, 1.243634, 0.000501,
805  99, 1.250931, 0.000504,
806  100, 1.243948, 0.000504};
807 
808  if (n <= 100) {
809  return c[(n-1)*3 + 1];
810  }
811  else {
812  return sqrt(M_PI/2);
813  }
814 }
815 
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 t)
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
#define assure(EXPR)
Definition: list.c:101
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