FORS Pipeline Reference Manual  5.0.9
fors_img_science-test.c
1 /* $Id: fors_img_science-test.c,v 1.6 2011-07-19 15:50:16 cgarcia Exp $
2  *
3  * This file is part of the FORS Library
4  * Copyright (C) 2002-2006 European Southern Observatory
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 /*
22  * $Author: cgarcia $
23  * $Date: 2011-07-19 15:50:16 $
24  * $Revision: 1.6 $
25  * $Name: not supported by cvs2svn $
26  */
27 
28 #ifdef HAVE_CONFIG_H
29 #include <config.h>
30 #endif
31 
32 #include <fors_img_science_impl.h>
33 #include <fors_dfs.h>
34 #include <fors_utils.h>
35 
36 #include <test_simulate.h>
37 #include <test.h>
38 
46 #undef cleanup
47 #define cleanup \
48 do { \
49  cpl_frameset_delete(frames); \
50  cpl_parameterlist_delete(parameters); \
51 } while(0)
52 
56 static void
58 {
59  /* Input */
60  cpl_frameset *frames = cpl_frameset_new();
61  cpl_parameterlist *parameters = cpl_parameterlist_new();
62  cpl_parameter *p = NULL;
63  double exptime = 1.0;
64  /* Products */
65 
66  /* Simulate data */
67  cpl_frameset_insert(frames, create_standard("img_science_standard_img.fits",
68  SCIENCE_IMG,
69  CPL_FRAME_GROUP_RAW));
70  cpl_frameset_insert(frames, create_master_bias("img_science_master_bias.fits",
71  MASTER_BIAS,
72  CPL_FRAME_GROUP_CALIB));
73  cpl_frameset_insert(frames, create_master_sky_flat("img_science_master_sky_flat.fits",
74  MASTER_SKY_FLAT_IMG,
75  CPL_FRAME_GROUP_CALIB, exptime));
76  cpl_frameset_insert(frames, create_std_cat("img_science_std_cat.fits",
77  FLX_STD_IMG,
78  CPL_FRAME_GROUP_CALIB));
79  cpl_frameset_insert(frames, create_phot_table("img_science_phot_table.fits",
80  PHOT_TABLE,
81  CPL_FRAME_GROUP_CALIB));
82 
83  /* Set parameters */
84  fors_img_science_define_parameters(parameters);
85  p = cpl_parameter_new_enum("fors.fors_img_science.extract_method",
86  CPL_TYPE_STRING,
87  "Source extraction method",
88  "fors.fors_img_science",
89  "sex", 2,
90  "sex", "test");
91  cpl_parameterlist_append(parameters, p);
92  assure( !cpl_error_get_code(), return,
93  "Create parameters failed");
94 
96 
97  /* Do not rely on SExtractor for this unit test */
98  cpl_parameter_set_string(cpl_parameterlist_find(parameters,
99  "fors.fors_img_science.extract_method"),
100  "test");
101 
102  fors_img_science(frames, parameters);
103 
104  /* Test existence of QC + products */
105  const char *const product_tags[] = {SOURCES_SCI,
106  SCIENCE_REDUCED_IMG,
107  PHOTOMETRY_TABLE,
108  PHOT_BACKGROUND_SCI_IMG};
109  const char *main_product = SCIENCE_REDUCED_IMG;
110 
111  const char *const qc[] =
112  {"QC SKYAVG", "QC SKYMED", "QC SKYRMS",
113  "QC IMGQU", "QC IMGQUERR", "QC STELLAVG",
114  "QC IMGQUELL", "QC IMGQUELLERR"};
115  test_recipe_output(frames,
116  product_tags, sizeof product_tags / sizeof *product_tags,
117  main_product,
118  qc, sizeof qc / sizeof *qc);
119 
120  cleanup;
121  return;
122 }
123 
124 
128 int main(void)
129 {
130  TEST_INIT;
131 
132  /* cpl_msg_set_level(CPL_MSG_DEBUG); */
134 
135  TEST_END;
136 }
137 
cpl_frame * create_master_sky_flat(const char *filename, const char *tag, cpl_frame_group group, double exptime)
Simulate master sky flat image.
int main(void)
Test of img_science recipe.
cpl_frame * create_master_bias(const char *filename, const char *tag, cpl_frame_group group)
Simulate master bias image.
#define assure(EXPR)
Definition: list.c:101
cpl_frame * create_std_cat(const char *filename, const char *tag, cpl_frame_group group)
Create standard star catalogue.
static void test_img_science(void)
Test science recipe.
cpl_frame * create_phot_table(const char *filename, const char *tag, cpl_frame_group group)
Create photometry table.
void test_recipe_output(const cpl_frameset *frames, const char *const product_tags[], int n_prod, const char *main_product, const char *const qc[], int n_qc)
Test existence of recipe products.
Definition: test.c:428
void fors_parameterlist_set_defaults(cpl_parameterlist *parlist)
Set unset parameters to default value.
Definition: fors_utils.c:545
cpl_frame * create_standard(const char *filename, const char *tag, cpl_frame_group group)
Create standard star image.