FORS Pipeline Reference Manual 4.9.20
fors_img_science-test.c
00001 /* $Id: fors_img_science-test.c,v 1.6 2011/07/19 15:50:16 cgarcia Exp $
00002  *
00003  * This file is part of the FORS Library
00004  * Copyright (C) 2002-2006 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  02110-1301 USA
00019  */
00020 
00021 /*
00022  * $Author: cgarcia $
00023  * $Date: 2011/07/19 15:50:16 $
00024  * $Revision: 1.6 $
00025  * $Name: fors-4_9_20 $
00026  */
00027 
00028 #ifdef HAVE_CONFIG_H
00029 #include <config.h>
00030 #endif
00031 
00032 #include <fors_img_science_impl.h>
00033 #include <fors_dfs.h>
00034 #include <fors_utils.h>
00035 
00036 #include <test_simulate.h>
00037 #include <test.h>
00038 
00046 #undef cleanup
00047 #define cleanup \
00048 do { \
00049     cpl_frameset_delete(frames); \
00050     cpl_parameterlist_delete(parameters); \
00051 } while(0)
00052 
00056 static void
00057 test_img_science(void)
00058 {
00059     /* Input */
00060     cpl_frameset      *frames     = cpl_frameset_new();
00061     cpl_parameterlist *parameters = cpl_parameterlist_new();
00062     cpl_parameter     *p          = NULL;
00063     double exptime = 1.0;
00064     /* Products */
00065     
00066     /* Simulate data */
00067     cpl_frameset_insert(frames, create_standard("img_science_standard_img.fits",
00068                                                 SCIENCE_IMG,
00069                                                 CPL_FRAME_GROUP_RAW));
00070     cpl_frameset_insert(frames, create_bias("img_science_master_bias.fits",
00071                                             MASTER_BIAS,
00072                                             CPL_FRAME_GROUP_CALIB));
00073     cpl_frameset_insert(frames, create_sky_flat("img_science_master_sky_flat.fits",
00074                                                 MASTER_SKY_FLAT_IMG,
00075                                                 CPL_FRAME_GROUP_CALIB, exptime));
00076     cpl_frameset_insert(frames, create_std_cat("img_science_std_cat.fits",
00077                                                FLX_STD_IMG,
00078                                                CPL_FRAME_GROUP_CALIB));
00079     cpl_frameset_insert(frames, create_phot_table("img_science_phot_table.fits",
00080                                                   PHOT_TABLE,
00081                                                   CPL_FRAME_GROUP_CALIB));
00082     
00083     /* Set parameters */
00084     fors_img_science_define_parameters(parameters);
00085     p = cpl_parameter_new_enum("fors.fors_img_science.extract_method",
00086                                CPL_TYPE_STRING,
00087                                "Source extraction method",
00088                                "fors.fors_img_science",
00089                                "sex", 2,
00090                                "sex", "test");
00091     cpl_parameterlist_append(parameters, p);
00092     assure( !cpl_error_get_code(), return, 
00093             "Create parameters failed");
00094     
00095     fors_parameterlist_set_defaults(parameters);
00096  
00097     /* Do not rely on SExtractor for this unit test */
00098     cpl_parameter_set_string(cpl_parameterlist_find(parameters,
00099                                                     "fors.fors_img_science.extract_method"),
00100                              "test");
00101 
00102     fors_img_science(frames, parameters);
00103 
00104     /* Test existence of QC + products */
00105     const char *const product_tags[] = {SOURCES_SCI, 
00106                                         SCIENCE_REDUCED_IMG, 
00107                                         PHOTOMETRY_TABLE,
00108                                         PHOT_BACKGROUND_SCI_IMG};
00109     const char *main_product = SCIENCE_REDUCED_IMG;
00110 
00111     const char *const qc[] = 
00112         {"QC SKYAVG", "QC SKYMED", "QC SKYRMS",
00113          "QC IMGQU", "QC IMGQUERR", "QC STELLAVG", 
00114          "QC IMGQUELL", "QC IMGQUELLERR"};
00115     test_recipe_output(frames, 
00116                        product_tags, sizeof product_tags / sizeof *product_tags,
00117                main_product,
00118                        qc, sizeof qc / sizeof *qc);
00119         
00120     cleanup;
00121     return;
00122 }
00123 
00124 
00128 int main(void)
00129 {
00130     TEST_INIT;
00131 
00132     /* cpl_msg_set_level(CPL_MSG_DEBUG); */
00133     test_img_science();
00134 
00135     TEST_END;
00136 }
00137