irplib_strehl-test.c

00001 /* $Id: irplib_strehl-test.c,v 1.10 2013-01-29 08:43:33 jtaylor Exp $
00002  *
00003  * This file is part of the ESO Common Pipeline Library
00004  * Copyright (C) 2001-2008 European Southern Observatory
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02111-1307  USA
00019  */
00020 
00021 /*
00022  * $Author: jtaylor $
00023  * $Date: 2013-01-29 08:43:33 $
00024  * $Revision: 1.10 $
00025  * $Name: not supported by cvs2svn $
00026  */
00027 
00028 /*-----------------------------------------------------------------------------
00029                                    Includes
00030  -----------------------------------------------------------------------------*/
00031 #ifdef HAVE_CONFIG_H
00032 #include <config.h>
00033 #endif
00034 
00035 #include "irplib_strehl.h"
00036 #include "irplib_utils.h"
00037 
00038 #include <string.h>
00039 
00040 /*-----------------------------------------------------------------------------
00041                                    Defines
00042  -----------------------------------------------------------------------------*/
00043 
00044 #ifndef IMAGESZ
00045 #define IMAGESZ 1024
00046 #endif
00047 
00048 #ifndef CWLEN
00049 #define CWLEN 1.6
00050 #endif
00051 
00052 #ifndef DWLEN
00053 #define DWLEN 0.05
00054 #endif
00055 
00056 #ifndef PIXSCALE
00057 #define PIXSCALE 12.25e-3
00058 #endif
00059 
00060 /*-----------------------------------------------------------------------------
00061                                    Static functions
00062  -----------------------------------------------------------------------------*/
00063 static void irplib_strehl_test_one(void);
00064 static void irplib_psf_test_one(int);
00065 static void irplib_psf_test(void);
00066 static cpl_image * irplib_strehl_create(cpl_size, cpl_size, cpl_type,
00067                                         double, double, double);
00068 static void irplib_strehl_test(const cpl_image *, double, double,
00069                                double, double, double, double, double,
00070                                const char *);
00071 
00072 static void irplib_strehl_test_fits(const char *, double, double, double,
00073                                     double, double, cpl_size);
00074 
00075 static const char * irplib_get_base_name(const char *);
00076 
00077 struct fitsinfo {
00078     const char *bname; /* filename with extension, but without path */
00079     double pixscale; /* Arcseconds per pixel */
00080     double cwlen;    /* micron */
00081     double dwlen;    /* micron */
00082     double m1;       /* The diameter of the primary mirror [m] */
00083     double m2;       /* The diameter of the secondary mirror [m] */
00084     cpl_size iplane;
00085 };
00086 
00087 /*-----------------------------------------------------------------------------
00088                                   Main
00089  -----------------------------------------------------------------------------*/
00090 /*----------------------------------------------------------------------------*/
00098 /*----------------------------------------------------------------------------*/
00099 int main (int argc, char * argv[])
00100 {
00101     /* Support the Strehl-method evaluation effort by Enrico Marchetti */
00102     const struct fitsinfo suite[] = {
00103         {"Berlin.fits",     12.25e-3, 1.6, 0.060, IRPLIB_STREHL_M1,
00104          IRPLIB_STREHL_M2, 0},
00105         {"Frankfurt.fits",  12.25e-3, 1.6, 0.060, IRPLIB_STREHL_M1,
00106          IRPLIB_STREHL_M2, 0},
00107         {"Hamburg.fits",    12.25e-3, 1.6, 0.060, IRPLIB_STREHL_M1,
00108          IRPLIB_STREHL_M2, 0},
00109         {"Koeln.fits",      12.25e-3, 1.6, 0.060, IRPLIB_STREHL_M1,
00110          IRPLIB_STREHL_M2, 0},
00111         {"Muenchen.fits",   12.25e-3, 1.6, 0.060, IRPLIB_STREHL_M1,
00112          IRPLIB_STREHL_M2, 0},
00113         {"Stuttgart.fits",  12.25e-3, 1.6, 0.060, IRPLIB_STREHL_M1,
00114          IRPLIB_STREHL_M2, 0},
00115 
00116         {"Torino_2.fits",   0.0331932, 1.635, 0.0001, 5.0800, 1.8288, 0},
00117         {"Trieste_2.fits",  0.0331932, 1.635, 0.0001, 5.0800, 1.8288, 0},
00118         {"Bologna_2.fits",  0.0331932, 1.635, 0.0001, 5.0800, 1.8288, 0},
00119         {"Cagliari_2.fits", 0.0331932, 1.635, 0.0001, 5.0800, 1.8288, 0},
00120         {"Catania_2.fits",  0.0331932, 1.635, 0.0001, 5.0800, 1.8288, 0},
00121         {"Firenze_2.fits",  0.0331932, 1.635, 0.0001, 5.0800, 1.8288, 0},
00122         {"Lapalma_2.fits",  0.0331932, 1.635, 0.0001, 5.0800, 1.8288, 0},
00123         {"Milano_2.fits",   0.0331932, 1.635, 0.0001, 5.0800, 1.8288, 0},
00124         {"Napoli_2.fits",   0.0331932, 1.635, 0.0001, 5.0800, 1.8288, 0},
00125         {"Padova_2.fits",   0.0331932, 1.635, 0.0001, 5.0800, 1.8288, 0},
00126         {"Palermo_2.fits",  0.0331932, 1.635, 0.0001, 5.0800, 1.8288, 0},
00127         {"Roma_2.fits",     0.0331932, 1.635, 0.0001, 5.0800, 1.8288, 0},
00128         {"Teramo_2.fits",   0.0331932, 1.635, 0.0001, 5.0800, 1.8288, 0},
00129 
00130         {"Bologna_4.fits",  0.0165966, 1.635, 0.0001, 5.0800, 1.8288, 0},
00131         {"Cagliari_4.fits", 0.0165966, 1.635, 0.0001, 5.0800, 1.8288, 0},
00132         {"Catania_4.fits",  0.0165966, 1.635, 0.0001, 5.0800, 1.8288, 0},
00133         {"Firenze_4.fits",  0.0165966, 1.635, 0.0001, 5.0800, 1.8288, 0},
00134         {"Lapalma.fits",    0.0165966, 1.635, 0.0001, 5.0800, 1.8288, 0},
00135         {"Milano_4.fits",   0.0165966, 1.635, 0.0001, 5.0800, 1.8288, 0},
00136         {"Naoli_4.fits",    0.0165966, 1.635, 0.0001, 5.0800, 1.8288, 0},
00137         {"Padova_4.fits",   0.0165966, 1.635, 0.0001, 5.0800, 1.8288, 0},
00138         {"Palermo_4.fits",  0.0165966, 1.635, 0.0001, 5.0800, 1.8288, 0},
00139         {"Roma_4.fits",     0.0165966, 1.635, 0.0001, 5.0800, 1.8288, 0},
00140         {"Teramo_4.fits",   0.0165966, 1.635, 0.0001, 5.0800, 1.8288, 0},
00141         {"Torino_4.fits",   0.0165966, 1.635, 0.0001, 5.0800, 1.8288, 0},
00142         {"Trieste_4.fits",  0.0165966, 1.635, 0.0001, 5.0800, 1.8288, 0},
00143 
00144         {"Antofagasta.fits", 0.17678, 2.2  , 0.05, IRPLIB_STREHL_M1,
00145          IRPLIB_STREHL_M2, 0},
00146         {"Bordeaux.fits",    0.01327, 2.166, 0.05, IRPLIB_STREHL_M1,
00147          IRPLIB_STREHL_M2, 0},
00148         {"Concepcion.fits",  0.01768, 2.2  , 0.05, IRPLIB_STREHL_M1,
00149          IRPLIB_STREHL_M2, 0},
00150         {"Grenoble.fits",    0.02715, 2.15 , 0.05, IRPLIB_STREHL_M1,
00151          IRPLIB_STREHL_M2, 0},
00152         {"LeHavre.fits",     0.01327, 1.65 , 0.05, IRPLIB_STREHL_M1,
00153          IRPLIB_STREHL_M2, 0},
00154         {"Lille.fits",       0.01327, 1.04 , 0.05, IRPLIB_STREHL_M1,
00155          IRPLIB_STREHL_M2, 8},
00156         {"Lyon.fits",        0.01327, 2.15 , 0.05, IRPLIB_STREHL_M1,
00157          IRPLIB_STREHL_M2, 0},
00158         {"Marseille.fits",   0.02715, 4.05 , 0.05, IRPLIB_STREHL_M1,
00159          IRPLIB_STREHL_M2, 0},
00160         {"Nantes.fits",      0.0546 , 2.15 , 0.05, IRPLIB_STREHL_M1,
00161          IRPLIB_STREHL_M2, 0},
00162         {"Nice.fits",        0.02715, 4.78 , 0.05, IRPLIB_STREHL_M1,
00163          IRPLIB_STREHL_M2, 0},
00164         {"Paris.fits",       0.0033 , 2.18 , 0.05, IRPLIB_STREHL_M1,
00165          IRPLIB_STREHL_M2, 0},
00166         {"Santiago.fits",    0.01768, 2.2  , 0.05, IRPLIB_STREHL_M1,
00167          IRPLIB_STREHL_M2, 0},
00168         {"Strasbourg.fits",  0.01327, 2.166, 0.05, IRPLIB_STREHL_M1,
00169          IRPLIB_STREHL_M2, 0},
00170         {"Toulouse.fits",    0.02715, 2.15 , 0.05, IRPLIB_STREHL_M1,
00171          IRPLIB_STREHL_M2, 0},
00172         {"Valdivia.fits",    0.07071, 2.2  , 0.05, IRPLIB_STREHL_M1,
00173          IRPLIB_STREHL_M2, 0}};
00174 
00175     const size_t suitesz = sizeof(suite) / sizeof(*suite);
00176     int iarg;
00177 
00178     cpl_test_init(PACKAGE_BUGREPORT, CPL_MSG_WARNING);
00179 
00180     cpl_msg_info("Strehl-testing with star with ",
00181                  IRPLIB_XSTRINGIFY(IRPLIB_STREHL_STAR_RADIUS) " = "
00182                  IRPLIB_STRINGIFY(IRPLIB_STREHL_STAR_RADIUS) ". "
00183                  IRPLIB_XSTRINGIFY(IRPLIB_STREHL_BACKGROUND_R1) " = "
00184                  IRPLIB_STRINGIFY(IRPLIB_STREHL_BACKGROUND_R1) ". "
00185                  IRPLIB_XSTRINGIFY(IRPLIB_STREHL_BACKGROUND_R2) " = "
00186                  IRPLIB_STRINGIFY(IRPLIB_STREHL_BACKGROUND_R2) ".");
00187 
00188     irplib_strehl_test_one();
00189 
00190     for (iarg = 1; iarg < argc; iarg++) {
00191         const char * basename = irplib_get_base_name(argv[iarg]);
00192         double       pixscale = PIXSCALE;
00193         double       cwlen    = CWLEN;
00194         double       dwlen    = DWLEN;
00195         double       m1       = IRPLIB_STREHL_M1;
00196         double       m2       = IRPLIB_STREHL_M2;
00197         cpl_size     iplane   = 0;
00198         size_t       i;
00199 
00200         cpl_test_assert(basename != NULL);
00201 
00202         for (i = 0; i < suitesz; i++) {
00203             if (!strcmp(basename, suite[i].bname)) {
00204                 pixscale = suite[i].pixscale;
00205                 cwlen    = suite[i].cwlen;
00206                 dwlen    = suite[i].dwlen;
00207                 m1       = suite[i].m1;
00208                 m2       = suite[i].m2;
00209                 iplane   = suite[i].iplane;
00210                 break;
00211             }
00212         }
00213 
00214         irplib_strehl_test_fits(argv[iarg], pixscale, cwlen, dwlen, m1, m2,
00215                                 iplane);
00216     }
00217 
00218     irplib_psf_test();
00219 
00220     return cpl_test_end(0);
00221 }
00222 
00223 
00224 /*----------------------------------------------------------------------------*/
00237 /*----------------------------------------------------------------------------*/
00238 static void irplib_strehl_test_fits(const char * file, double pixscale,
00239                                     double lam, double dlam, double m1,
00240                                     double m2, cpl_size iplane)
00241 {
00242 
00243     cpl_type type = CPL_TYPE_DOUBLE;
00244     int i;
00245 
00246     for (i = 0; i < 1; i++, type = CPL_TYPE_FLOAT) {
00247 
00248         cpl_image * img = cpl_image_load(file, type, iplane, 0);
00249 
00250         cpl_test_error(CPL_ERROR_NONE);
00251         cpl_test_nonnull(img);
00252 
00253         irplib_strehl_test(img, 0.0, 10.0, pixscale, lam, dlam, m1, m2, file);
00254 
00255         cpl_image_delete(img);
00256     }
00257 }
00258 
00259 
00260 /*----------------------------------------------------------------------------*/
00266 /*----------------------------------------------------------------------------*/
00267 static void irplib_psf_test(void)
00268 {
00269 
00270     const int is_bench = cpl_msg_get_level() <= CPL_MSG_INFO
00271         ? CPL_TRUE : CPL_FALSE;
00272 
00273     double tstop;
00274     const double tstart = cpl_test_get_cputime();
00275 
00276     int szstart = 4;
00277     int szstop = is_bench ? IMAGESZ : IRPLIB_STREHL_BOX_SIZE * 2;
00278 
00279     int isz, irep;
00280 
00281     for (irep = 0; irep < (is_bench ? 3 : 1); irep++) {
00282 
00283         for (isz = szstart; isz <= szstop; isz *= 2) {
00284             irplib_psf_test_one(isz);
00285         }
00286     }
00287 
00288     tstop = cpl_test_get_cputime() - tstart;
00289 
00290     cpl_msg_info(cpl_func, "Time to generate %d set(s) of PSFs up to size "
00291                  "%d X %d [s]: %g", irep, szstop, szstop, tstop);
00292 }
00293 
00294 /*----------------------------------------------------------------------------*/
00300 /*----------------------------------------------------------------------------*/
00301 static void irplib_psf_test_one(int size)
00302 {
00303     cpl_image * imgpsf = irplib_strehl_generate_psf(IRPLIB_STREHL_M1,
00304                                                     IRPLIB_STREHL_M2,
00305                                                     CWLEN, DWLEN, PIXSCALE,
00306                                                     size);
00307     cpl_test_error(CPL_ERROR_NONE);
00308     cpl_test_nonnull(imgpsf);
00309     cpl_test_eq(cpl_image_get_size_x(imgpsf),
00310                 cpl_image_get_size_y(imgpsf));
00311 
00312     cpl_test_eq(cpl_image_get_size_x(imgpsf), size);
00313 
00314     cpl_image_delete(imgpsf);
00315 }
00316 
00317 /*----------------------------------------------------------------------------*/
00323 /*----------------------------------------------------------------------------*/
00324 static void irplib_strehl_test_one(void)
00325 {
00326     cpl_type type = CPL_TYPE_DOUBLE;
00327     int i;
00328 
00329     for (i = 0; i < 2; i++, type = CPL_TYPE_FLOAT) {
00330 
00331         cpl_image * img = irplib_strehl_create(IMAGESZ, IMAGESZ, type,
00332                                                1000.0, 1.0, 1.0);
00333 
00334         irplib_strehl_test(img, 1000.0, 1.0, 0.03,
00335                            2.18, 0.35, IRPLIB_STREHL_M1, IRPLIB_STREHL_M2,
00336                            "Synthetic image"); /* NACO values */
00337 
00338         cpl_image_delete(img);
00339     }
00340 }
00341 
00342 /*----------------------------------------------------------------------------*/
00355 /*----------------------------------------------------------------------------*/
00356 static cpl_image * irplib_strehl_create(cpl_size nx, cpl_size ny,
00357                                         cpl_type type,
00358                                         double norm,
00359                                         double sig_x,
00360                                         double sig_y)
00361 {
00362 
00363     const double noise = FLT_EPSILON;
00364     cpl_size     mx, my;
00365     cpl_image * im1 = cpl_image_new(nx, ny, type);
00366     cpl_error_code code;
00367 
00368     code = cpl_image_fill_gaussian(im1, nx/2, ny/2, norm, sig_x, sig_y);
00369     cpl_test_eq_error(code, CPL_ERROR_NONE);
00370 
00371     if (noise != 0.0) {
00372         cpl_image * im0 = cpl_image_new(nx, ny, CPL_TYPE_FLOAT);
00373         code = cpl_image_fill_noise_uniform(im0, -noise, noise);
00374         cpl_test_eq_error(code, CPL_ERROR_NONE);
00375         code = cpl_image_subtract(im1, im0);
00376         cpl_test_eq_error(code, CPL_ERROR_NONE);
00377         cpl_image_delete(im0);
00378     }
00379 
00380     code = cpl_image_get_maxpos(im1, &mx, &my);
00381     cpl_test_eq_error(code, CPL_ERROR_NONE);
00382     cpl_test_eq(mx, nx/2);
00383     cpl_test_eq(my, ny/2);
00384 
00385     return im1;
00386 }
00387 
00388 /*----------------------------------------------------------------------------*/
00403 /*----------------------------------------------------------------------------*/
00404 static void irplib_strehl_test(const cpl_image * im1, double norm,
00405                                double sigma,
00406                                double pixscale, double lam, double dlam,
00407                                double m1, double m2,
00408                                const char * label)
00409 {
00410 
00411     const cpl_size nx = cpl_image_get_size_x(im1);
00412     const cpl_size ny = cpl_image_get_size_y(im1);
00413     cpl_error_code code;
00414 
00415     /* Sigma-levels for detection of a bright star, copied from NACO */
00416     const double    psigmas[] = {sigma, sigma/2.0, sigma/4.0};
00417     const size_t    nsigmas = sizeof(psigmas)/sizeof(*psigmas);
00418     cpl_size        isigma;
00419     cpl_vector    * sigmas = cpl_vector_wrap(nsigmas, (double*)psigmas);
00420     cpl_apertures * apert = NULL;
00421     double          fwhm_x, fwhm_y;
00422     cpl_size        mx, my;
00423     cpl_image     * imgpsf;
00424 
00425     double strehl = 0.0, strehl_err = 0.0;
00426     double star_bg = 0.0, star_peak = 0.0, star_flux = 0.0;
00427     double psf_peak = 0.0, psf_flux = 0.0, bg_noise = 0.0;
00428 
00429     const double star_radius  = IRPLIB_STREHL_STAR_RADIUS;
00430     const double background_1 = IRPLIB_STREHL_BACKGROUND_R1;
00431     const double background_2 = IRPLIB_STREHL_BACKGROUND_R2;
00432 
00433     code = cpl_image_get_maxpos(im1, &mx, &my);
00434     cpl_test_eq_error(code, CPL_ERROR_NONE);
00435     cpl_test_leq(mx - nx/4, mx);
00436     cpl_test_leq(my - ny/4, my);
00437     cpl_test_leq(mx, mx + nx/4);
00438     cpl_test_leq(my, my + ny/4);
00439 
00440     apert = cpl_apertures_extract_window(im1, sigmas,
00441                                          mx - nx/4, my - ny/4,
00442                                          mx + nx/4, my + ny/4,
00443                                          &isigma);
00444     cpl_test_error(CPL_ERROR_NONE);
00445     cpl_test_nonnull(apert);
00446     cpl_test_zero(isigma);
00447 
00448     cpl_apertures_delete(apert);
00449     cpl_test_eq_ptr(cpl_vector_unwrap(sigmas), psigmas);
00450 
00451     cpl_test_lt(0.0, pixscale);
00452 
00453     code = cpl_image_get_fwhm(im1, mx, my, &fwhm_x, &fwhm_y);
00454     cpl_test_eq_error(code, CPL_ERROR_NONE);
00455 
00456     cpl_msg_info(cpl_func, "Expected star-radius vs. actual FWHM [pixel]: "
00457                  "%g <=> (%g, %g)", star_radius / pixscale,
00458                  fwhm_x, fwhm_y);
00459 
00460     cpl_msg_debug(cpl_func, "Inner and outer radius of ring-zone for noise "
00461                   "estimate [pixel]: %g < %g", background_1 / pixscale,
00462                   background_2 / pixscale);
00463 
00464 
00465     imgpsf = irplib_strehl_generate_psf(m1, m2,
00466                                         lam, dlam, pixscale,
00467                                         IRPLIB_STREHL_BOX_SIZE);
00468     cpl_test_error(CPL_ERROR_NONE);
00469     cpl_test_nonnull(imgpsf);
00470     cpl_test_eq(cpl_image_get_size_x(imgpsf),
00471                 cpl_image_get_size_y(imgpsf));
00472 
00473     cpl_test_eq(cpl_image_get_size_x(imgpsf),
00474                 IRPLIB_STREHL_BOX_SIZE);
00475 
00476     if (cpl_msg_get_level() <= CPL_MSG_DEBUG) {
00477         cpl_plot_image("", "", "", imgpsf);
00478     }
00479     cpl_image_delete(imgpsf);
00480 
00481     code = irplib_strehl_compute(im1, m1, m2,
00482                                  lam, dlam, pixscale,
00483                                  IRPLIB_STREHL_BOX_SIZE,
00484                                  mx, my,
00485                                  star_radius,
00486                                  background_1,
00487                                  background_2,
00488                                  -1, -1,
00489                                  &strehl,
00490                                  &strehl_err,
00491                                  &star_bg,
00492                                  &star_peak,
00493                                  &star_flux,
00494                                  &psf_peak,
00495                                  &psf_flux,
00496                                  &bg_noise);
00497     cpl_test_eq_error(code, CPL_ERROR_NONE);
00498     cpl_test_leq(0.0, strehl);
00499     cpl_test_leq(strehl, 1.0);
00500     cpl_test_leq(0.0, strehl_err);
00501     if (norm > 0.0) {
00502         cpl_test_rel(norm, star_flux, 0.01);
00503     }
00504 
00505     cpl_msg_info(cpl_func, "Strehl: ratio=%g, error=%g; Background: flux=%g, "
00506                  "noise=%g; Star: peak=%g, flux=%g; PSF: peak=%g, flux=%g",
00507                  strehl, strehl_err, star_bg, bg_noise, star_peak, star_flux,
00508                  psf_peak, psf_flux);
00509 
00510     cpl_msg_info(cpl_func, "%-16s %-10.9g %-8.6g %-8.6g %-8.6g %-8.6g "
00511                  "%-8.4g %-8.4g", label, pixscale, lam, dlam, m1, m2,
00512                  strehl, strehl_err);
00513 
00514     /* Test for various errors */
00515 
00516     /* M2 < 0*/
00517     code = irplib_strehl_compute(im1, m1, 0.0,
00518                                  lam, dlam, pixscale,
00519                                  IRPLIB_STREHL_BOX_SIZE, 
00520                                  nx/2, ny/2,
00521                                  star_radius,
00522                                  background_1,
00523                                  background_2,
00524                                  -1, -1,
00525                                  &strehl,
00526                                  &strehl_err,
00527                                  &star_bg,
00528                                  &star_peak,
00529                                  &star_flux,
00530                                  &psf_peak,
00531                                  &psf_flux,
00532                                  &bg_noise);
00533     cpl_test_eq_error(code, CPL_ERROR_ILLEGAL_INPUT);
00534 
00535 
00536     /* M1 < M2 */
00537     code = irplib_strehl_compute(im1, m2, m1,
00538                                  lam, dlam, pixscale,
00539                                  IRPLIB_STREHL_BOX_SIZE, 
00540                                  nx/2, ny/2,
00541                                  star_radius,
00542                                  background_1,
00543                                  background_2,
00544                                  -1, -1,
00545                                  &strehl,
00546                                  &strehl_err,
00547                                  &star_bg,
00548                                  &star_peak,
00549                                  &star_flux,
00550                                  &psf_peak,
00551                                  &psf_flux,
00552                                  &bg_noise);
00553     cpl_test_eq_error(code, CPL_ERROR_ILLEGAL_INPUT);
00554 
00555 
00556     /* lam = 0 */
00557     code = irplib_strehl_compute(im1, m1, m2,
00558                                  0.0, dlam, pixscale,
00559                                  IRPLIB_STREHL_BOX_SIZE, 
00560                                  nx/2, ny/2,
00561                                  star_radius,
00562                                  background_1,
00563                                  background_2,
00564                                  -1, -1,
00565                                  &strehl,
00566                                  &strehl_err,
00567                                  &star_bg,
00568                                  &star_peak,
00569                                  &star_flux,
00570                                  &psf_peak,
00571                                  &psf_flux,
00572                                  &bg_noise);
00573     cpl_test_eq_error(code, CPL_ERROR_ILLEGAL_INPUT);
00574 
00575     /* dlam = 0 */
00576     code = irplib_strehl_compute(im1, m1, m2,
00577                                  lam, 0.0, pixscale,
00578                                  IRPLIB_STREHL_BOX_SIZE, 
00579                                  nx/2, ny/2,
00580                                  star_radius,
00581                                  background_1,
00582                                  background_2,
00583                                  -1, -1,
00584                                  &strehl,
00585                                  &strehl_err,
00586                                  &star_bg,
00587                                  &star_peak,
00588                                  &star_flux,
00589                                  &psf_peak,
00590                                  &psf_flux,
00591                                  &bg_noise);
00592     cpl_test_eq_error(code, CPL_ERROR_ILLEGAL_INPUT);
00593 
00594     /* pixscale = 0 */
00595     code = irplib_strehl_compute(im1, m1, m2,
00596                                  lam, dlam, 0.0,
00597                                  IRPLIB_STREHL_BOX_SIZE, 
00598                                  nx/2, ny/2,
00599                                  star_radius,
00600                                  background_1,
00601                                  background_2,
00602                                  -1, -1,
00603                                  &strehl,
00604                                  &strehl_err,
00605                                  &star_bg,
00606                                  &star_peak,
00607                                  &star_flux,
00608                                  &psf_peak,
00609                                  &psf_flux,
00610                                  &bg_noise);
00611     cpl_test_eq_error(code, CPL_ERROR_ILLEGAL_INPUT);
00612 
00613     /* IRPLIB_STREHL_BOX_SIZE = 0 */
00614     code = irplib_strehl_compute(im1, m1, m2,
00615                                  lam, dlam, pixscale,
00616                                  0, 
00617                                  nx/2, ny/2,
00618                                  star_radius,
00619                                  background_1,
00620                                  background_2,
00621                                  -1, -1,
00622                                  &strehl,
00623                                  &strehl_err,
00624                                  &star_bg,
00625                                  &star_peak,
00626                                  &star_flux,
00627                                  &psf_peak,
00628                                  &psf_flux,
00629                                  &bg_noise);
00630     cpl_test_eq_error(code, CPL_ERROR_ILLEGAL_INPUT);
00631 
00632     /* star_radius = 0 */
00633     code = irplib_strehl_compute(im1, m1, m2,
00634                                  lam, dlam, pixscale,
00635                                  IRPLIB_STREHL_BOX_SIZE, 
00636                                  nx/2, ny/2,
00637                                  0.0,
00638                                  background_1,
00639                                  background_2,
00640                                  -1, -1,
00641                                  &strehl,
00642                                  &strehl_err,
00643                                  &star_bg,
00644                                  &star_peak,
00645                                  &star_flux,
00646                                  &psf_peak,
00647                                  &psf_flux,
00648                                  &bg_noise);
00649     cpl_test_eq_error(code, CPL_ERROR_ILLEGAL_INPUT);
00650 
00651     /* background_1 = 0 */
00652     code = irplib_strehl_compute(im1, m1, m2,
00653                                  lam, dlam, pixscale,
00654                                  IRPLIB_STREHL_BOX_SIZE, 
00655                                  nx/2, ny/2,
00656                                  star_radius,
00657                                  0.0,
00658                                  background_2,
00659                                  -1, -1,
00660                                  &strehl,
00661                                  &strehl_err,
00662                                  &star_bg,
00663                                  &star_peak,
00664                                  &star_flux,
00665                                  &psf_peak,
00666                                  &psf_flux,
00667                                  &bg_noise);
00668     cpl_test_eq_error(code, CPL_ERROR_ILLEGAL_INPUT);
00669 
00670     /* background_2 too small */
00671     code = irplib_strehl_compute(im1, m1, m2,
00672                                  lam, dlam, pixscale,
00673                                  IRPLIB_STREHL_BOX_SIZE, 
00674                                  nx/2, ny/2,
00675                                  star_radius,
00676                                  background_1,
00677                                  background_1,
00678                                  -1, -1,
00679                                  &strehl,
00680                                  &strehl_err,
00681                                  &star_bg,
00682                                  &star_peak,
00683                                  &star_flux,
00684                                  &psf_peak,
00685                                  &psf_flux,
00686                                  &bg_noise);
00687     cpl_test_eq_error(code, CPL_ERROR_ILLEGAL_INPUT);
00688 
00689     /* strehl pointer is NULL */
00690     code = irplib_strehl_compute(im1, m1, m2,
00691                                  lam, dlam, pixscale,
00692                                  IRPLIB_STREHL_BOX_SIZE, 
00693                                  nx/2, ny/2,
00694                                  star_radius,
00695                                  background_1,
00696                                  background_2,
00697                                  -1, -1,
00698                                  NULL,
00699                                  &strehl_err,
00700                                  &star_bg,
00701                                  &star_peak,
00702                                  &star_flux,
00703                                  &psf_peak,
00704                                  &psf_flux,
00705                                  &bg_noise);
00706     cpl_test_eq_error(code, CPL_ERROR_NULL_INPUT);
00707 
00708     /* strehl_err pointer is NULL */
00709     code = irplib_strehl_compute(im1, m1, m2,
00710                                  lam, dlam, pixscale,
00711                                  IRPLIB_STREHL_BOX_SIZE, 
00712                                  nx/2, ny/2,
00713                                  star_radius,
00714                                  background_1,
00715                                  background_2,
00716                                  -1, -1,
00717                                  &strehl,
00718                                  NULL,
00719                                  &star_bg,
00720                                  &star_peak,
00721                                  &star_flux,
00722                                  &psf_peak,
00723                                  &psf_flux,
00724                                  &bg_noise);
00725     cpl_test_eq_error(code, CPL_ERROR_NULL_INPUT);
00726 
00727     /* star_bg pointer is NULL */
00728     code = irplib_strehl_compute(im1, m1, m2,
00729                                  lam, dlam, pixscale,
00730                                  IRPLIB_STREHL_BOX_SIZE, 
00731                                  nx/2, ny/2,
00732                                  star_radius,
00733                                  background_1,
00734                                  background_2,
00735                                  -1, -1,
00736                                  &strehl,
00737                                  &strehl_err,
00738                                  NULL,
00739                                  &star_peak,
00740                                  &star_flux,
00741                                  &psf_peak,
00742                                  &psf_flux,
00743                                  &bg_noise);
00744     cpl_test_eq_error(code, CPL_ERROR_NULL_INPUT);
00745 
00746     /* star_peak pointer is NULL */
00747     code = irplib_strehl_compute(im1, m1, m2,
00748                                  lam, dlam, pixscale,
00749                                  IRPLIB_STREHL_BOX_SIZE, 
00750                                  nx/2, ny/2,
00751                                  star_radius,
00752                                  background_1,
00753                                  background_2,
00754                                  -1, -1,
00755                                  &strehl,
00756                                  &strehl_err,
00757                                  &star_bg,
00758                                  NULL,
00759                                  &star_flux,
00760                                  &psf_peak,
00761                                  &psf_flux,
00762                                  &bg_noise);
00763     cpl_test_eq_error(code, CPL_ERROR_NULL_INPUT);
00764 
00765     /* psf_peak pointer is NULL */
00766     code = irplib_strehl_compute(im1, m1, m2,
00767                                  lam, dlam, pixscale,
00768                                  IRPLIB_STREHL_BOX_SIZE, 
00769                                  nx/2, ny/2,
00770                                  star_radius,
00771                                  background_1,
00772                                  background_2,
00773                                  -1, -1,
00774                                  &strehl,
00775                                  &strehl_err,
00776                                  &star_bg,
00777                                  &star_peak,
00778                                  &star_flux,
00779                                  NULL,
00780                                  &psf_flux,
00781                                  &bg_noise);
00782     cpl_test_eq_error(code, CPL_ERROR_NULL_INPUT);
00783 
00784     /* psf_flux pointer is NULL */
00785     code = irplib_strehl_compute(im1, m1, m2,
00786                                  lam, dlam, pixscale,
00787                                  IRPLIB_STREHL_BOX_SIZE, 
00788                                  nx/2, ny/2,
00789                                  star_radius,
00790                                  background_1,
00791                                  background_2,
00792                                  -1, -1,
00793                                  &strehl,
00794                                  &strehl_err,
00795                                  &star_bg,
00796                                  &star_peak,
00797                                  &star_flux,
00798                                  &psf_peak,
00799                                  NULL,
00800                                  &bg_noise);
00801     cpl_test_eq_error(code, CPL_ERROR_NULL_INPUT);
00802 
00803 
00804     /* bg_noise pointer is NULL */
00805     code = irplib_strehl_compute(im1, m1, m2,
00806                                  lam, dlam, pixscale,
00807                                  IRPLIB_STREHL_BOX_SIZE, 
00808                                  nx/2, ny/2,
00809                                  star_radius,
00810                                  background_1,
00811                                  background_2,
00812                                  -1, -1,
00813                                  &strehl,
00814                                  &strehl_err,
00815                                  &star_bg,
00816                                  &star_peak,
00817                                  &star_flux,
00818                                  &psf_peak,
00819                                  &psf_flux,
00820                                  NULL);
00821     cpl_test_eq_error(code, CPL_ERROR_NULL_INPUT);
00822 }
00823 
00824 
00825 /*----------------------------------------------------------------------------*/
00835 /*----------------------------------------------------------------------------*/
00836 static const char * irplib_get_base_name(const char * self)
00837 {
00838     const char * p = self ? strrchr(self, '/') : NULL;
00839 
00840     return p ? p + 1 : self;
00841 }
Generated on Mon Feb 17 15:01:44 2014 for NACO Pipeline Reference Manual by  doxygen 1.6.3