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

Generated on Fri Apr 18 14:11:44 2008 for UVES Pipeline Reference Manual by  doxygen 1.5.1