uves_wavecal-test.c

00001 /*                                                                              *
00002  *   This file is part of the ESO UVES Pipeline                                 *
00003  *   Copyright (C) 2004,2005 European Southern Observatory                      *
00004  *                                                                              *
00005  *   This library 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: jmlarsen $
00022  * $Date: 2007/05/23 06:43:23 $
00023  * $Revision: 1.2 $
00024  * $Name: uves-3_3_1 $
00025  * $Log: uves_wavecal-test.c,v $
00026  * Revision 1.2  2007/05/23 06:43:23  jmlarsen
00027  * Removed unused variables
00028  *
00029  * Revision 1.1  2007/03/15 12:27:18  jmlarsen
00030  * Moved unit tests to ./uves/tests and ./flames/tests
00031  *
00032  * Revision 1.3  2007/02/27 14:04:14  jmlarsen
00033  * Move unit test infrastructure to IRPLIB
00034  *
00035  * Revision 1.2  2007/01/29 12:17:54  jmlarsen
00036  * Support setting verbosity from command line
00037  *
00038  * Revision 1.1  2006/11/28 08:26:35  jmlarsen
00039  * Added QC log unit test
00040  *
00041  */
00042 
00043 /*-----------------------------------------------------------------------------
00044                                 Includes
00045  -----------------------------------------------------------------------------*/
00046 
00047 #ifdef HAVE_CONFIG_H
00048 #  include <config.h>
00049 #endif
00050 
00051 #include <uves_wavecal_identify.h>
00052 #include <uves_wavecal_utils.h>
00053 #include <uves_utils_wrappers.h>
00054 #include <uves_error.h>
00055 #include <irplib_test.h>
00056 
00057 #include <cpl.h>
00058 #include <math.h>
00059 /*-----------------------------------------------------------------------------
00060                                 Defines
00061  -----------------------------------------------------------------------------*/
00062 
00063 /*-----------------------------------------------------------------------------
00064                             Functions prototypes
00065  -----------------------------------------------------------------------------*/
00066 
00067 
00068 /*----------------------------------------------------------------------------*/
00072 /*----------------------------------------------------------------------------*/
00075 /*----------------------------------------------------------------------------*/
00079 /*----------------------------------------------------------------------------*/
00080 static void
00081 test_ppm(void)
00082 {
00083     int nlines = 50;
00084     int minorder = 94;
00085     int maxorder = 97;
00086     const int norders = maxorder - minorder + 1;
00087     int i, order;
00088 
00089     cpl_table *linetable  = cpl_table_new(norders * nlines);
00090     cpl_table *line_refer = cpl_table_new(nlines);
00091 
00092     cpl_table_new_column(line_refer, "Wave", CPL_TYPE_DOUBLE);
00093  
00094     for (i = 0; i < nlines; i++)
00095         {
00096             cpl_table_set_double(line_refer, "Wave", i, 1000 + 500*sin(i));
00097         }
00098 
00099     irplib_test_eq( cpl_error_get_code(), CPL_ERROR_NONE );
00100     
00101     cpl_table_new_column(linetable, "X"              , CPL_TYPE_DOUBLE);
00102     cpl_table_new_column(linetable, "Order"          , CPL_TYPE_INT);
00103     cpl_table_new_column(linetable, LINETAB_LAMBDAC  , CPL_TYPE_DOUBLE);
00104     cpl_table_new_column(linetable, LINETAB_PIXELSIZE, CPL_TYPE_DOUBLE);
00105     
00106     for (order = minorder; order <= maxorder; order++)
00107         {
00108             for (i = 0; i < nlines; i++)
00109                 {
00110                     int row = (order-minorder)*nlines + i;
00111 
00112                     cpl_table_set_int(linetable, "Order", row, 
00113                                       order);
00114 
00115                     cpl_table_set_double(linetable, LINETAB_PIXELSIZE, row, 1);
00116 
00117                     /* Set X = catalogue wavelength */
00118                     cpl_table_set_double(linetable, "X", row, 
00119                                          cpl_table_get_double(line_refer, "Wave", i, NULL));
00120                     
00121                     cpl_table_set_double(linetable, LINETAB_LAMBDAC, row, 
00122                                          cpl_table_get_double(line_refer, "Wave", i, NULL));
00123                 }
00124         }
00125 
00126     irplib_test_eq( cpl_error_get_code(), CPL_ERROR_NONE );
00127 
00128 /*
00129   cpl_table_dump_structure(linetable, stdout);
00130   cpl_table_dump(linetable, 0, cpl_table_get_nrow(linetable), stdout);
00131   cpl_table_dump(line_refer, 0, cpl_table_get_nrow(line_refer), stdout);
00132 */
00133 
00134     uves_wavecal_identify_lines_ppm(linetable, 
00135                                     line_refer);
00136 
00137     irplib_test( cpl_table_has_column(linetable, "Ident_ppm") );
00138 
00139     uves_free_table(&linetable);
00140     uves_free_table(&line_refer);    
00141 
00142     return;
00143 }
00144 
00145    
00146 /*----------------------------------------------------------------------------*/
00150 /*----------------------------------------------------------------------------*/
00151 
00152 int main(void)
00153 {
00154     IRPLIB_TEST_INIT;
00155 
00156     test_ppm();
00157 
00158     if (cpl_error_get_code() != CPL_ERROR_NONE)
00159         {
00160             uves_error_dump();
00161         }
00162     IRPLIB_TEST_END;
00163 }
00164 
00165 

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