irplib_detmon_lg-test.c

00001 /*                                                                              *
00002  *   This file is part of the ESO IRPLIB package                                *
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 #ifdef HAVE_CONFIG_H
00021 #include <config.h>
00022 #endif
00023 
00024 /*----------------------------------------------------------------------------
00025                                 Includes
00026  ----------------------------------------------------------------------------*/
00027 
00028 #include <irplib_test.h>
00029 
00030 #include <irplib_detmon_lg.h>
00031 
00032 #include <irplib_math_const.h>
00033 
00034 #ifdef HAVE_FFTW
00035 #include <complex.h>
00036 #include <fftw3.h>
00037 #endif
00038 
00039 #include <math.h>
00040 /*---------------------------------------------------------------------------*/
00041 /*
00042  * @defgroup irplib_detmon_test   Testing of the IRPLIB utilities
00043  */
00044 /*---------------------------------------------------------------------------*/
00045 
00046 #define PI 3.141592653
00047 /*----------------------------------------------------------------------------
00048                                 Defines
00049  ----------------------------------------------------------------------------*/
00050 
00051 #ifndef IMAGESIZE
00052 #define IMAGESIZE       64
00053 #endif
00054 
00055 #define IMAGELISTSIZE   10
00056 
00057 #define NBADPIXS        10
00058 
00059 /*----------------------------------------------------------------------------
00060                             Private Function prototypes
00061  ----------------------------------------------------------------------------*/
00062 
00063 static void irplib_detmon_lg_tests(void);
00064 
00065 cpl_frameset * irplib_detmon_tests_fill_frameset(const char     * tag_on,
00066                                                  const char     * tag_off,
00067                                                  int              non,
00068                                                  cpl_boolean      opt_nir,
00069                                                  cpl_boolean      with_exts,
00070                                                  int              nexts);
00071 
00072 cpl_frameset * irplib_detmon_tests_fill_frameset_oct(const char         * tag_on,
00073                                                  const char     * tag_off,
00074                                                  int              non,
00075                                                  cpl_boolean      opt_nir,
00076                                                  cpl_boolean      with_exts,
00077                                                      int              nexts);
00078 
00079 
00080 /*---------------------------------------------------------------------------*/
00081 /*
00082  * @brief   Unit tests of fit module
00083  */
00084 /*---------------------------------------------------------------------------*/
00085 
00086 int main(void)
00087 {
00088     /* Initialize CPL + IRPLIB */
00089     IRPLIB_TEST_INIT;
00090 
00091     irplib_detmon_lg_tests();
00092 
00093     IRPLIB_TEST_END;
00094 }
00095 
00096 static void irplib_detmon_lg_tests(void)
00097 {
00098 
00099     /* Variables used for correlation function */
00100     int                   px, py;
00101     cpl_image           * image1;
00102 #ifdef HAVE_FFTW
00103     cpl_image           * image2;
00104 #endif
00105     cpl_image           * result;
00106 
00107     cpl_parameterlist   * parlist;
00108     cpl_frameset        * frameset;
00109 
00110     /* Variables used for detmon_ir_lg function */
00111     const char                * tag_on;
00112     const char                * tag_off;
00113 
00114 #ifdef HAVE_FFTW
00115     /* CORRELATION */
00116 
00117     /* 1. trial: all inputs illegal, NULL pointers */
00118     result = irplib_detmon_image_correlate(NULL, NULL, 0, 0);
00119     irplib_test(cpl_error_get_code() == CPL_ERROR_NULL_INPUT);
00120     cpl_error_reset();
00121     irplib_test(result == NULL);
00122     cpl_image_delete(result);
00123 
00124     /* 2. trial: 2 equal and symmetrical images */
00125     image1 = cpl_image_new(IMAGESIZE, IMAGESIZE, CPL_TYPE_FLOAT);
00126     cpl_image_fill_gaussian(image1, (IMAGESIZE + 1)/2, (IMAGESIZE + 1)/2, 25, 40, 40);
00127 
00128     image2 = cpl_image_new(IMAGESIZE, IMAGESIZE, CPL_TYPE_FLOAT);
00129     cpl_image_fill_gaussian(image2, (IMAGESIZE + 1)/2, (IMAGESIZE + 1)/2, 25, 40, 40);
00130 
00131     px = -1;
00132     py = -1;
00133 
00134     result = irplib_detmon_image_correlate(image1, image2, 13, 13);
00135 
00136     cpl_image_get_maxpos(result, &px, &py);
00137     irplib_test(px == 13+1 && py == 13+1);
00138 
00139     cpl_image_delete(image1);
00140     cpl_image_delete(image2);
00141     cpl_image_delete(result);
00142 
00143     /* 3. trial: 2 equal but not symmetrical images */
00144     image1 = cpl_image_new(IMAGESIZE, IMAGESIZE, CPL_TYPE_FLOAT);
00145     cpl_image_fill_gaussian(image1, (IMAGESIZE + 1)/2+30, (IMAGESIZE + 1)/2+30, 25, 40, 40);
00146 
00147     image2 = cpl_image_new(IMAGESIZE, IMAGESIZE, CPL_TYPE_FLOAT);
00148     cpl_image_fill_gaussian(image2, (IMAGESIZE + 1)/2+30, (IMAGESIZE + 1)/2+30, 25, 40, 40);
00149 
00150     px = -1;
00151     py = -1;
00152 
00153     result = irplib_detmon_image_correlate(image1, image2, 13, 13);
00154 
00155     cpl_image_get_maxpos(result, &px, &py);
00156     irplib_test(px == 13+1 && py == 13+1);
00157 
00158     cpl_image_delete(image1);
00159     cpl_image_delete(image2);
00160     cpl_image_delete(result);
00161 
00162     /* 4. trial: 2 different images */
00163     image1 = cpl_image_new(IMAGESIZE, IMAGESIZE, CPL_TYPE_FLOAT);
00164     cpl_image_fill_gaussian(image1, (IMAGESIZE + 1)/2+30, (IMAGESIZE + 1)/2+30, 25, 40, 40);
00165 
00166     image2 = cpl_image_new(IMAGESIZE, IMAGESIZE, CPL_TYPE_FLOAT);
00167     cpl_image_fill_gaussian(image2, (IMAGESIZE + 1)/2+40, (IMAGESIZE + 1)/2+40, 25, 40, 40);
00168 
00169     px = -1;
00170     py = -1;
00171  
00172     result = irplib_detmon_image_correlate(image1, image2, 13, 13);
00173 
00174     cpl_image_get_maxpos(result, &px, &py);
00175     irplib_test(px == 13+11 && py == 13+11);
00176         
00177     cpl_image_delete(image1);
00178     cpl_image_delete(image2);
00179     cpl_image_delete(result);
00180 #else
00181     /* CORRELATION with cpl_image_fft() */
00182 
00183     /* 1. trial: all inputs illegal, NULL pointers */
00184     result = irplib_detmon_autocorrelate(NULL, 0, 0);
00185     irplib_test(cpl_error_get_code() == CPL_ERROR_NULL_INPUT);
00186     cpl_error_reset();
00187     irplib_test(result == NULL);
00188     cpl_image_delete(result);
00189 
00190     /* 2. trial: 2 equal and symmetrical images */
00191     image1 = cpl_image_new(IMAGESIZE, IMAGESIZE, CPL_TYPE_FLOAT);
00192     cpl_image_fill_gaussian(image1, (IMAGESIZE + 1)/2, (IMAGESIZE + 1)/2, 25, 40, 40);
00193 
00194     px = -1;
00195     py = -1;
00196 
00197     result = irplib_detmon_autocorrelate(image1, 13, 13);
00198 //    cpl_msg_error(cpl_func, cpl_error_get_where());
00199 
00200     cpl_image_get_maxpos(result, &px, &py);
00201     irplib_test(px == 13+1 && py == 13+1);
00202 
00203     cpl_image_delete(image1);
00204     cpl_image_delete(result);
00205 
00206 #endif
00207 
00208     /* HIGH LEVEL FUNCTION FOR LINEARITY/GAIN RECIPE */
00209 
00210     /* 1. trial: All inputs illegal, NULL pointers */
00211     irplib_detmon_lg(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, TRUE);
00212     irplib_test(cpl_error_get_code() == CPL_ERROR_NULL_INPUT);
00213     cpl_error_reset();
00214 
00215 
00216 
00217     tag_on = "FRAME_ON";
00218     tag_off = "FRAME_OFF";
00219 
00220     /* Fill the parameter list */
00221     parlist = cpl_parameterlist_new();
00222     irplib_detmon_fill_params_default(parlist, "detmon_ir_lg", "detmon");
00223 
00224     /* Fill a frameset */
00225     frameset = irplib_detmon_tests_fill_frameset(tag_on, tag_off, 20, TRUE, FALSE, 0);
00226 
00227     irplib_detmon_lg(frameset, parlist, tag_on, tag_off, "detmon_ir_lg", "detmon", REGEXP,
00228                      "PRO-1.15", "PRO-1.15", "PRO-1.15", "PRO-1.15", "PRO-1.15", "PRO-1.15", "DETMON / 1.0", NULL, NULL, TRUE);
00229     irplib_test(cpl_error_get_code() == CPL_ERROR_NONE ||
00230                 cpl_error_get_code() == CPL_ERROR_UNSUPPORTED_MODE);
00231     cpl_error_reset();
00232     cpl_frameset_delete(frameset);
00233     cpl_parameterlist_delete(parlist);
00234 
00235     parlist = cpl_parameterlist_new();
00236     irplib_detmon_fill_params_default(parlist, "detmon_opt_lg", "detmon");
00237 
00238     frameset = irplib_detmon_tests_fill_frameset(tag_on, tag_off, 21, FALSE, FALSE, 0);
00239 
00240     irplib_detmon_lg(frameset, parlist, tag_on, tag_off, "detmon_opt_lg", "detmon", REGEXP,
00241                      "PRO-1.15", "PRO-1.15", "PRO-1.15", "PRO-1.15", "PRO-1.15", "PRO-1.15", "DETMON / 1.0", NULL, NULL, FALSE);
00242     irplib_test(cpl_error_get_code() == CPL_ERROR_NONE ||
00243                 cpl_error_get_code() == CPL_ERROR_UNSUPPORTED_MODE);
00244     cpl_error_reset();
00245 
00246     cpl_parameterlist_delete(parlist);
00247     cpl_frameset_delete(frameset);
00248 
00249 
00250     /* Trial: passing a frameset where frames have extensions */
00251     parlist = cpl_parameterlist_new();
00252     irplib_detmon_fill_params(parlist, "detmon_ir_lg", "detmon",
00253                   "PTC",
00254                             3,                /* --order         */
00255                             3,                /* --kappa         */
00256                             25,               /* --niter         */
00257                             0,                /* --threshold_min */
00258                             10000,            /* --threshold_max */
00259                             -1,               /* --llx           */
00260                             -1,               /* --lly           */    
00261                             -1,               /* --urx           */
00262                             -1,               /* --ury           */
00263                             10000,            /* --ref_level     */
00264                             10000,            /* --threshold     */
00265                             "CPL_FALSE",      /* --intermediate  */
00266                             "CPL_FALSE",      /* --autocorr      */
00267                             "CPL_FALSE",      /* --collapse      */
00268                             "CPL_TRUE",       /* --rescale       */
00269                               -1,             /* --filter        */
00270                             26,               /* --m             */
00271                             26,               /* --n             */
00272                             -1,               /* --llx1          */
00273                             -1,               /* --lly1          */
00274                             -1,               /* --urx1          */
00275                             -1,               /* --ury1          */
00276                             -1,               /* --llx2          */
00277                             -1,               /* --lly2          */
00278                             -1,               /* --urx2          */
00279                             -1,               /* --ury2          */
00280                             -1,               /* --llx3          */
00281                             -1,               /* --lly3          */
00282                             -1,               /* --urx3          */
00283                             -1,               /* --ury3          */
00284                             -1,               /* --llx4          */
00285                             -1,               /* --lly4          */
00286                             -1,               /* --urx4          */
00287                             -1,               /* --ury4          */
00288                             -1,               /* --llx5          */
00289                             -1,               /* --lly5          */
00290                             -1,               /* --urx5          */
00291                             -1,               /* --ury5          */
00292                             -1);               /* --exts          */
00293     /*
00294                                     * Unique change of this call with
00295                                     * respect of the default call:
00296                                     * last parameter --exts = -1
00297                                     * to tell the recipe to compute on
00298                                     * all extensions.
00299                                     */
00300 
00301     frameset = irplib_detmon_tests_fill_frameset(tag_on, tag_off,
00302                                                  20, TRUE, TRUE, 8);
00303     
00304     irplib_detmon_lg(frameset, parlist, tag_on, tag_off, "detmon_ir_lg", "detmon", REGEXP,
00305                      "PRO-1.15", "PRO-1.15", "PRO-1.15", "PRO-1.15", "PRO-1.15", "PRO-1.15", "DETMON / 1.0", NULL, NULL, TRUE);
00306     irplib_test(cpl_error_get_code() == CPL_ERROR_NONE ||
00307                 cpl_error_get_code() == CPL_ERROR_UNSUPPORTED_MODE);
00308     //    cpl_msg_error(cpl_func, cpl_error_get_where());
00309     cpl_error_reset();
00310     
00311     cpl_parameterlist_delete(parlist);
00312     cpl_frameset_delete(frameset);
00313 
00314 
00315     /* 2 Trial: passing a frameset where frames have extensions,
00316        but computing on a single extension */
00317     parlist = cpl_parameterlist_new();
00318     irplib_detmon_fill_params(parlist, "detmon_ir_lg", "detmon",
00319                   "PTC",
00320                             3,                /* --order         */
00321                             3,                /* --kappa         */
00322                             25,               /* --niter         */
00323                             0,                /* --threshold_min */
00324                             10000,            /* --threshold_max */
00325                             -1,               /* --llx           */
00326                             -1,               /* --lly           */    
00327                             -1,               /* --urx           */
00328                             -1,               /* --ury           */
00329                             10000,            /* --ref_level     */
00330                             10000,            /* --threshold     */
00331                             "CPL_FALSE",      /* --intermediate  */
00332                             "CPL_FALSE",      /* --autocorr      */
00333                             "CPL_FALSE",      /* --collapse      */
00334                             "CPL_TRUE",       /* --rescale       */
00335                               -1,             /* --filter        */
00336                             26,               /* --m             */
00337                             26,               /* --n             */
00338                             -1,               /* --llx1          */
00339                             -1,               /* --lly1          */
00340                             -1,               /* --urx1          */
00341                             -1,               /* --ury1          */
00342                             -1,               /* --llx2          */
00343                             -1,               /* --lly2          */
00344                             -1,               /* --urx2          */
00345                             -1,               /* --ury2          */
00346                             -1,               /* --llx3          */
00347                             -1,               /* --lly3          */
00348                             -1,               /* --urx3          */
00349                             -1,               /* --ury3          */
00350                             -1,               /* --llx4          */
00351                             -1,               /* --lly4          */
00352                             -1,               /* --urx4          */
00353                             -1,               /* --ury4          */
00354                             -1,               /* --llx5          */
00355                             -1,               /* --lly5          */
00356                             -1,               /* --urx5          */
00357                             -1,               /* --ury5          */
00358                              2);               /* --exts          */
00359     /*
00360                                     * Main change of this call with
00361                                     * respect of the default call:
00362                                     * last parameter --exts = 2
00363                                     * to tell the recipe to compute only on
00364                                     * the second extension.
00365                                     */
00366 
00367     frameset = irplib_detmon_tests_fill_frameset(tag_on, tag_off,
00368                                                  20, TRUE, TRUE, 8);
00369     
00370     irplib_detmon_lg(frameset, parlist, tag_on, tag_off, "detmon_ir_lg", "detmon", REGEXP,
00371                      "PRO-1.15", "PRO-1.15", "PRO-1.15", "PRO-1.15", "PRO-1.15", "PRO-1.15", "DETMON / 1.0", NULL, NULL, TRUE);
00372     irplib_test(cpl_error_get_code() == CPL_ERROR_NONE ||
00373                 cpl_error_get_code() == CPL_ERROR_UNSUPPORTED_MODE);
00374     //    cpl_msg_error(cpl_func, cpl_error_get_where());
00375     cpl_error_reset();
00376     
00377     cpl_parameterlist_delete(parlist);
00378     cpl_frameset_delete(frameset);
00379 
00380 
00381     /* New trial. With a octatett instead of a quartett. */
00382     parlist = cpl_parameterlist_new();
00383     irplib_detmon_fill_params_default(parlist, "detmon_ir_lg", "detmon");
00384 
00385     frameset = irplib_detmon_tests_fill_frameset_oct(tag_on, tag_off, 20, TRUE, FALSE, 0);
00386 
00387     irplib_detmon_lg(frameset, parlist, tag_on, tag_off, "detmon_ir_lg", "detmon", REGEXP,
00388                      "PRO-1.15", "PRO-1.15", "PRO-1.15", "PRO-1.15", "PRO-1.15", "PRO-1.15", "DETMON / 1.0", NULL, NULL, TRUE);
00389     irplib_test(cpl_error_get_code() == CPL_ERROR_NONE ||
00390                 cpl_error_get_code() == CPL_ERROR_UNSUPPORTED_MODE);
00391     cpl_error_reset();
00392 
00393     cpl_parameterlist_delete(parlist);
00394     cpl_frameset_delete(frameset);
00395 }
00396 
00397 /*---------------------------------------------------------------------------*/
00398 /*
00399  * @brief  Detect bad pixels of a selected type
00400  * @param  in           Input image
00401  * @param  mean         Mean level of the image - used to compute threshold
00402  * @param  sigma        Stdev level of the image - used to compute threshold
00403  * @param  flag         Flag - represents selected type of bad pixels (see enum)
00404  * @return The detected bad pixels in a cpl_mask.
00405  */
00406 /*---------------------------------------------------------------------------*/
00407 
00408 cpl_frameset * irplib_detmon_tests_fill_frameset(const char     * tag_on,
00409                                                  const char     * tag_off,
00410                                                  int              non,
00411                                                  cpl_boolean      opt_nir,
00412                                                  cpl_boolean      with_exts,
00413                                                  int              nexts)
00414 {
00415     cpl_frameset                * frameset;
00416     cpl_frame                   * frame;
00417     int i;
00418     char                        frame_name[20];
00419     cpl_propertylist            * plist;
00420     cpl_image                   * image;
00421     frameset = cpl_frameset_new();
00422 
00423     for (i=0; i<non; i++) {
00424         frame = cpl_frame_new();
00425         sprintf(frame_name, "dummyon%d.fits",i);
00426         cpl_frame_set_filename(frame, frame_name);
00427         cpl_frame_set_tag(frame, tag_on);
00428         cpl_frame_set_type(frame, CPL_FRAME_TYPE_IMAGE);
00429         cpl_frame_set_group(frame, CPL_FRAME_GROUP_RAW);
00430 
00431         cpl_frameset_insert(frameset, frame);
00432 
00433         plist = cpl_propertylist_new();
00434         if(opt_nir == TRUE) {
00435             cpl_propertylist_append_double(plist, "ESO DET DIT", (double)(i/2+1));
00436             cpl_propertylist_append_double(plist, "EXPTIME", (double)(i/2+1));
00437             cpl_propertylist_append_double(plist, "MJD-OBS", 0);
00438         } else {
00439             cpl_propertylist_append_double(plist, "ESO DET DIT", (double)((i+1)/2));
00440             cpl_propertylist_append_double(plist, "EXPTIME", (double)((i+1)/2));
00441             cpl_propertylist_append_double(plist, "MJD-OBS", 0);
00442         }
00443 
00444         if(with_exts == TRUE) {
00445           int j;
00446           cpl_image_save(NULL, frame_name, CPL_BPP_IEEE_FLOAT, plist, CPL_IO_DEFAULT);
00447           for(j = 0; j < nexts; j++) {
00448             image = cpl_image_new(IMAGESIZE, IMAGESIZE, CPL_TYPE_FLOAT);
00449             cpl_image_fill_noise_uniform(image, 25, 50);
00450             cpl_ensure(cpl_error_get_code()== CPL_ERROR_NONE, CPL_ERROR_NULL_INPUT, NULL);
00451 
00452             cpl_image_save(image, frame_name, CPL_BPP_IEEE_FLOAT, plist, CPL_IO_EXTEND);
00453             cpl_image_delete(image);
00454           }
00455         } else {
00456             image = cpl_image_new(IMAGESIZE, IMAGESIZE, CPL_TYPE_FLOAT);
00457             cpl_image_fill_noise_uniform(image, 25, 50);
00458             cpl_ensure(cpl_error_get_code()== CPL_ERROR_NONE, CPL_ERROR_NULL_INPUT, NULL);
00459 
00460             cpl_image_save(image, frame_name, CPL_BPP_IEEE_FLOAT, plist, CPL_IO_DEFAULT);
00461 
00462 
00463             cpl_image_delete(image);
00464         }
00465         cpl_propertylist_delete(plist);
00466 
00467 
00468         frame = cpl_frame_new();
00469         sprintf(frame_name, "dummyoff%d.fits",i);
00470         cpl_frame_set_filename(frame, frame_name);
00471         cpl_frame_set_tag(frame, tag_off);
00472         cpl_frame_set_type(frame, CPL_FRAME_TYPE_IMAGE);
00473         cpl_frame_set_group(frame, CPL_FRAME_GROUP_RAW);
00474 
00475         cpl_frameset_insert(frameset, frame);
00476 
00477         plist = cpl_propertylist_new();
00478         if(opt_nir == TRUE) {
00479             cpl_propertylist_append_double(plist, "ESO DET DIT", (double)(i/2+1));
00480             cpl_propertylist_append_double(plist, "EXPTIME", (double)(i/2+1));
00481             cpl_propertylist_append_double(plist, "MJD-OBS", 0);
00482         } else {
00483             cpl_propertylist_append_double(plist, "ESO DET DIT", (double)((i+1)/2));
00484             cpl_propertylist_append_double(plist, "EXPTIME", (double)((i+1)/2));
00485             cpl_propertylist_append_double(plist, "MJD-OBS", 0);
00486         }
00487 
00488         if(with_exts == TRUE) {
00489           int j;
00490           cpl_image_save(NULL, frame_name, CPL_BPP_IEEE_FLOAT, plist, CPL_IO_DEFAULT);
00491           for(j = 0; j < nexts; j++) {
00492             image = cpl_image_new(IMAGESIZE, IMAGESIZE, CPL_TYPE_FLOAT);
00493             cpl_image_fill_noise_uniform(image, 25, 50);
00494             cpl_ensure(cpl_error_get_code()== CPL_ERROR_NONE, CPL_ERROR_NULL_INPUT, NULL);
00495 
00496             cpl_image_save(image, frame_name, CPL_BPP_IEEE_FLOAT, plist, CPL_IO_EXTEND);
00497             cpl_image_delete(image);
00498           }
00499         } else {
00500             image = cpl_image_new(IMAGESIZE, IMAGESIZE, CPL_TYPE_FLOAT);
00501             cpl_image_fill_noise_uniform(image, 25, 50);
00502             cpl_ensure(cpl_error_get_code()== CPL_ERROR_NONE, CPL_ERROR_NULL_INPUT, NULL);
00503 
00504             cpl_image_save(image, frame_name, CPL_BPP_IEEE_FLOAT, plist, CPL_IO_DEFAULT);
00505 
00506 
00507             cpl_image_delete(image);
00508         }
00509         cpl_propertylist_delete(plist);
00510     }
00511 
00512     return frameset;
00513 }
00514 
00515 
00516 cpl_frameset * irplib_detmon_tests_fill_frameset_oct(const char         * tag_on,
00517                                                  const char     * tag_off,
00518                                                  int              non,
00519                                                  cpl_boolean      opt_nir,
00520                                                  cpl_boolean      with_exts,
00521                                                  int              nexts)
00522 {
00523     cpl_frameset                * frameset;
00524     cpl_frame                   * frame;
00525     int i;
00526     char                        frame_name[20];
00527     cpl_propertylist            * plist;
00528     cpl_image                   * image;
00529     frameset = cpl_frameset_new();
00530 
00531     for (i=0; i<non; i++) {
00532         frame = cpl_frame_new();
00533         sprintf(frame_name, "dummyon%d.fits",i);
00534         cpl_frame_set_filename(frame, frame_name);
00535         cpl_frame_set_tag(frame, tag_on);
00536         cpl_frame_set_type(frame, CPL_FRAME_TYPE_IMAGE);
00537         cpl_frame_set_group(frame, CPL_FRAME_GROUP_RAW);
00538 
00539         cpl_frameset_insert(frameset, frame);
00540 
00541         plist = cpl_propertylist_new();
00542         if(opt_nir == TRUE) {
00543           if( i == 2 || i == 3) {
00544             cpl_propertylist_append_double(plist, "ESO DET DIT", (double)(1));
00545             cpl_propertylist_append_double(plist, "EXPTIME", (double)(1));
00546             cpl_propertylist_append_double(plist, "MJD-OBS", 0);
00547           } else {
00548             cpl_propertylist_append_double(plist, "ESO DET DIT", (double)(i/2+1));
00549             cpl_propertylist_append_double(plist, "EXPTIME", (double)(i/2+1));
00550             cpl_propertylist_append_double(plist, "MJD-OBS", 0);
00551           }
00552         } else {
00553             cpl_propertylist_append_double(plist, "ESO DET DIT", (double)((i+1)/2));
00554             cpl_propertylist_append_double(plist, "EXPTIME", (double)((i+1)/2));
00555             cpl_propertylist_append_double(plist, "MJD-OBS", 0);
00556         }
00557 
00558         if(with_exts == TRUE) {
00559           int j;
00560           cpl_image_save(NULL, frame_name, CPL_BPP_IEEE_FLOAT, plist, CPL_IO_DEFAULT);
00561           for(j = 0; j < nexts; j++) {
00562             image = cpl_image_new(IMAGESIZE, IMAGESIZE, CPL_TYPE_FLOAT);
00563             cpl_image_fill_noise_uniform(image, 25, 50);
00564             cpl_ensure(cpl_error_get_code()== CPL_ERROR_NONE, CPL_ERROR_NULL_INPUT, NULL);
00565 
00566             cpl_image_save(image, frame_name, CPL_BPP_IEEE_FLOAT, plist, CPL_IO_EXTEND);
00567             cpl_image_delete(image);
00568           }
00569         } else {
00570             image = cpl_image_new(IMAGESIZE, IMAGESIZE, CPL_TYPE_FLOAT);
00571             cpl_image_fill_noise_uniform(image, 25, 50);
00572             cpl_ensure(cpl_error_get_code()== CPL_ERROR_NONE, CPL_ERROR_NULL_INPUT, NULL);
00573 
00574             cpl_image_save(image, frame_name, CPL_BPP_IEEE_FLOAT, plist, CPL_IO_DEFAULT);
00575 
00576 
00577             cpl_image_delete(image);
00578         }
00579         cpl_propertylist_delete(plist);
00580 
00581 
00582         frame = cpl_frame_new();
00583         sprintf(frame_name, "dummyoff%d.fits",i);
00584         cpl_frame_set_filename(frame, frame_name);
00585         cpl_frame_set_tag(frame, tag_off);
00586         cpl_frame_set_type(frame, CPL_FRAME_TYPE_IMAGE);
00587         cpl_frame_set_group(frame, CPL_FRAME_GROUP_RAW);
00588 
00589         cpl_frameset_insert(frameset, frame);
00590 
00591         plist = cpl_propertylist_new();
00592         if(opt_nir == TRUE) {
00593           if( i == 2 || i == 3) {
00594             cpl_propertylist_append_double(plist, "ESO DET DIT", (double)(1));
00595             cpl_propertylist_append_double(plist, "EXPTIME", (double)(1));
00596             cpl_propertylist_append_double(plist, "MJD-OBS", 0);
00597           } else {
00598             cpl_propertylist_append_double(plist, "ESO DET DIT", (double)(i/2+1));
00599             cpl_propertylist_append_double(plist, "EXPTIME", (double)(i/2+1));
00600             cpl_propertylist_append_double(plist, "MJD-OBS", 0);
00601           }
00602         } else {
00603             cpl_propertylist_append_double(plist, "ESO DET DIT", (double)((i+1)/2));
00604             cpl_propertylist_append_double(plist, "EXPTIME", (double)((i+1)/2));
00605             cpl_propertylist_append_double(plist, "MJD-OBS", 0);
00606         }
00607 
00608         if(with_exts == TRUE) {
00609           int j;
00610           cpl_image_save(NULL, frame_name, CPL_BPP_IEEE_FLOAT, plist, CPL_IO_DEFAULT);
00611           for(j = 0; j < nexts; j++) {
00612             image = cpl_image_new(IMAGESIZE, IMAGESIZE, CPL_TYPE_FLOAT);
00613             cpl_image_fill_noise_uniform(image, 25, 50);
00614             cpl_ensure(cpl_error_get_code()== CPL_ERROR_NONE, CPL_ERROR_NULL_INPUT, NULL);
00615 
00616             cpl_image_save(image, frame_name, CPL_BPP_IEEE_FLOAT, plist, CPL_IO_EXTEND);
00617             cpl_image_delete(image);
00618           }
00619         } else {
00620             image = cpl_image_new(IMAGESIZE, IMAGESIZE, CPL_TYPE_FLOAT);
00621             cpl_image_fill_noise_uniform(image, 25, 50);
00622             cpl_ensure(cpl_error_get_code()== CPL_ERROR_NONE, CPL_ERROR_NULL_INPUT, NULL);
00623 
00624             cpl_image_save(image, frame_name, CPL_BPP_IEEE_FLOAT, plist, CPL_IO_DEFAULT);
00625 
00626 
00627             cpl_image_delete(image);
00628         }
00629         cpl_propertylist_delete(plist);
00630     }
00631 
00632     return frameset;
00633 }

Generated on Thu Nov 15 14:32:25 2007 for UVES Pipeline Reference Manual by  doxygen 1.5.1