uves_utils_wrappers.h

00001 /*
00002  * This file is part of the ESO UVES Pipeline
00003  * Copyright (C) 2004,2005 European Southern Observatory
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, 51 Franklin St, Fifth Floor, Boston, MA  02111-1307  USA
00018  */
00019 
00020 /*
00021  * $Author: amodigli $
00022  * $Date: 2007/06/06 08:17:33 $
00023  * $Revision: 1.56 $
00024  * $Name: uves-3_3_1 $
00025  * $Log: uves_utils_wrappers.h,v $
00026  * Revision 1.56  2007/06/06 08:17:33  amodigli
00027  * replace tab with 4 spaces
00028  *
00029  * Revision 1.55  2007/05/07 10:17:46  jmlarsen
00030  * Added uves_image_reject_all
00031  *
00032  * Revision 1.54  2007/05/04 13:15:08  jmlarsen
00033  * Added workaround for slow CPL functions
00034  *
00035  * Revision 1.53  2007/05/03 15:24:29  jmlarsen
00036  * Added deallocator functions
00037  *
00038  * Revision 1.52  2007/04/24 12:50:29  jmlarsen
00039  * Replaced cpl_propertylist -> uves_propertylist which is much faster
00040  *
00041  * Revision 1.51  2007/04/24 09:43:16  jmlarsen
00042  * Renamed uves_propertylist_append -> uves_propertylist_append_property
00043  *
00044  * Revision 1.50  2007/04/20 14:45:39  jmlarsen
00045  * Added uves_sort_table_3()
00046  *
00047  * Revision 1.49  2007/04/03 11:03:06  jmlarsen
00048  * Added uves_free_float
00049  *
00050  * Revision 1.48  2007/03/19 13:50:48  jmlarsen
00051  * Added workaround for cpl_table_and_selected_invalid
00052  *
00053  * Revision 1.47  2007/03/05 10:15:20  jmlarsen
00054  * Support slope parameter in 1d fitting
00055  *
00056  * Revision 1.46  2007/02/26 11:55:54  jmlarsen
00057  * Renamed and generalized function uves_raise_to_median() -> uves_raise_to_median_frac()
00058  *
00059  * Revision 1.45  2007/02/09 09:00:59  jmlarsen
00060  * Added context as parameter of uves_set_parameter_default
00061  *
00062  * Revision 1.44  2007/01/17 13:28:34  jmlarsen
00063  * Added uves_free_frame
00064  *
00065  * Revision 1.43  2006/12/01 12:31:34  jmlarsen
00066  * Added uves_free_string_const
00067  *
00068  * Revision 1.42  2006/11/15 15:02:15  jmlarsen
00069  * Implemented const safe workarounds for CPL functions
00070  *
00071  * Revision 1.40  2006/11/15 14:04:08  jmlarsen
00072  * Removed non-const version of parameterlist_get_first/last/next which is
00073  * already in CPL, added const-safe wrapper, unwrapper and deallocator functions
00074  *
00075  * Revision 1.39  2006/11/13 12:50:05  jmlarsen
00076  * Added type-safe wrappers of cpl_free
00077  *
00078  * Revision 1.38  2006/11/07 14:06:35  jmlarsen
00079  * Added cpl_array_delete wrapper
00080  *
00081  * Revision 1.37  2006/09/20 12:53:57  jmlarsen
00082  * Replaced stringcat functions with uves_sprintf()
00083  *
00084  * Revision 1.36  2006/09/19 14:23:35  jmlarsen
00085  * uves_find_frame(): Support returning pointer to frame
00086  *
00087  * Revision 1.35  2006/09/01 14:01:14  jmlarsen
00088  * Exported function uves_fit
00089  *
00090  * Revision 1.34  2006/08/23 15:08:31  jmlarsen
00091  * Added uves_free_bivector()
00092  *
00093  * Revision 1.33  2006/08/11 14:36:11  jmlarsen
00094  * Implemented workaround for slow cpl_table_erase_selected
00095  *
00096  * Revision 1.32  2006/08/10 10:54:30  jmlarsen
00097  * Removed workaround for cpl_image_get_bpm
00098  *
00099  * Revision 1.31  2006/08/08 11:27:18  amodigli
00100  * upgrade to CPL3
00101  *
00102  * Revision 1.30  2006/07/14 12:43:15  jmlarsen
00103  * Added uves_extract_table_rows_local
00104  *
00105  * Revision 1.29  2006/07/03 13:28:19  jmlarsen
00106  * Changed 1d-fit parameter estimation method when only sky needs to be determined
00107  *
00108  * Revision 1.28  2006/06/13 12:02:55  jmlarsen
00109  * Renamed y0 -> y_0
00110  *
00111  * Revision 1.27  2006/06/06 08:40:11  jmlarsen
00112  * Shortened max line length
00113  *
00114  * Revision 1.26  2006/05/12 15:12:43  jmlarsen
00115  * Pass image bpm as extra parameter to fitting routine for efficiency reasons
00116  *
00117  * Revision 1.25  2006/04/24 09:31:49  jmlarsen
00118  * Allow fixing background of 1d fit
00119  *
00120  * Revision 1.24  2006/04/06 08:52:48  jmlarsen
00121  * Added raise-to-median of table column function
00122  *
00123  * Revision 1.23  2006/01/31 08:25:08  jmlarsen
00124  * Wrapper for cpl_image_get_bpm
00125  *
00126  * Revision 1.22  2006/01/25 16:13:20  jmlarsen
00127  * Changed interface of gauss.fitting routine
00128  *
00129  * Revision 1.21  2005/12/20 08:11:44  jmlarsen
00130  * Added CVS  entry
00131  *
00132  */
00133 #ifndef UVES_UTILS_WRAPPERS_H
00134 #define UVES_UTILS_WRAPPERS_H
00135 
00136 #ifdef HAVE_CONFIG_H
00137 #  include <config.h>
00138 #endif
00139 /*-----------------------------------------------------------------------------
00140                     Includes
00141  -----------------------------------------------------------------------------*/
00142 
00143 #include <uves_propertylist.h>
00144 #include <irplib_utils.h>
00145 
00146 #include <cpl.h>
00147 
00148 #include <stdbool.h>
00149 /*-----------------------------------------------------------------------------
00150                              Defines
00151  -----------------------------------------------------------------------------*/
00152 
00153 
00154 /*-----------------------------------------------------------------------------
00155                                    Prototypes
00156  -----------------------------------------------------------------------------*/
00157 
00158 #define uves_sprintf(...) irplib_sprintf(__VA_ARGS__)
00159 
00160 const char *uves_find_frame(const cpl_frameset *frames, const char **wanted, 
00161                 int N, int *found, const cpl_frame **frame);
00162 cpl_error_code uves_cast_image(cpl_image **image, cpl_type to_type);
00163 cpl_error_code uves_crop_image(cpl_image **image, int x1, int y_1, int x2, int y2);
00164 
00165 cpl_error_code uves_get_property_value(const uves_propertylist *plist,
00166                        const char *keyword, cpl_type keywordtype, 
00167                        void *result);
00168 cpl_error_code uves_get_parameter(const cpl_parameterlist *parameters,
00169                   const char *context, const char *recipe_id, 
00170                   const char *name, cpl_type type, void *value);
00171 cpl_error_code uves_set_parameter(cpl_parameterlist *parameters, 
00172                   const char *context, const char *name,
00173                   cpl_type type, void *value);
00174 cpl_error_code uves_set_parameter_default(cpl_parameterlist *parameters, 
00175                       const char *context,
00176                       const char *parname, 
00177                       cpl_type type, void *value);
00178 
00179 void uves_image_reject_all(cpl_image *image);
00180 
00181 int uves_get_nextensions(const char *filename);
00182 int uves_select_table_rows(cpl_table *t,  const char *column,
00183                       cpl_table_select_operator operator, 
00184                       double value);
00185 int uves_erase_invalid_table_rows(cpl_table *t, const char *column);
00186 int uves_erase_table_rows(cpl_table *t, const char *column, 
00187               cpl_table_select_operator operator,
00188               double value);
00189 int uves_extract_table_rows_local(cpl_table *t, const char *column,
00190                   cpl_table_select_operator operator, double value);
00191 
00192 cpl_table *uves_extract_table_rows(const cpl_table *t, const char *column,
00193                    cpl_table_select_operator operator,
00194                    double value);
00195 
00196 cpl_error_code
00197 uves_table_sort_dfsxxxx(cpl_table *table, const uves_propertylist *reflist);
00198 
00199 void uves_sort_table_1(cpl_table *t, const char *column1,
00200                bool reverse1);
00201 void uves_sort_table_2(cpl_table *t, const char *column1, 
00202                const char *column2, bool reverse1, 
00203                bool reverse2);
00204 void uves_sort_table_3(cpl_table *t, const char *column1, 
00205                const char *column2, const char *column3,
00206                bool reverse1, bool reverse2, bool reverse3);
00207 
00208 
00209 cpl_error_code uves_fit(const cpl_matrix *x, const cpl_matrix *sigma_x,
00210             const cpl_vector *y, const cpl_vector *sigma_y,
00211             cpl_vector *a, const int ia[],
00212             int    (*f)(const double x[], const double a[], 
00213                     double *result),
00214             int (*dfda)(const double x[], const double a[], 
00215                     double result[]),
00216             double *mse,
00217             double *red_chisq,
00218             cpl_matrix **covariance);
00219 
00220 cpl_error_code
00221 uves_fit_1d(const cpl_vector *x, const cpl_vector *sigma_x,
00222         const cpl_vector *y, const cpl_vector *sigma_y,
00223         cpl_fit_mode fit_pars, bool fit_back,
00224         double *x0, double *sigma, double *area, double *offset, double *slope,
00225             double *mse, double *red_chisq,
00226         cpl_matrix **covariance,
00227         int (*f)   (const double x[], const double a[], double *result),
00228         int (*dfda)(const double x[], const double a[], double result[]),
00229         int M);
00230 
00231 cpl_error_code
00232 uves_fit_1d_image(const cpl_image *image, const cpl_image *noise,
00233           const cpl_binary *image_badmap,
00234           bool horizontal, bool fix_back, bool fit_back,
00235           int xlo, int xhi, int y_0,
00236           double *x0, double *sigma, double *norm, double *background,
00237                   double *slope,
00238           double *mse, double *red_chisq,
00239           cpl_matrix **covariance,
00240           int (*f)   (const double x[], const double a[], double *result),
00241           int (*dfda)(const double x[], const double a[], double result[]),
00242           int M);
00243 
00244 
00245 void uves_propertylist_append_property(uves_propertylist *result, const cpl_property *p);
00246 
00247 cpl_error_code uves_table_erase_selected_dfs02356(cpl_table *t);
00248 int uves_table_and_selected_invalid(cpl_table *t, const char *column);
00249 
00250 void uves_raise_to_median_frac(cpl_table *t, const char *column, double fraction);
00251 void uves_free_image(cpl_image **i);
00252 void uves_free_mask(cpl_mask **m);
00253 void uves_free_imagelist(cpl_imagelist **i);
00254 void uves_free_table(cpl_table **t);
00255 void uves_free_table_const(const cpl_table **t);
00256 void uves_free_propertylist(uves_propertylist **p);
00257 void uves_free_propertylist_const(const uves_propertylist **p);
00258 void uves_free_property(cpl_property **p);
00259 void uves_free_polynomial(cpl_polynomial **p);
00260 void uves_free_matrix(cpl_matrix **m);
00261 void uves_free_vector(cpl_vector **v);
00262 void uves_free_bivector(cpl_bivector **b);
00263 void uves_free_stats(cpl_stats **s);
00264 void uves_unwrap_vector(cpl_vector **v);
00265 void uves_unwrap_vector_const(const cpl_vector **v);
00266 void uves_unwrap_bivector_vectors(cpl_bivector **b);
00267 void uves_free_parameterlist(cpl_parameterlist **p);
00268 void uves_free_frameset(cpl_frameset **f);
00269 void uves_free_frame(cpl_frame **f);
00270 void uves_free_array(cpl_array **a);
00271 void uves_free_int(int **i);
00272 void uves_free_int_const(const int **i);
00273 void uves_free_float(float **f);
00274 void uves_free_double(double **d);
00275 void uves_free_string(char **s);
00276 void uves_free_string_const(const char **s);
00277 
00278 #endif
00279 
00280 
00281 
00282 
00283 
00284 
00285 
00286 
00287 
00288 
00289 
00290 

Generated on Tue Jun 19 14:39:20 2007 for UVES Pipeline Reference Manual by  doxygen 1.4.6