uves_dfs-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: amodigli $
00022  * $Date: 2007/09/11 17:09:45 $
00023  * $Revision: 1.19 $
00024  * $Name: uves-3_9_0 $
00025  * $Log: uves_dfs-test.c,v $
00026  * Revision 1.19  2007/09/11 17:09:45  amodigli
00027  * added parse_midas_poly
00028  *
00029  * Revision 1.18  2007/08/21 13:14:29  jmlarsen
00030  * Update to changed functionality of uves_read_midas_array
00031  *
00032  * Revision 1.17  2007/08/13 12:15:43  amodigli
00033  * support of CPL4
00034  *
00035  * Revision 1.16  2007/06/26 14:51:00  jmlarsen
00036  * Fixed bug in load_linetable
00037  *
00038  * Revision 1.15  2007/06/22 14:50:11  jmlarsen
00039  * Expanded, again, interface of uves_save_image()
00040  *
00041  * Revision 1.14  2007/06/22 09:33:21  jmlarsen
00042  * Changed interface of uves_save_image
00043  *
00044  * Revision 1.13  2007/06/20 15:55:37  jmlarsen
00045  * Parametrized assumption about MIDAS format
00046  *
00047  * Revision 1.12  2007/06/20 15:50:44  jmlarsen
00048  * Expanded test
00049  *
00050  * Revision 1.11  2007/05/23 06:43:23  jmlarsen
00051  * Removed unused variables
00052  *
00053  * Revision 1.10  2007/05/22 14:51:02  jmlarsen
00054  * Removed unused variables
00055  *
00056  * Revision 1.9  2007/04/24 12:50:29  jmlarsen
00057  * Replaced cpl_propertylist -> uves_propertylist which is much faster
00058  *
00059  * Revision 1.8  2007/04/24 08:07:11  jmlarsen
00060  * Shortened line
00061  *
00062  * Revision 1.7  2007/04/24 08:04:29  jmlarsen
00063  * Added performance test
00064  *
00065  * Revision 1.6  2007/04/10 12:51:43  jmlarsen
00066  * Fixed wrong reference value
00067  *
00068  * Revision 1.5  2007/04/10 12:50:56  jmlarsen
00069  * Added check of float values
00070  *
00071  * Revision 1.4  2007/04/10 11:35:06  jmlarsen
00072  * Added error checking
00073  *
00074  * Revision 1.3  2007/04/03 11:02:30  jmlarsen
00075  * Support reading float MIDAS arrays
00076  *
00077  * Revision 1.2  2007/03/15 15:04:14  jmlarsen
00078  * Allow spaces in HISTORY keyword string values
00079  *
00080  * Revision 1.1  2007/03/15 12:27:18  jmlarsen
00081  * Moved unit tests to ./uves/tests and ./flames/tests
00082  *
00083  * Revision 1.6  2007/02/27 14:04:14  jmlarsen
00084  * Move unit test infrastructure to IRPLIB
00085  *
00086  * Revision 1.5  2007/01/31 15:11:09  jmlarsen
00087  * Test of inf+nan when saving FITS files
00088  *
00089  * Revision 1.4  2007/01/29 12:17:54  jmlarsen
00090  * Support setting verbosity from command line
00091  *
00092  * Revision 1.3  2006/11/28 08:26:23  jmlarsen
00093  * Changed message
00094  *
00095  * Revision 1.2  2006/11/24 09:39:35  jmlarsen
00096  * Factored out termination code
00097  *
00098  * Revision 1.1  2006/11/22 08:04:59  jmlarsen
00099  * Added uves_dfs unit test module
00100  *
00101  * Revision 1.20  2006/11/16 09:49:25  jmlarsen
00102  * Fixed doxygen bug
00103  *
00104  * Revision 1.19  2006/11/08 14:04:03  jmlarsen
00105  * Doxybugfix
00106  *
00107  * Revision 1.18  2006/11/06 15:30:54  jmlarsen
00108  * Added missing includes
00109  *
00110  * Revision 1.17  2006/11/03 15:02:06  jmlarsen
00111  * Added test of uves_align
00112  *
00113  * Revision 1.16  2006/09/11 13:59:01  jmlarsen
00114  * Renamed identifier reserved by POSIX
00115  *
00116  * Revision 1.15  2006/08/24 11:46:18  jmlarsen
00117  * Fixed typo
00118  *
00119  * Revision 1.14  2006/08/24 07:18:17  amodigli
00120  * fixed doxygen warnings
00121  *
00122  * Revision 1.13  2006/08/24 06:39:57  jmlarsen
00123  * Reduced maximum line length
00124  *
00125  * Revision 1.12  2006/08/17 14:11:25  jmlarsen
00126  * Use assure_mem macro to check for memory allocation failure
00127  *
00128  * Revision 1.11  2006/08/14 12:13:27  jmlarsen
00129  * Reset irplib error handler
00130  *
00131  * Revision 1.10  2006/08/14 07:45:41  amodigli
00132  * doxigen doc
00133  *
00134  * Revision 1.9  2006/03/03 13:54:11  jmlarsen
00135  * Changed syntax of check macro
00136  *
00137  * Revision 1.8  2006/02/03 07:47:53  jmlarsen
00138  * Moved recipe implementations to ./uves directory
00139  *
00140  * Revision 1.7  2006/01/31 08:26:56  jmlarsen
00141  * Disabled recipe run tests
00142  *
00143  * Revision 1.6  2006/01/25 16:14:14  jmlarsen
00144  * Changed interface of gauss.fitting routine
00145  *
00146  * Revision 1.5  2005/12/16 14:22:22  jmlarsen
00147  * Removed midas test data; Added sof files
00148  *
00149  * Revision 1.4  2005/11/18 10:54:43  jmlarsen
00150  * Minor changes
00151  *
00152  * Revision 1.3  2005/11/14 13:18:44  jmlarsen
00153  * Minor update
00154  *
00155  * Revision 1.2  2005/11/11 13:18:54  jmlarsen
00156  * Reorganized code, renamed source files
00157  *
00158  * Revision 1.1  2005/11/10 16:33:41  jmlarsen
00159  * Added weighted extraction, test of gauss. fit
00160  *
00161  */
00162 
00163 /*-----------------------------------------------------------------------------
00164                                 Includes
00165  -----------------------------------------------------------------------------*/
00166 
00167 #ifdef HAVE_CONFIG_H
00168 #  include <config.h>
00169 #endif
00170 
00171 #include <uves_dfs.h>
00172 #include <uves_parameters.h>
00173 #include <uves_utils_wrappers.h>
00174 #include <uves_test_simulate.h>
00175 #include <uves_pfits.h>
00176 #include <uves_error.h>
00177 
00178 #include <irplib_test.h>
00179 #include <cpl.h>
00180 
00181 #include <float.h>
00182 /*-----------------------------------------------------------------------------
00183                                 Defines
00184  -----------------------------------------------------------------------------*/
00185 
00186 /*-----------------------------------------------------------------------------
00187                             Functions prototypes
00188  -----------------------------------------------------------------------------*/
00189 
00190 
00191 /*----------------------------------------------------------------------------*/
00195 /*----------------------------------------------------------------------------*/
00199 /*----------------------------------------------------------------------------*/
00203 /*----------------------------------------------------------------------------*/
00204 static void
00205 parse_midas_poly(void)
00206 {
00207     uves_propertylist *header = uves_propertylist_new();
00208     polynomial *p = NULL;
00209 
00210     const char *data[] = {"",
00211             "'COEFFI','I*4',1,7,'7I10'",
00212             "     53889         2         3         2         1         4         5",
00213             "",
00214             "'COEFFR','R*4',1,5,'5E14.7'",
00215             " 4.3300000E+02 4.0880000E+03 1.0000000E+00 2.1000000E+01 0.0000000E+00",
00216             "",
00217             "'COEFFD','R*8',1,30,'3E23.15'",
00218             " -7.097005629698889E+01  4.050908371864904E-02 -2.886756545398909E-06",
00219             "  5.504345508879626E-10 -5.583004967206025E-14  7.624532125635992E+01",
00220             " -2.428213567964009E-03  1.819158447566360E-06 -5.090366383338846E-10",
00221             "  5.198098506055602E-14  3.513177145982783E-01  5.570332137951829E-04",
00222             " -3.876157463910250E-07  1.113253735718822E-10 -1.132455173423791E-14",
00223             "  2.977232589499959E-02 -5.389240622889887E-05  3.777456726044612E-08",
00224             " -1.083863050648735E-11  1.098450510939580E-15 -1.093309039442914E-03",            
00225             "  2.402609262989674E-06 -1.688416547941747E-09  4.839101712729582E-13",
00226             " -4.884504488944702E-17  1.919853952642526E-05 -4.004133160220927E-08",
00227             "  2.816206503824200E-11 -8.051313882805877E-15  8.090579180112579E-19",
00228             " ",
00229             "'TAB_IN_OUT_YSHIFT','R*8',1,1,'3E23.15'",
00230             "  4.180818583555659E+01            ",
00231             " "};
00232     unsigned int i;
00233     
00234     /* Create typical FLAMES ordef table header */
00235     for (i = 0; i < 8000; i++)
00236     {
00237         uves_propertylist_append_string(
00238         header, "HISTORY",
00239         " 35834     35835     35836     35837     35838     35839     35840");
00240     }
00241 
00242     for (i = 0; i < sizeof(data)/sizeof(char *); i++)
00243     {
00244         uves_propertylist_append_string(
00245         header, "HISTORY",
00246         data[i]);
00247     }
00248 
00249     check_nomsg( p = uves_polynomial_convert_from_plist_midas(header, 
00250                                   "COEFF",-1));
00251     
00252     assure( uves_polynomial_get_dimension(p) == 2, CPL_ERROR_ILLEGAL_OUTPUT,
00253         "Dimension is %d, 2 expected", uves_polynomial_get_dimension(p));
00254 
00255   cleanup:
00256     uves_free_propertylist(&header);
00257     uves_polynomial_delete(&p);
00258 
00259     return;
00260 }
00261 
00262 /*----------------------------------------------------------------------------*/
00266 /*----------------------------------------------------------------------------*/
00267 static void
00268 test_load_linetable(void)
00269 {
00270     const char * const filename = "linetable.fits";
00271     cpl_table *linetable_in = NULL;
00272     polynomial *dispersion = NULL;
00273     polynomial *absorder = NULL;
00274     uves_propertylist *header = uves_propertylist_new();
00275     uves_propertylist *eheader = uves_propertylist_new();
00276 
00277     cpl_frame *f = cpl_frame_new();
00278     cpl_frameset *frames = cpl_frameset_new();
00279     bool flames = false;
00280     const char *const chip_id = "CCD42";
00281     cpl_table *ordertable = NULL;
00282     cpl_table *tracetable = NULL;
00283     polynomial *order_locations = NULL;
00284     int firstabs, lastabs;
00285     enum uves_chip chip = UVES_CHIP_BLUE;
00286     int minorder = 1;
00287     int maxorder = 5;
00288     int nx = 150;
00289     /*int ny = 100;*/
00290     int trace_id = 0;
00291     int window = 1;
00292 
00293     /* output */
00294     const char *linetable_filename;
00295     cpl_table *linetable_out = NULL;
00296     uves_propertylist *header_out = NULL;
00297     polynomial *dispersion_out = NULL;
00298     polynomial *absorder_out = NULL;
00299 
00300     /* build data */
00301     check_nomsg( create_order_table(&ordertable, &order_locations, &tracetable,
00302                                     minorder, maxorder, nx));
00303     check_nomsg( create_line_table(&linetable_in, &dispersion, &absorder, 
00304                                    &firstabs, &lastabs,
00305                                    minorder, maxorder, nx));
00306     check_nomsg( uves_propertylist_append_string(header, UVES_CHIP_ID(chip), chip_id));
00307     check_nomsg( uves_propertylist_append_string(header, UVES_DRS_ID, "CPL"));
00308     
00309     check_nomsg( uves_pfits_set_firstabsorder(eheader, firstabs) );
00310     check_nomsg( uves_pfits_set_lastabsorder(eheader, lastabs) );
00311     
00312     check_nomsg( uves_pfits_set_traceid(eheader, trace_id) );
00313     check_nomsg( uves_pfits_set_windownumber(eheader, window) );
00314 
00315     check_nomsg( uves_table_save(linetable_in, header, eheader, filename, CPL_IO_DEFAULT) );
00316     check_nomsg( uves_save_polynomial(dispersion, filename, eheader) );
00317     check_nomsg( uves_save_polynomial(absorder, filename, eheader) );
00318 
00319     irplib_test_eq(cpl_error_get_code(), CPL_ERROR_NONE);
00320 
00321     cpl_frame_set_filename(f, filename);
00322     cpl_frame_set_tag(f, "LINE_TABLE_BLUE");
00323     cpl_frameset_insert(frames, f);
00324 
00325     check_nomsg( uves_load_linetable(frames,
00326                                      flames,
00327                                      chip_id,
00328                                      order_locations, minorder, maxorder,
00329                                      &linetable_filename,
00330                                      &linetable_out,
00331                                      &header_out,
00332                                      &dispersion_out,
00333                                      &absorder_out,
00334                                      chip, trace_id, window));
00335 
00336     irplib_test_eq(cpl_error_get_code(), CPL_ERROR_NONE);
00337 
00338     irplib_test( linetable_out != NULL );
00339     irplib_test( header_out != NULL );
00340     irplib_test( dispersion_out != NULL );
00341     irplib_test( absorder_out != NULL );
00342 
00343     irplib_test_eq( cpl_table_get_nrow(linetable_in),
00344                     cpl_table_get_nrow(linetable_out) );
00345 
00346     /* not required: irplib_test_eq( cpl_table_get_ncol(linetable_in),
00347        cpl_table_get_ncol(linetable_out) );
00348     */
00349 
00350     irplib_test_eq_string( filename, linetable_filename );
00351 
00352     {
00353         int order;
00354         int x;
00355         
00356         for (order = minorder; order <= maxorder; order++) {
00357             for (x = 1; x <= nx; x += nx/6) {
00358                 irplib_test_rel( 
00359                     uves_polynomial_evaluate_2d(absorder    , x, order),
00360                     uves_polynomial_evaluate_2d(absorder_out, x, order), 0.001);
00361                 
00362                 irplib_test_rel( 
00363                     uves_polynomial_evaluate_2d(dispersion  , x, order),
00364                     uves_polynomial_evaluate_2d(dispersion_out, x, order), 0.001);
00365             }
00366         }
00367     }
00368                 
00369   cleanup:
00370     uves_free_frameset(&frames);
00371     uves_free_table(&linetable_in);
00372     uves_free_table(&linetable_out);
00373     uves_polynomial_delete(&dispersion);
00374     uves_polynomial_delete(&absorder);
00375     uves_polynomial_delete(&dispersion_out);
00376     uves_polynomial_delete(&absorder_out);
00377     uves_free_propertylist(&header_out);
00378     uves_free_propertylist(&header);
00379     uves_free_propertylist(&eheader);
00380     uves_free_table(&ordertable);
00381     uves_free_table(&tracetable);
00382     uves_polynomial_delete(&order_locations);
00383 
00384     return;
00385 }
00386 
00387 
00388 /*----------------------------------------------------------------------------*/
00392 /*----------------------------------------------------------------------------*/
00393 static void
00394 convert_midas_array(void)
00395 {
00396     const char *values[] = {"HISTORY", "", 
00397                 "HISTORY", "'FIBREPOS','R*8',1,9,'3E23.15'",
00398                 "HISTORY", " -3.243571124678650E+01 -2.309646501161805E+01 -1.402902770375962E+01",
00399                 "HISTORY", " -4.772375924542811E+00  4.827040349175236E+00  1.378761244187003E+01",
00400                 "HISTORY", "  2.321337764943556E+01  3.243571124678650E+01 -3.552713678800501E-15",
00401                 "HISTORY", "",
00402                             "HISTORY", "'COEFFR','R*4',1,20,'5E14.7'",
00403                             "HISTORY", "9.4893160E+00 4.0716226E+03 0.0000000E+00 2.3000000E+01 1.8538159E-04",
00404                             "HISTORY", "0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00",
00405                 "HISTORY", "",
00406                 "HISTORY", "'INTVAL','I",
00407                 "HISTORY", "1 2 3 4 5 6",
00408                 "HISTORY", "7",
00409                 "HISTORY", "",
00410                 "HISTORY", "'LEGAL','C",
00411                 "HISTORY", " a sdfasdf",
00412                 "HISTORY", "",
00413                 "HISTORY", "'ILLEGAL','C",
00414                 "HISTORY", "1bsdf",
00415                 "HISTORY", "bsdf",
00416                 "HISTORY", "",
00417                 "HISTORY", "'CHIPCHOICE','C",
00418                 "HISTORY", "abcd",
00419                 "HISTORY", ""};
00420 
00421     int N = sizeof(values) / sizeof(const char *) / 2;
00422 
00423     uves_propertylist *header = NULL;
00424     double *resultd = NULL;
00425     int *resulti = NULL;
00426     float *resultf = NULL;
00427     const char *results = NULL;
00428     int result_length, i;
00429     int nkeys;
00430     cpl_type result_type;
00431 
00432     header = uves_propertylist_new();
00433     for (i = 0; i < N; i++)
00434     {
00435         uves_propertylist_append_string(header, values[i*2], values[i*2+1]);
00436     }
00437 
00438     check_nomsg(resultd = uves_read_midas_array(header, "FIBREPOS", &result_length,
00439                                                &result_type, &nkeys));
00440 
00441     irplib_test_eq(result_type, CPL_TYPE_DOUBLE);
00442     irplib_test_eq(result_length, 9);
00443     irplib_test_eq(nkeys, 5);
00444 
00445     /* Check numbers, see above */
00446     irplib_test_rel(resultd[0], -32, 0.10);
00447     irplib_test_rel(resultd[3], -4.7, 0.10);
00448     irplib_test_rel(resultd[6], 23, 0.10);
00449     irplib_test( fabs(resultd[8]) < 0.001);
00450 
00451     /* float */
00452     check_nomsg(resultf = uves_read_midas_array(header, "COEFFR", &result_length,
00453                                                 &result_type, &nkeys));
00454     irplib_test_eq(result_type, CPL_TYPE_FLOAT);
00455     irplib_test_eq(result_length, 10);
00456     irplib_test_eq(nkeys, 4);
00457 
00458     irplib_test_rel(resultf[0], 9.489, 0.01);
00459     irplib_test_rel(resultf[1], 4071,  0.01);
00460     irplib_test_abs(resultf[2], 0.000, 0.01);
00461     irplib_test_rel(resultf[3], 23.00, 0.01);
00462 
00463     /* integer */
00464     check_nomsg(resulti = uves_read_midas_array(header, "INTVAL", &result_length,
00465                                                &result_type, &nkeys));
00466 
00467     irplib_test_eq(result_type, CPL_TYPE_INT);
00468     irplib_test_eq(result_length, 7);
00469     irplib_test_eq(nkeys, 4);
00470     for (i = 1; i <= 7; i++)
00471         {
00472             irplib_test_eq(resulti[i-1], i);
00473         }
00474 
00475 
00476     /* string */
00477     check_nomsg( results = uves_read_midas_array(header, "LEGAL", &result_length,
00478                                        &result_type, &nkeys) );
00479 
00480     irplib_test_eq(result_type, CPL_TYPE_STRING);
00481     irplib_test_eq(result_length, 10);
00482     irplib_test_eq(nkeys, 3);
00483     irplib_test_eq_string(results, " a sdfasdf");
00484 
00485     irplib_test(uves_read_midas_array(header, "ILLEGAL2", &result_length,
00486                                       &result_type, &nkeys) == NULL);
00487     uves_error_reset();
00488 
00489     uves_free_string_const(&results);
00490     check_nomsg(results = uves_read_midas_array(header, "CHIPCHOICE", &result_length,
00491                                                &result_type, &nkeys));
00492 
00493     irplib_test_eq(result_type, CPL_TYPE_STRING);
00494     irplib_test_eq(result_length, 4);
00495     irplib_test_eq(nkeys, 3);
00496     irplib_test_eq_string(results, "abcd");
00497 
00498     /* Performance test (relevant for long FLAMES FITS headers) */
00499     N = 9000;
00500     uves_free_propertylist(&header);
00501     header = uves_propertylist_new();
00502     uves_propertylist_append_string(header, "HISTORY", "'SELIDX','I*4',1,48389,'7I10'");
00503     for (i = 0; i < N; i++)
00504     {
00505         uves_propertylist_append_string(
00506                 header, "HISTORY", 
00507                 "  64605     64606     64607     64608     64609     64610     64611");
00508     }
00509     uves_propertylist_append_string(header, "HISTORY", "");
00510     
00511     uves_free_int(&resulti);
00512     check_nomsg( resulti = uves_read_midas_array(header, "SELIDX", &result_length,
00513                                                  &result_type, &nkeys));
00514 
00515     irplib_test_eq(result_type, CPL_TYPE_INT);
00516     irplib_test_eq(result_length, N*7);
00517     irplib_test_eq(nkeys, 1+N+1);
00518 
00519   cleanup:
00520     uves_free_propertylist(&header);
00521     uves_free_double(&resultd);
00522     uves_free_int(&resulti);
00523     uves_free_float(&resultf);
00524     uves_free_string_const(&results);
00525     return;
00526 }
00527    
00528 /*----------------------------------------------------------------------------*/
00532 /*----------------------------------------------------------------------------*/
00533 static void
00534 test_save_image(void)
00535 {
00536     const int N = 100;
00537     int i;
00538 
00539     cpl_image *image = cpl_image_new(N, 1, CPL_TYPE_DOUBLE);
00540 
00541     double inf = DBL_MAX;
00542     for (i = 1; i <= N; i++)
00543     {
00544         cpl_image_set(image, i, 1, -FLT_MAX*200);
00545         inf *= 10;
00546     }
00547 
00548 
00549     cpl_image_set(image, 1, 1, inf);
00550     cpl_image_set(image, 2, 1, inf/inf);
00551 
00552     uves_save_image(image, "dfs.fits", NULL, true, true);
00553     uves_free_image(&image);
00554 
00555     return;
00556 }
00557 
00558 /*----------------------------------------------------------------------------*/
00562 /*----------------------------------------------------------------------------*/
00563 static void
00564 test_save_frame(void)
00565 {
00566     cpl_frameset *frames = cpl_frameset_new();
00567     cpl_parameterlist *parameters = cpl_parameterlist_new();
00568     int nx = 1500;
00569     int ny = 1024;
00570     int nkey = 360;
00571     cpl_image *image = cpl_image_new(nx, ny, CPL_TYPE_DOUBLE);
00572     uves_propertylist *raw_header = uves_propertylist_new();
00573     uves_propertylist *product_header = uves_propertylist_new();
00574     const char *starttime;
00575     const char *recipe_id = "uves_cal_phony";
00576     const char *tag = "PHONY_TAG";
00577     const char *raw_filename = "raw_file.fits";
00578 
00579     uves_define_global_parameters(parameters);
00580     irplib_test_eq( cpl_error_get_code(), CPL_ERROR_NONE );
00581 
00582     /* Create raw image */
00583     {
00584         cpl_image *raw_image = cpl_image_new(nx, ny, CPL_TYPE_DOUBLE);
00585         cpl_frame *raw_frame = cpl_frame_new();
00586 
00587         {
00588             int i;
00589             for (i = 0; i < nkey; i++)
00590                 {
00591                     const char *key_name = uves_sprintf("KEY%d", i);
00592                     uves_propertylist_append_int(raw_header, key_name, i);
00593                     uves_free_string_const(&key_name);
00594                 }
00595             uves_propertylist_append_string(raw_header, "ORIGIN", "unknown...");
00596         }
00597 
00598         uves_image_save(raw_image, 
00599                         raw_filename,
00600                         CPL_BPP_IEEE_FLOAT,
00601                         raw_header,
00602                         CPL_IO_DEFAULT);
00603         irplib_test_eq( cpl_error_get_code(), CPL_ERROR_NONE );
00604         
00605         uves_free_image(&raw_image);
00606 
00607         /* Wrap frame */
00608         cpl_frame_set_tag(raw_frame, "BIAS_BLUE"); /* Use recognized tag,
00609                                                       so that FRAME_TYPE
00610                                                       is set to RAW */
00611         cpl_frame_set_filename(raw_frame, raw_filename);
00612         cpl_frameset_insert(frames, raw_frame);
00613     }
00614 
00615     starttime = uves_initialize(frames, parameters, recipe_id,
00616                                 "This recipe does not do anything");
00617     irplib_test_eq( cpl_error_get_code(), CPL_ERROR_NONE );
00618 
00619     uves_frameset_insert(frames, 
00620                          image, 
00621                          CPL_FRAME_GROUP_PRODUCT,
00622                          CPL_FRAME_TYPE_IMAGE,
00623                          CPL_FRAME_LEVEL_INTERMEDIATE,
00624                          "dfs_product.fits",
00625                          tag,
00626                          raw_header,
00627                          product_header,
00628                          NULL, /* table header */
00629                          parameters, 
00630                          recipe_id,
00631                          PACKAGE "/" PACKAGE_VERSION,
00632                          NULL, /* qc table */
00633                          starttime,
00634                          false,   /* dump PAF */
00635                          0   /* stats_mask */);
00636 
00637     irplib_test_eq( cpl_error_get_code(), CPL_ERROR_NONE );
00638     irplib_test( cpl_frameset_find(frames, tag) != NULL);
00639 
00640     uves_free_frameset(&frames);
00641     uves_free_parameterlist(&parameters);
00642     uves_free_image(&image);
00643     uves_free_propertylist(&raw_header);
00644     uves_free_propertylist(&product_header);
00645     uves_free_string_const(&starttime);
00646     return;
00647 }
00648 
00649 
00650 /*----------------------------------------------------------------------------*/
00654 /*----------------------------------------------------------------------------*/
00655 
00656 int main(void)
00657 {
00658     /* Initialize CPL + UVES messaging */
00659     IRPLIB_TEST_INIT;
00660 #if defined CPL_VERSION_CODE && CPL_VERSION_CODE >= CPL_VERSION(4, 0, 0)
00661     cpl_errorstate initial_errorstate = cpl_errorstate_get();
00662 #endif
00663 //    cpl_msg_set_level(CPL_MSG_DEBUG);
00664 
00665     check( parse_midas_poly(),
00666        "Test of MIDAS array conversion");
00667 
00668 
00669     check_nomsg( test_load_linetable() );
00670 
00671     check( convert_midas_array(),
00672        "Test of MIDAS array conversion failed");
00673 
00674     check_nomsg( test_save_image() );
00675 
00676     check_nomsg( test_save_frame() );
00677 
00678   cleanup:
00679     if (cpl_error_get_code() != CPL_ERROR_NONE)
00680         {
00681 #if defined CPL_VERSION_CODE && CPL_VERSION_CODE >= CPL_VERSION(4, 0, 0)
00682       cpl_errorstate_dump(initial_errorstate,CPL_FALSE,NULL);
00683 #else
00684             uves_error_dump();
00685 #endif
00686         }
00687     IRPLIB_TEST_END;
00688 }
00689 
00690 

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