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_dark_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_image_delete(&raw_dark); \
00053 fors_image_delete(&master_dark); \
00054 fors_image_delete(&master_bias); \
00055 fors_setting_delete(&setting); \
00056 } while(0)
00057
00061 static void
00062 test_dark(void)
00063 {
00064
00065 cpl_frameset *frames = cpl_frameset_new();
00066 cpl_parameterlist *parameters = cpl_parameterlist_new();
00067
00068
00069 fors_image *master_dark = NULL;
00070 fors_image *master_bias = NULL;
00071 fors_image *raw_dark = NULL;
00072
00073 fors_setting *setting = NULL;
00074
00075
00076 const char *dark_filename[] = {"dark_1.fits",
00077 "dark_2.fits",
00078 "dark_3.fits"};
00079
00080 {
00081 unsigned i;
00082
00083 for (i = 0; i < sizeof(dark_filename)/sizeof(char *); i++) {
00084 cpl_frameset_insert(frames,
00085 create_dark(dark_filename[i],
00086 DARK, CPL_FRAME_GROUP_RAW));
00087 }
00088 }
00089
00090 setting = fors_setting_new(cpl_frameset_get_first(frames));
00091
00092 cpl_frameset_insert(frames,
00093 create_bias("dark_master_bias.fits",
00094 MASTER_BIAS, CPL_FRAME_GROUP_CALIB));
00095
00096 fors_dark_define_parameters(parameters);
00097 assure( !cpl_error_get_code(), return,
00098 "Create parameters failed");
00099
00100 fors_parameterlist_set_defaults(parameters);
00101
00102
00103 fors_dark(frames, parameters);
00104 assure( !cpl_error_get_code(), return,
00105 "Execution error");
00106
00107
00108 {
00109
00110 test( cpl_frameset_find(frames, MASTER_DARK) != NULL );
00111 test( cpl_frameset_find(frames, MASTER_BIAS) != NULL );
00112 test( cpl_frameset_find(frames, DARK) != NULL );
00113
00114 master_dark = fors_image_load(
00115 cpl_frameset_find(frames, MASTER_DARK), NULL, setting, NULL);
00116
00117 master_bias = fors_image_load(
00118 cpl_frameset_find(frames, MASTER_BIAS), NULL, setting, NULL);
00119
00120 raw_dark = fors_image_load(
00121 cpl_frameset_find(frames, DARK), NULL, setting, NULL);
00122
00123
00124
00125 test_rel( fors_image_get_mean(master_dark, NULL),
00126 fors_image_get_mean(raw_dark, NULL) -
00127 fors_image_get_mean(master_bias, NULL),
00128 0.01);
00129
00130
00131 {
00132 test( fors_image_get_error_mean(master_dark, NULL) /
00133 (fors_image_get_mean(master_dark, NULL) +
00134 fors_image_get_mean(master_bias, NULL))
00135 <
00136 fors_image_get_error_mean(raw_dark, NULL) /
00137 fors_image_get_mean(raw_dark, NULL));
00138 }
00139 }
00140
00141 cleanup;
00142 return;
00143 }
00144
00148 int main(void)
00149 {
00150 TEST_INIT;
00151
00152 test_dark();
00153
00154 TEST_END;
00155 }
00156