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 #ifdef HAVE_CONFIG_H
00054 # include <config.h>
00055 #endif
00056
00057 #include <uves_corrbadpix.h>
00058 #include <uves_chip.h>
00059 #include <uves_utils_wrappers.h>
00060 #include <uves_error.h>
00061 #include <irplib_test.h>
00062
00063 #include <cpl.h>
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00077
00080
00084
00085 static void
00086 test_bad_corr(void)
00087 {
00088 cpl_image *master_bias = NULL;
00089 uves_propertylist *header = uves_propertylist_new();
00090 int **map = NULL;
00091 int mark_bad;
00092 int blue, binx, biny;
00093
00094
00095 map = cpl_calloc(1, sizeof(int*));
00096 map[0] = cpl_calloc(4, sizeof(int));
00097 map[0][0] = -1;
00098 map[0][1] = -1;
00099 map[0][2] = -1;
00100 map[0][3] = -1;
00101 uves_badmap_free(&map);
00102
00103
00104 map = cpl_calloc(3, sizeof(int*));
00105 map[0] = cpl_calloc(4, sizeof(int));
00106 map[0][0] = 1;
00107 map[0][1] = 2;
00108 map[0][2] = 3;
00109 map[0][3] = 4;
00110 map[1] = cpl_calloc(4, sizeof(int));
00111 map[1][0] = 5;
00112 map[1][1] = 6;
00113 map[1][2] = 7;
00114 map[1][3] = 8;
00115 map[2] = cpl_calloc(4, sizeof(int));
00116 map[2][0] = -1;
00117 map[2][1] = -1;
00118 map[2][2] = -1;
00119 map[2][3] = -1;
00120 uves_badmap_free(&map);
00121
00122 for (blue = 0; blue <= 1; blue++)
00123 for (binx = 1; binx <= 3; binx++)
00124 for (biny = 1; biny <= 3; biny++)
00125 if (!(
00126 (binx == 1 && biny == 3) ||
00127 (binx == 2 && biny == 1) ||
00128 (binx == 3 && biny == 1) ||
00129 (binx == 3 && biny == 2) ||
00130 (binx == 3 && biny == 3)
00131 )){
00132 enum uves_chip chip;
00133 for (chip = uves_chip_get_first(blue);
00134 chip != UVES_CHIP_INVALID;
00135 chip = uves_chip_get_next(chip))
00136 {
00137 uves_free_image(&master_bias);
00138 master_bias = cpl_image_new(4096/biny, 2048/binx, CPL_TYPE_DOUBLE);
00139 assure_mem( master_bias );
00140
00141 for (mark_bad = 0; mark_bad <= 1; mark_bad++)
00142 {
00143 int expected_size;
00144
00145
00146 check( map = uves_get_badpix(chip, binx, biny, mark_bad),
00147 "Error getting bad pixel map");
00148 uves_badmap_free(&map);
00149
00150
00151 uves_propertylist_empty(header);
00152 check( uves_correct_badpix_all(master_bias, header,
00153 chip,
00154 binx, biny, mark_bad),
00155 "Error in bad pixel correction");
00156
00157
00158 if (chip == UVES_CHIP_BLUE)
00159 {
00160 expected_size = 0;
00161 }
00162 else
00163 {
00164 expected_size = 1;
00165 }
00166 assure( uves_propertylist_get_size(header) == expected_size,
00167 CPL_ERROR_ILLEGAL_OUTPUT, "Wrong output header size: %ld "
00168 "(%d expected)",
00169 uves_propertylist_get_size(header), expected_size);
00170 }
00171
00172 }
00173 }
00174
00175 cleanup:
00176 uves_badmap_free(&map);
00177 uves_free_propertylist(&header);
00178 uves_free_image(&master_bias);
00179 return;
00180 }
00181
00182
00183
00187
00188
00189 int main(void)
00190 {
00191
00192 IRPLIB_TEST_INIT;
00193
00194 check( test_bad_corr(),
00195 "Test failed");
00196
00197 cleanup:
00198 IRPLIB_TEST_END;
00199 }
00200
00201