uves_corrbadpix-test.c
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
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062 #ifdef HAVE_CONFIG_H
00063 # include <config.h>
00064 #endif
00065
00066 #include <uves_corrbadpix.h>
00067 #include <uves_chip.h>
00068 #include <uves_utils_wrappers.h>
00069 #include <uves_error.h>
00070 #include <cpl_test.h>
00071
00072 #include <cpl.h>
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00086
00089
00093
00094 static void
00095 test_bad_corr(void)
00096 {
00097 cpl_image *master_bias = NULL;
00098 uves_propertylist *header = uves_propertylist_new();
00099 int **map = NULL;
00100 int mark_bad;
00101 int blue, binx, biny;
00102
00103
00104 map = cpl_calloc(1, sizeof(int*));
00105 map[0] = cpl_calloc(4, sizeof(int));
00106 map[0][0] = -1;
00107 map[0][1] = -1;
00108 map[0][2] = -1;
00109 map[0][3] = -1;
00110 uves_badmap_free(&map);
00111
00112
00113 map = cpl_calloc(3, sizeof(int*));
00114 map[0] = cpl_calloc(4, sizeof(int));
00115 map[0][0] = 1;
00116 map[0][1] = 2;
00117 map[0][2] = 3;
00118 map[0][3] = 4;
00119 map[1] = cpl_calloc(4, sizeof(int));
00120 map[1][0] = 5;
00121 map[1][1] = 6;
00122 map[1][2] = 7;
00123 map[1][3] = 8;
00124 map[2] = cpl_calloc(4, sizeof(int));
00125 map[2][0] = -1;
00126 map[2][1] = -1;
00127 map[2][2] = -1;
00128 map[2][3] = -1;
00129 uves_badmap_free(&map);
00130
00131 for (blue = 0; blue <= 1; blue++)
00132 for (binx = 1; binx <= 3; binx++)
00133 for (biny = 1; biny <= 3; biny++)
00134 if (!(
00135 (binx == 1 && biny == 3) ||
00136 (binx == 2 && biny == 1) ||
00137 (binx == 3 && biny == 1) ||
00138 (binx == 3 && biny == 2) ||
00139 (binx == 3 && biny == 3)
00140 )){
00141 enum uves_chip chip;
00142 for (chip = uves_chip_get_first(blue);
00143 chip != UVES_CHIP_INVALID;
00144 chip = uves_chip_get_next(chip))
00145 {
00146 uves_free_image(&master_bias);
00147 master_bias = cpl_image_new(4096/biny, 2048/binx, CPL_TYPE_DOUBLE);
00148 assure_mem( master_bias );
00149
00150 for (mark_bad = 0; mark_bad <= 1; mark_bad++)
00151 {
00152 int expected_size;
00153
00154
00155 check( map = uves_get_badpix(chip, binx, biny, mark_bad,0),
00156 "Error getting bad pixel map");
00157 uves_badmap_free(&map);
00158
00159
00160 uves_propertylist_empty(header);
00161 check( uves_correct_badpix_all(master_bias, header,
00162 chip,
00163 binx, biny, mark_bad,0),
00164 "Error in bad pixel correction");
00165
00166
00167 if (chip == UVES_CHIP_BLUE)
00168 {
00169 expected_size = 0;
00170 }
00171 else
00172 {
00173 expected_size = 1;
00174 }
00175 assure( uves_propertylist_get_size(header) == expected_size,
00176 CPL_ERROR_ILLEGAL_OUTPUT, "Wrong output header size: %ld "
00177 "(%d expected)",
00178 uves_propertylist_get_size(header), expected_size);
00179 }
00180
00181 }
00182 }
00183
00184 cleanup:
00185 uves_badmap_free(&map);
00186 uves_free_propertylist(&header);
00187 uves_free_image(&master_bias);
00188 return;
00189 }
00190
00191
00192
00196
00197
00198 int main(void)
00199 {
00200
00201 cpl_test_init(PACKAGE_BUGREPORT, CPL_MSG_WARNING);
00202
00203 check( test_bad_corr(),
00204 "Test failed");
00205
00206 cleanup:
00207 return cpl_test_end(0);
00208 }
00209
00210