GRAVI Pipeline Reference Manual  1.2.3
gravi_cpl.h
1 /* $Id: gravi_cpl.h,v 1.12 2014/11/12 06:10:40 nazouaoui Exp $
2  *
3  * This file is part of the GRAVI Pipeline
4  * Copyright (C) 2002,2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  */
20 
21 #ifndef GRAVI_CPL_H_
22 #define GRAVI_CPL_H_
23 
24 /*-----------------------------------------------------------------------------
25  Includes
26  -----------------------------------------------------------------------------*/
27 
28 #include <cpl.h>
29 
30 /*-----------------------------------------------------------------------------
31  Prototypes
32  -----------------------------------------------------------------------------*/
33 
34 cpl_array ** gravi_array_new_list (int n, cpl_type type, int size);
35 
36 double ** gravi_table_get_data_array_double (cpl_table * table, const char * name);
37 float ** gravi_table_get_data_array_float (cpl_table * table, const char * name);
38 float complex ** gravi_table_get_data_array_float_complex (cpl_table * table, const char * name);
39 double complex ** gravi_table_get_data_array_double_complex (cpl_table * table, const char * name);
40 int ** gravi_table_get_data_array_int (cpl_table * table, const char * name);
41 
42 double gravi_table_get_column_mean (cpl_table * table, const char * name, int base, int nbase);
43 double gravi_table_get_column_std (cpl_table * table, const char * name, int base, int nbase);
44 cpl_array * gravi_table_get_column_mean_array (cpl_table * table, const char * name, int base, int nbase);
45 
46 #define gravi_table_get_value(table,name,row,value) cpl_array_get (cpl_table_get_array (table,name,row), value, NULL)
47 #define gravi_table_set_value(table,name,row,value,val) cpl_array_set (cpl_table_get_data_array (table,name)[row], value, val);
48 
49 int gravi_array_threshold_min (cpl_array * array, double lo_cut,
50  double assign_lo_cut);
51 
52 cpl_array * gravi_array_init_double (long n , double value);
53 cpl_array * gravi_array_init_int (long n, int value);
54 cpl_array * gravi_array_init_double_complex (long n, double complex value);
55 cpl_array * gravi_array_init_float_complex (long n, float complex value);
56 
57 cpl_array * gravi_array_wrap_complex (cpl_array * input_re, cpl_array * input_im);
58 cpl_array * gravi_array_wrap_float_complex (cpl_array * input_re, cpl_array * input_im);
59 cpl_array * gravi_array_compute_norm2 (cpl_array * input_re, cpl_array * input_im);
60 cpl_array * gravi_array_smooth (cpl_array * input, int nsmooth);
61 cpl_array * gravi_array_rebin (const cpl_array * input, const cpl_array * errs,
62  cpl_table * oi_wave_sc, cpl_table * oi_wave_ft);
63 cpl_array * gravi_array_create_inverse (cpl_array *input);
64 cpl_array * gravi_array_cexp (double complex factor, const cpl_array * input);
65 
66 cpl_error_code gravi_array_normalize_complex (cpl_array * input);
67 cpl_error_code gravi_array_phase_unwrap (cpl_array * input);
68 cpl_error_code gravi_array_phase_wrap (cpl_array * input);
69 cpl_error_code gravi_array_multiply_phasor (cpl_array * input, double complex factor, cpl_array * phase);
70 cpl_error_code gravi_array_add_phasor (cpl_array * input, double complex factor, cpl_array * phase);
71 cpl_error_code gravi_array_add_phase (cpl_array * input, double factor, cpl_array * phase);
72 cpl_error_code gravi_array_multiply_conj (cpl_array * input1, cpl_array * input2);
73 cpl_error_code gravi_array_add_phasors (cpl_array * input, cpl_array * add, cpl_array * sub);
74 
75 cpl_error_code gravi_table_set_array_double_complex (cpl_table * table, const char * name,
76  cpl_size row, cpl_array * visR, cpl_array * visI);
77 cpl_error_code gravi_table_set_array_phase (cpl_table * table, const char * name,
78  cpl_size row, cpl_array * phase);
79 cpl_error_code gravi_table_set_string_fixlen (cpl_table *table, const char *name,
80  int row, const char *value, int len);
81 int gravi_table_are_equal (cpl_table * first, cpl_table * second);
82 
83 cpl_error_code gravi_table_new_column (cpl_table * table, const char * name, const char * unit, cpl_type type);
84 cpl_error_code gravi_table_new_column_array (cpl_table * table, const char * name, const char * unit, cpl_type type, cpl_size size);
85 cpl_error_code gravi_table_init_column_array (cpl_table * table, const char * name, const char * unit, cpl_type type, cpl_size size);
86 
87 cpl_error_code gravi_table_interpolate_column (cpl_table * to_table,
88  const char * to_x,
89  const char * to_y,
90  const cpl_table * from_table,
91  const char * from_x,
92  const char * from_y);
93 
94 cpl_error_code gravi_table_add_columns (cpl_table * oi_vis1, const char *name1,
95  cpl_table * oi_vis2, const char *name2);
96 cpl_error_code gravi_table_runint_column (cpl_table * oi_vis, const char *input_name,
97  const char *output_name, int nsmooth, int nbase);
98 cpl_error_code gravi_table_smooth_column (cpl_table * oi_vis, const char *input_name,
99  const char *output_name, int nsmooth, int nbase);
100 
101 cpl_error_code gravi_table_multiply_scalar (cpl_table * table, const char * name, int base, int nbase, double value);
102 cpl_error_code gravi_table_add_scalar (cpl_table * table, const char * name, int base, int nbase, double value);
103 
104 cpl_array * gravi_table_create_sigma_array (cpl_table * oi_wave);
105 cpl_array * gravi_table_create_wave_array (cpl_table * oi_wave);
106 
107 cpl_error_code gravi_array_get_group_delay_loop (cpl_array ** input, cpl_array * sigma,
108  double * gd, cpl_size nrow,
109  double max_width, int verbose);
110 
111 cpl_error_code gravi_table_compute_group_delay (cpl_table * table, const char *input,
112  const char *output, cpl_table * oi_wave);
113 
114 cpl_matrix * get_matrix_from_vector (cpl_vector * , cpl_vector * );
115 
116 cpl_imagelist * gravi_imagelist_from_column (cpl_table * table_data, const char * data_x);
117 cpl_imagelist * gravi_imagelist_wrap_column (cpl_table * table_data, const char * data_x);
118 cpl_error_code gravi_imagelist_unwrap_images (cpl_imagelist * imglist);
119 double gravi_image_get_noise_window (cpl_image *img,
120  cpl_size llx, cpl_size lly,
121  cpl_size urx, cpl_size ury);
122 
123 cpl_vector * gravi_table_get_vector (cpl_table * , cpl_size , const char * );
124 cpl_vector * gravi_table_get_vector_scalar (cpl_table * table,
125  const char * name,
126  cpl_size base,
127  cpl_size nbase);
128 
129 cpl_vector * gravi_table_get_vector_diff (cpl_table * spectrum_data, int index,
130  const char * regname1,
131  const char * regname2);
132 
133 cpl_array * gravi_array_wrap_image (cpl_image *);
134 
135 cpl_error_code gravi_image_subtract_window (cpl_image * img1, const cpl_image * img2,
136  cpl_size llx, cpl_size lly,
137  cpl_size urx, cpl_size ury,
138  cpl_size llx2, cpl_size lly2);
139 cpl_error_code gravi_image_fill (cpl_image * img, double value);
140 cpl_image * gravi_image_wrap_matrix (cpl_matrix * matrix);
141 cpl_image * gravi_image_from_matrix (cpl_matrix * matrix);
142 cpl_image * gravi_image_wrap_vector (cpl_vector * vector);
143 cpl_image * gravi_image_from_vector (cpl_vector * vector);
144 cpl_image * gravi_image_from_column (cpl_table * table_data, const char * data_x, cpl_size row);
145 
146 double gravi_image_get_quantile (const cpl_image * img, double value);
147 double gravi_array_get_quantile (cpl_array * arr, double value);
148 
149 cpl_size gravi_vector_get_maxpos (cpl_vector * vector);
150 cpl_vector * gravi_vector_extract (const cpl_vector * vector, int start, int step);
151 cpl_error_code gravi_vector_unwrap_with_guess (cpl_vector * vector, cpl_vector * ref, double ref_to_phase);
152 
153 double gravi_vector_get_mean_clip (cpl_vector * vector_in,
154  double percent, double nsigma);
155 
156 cpl_array * gravi_table_get_column_dimension (const cpl_table * table, const char * name);
157 
158 cpl_matrix * gravi_matrix_interpolate_col (cpl_matrix * matrix,
159  cpl_vector * xref,
160  cpl_vector * xout);
161 
162 cpl_matrix * gravi_matrix_invertSV_create (cpl_matrix * a_in);
163 
164 cpl_table * gravi_table_extract_time_interval (cpl_table *table, double start, double end);
165 
166 
167 #endif /* GRAVI_CPL_H_ */
168 
169 
double gravi_image_get_quantile(const cpl_image *img, double value)
Compute the quantile of an image.
Definition: gravi_cpl.c:2112
cpl_array * gravi_table_get_column_dimension(const cpl_table *table, const char *name)
Return an array ready for cpl_table_set_column_dimension.
Definition: gravi_cpl.c:1749
cpl_vector * gravi_table_get_vector(cpl_table *, cpl_size, const char *)
Create a vector from the row index of the column regname.
Definition: gravi_cpl.c:1870
cpl_imagelist * gravi_imagelist_from_column(cpl_table *table_data, const char *data_x)
Create an imagelist from a column array in table.
Definition: gravi_cpl.c:1719
cpl_vector * gravi_vector_extract(const cpl_vector *vector, int start, int step)
Extract part of a vector.
Definition: gravi_cpl.c:2261
cpl_error_code gravi_array_add_phasor(cpl_array *input, double complex factor, cpl_array *phase)
Add a REAL phase to a COMPLEX array, in-place: input = input + cexp (factor * phase) ...
Definition: gravi_cpl.c:1021
cpl_array * gravi_array_cexp(double complex factor, const cpl_array *input)
Compute the complex exponention of an array: cexp (factor * input)
Definition: gravi_cpl.c:973
cpl_error_code gravi_table_multiply_scalar(cpl_table *table, const char *name, int base, int nbase, double value)
Multiply scalar or array column by scalar.
Definition: gravi_cpl.c:2331
cpl_matrix * gravi_matrix_interpolate_col(cpl_matrix *matrix, cpl_vector *xref, cpl_vector *xout)
Linear interpolation of matrix column.
Definition: gravi_cpl.c:2432
int gravi_table_are_equal(cpl_table *first, cpl_table *second)
Check if two tables have the same content.
Definition: gravi_cpl.c:1358
cpl_table * gravi_table_extract_time_interval(cpl_table *table, double start, double end)
Extract rows from table based on the TIME column.
Definition: gravi_cpl.c:2826
cpl_array ** gravi_array_new_list(int n, cpl_type type, int size)
Allocate a list of arrays, pre-filled with 0.0.
Definition: gravi_cpl.c:94
cpl_error_code gravi_array_multiply_phasor(cpl_array *input, double complex factor, cpl_array *phase)
Multiply a REAL phase to a COMPLEX array, in-place: input = input * cexp (factor * phase) ...
Definition: gravi_cpl.c:995
cpl_error_code gravi_array_get_group_delay_loop(cpl_array **input, cpl_array *sigma, double *gd, cpl_size nrow, double max_width, int verbose)
Optimized computation of GDELAY for a list of arrays.
Definition: gravi_cpl.c:1187
cpl_error_code gravi_array_add_phase(cpl_array *input, double factor, cpl_array *phase)
Add a REAL phase to a REAL phase array, in-place: input = input + factor * phase. ...
Definition: gravi_cpl.c:1077
cpl_error_code gravi_image_fill(cpl_image *img, double value)
Fill entire image with value.
Definition: gravi_cpl.c:2033
cpl_matrix * gravi_matrix_invertSV_create(cpl_matrix *a_in)
Invers a matrix with singular value decomposition.
Definition: gravi_cpl.c:2486
cpl_array * gravi_array_wrap_image(cpl_image *)
Wrap the data of na image into an array.
Definition: gravi_cpl.c:1776
cpl_error_code gravi_table_set_string_fixlen(cpl_table *table, const char *name, int row, const char *value, int len)
Set string in table, ensuring fixed length (right space padding). see cpl_table_set_string.
Definition: gravi_cpl.c:605
cpl_error_code gravi_imagelist_unwrap_images(cpl_imagelist *imglist)
Unwrap an imagelist an all its images.
Definition: gravi_cpl.c:1496
double gravi_image_get_noise_window(cpl_image *img, cpl_size llx, cpl_size lly, cpl_size urx, cpl_size ury)
Estimate the median noise in a window. This noise is estimated as the median{img**2}**0.5, so that it is a robust estimate.
Definition: gravi_cpl.c:1608
cpl_image * gravi_image_from_column(cpl_table *table_data, const char *data_x, cpl_size row)
Create an image from a column array in table.
Definition: gravi_cpl.c:1687
double gravi_vector_get_mean_clip(cpl_vector *vector_in, double percent, double nsigma)
Return the mean of a vector after extrema and RMS clipping.
Definition: gravi_cpl.c:2207
cpl_vector * gravi_table_get_vector_diff(cpl_table *spectrum_data, int index, const char *regname1, const char *regname2)
Create a vector from the row index of the column regname.
Definition: gravi_cpl.c:1991
double gravi_array_get_quantile(cpl_array *arr, double value)
Compute the value of the vector corresponding to the quantile &#39;thr&#39; (0 < thr < 1) ...
Definition: gravi_cpl.c:2146
cpl_error_code gravi_vector_unwrap_with_guess(cpl_vector *vector, cpl_vector *ref, double ref_to_phase)
Unwrap a phase vector following a guess vector. The difference is actually unwrap and shall thus be s...
Definition: gravi_cpl.c:2284
cpl_error_code gravi_table_add_scalar(cpl_table *table, const char *name, int base, int nbase, double value)
Multply scalar or array column by scalar.
Definition: gravi_cpl.c:2381
cpl_size gravi_vector_get_maxpos(cpl_vector *vector)
Return the index of maximum in a vector. If several indexes exists with the maximum value...
Definition: gravi_cpl.c:2179
cpl_error_code gravi_array_add_phasors(cpl_array *input, cpl_array *add, cpl_array *sub)
Add a pair of COMPLEX arrays to a COMPLEX array, in-place: input = input + add*conj(sub) ...
Definition: gravi_cpl.c:1047
cpl_image * gravi_image_wrap_matrix(cpl_matrix *matrix)
Wrap matrix into an image (data not duplicated)
Definition: gravi_cpl.c:2050
cpl_image * gravi_image_wrap_vector(cpl_vector *vector)
Wrap vector into an image (data not duplicated)
Definition: gravi_cpl.c:2078
cpl_imagelist * gravi_imagelist_wrap_column(cpl_table *table_data, const char *data_x)
Wrap a column array of a table into an imagelist.
Definition: gravi_cpl.c:1526
cpl_matrix * get_matrix_from_vector(cpl_vector *, cpl_vector *)
Copy the content of two vector into a newly allocated 2D matrix.
Definition: gravi_cpl.c:1820