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_bias_impl.h>
00033 #include <fors_dfs.h>
00034 #include <fors_utils.h>
00035
00036 #include <test_simulate.h>
00037 #include <test.h>
00038
00039 #include <cpl.h>
00040
00047 #undef cleanup
00048 #define cleanup \
00049 do { \
00050 cpl_frameset_delete(frames); \
00051 cpl_parameterlist_delete(parameters); \
00052 fors_setting_delete(&setting); \
00053 fors_image_delete(&raw_bias); \
00054 fors_image_delete(&master_bias); \
00055 cpl_propertylist_delete(product_header); \
00056 } while(0)
00057
00061 static void
00062 test_bias(void)
00063 {
00064
00065 cpl_frameset *frames = cpl_frameset_new();
00066 cpl_parameterlist *parameters = cpl_parameterlist_new();
00067
00068
00069 fors_image *master_bias = NULL;
00070 fors_image *raw_bias = NULL;
00071 cpl_propertylist *product_header = NULL;
00072
00073 fors_setting *setting = NULL;
00074
00075
00076 const char *bias_filename[] = {"bias_1.fits",
00077 "bias_2.fits",
00078 "bias_3.fits",
00079 "bias_4.fits",
00080 "bias_5.fits"};
00081
00082 {
00083 unsigned i;
00084
00085 for (i = 0; i < sizeof(bias_filename)/sizeof(char *); i++) {
00086 cpl_frameset_insert(frames,
00087 create_bias(bias_filename[i],
00088 BIAS, CPL_FRAME_GROUP_RAW));
00089 }
00090 }
00091
00092 setting = fors_setting_new(cpl_frameset_get_first(frames));
00093
00094 fors_bias_define_parameters(parameters);
00095 assure( !cpl_error_get_code(), return,
00096 "Create parameters failed");
00097
00098 fors_parameterlist_set_defaults(parameters);
00099
00100
00101 fors_bias(frames, parameters);
00102 assure( !cpl_error_get_code(), return,
00103 "Execution error");
00104
00105
00106 const char *const product_tags[] = {MASTER_BIAS};
00107 const char *const qc[] =
00108 {"QC BIAS STRUCT", "QC BIAS LEVEL", "QC RON", "QC BIAS FPN",
00109 "QC MBIAS LEVEL",
00110 "QC MBIAS RONEXP", "QC MBIAS NOISE", "QC MBIAS NRATIO", "QC MBIAS STRUCT"};
00111 test_recipe_output(frames,
00112 product_tags, sizeof product_tags / sizeof *product_tags,
00113 MASTER_BIAS,
00114 qc, sizeof qc / sizeof *qc);
00115
00116
00117 {
00118
00119 test( cpl_frameset_find(frames, BIAS) != NULL );
00120
00121 master_bias = fors_image_load(
00122 cpl_frameset_find(frames, MASTER_BIAS), NULL, setting, NULL);
00123
00124 raw_bias = fors_image_load(
00125 cpl_frameset_find(frames, BIAS), NULL, setting, NULL);
00126
00127
00128 test( fors_image_get_error_mean(master_bias, NULL) /
00129 fors_image_get_mean(master_bias, NULL)
00130 <
00131 fors_image_get_error_mean(raw_bias, NULL) /
00132 fors_image_get_mean(raw_bias, NULL));
00133
00134
00135
00136 product_header =
00137 cpl_propertylist_load(cpl_frame_get_filename(
00138 cpl_frameset_find(frames,
00139 MASTER_BIAS)),
00140 0);
00141 assure( product_header != NULL, return, NULL );
00142
00143 test_rel( cpl_propertylist_get_double(product_header,
00144 "ESO QC BIAS LEVEL"),
00145 fors_image_get_median(master_bias, NULL), 0.01 );
00146
00147 test_rel( cpl_propertylist_get_double(product_header,
00148 "ESO QC MBIAS LEVEL"),
00149 fors_image_get_median(master_bias, NULL), 0.01 );
00150
00151 test_rel( cpl_propertylist_get_double(product_header,
00152 "ESO QC RON"),
00153 fors_image_get_stdev(raw_bias, NULL), 0.10 );
00154
00155
00156 test_abs( cpl_propertylist_get_double(product_header,
00157 "ESO QC BIAS FPN"),
00158 0, 0.01*fors_image_get_median(master_bias, NULL));
00159
00160 test_abs( cpl_propertylist_get_double(product_header,
00161 "ESO QC BIAS STRUCT"),
00162 0, 0.01*fors_image_get_median(master_bias, NULL));
00163 }
00164
00165 cleanup;
00166 return;
00167 }
00168
00172 int main(void)
00173 {
00174 TEST_INIT;
00175
00176 test_bias();
00177
00178 TEST_END;
00179 }
00180