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

Generated on 8 Mar 2011 for UVES Pipeline Reference Manual by  doxygen 1.6.1