00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifdef HAVE_CONFIG_H
00029 #include <config.h>
00030 #endif
00031
00032 #include <fors_img_screen_flat_impl.h>
00033 #include <fors_dfs.h>
00034 #include <fors_pfits.h>
00035 #include <fors_utils.h>
00036
00037 #include <test_simulate.h>
00038 #include <test.h>
00039
00040 #include <cpl.h>
00041 #include <math.h>
00042
00049 #undef cleanup
00050 #define cleanup \
00051 do { \
00052 cpl_frameset_delete(frames); \
00053 cpl_parameterlist_delete(parameters); \
00054 fors_image_delete(&raw_sflat); \
00055 fors_image_delete(&master_sflat); \
00056 fors_image_delete(&master_bias); \
00057 fors_setting_delete(&setting); \
00058 cpl_propertylist_delete(product_header); \
00059 } while(0)
00060
00064 static void
00065 test_img_screen_flat(void)
00066 {
00067
00068 cpl_frameset *frames = cpl_frameset_new();
00069 cpl_parameterlist *parameters = cpl_parameterlist_new();
00070
00071
00072 fors_image *raw_sflat = NULL;
00073 fors_image *master_sflat = NULL;
00074 fors_image *master_bias = NULL;
00075 fors_setting *setting = NULL;
00076 cpl_propertylist *product_header = NULL;
00077
00078
00079 const char *screen_flat_filename[] = {"img_screen_flat_1.fits",
00080 "img_screen_flat_2.fits",
00081 "img_screen_flat_3.fits"};
00082 const unsigned N = sizeof(screen_flat_filename)/sizeof(char *);
00083
00084 {
00085 unsigned i;
00086
00087 for (i = 0; i < N; i++) {
00088 cpl_frameset_insert(
00089 frames,
00090 create_screen_flat(screen_flat_filename[i],
00091 SCREEN_FLAT_IMG, CPL_FRAME_GROUP_RAW));
00092 }
00093 }
00094
00095 cpl_frameset_insert(frames,
00096 create_bias("img_screen_flat_master_bias.fits",
00097 MASTER_BIAS, CPL_FRAME_GROUP_CALIB));
00098
00099
00100 fors_img_screen_flat_define_parameters(parameters);
00101
00102 assure( !cpl_error_get_code(), return,
00103 "Create parameters failed");
00104
00105 fors_parameterlist_set_defaults(parameters);
00106
00107 cpl_parameter_set_int(cpl_parameterlist_find(parameters,
00108 "fors.fors_img_screen_flat.xradius"),
00109 1);
00110 cpl_parameter_set_int(cpl_parameterlist_find(parameters,
00111 "fors.fors_img_screen_flat.yradius"),
00112 1);
00113
00114 cpl_parameter_set_int(cpl_parameterlist_find(parameters,
00115 "fors.fors_img_screen_flat.degree"),
00116 -1);
00117
00118
00119 fors_img_screen_flat(frames, parameters);
00120 assure( !cpl_error_get_code(), return,
00121 "Execution error");
00122
00123
00124
00125
00126 const char *const product_tags[] = {MASTER_SCREEN_FLAT_IMG,
00127 MASTER_NORM_FLAT_IMG};
00128 const char *const qc[] = {"QC OVEREXPO",
00129 "QC FLAT EFF",
00130 "QC FLAT PHN",
00131 "QC FLAT FPN",
00132 "QC FLAT CONAD",
00133 "QC FLAT CONADERR"};
00134
00135 test_recipe_output(frames,
00136 product_tags, sizeof product_tags / sizeof *product_tags,
00137 MASTER_NORM_FLAT_IMG,
00138 qc, sizeof qc / sizeof *qc);
00139
00140
00141 setting = fors_setting_new(cpl_frameset_find(frames,
00142 SCREEN_FLAT_IMG));
00143
00144 {
00145
00146 test( cpl_frameset_find(frames, MASTER_SCREEN_FLAT_IMG) != NULL );
00147 test( cpl_frameset_find(frames, MASTER_NORM_FLAT_IMG) != NULL );
00148 test( cpl_frameset_find(frames, MASTER_BIAS) != NULL );
00149 test( cpl_frameset_find(frames, SCREEN_FLAT_IMG) != NULL );
00150
00151 master_sflat = fors_image_load(
00152 cpl_frameset_find(frames, MASTER_NORM_FLAT_IMG), NULL, setting, NULL);
00153 master_bias = fors_image_load(
00154 cpl_frameset_find(frames, MASTER_BIAS), NULL, setting, NULL);
00155
00156 raw_sflat = fors_image_load(
00157 cpl_frameset_find(frames, SCREEN_FLAT_IMG), master_bias, setting, NULL);
00158
00159
00160 test( fors_image_get_error_mean(master_sflat, NULL) /
00161 fors_image_get_mean(master_sflat, NULL)
00162 <
00163 fors_image_get_error_mean(raw_sflat, NULL) /
00164 fors_image_get_mean(raw_sflat, NULL));
00165
00166
00167 test_rel( fors_image_get_mean(master_sflat, NULL),
00168 1.0, 0.01);
00169
00170
00171 product_header =
00172 cpl_propertylist_load(cpl_frame_get_filename(
00173 cpl_frameset_find(frames,
00174 MASTER_NORM_FLAT_IMG)),
00175 0);
00176 assure( product_header != NULL, return, NULL );
00177
00178
00179 test_rel( cpl_propertylist_get_double(product_header,
00180 "ESO QC FLAT EFF"),
00181 fors_image_get_median(raw_sflat, NULL) / setting->exposure_time,
00182 0.01 );
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197 test_rel( cpl_propertylist_get_double(product_header,
00198 "ESO QC FLAT CONAD"),
00199 cpl_propertylist_get_double(product_header,
00200 FORS_PFITS_CONAD[0]),
00201
00202 0.1);
00203
00204 test( cpl_propertylist_get_double(product_header,
00205 "ESO QC FLAT CONADERR") <
00206 0.1 * cpl_propertylist_get_double(product_header,
00207 "ESO QC FLAT CONAD") );
00208 }
00209
00210 cleanup;
00211 return;
00212 }
00213
00217 int main(void)
00218 {
00219 TEST_INIT;
00220
00221 test_img_screen_flat();
00222
00223 TEST_END;
00224 }
00225