FORS Pipeline Reference Manual  4.12.5
fors_zeropoint-test.c
1 /* $Id: fors_zeropoint-test.c,v 1.18 2011-07-19 15:49:52 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:49:52 $
24  * $Revision: 1.18 $
25  * $Name: not supported by cvs2svn $
26  */
27 
28 #ifdef HAVE_CONFIG_H
29 #include <config.h>
30 #endif
31 
32 #include <fors_zeropoint_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("zeropoint_standard_img.fits",
68  STANDARD_IMG,
69  CPL_FRAME_GROUP_RAW));
70  cpl_frameset_insert(frames, create_bias("zeropoint_master_bias.fits",
71  MASTER_BIAS,
72  CPL_FRAME_GROUP_CALIB));
73  cpl_frameset_insert(frames, create_sky_flat("zeropoint_master_sky_flat.fits",
74  MASTER_SKY_FLAT_IMG,
75  CPL_FRAME_GROUP_CALIB, exptime));
76  cpl_frameset_insert(frames, create_std_cat("zeropoint_std_cat.fits",
77  FLX_STD_IMG,
78  CPL_FRAME_GROUP_CALIB));
79  cpl_frameset_insert(frames, create_phot_table("zeropoint_phot_table.fits",
80  PHOT_TABLE,
81  CPL_FRAME_GROUP_CALIB));
82 
83  /* Set parameters */
84  fors_zeropoint_define_parameters(parameters);
85  p = cpl_parameter_new_enum("fors.fors_zeropoint.extract_method",
86  CPL_TYPE_STRING,
87  "Source extraction method",
88  "fors.fors_zeropoint",
89  "sex", 2,
90  "sex", "test");
91  cpl_parameterlist_append(parameters, p);
92 
93  assure( !cpl_error_get_code(), return,
94  "Create parameters failed");
95 
97 
98  /* Do not rely on SExtractor for this unit test */
99  cpl_parameter_set_string(cpl_parameterlist_find(parameters,
100  "fors.fors_zeropoint.extract_method"),
101  "test");
102 
103  /* Note: the extracted source positions do not match the catalogue,
104  but the recipe will find a solution anyway by increasing the
105  search radius. Suppress warnings */
106  cpl_msg_severity before = cpl_msg_get_level();
107  cpl_msg_set_level(CPL_MSG_ERROR);
108 
109 // Disable test until pattern-matching vs robust shift is decided.
110 cleanup;
111 return;
112 
113  fors_zeropoint(frames, parameters);
114 
115  cpl_msg_set_level(before);
116 
117 
118 
119  /* Test existence of QC + products */
120  const char *const product_tags[] = {SOURCES_STD,
121  ALIGNED_PHOT,
122  STANDARD_REDUCED_IMG,
123  PHOT_BACKGROUND_STD_IMG};
124  const char *const qc[] =
125  {"QC ZPOINT", "QC ZPOINTRMS", "QC ZPOINT NSTARS",
126  "QC EXTCOEFF"};
127  const char *main_product = ALIGNED_PHOT;
128 
129  test_recipe_output(frames,
130  product_tags, sizeof product_tags / sizeof *product_tags,
131  main_product,
132  qc, sizeof qc / sizeof *qc);
133 
134  cleanup;
135  return;
136 }
137 
138 
142 int main(void)
143 {
144  TEST_INIT;
145 
146  /* cpl_msg_set_level(CPL_MSG_DEBUG); */
147  test_zeropoint();
148 
149  TEST_END;
150 }
151 
int main(void)
Test of zeropoint recipe.
cpl_frame * create_bias(const char *filename, const char *tag, cpl_frame_group group)
Simulate bias image.
#define assure(EXPR)
Definition: list.c:101
static void test_zeropoint(void)
Test zeropoint recipe.
cpl_frame * create_std_cat(const char *filename, const char *tag, cpl_frame_group group)
Create standard star catalogue.
cpl_frame * create_sky_flat(const char *filename, const char *tag, cpl_frame_group group, double exptime)
Simulate sky flat image.
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.