Changeset 15985 for trunk/psModules/test/objects/tap_pmSourceUtils.c
- Timestamp:
- Jan 2, 2008, 10:45:23 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/psModules/test/objects/tap_pmSourceUtils.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/test/objects/tap_pmSourceUtils.c
r15726 r15985 5 5 #include "tap.h" 6 6 #include "pstap.h" 7 // XXX: We only test with unallowable input parameters so far. 7 /* STATUS 8 All functions are tested. 9 pmSourceFromModel(): Must verify the pmSourceDefinePixels() set the 10 values correctly. 11 */ 8 12 9 13 #define MISC_NUM 32 … … 14 18 #define VERBOSE 0 15 19 #define ERR_TRACE_LEVEL 0 16 #define TEST_FLOATS_EQUAL(X, Y) (abs( X - Y) < 0.0001)20 #define TEST_FLOATS_EQUAL(X, Y) (abs((X) - (Y)) < 0.0001) 17 21 #define NUM_SOURCES 100 18 22 … … 83 87 } 84 88 85 //XXX: Should the region be set some other way? Like through the various config files?86 // psRegion *region = psRegionAlloc(0.0, TEST_NUM_COLS-1, 0.0, TEST_NUM_ROWS-1);87 89 psRegion *region = psRegionAlloc(0.0, 0.0, 0.0, 0.0); 88 90 // You shouldn't have to remove the key from the metadata. Find out how to simply change the key value. … … 108 110 psTraceSetLevel("err", ERR_TRACE_LEVEL); 109 111 psTraceSetLevel("psModules.objects", 0); 110 plan_tests( 14);112 plan_tests(23); 111 113 112 114 113 115 // ---------------------------------------------------------------------- 114 116 // pmSourceModelGuess() tests 115 // pmModel *pmSourceModelGuess(pmSource *source, pmModelType modelType)116 117 // Call pmSourceModelGuess() with NULL pmSource input parameter 117 if (1){118 { 118 119 psMemId id = psMemGetId(); 119 120 pmSource *src = pmSourceAlloc(); … … 130 131 131 132 // Call pmSourceModelGuess() with NULL pmSource->peak input parameter 132 if (1){133 { 133 134 psMemId id = psMemGetId(); 134 135 pmSource *src = pmSourceAlloc(); … … 144 145 145 146 // Call pmSourceModelGuess() with NULL pmSource->moments input parameter 146 if (1){147 { 147 148 psMemId id = psMemGetId(); 148 149 pmSource *src = pmSourceAlloc(); … … 159 160 // pmModel *pmSourceModelGuess(pmSource *source, pmModelType modelType) 160 161 // Call pmSourceModelGuess() with acceptable input parameters 161 // XXX: Must verify that the values of the new pmModel are set correctly. 162 if (1) { 162 // We only test a single model (PS_MODEL_GAUSS), but since this function is mostly 163 // a wrapper to the model functions, that will suffice. 164 { 163 165 psMemId id = psMemGetId(); 164 166 pmSource *src = pmSourceAlloc(); … … 174 176 src->moments->y = 7.0; 175 177 176 pmModelType type = pmModelClassGetType ("PS_MODEL_GAUSS");178 pmModelType type = pmModelClassGetType("PS_MODEL_GAUSS"); 177 179 pmModel *testModel = pmModelAlloc(type); 178 180 testModel->modelGuess(testModel, src); 179 181 pmModel *model = pmSourceModelGuess(src, type); 180 182 ok(model != NULL, "pmSourceModelGuess() returned non-NULL with acceptable input parameters"); 181 183 psF32 *PAR = model->params->data.F32; 184 psEllipseMoments emoments; 185 emoments.x2 = src->moments->Sx; 186 emoments.y2 = src->moments->Sy; 187 emoments.xy = src->moments->Sxy; 188 // force the axis ratio to be < 20.0 189 psEllipseAxes axes = psEllipseMomentsToAxes (emoments, 20.0); 190 psEllipseShape shape = psEllipseAxesToShape (axes); 191 ok(TEST_FLOATS_EQUAL(PAR[PM_PAR_SKY], src->moments->Sky), "pmSourceModelGuess() returned set model->params[PM_PAR_SKY] correctly"); 192 ok(TEST_FLOATS_EQUAL(PAR[PM_PAR_I0], src->moments->Peak - src->moments->Sky), "pmSourceModelGuess() returned set model->params[PM_PAR_IO] correctly"); 193 ok(TEST_FLOATS_EQUAL(PAR[PM_PAR_XPOS], src->moments->x), "pmSourceModelGuess() returned set model->params[PM_PAR_XPOS] correctly"); 194 ok(TEST_FLOATS_EQUAL(PAR[PM_PAR_YPOS], src->moments->y), "pmSourceModelGuess() returned set model->params[PM_PAR_YPOS] correctly"); 195 ok(TEST_FLOATS_EQUAL(PAR[PM_PAR_SXX], PS_MAX(0.5, M_SQRT2*shape.sx)), "pmSourceModelGuess() returned set model->params[PM_PAR_SXX] correctly"); 196 ok(TEST_FLOATS_EQUAL(PAR[PM_PAR_SYY], PS_MAX(0.5, M_SQRT2*shape.sy)), "pmSourceModelGuess() returned set model->params[PM_PAR_SYY] correctly"); 197 ok(TEST_FLOATS_EQUAL(PAR[PM_PAR_SXY], shape.sxy), "pmSourceModelGuess() returned set model->params[PM_PAR_SXY] correctly"); 182 198 psFree(src); 183 199 psFree(testModel); … … 190 206 // ---------------------------------------------------------------------- 191 207 // pmSourceModelGuess() tests 192 // pmSource *pmSourceFromModel (pmModel *model, pmReadout *readout,193 // float radius, pmSourceType type)194 208 // Call pmSourceFromModel() with NULL pmModel input parameter 195 if (1){209 { 196 210 psMemId id = psMemGetId(); 197 211 pmModelType type = pmModelClassGetType ("PS_MODEL_GAUSS"); … … 210 224 211 225 // Call pmSourceFromModel() with NULL pmReadout input parameter 212 if (1){226 { 213 227 psMemId id = psMemGetId(); 214 228 … … 227 241 228 242 // Call pmSourceFromModel() with acceptable input parameters 229 // XXX: Must verify that the values of the new pmSource are set correctly. 230 if (1) { 231 psMemId id = psMemGetId(); 232 233 pmModelType type = pmModelClassGetType ("PS_MODEL_GAUSS"); 234 pmModel *model = pmModelAlloc(type); 243 // XXX: Must verify the pmSourceDefinePixels() set the values correctly. 244 { 245 psMemId id = psMemGetId(); 246 247 pmModel *model = pmModelAlloc(pmModelClassGetType("PS_MODEL_GAUSS")); 248 float Io = model->params->data.F32[PM_PAR_I0] = 2.0; 249 float xChip = model->params->data.F32[PM_PAR_XPOS] = 3.0; 250 float yChip = model->params->data.F32[PM_PAR_YPOS] = 5.0; 235 251 pmCell *cell = generateSimpleCell(NULL); 236 252 pmReadout *readout = cell->readouts->data[0]; 237 253 pmSource *src = pmSourceFromModel(model, readout, 10.0, PM_SOURCE_TYPE_STAR); 238 254 ok(src != NULL, "pmSourceFromModel() returned non-NULL with acceptable input parameters"); 255 ok(src->modelPSF == model, "pmSourceFromModel() set pmSource->modelPSF correctly"); 256 257 pmPeak *tmpPeak = pmPeakAlloc (xChip, yChip, Io, PM_PEAK_LONE); 258 ok(src->peak->x == xChip, "pmSourceFromModel() set pmSource->peak->x correctly (%.2f %.2f)", src->peak->x, xChip); 259 239 260 psFree(model); 240 261 // XXX: We get psMemory aborts if the following is not done. 241 262 // There is probably an issue with psMemIncrRefCounter() in pmSourceUtils.c 263 242 264 src->modelPSF = NULL; 243 265 src->modelEXT = NULL; 244 266 psFree(src); 267 psFree(tmpPeak); 245 268 myFreeCell(cell); 246 269 pmModelClassCleanup(); 247 270 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 248 271 } 249 250 251 } 252 272 }
Note:
See TracChangeset
for help on using the changeset viewer.
