Changeset 15726 for trunk/psModules/test/objects/tap_pmGrowthCurve.c
- Timestamp:
- Nov 30, 2007, 1:08:23 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/psModules/test/objects/tap_pmGrowthCurve.c (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/test/objects/tap_pmGrowthCurve.c
r9922 r15726 3 3 #include <pslib.h> 4 4 #include <psmodules.h> 5 6 5 #include "tap.h" 7 6 #include "pstap.h" 8 7 9 int main (void) 8 #define VERBOSE 0 9 #define ERR_TRACE_LEVEL 10 10 11 int main(int argc, char* argv[]) 10 12 { 11 pmModelGroupInit (); 12 13 plan_tests(57); 14 15 diag("pmGrowthCurve tests"); 16 17 // test allocation 18 diag("offset of 0.0,0.0 wrt growth ref source"); 13 psLogSetFormat("HLNM"); 14 psLogSetLevel(PS_LOG_INFO); 15 psTraceSetLevel("err", ERR_TRACE_LEVEL); 16 plan_tests(15); 17 18 // ---------------------------------------------------------------------- 19 // pmGrowthCurveAlloc() tests 20 // call pmGrowthCurveAlloc() with acceptable input parameters. 21 { 22 psMemId id = psMemGetId(); 23 pmGrowthCurve *growthCurve = pmGrowthCurveAlloc(1.0, 2.0, 3.0); 24 ok(growthCurve && psMemCheckGrowthCurve(growthCurve), "pmGrowthCurveAlloc() allocated a pmGrowthCurve correctly"); 25 ok(growthCurve->radius && psMemCheckVector(growthCurve->radius), "pmGrowthCurveAlloc() allocated the radius psVector correctly"); 26 ok(growthCurve->apMag && psMemCheckVector(growthCurve->apMag) && 27 growthCurve->apMag->n == growthCurve->radius->n, "pmGrowthCurveAlloc() allocated the apMag psVector correctly"); 28 ok(growthCurve->refRadius == 3.0, "pmGrowthCurveAlloc() set growthCurve->refRadius correctly"); 29 ok(growthCurve->maxRadius == 2.0, "pmGrowthCurveAlloc() set growthCurve->maxRadius correctly"); 30 ok(growthCurve->apLoss == 0.0, "pmGrowthCurveAlloc() set growthCurve->apLoss correctly"); 31 ok(growthCurve->fitMag == 0.0, "pmGrowthCurveAlloc() set growthCurve->fitMag correctly"); 32 psFree(growthCurve); 33 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 34 } 35 36 37 // ---------------------------------------------------------------------- 38 // pmGrowthCurveCorrect() tests 39 // Call pmGrowthCurveCorrect() with NULL input pmGrowthCurve 40 { 41 psMemId id = psMemGetId(); 42 pmGrowthCurve *growthCurve = pmGrowthCurveAlloc(1.0, 2.0, 3.0); 43 ok(isnan(pmGrowthCurveCorrect(NULL, 0.0)), "pmGrowthCurveCorrect() returned NAN with NULL input pmGrowthCurve"); 44 psFree(growthCurve); 45 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 46 } 47 48 // Call pmGrowthCurveCorrect() with bad type for input pmGrowthCurve arg 49 // XX: This is commented out for now because we are not asserting, inside 50 // pmGrowthCurveCorrect(), that input parameters are of the correct type. 51 if (0) { 52 psMemId id = psMemGetId(); 53 pmGrowthCurve *growthCurve = pmGrowthCurveAlloc(1.0, 2.0, 3.0); 54 psVector *junkVec = psVectorAlloc(10, PS_TYPE_F32); 55 ok(isnan(pmGrowthCurveCorrect((pmGrowthCurve *) junkVec, 0.0)), "pmGrowthCurveCorrect() returned NAN with NULL input pmGrowthCurve"); 56 psFree(growthCurve); 57 psFree(junkVec); 58 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 59 } 60 61 62 // Call pmGrowthCurveCorrect() with acceptable input parameters. 63 { 64 #define RADIUS 0.5 65 psMemId id = psMemGetId(); 66 pmGrowthCurve *growthCurve = pmGrowthCurveAlloc(1.0, 2.0, 3.0); 67 float testCor = pmGrowthCurveCorrect(growthCurve, RADIUS); 68 float actRad = psVectorInterpolate (growthCurve->radius, growthCurve->apMag, RADIUS); 69 float actCor = growthCurve->apRef - actRad; 70 71 ok(!isnan(testCor), "pmGrowthCurveCorrect() call was successful"); 72 ok(actCor == testCor, "pmGrowthCurveCorrect() calculated the correction correctly"); 73 74 psFree(growthCurve); 75 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 76 } 77 78 79 // EM test 01: test allocation 80 // offset of 0.0,0.0 wrt growth ref source 19 81 { 20 82 psMemId id = psMemGetId(); … … 43 105 44 106 // generate a simple psf 45 pmPSF *psf = pmPSFBuildSimple ("PS_MODEL_GAUSS", 1.5, 1.5, 0.0); 107 pmModelClassInit(); 108 pmPSF *psf = pmPSFBuildSimple("PS_MODEL_GAUSS", 1.5, 1.5, 0.0); 46 109 psf->growth = growth; 47 110 48 pmGrowthCurveGenerate (readout, psf, false);111 pmGrowthCurveGenerate(readout, psf, false, 0, 0); 49 112 50 113 // check ap mags for a few radii set by hand … … 71 134 source->type = PM_SOURCE_TYPE_STAR; 72 135 source->pixels = psMemIncrRefCounter (readout->image); 73 source->mask = psMemIncrRefCounter (readout->mask);136 source->maskObj = psMemIncrRefCounter (readout->mask); 74 137 75 138 source->modelPSF->dparams->data.F32[PM_PAR_I0] = 1; … … 77 140 78 141 source->modelPSF->radiusFit = 15.0; 79 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP); 142 143 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP, 0, 0); 80 144 double refMag = source->apMag; 81 145 82 146 source->modelPSF->radiusFit = 10.0; 83 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP );147 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP, 0, 0); 84 148 ok_float_tol(refMag - source->apMag, +0.0000, 0.0001, "growth offset is is %f", refMag - source->apMag); 85 149 86 150 source->modelPSF->radiusFit = 8.0; 87 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP );151 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP, 0, 0); 88 152 ok_float_tol(refMag - source->apMag, +0.0000, 0.0001, "growth offset is is %f", refMag - source->apMag); 89 153 90 154 source->modelPSF->radiusFit = 6.0; 91 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP );155 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP, 0, 0); 92 156 ok_float_tol(refMag - source->apMag, +0.0003, 0.0001, "growth offset is is %f", refMag - source->apMag); 93 157 94 158 source->modelPSF->radiusFit = 4.0; 95 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP );159 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP, 0, 0); 96 160 ok_float_tol(refMag - source->apMag, +0.0020, 0.0001, "growth offset is is %f", refMag - source->apMag); 97 161 98 162 source->modelPSF->radiusFit = 3.0; 99 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP );163 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP, 0, 0); 100 164 ok_float_tol(refMag - source->apMag, -0.0001, 0.0001, "growth offset is is %f", refMag - source->apMag); 101 165 102 166 source->modelPSF->radiusFit = 2.0; 103 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP );167 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP, 0, 0); 104 168 ok_float_tol(refMag - source->apMag, -0.0075, 0.0001, "growth offset is is %f", refMag - source->apMag); 105 169 … … 116 180 } 117 181 118 // test allocation 119 diag("offset of 0.2,0.2 wrt growth ref source"); 182 183 // EM test 02: test allocation 184 // offset of 0.2,0.2 wrt growth ref source 120 185 { 121 186 psMemId id = psMemGetId(); … … 147 212 psf->growth = growth; 148 213 149 pmGrowthCurveGenerate (readout, psf, false );214 pmGrowthCurveGenerate (readout, psf, false, 0, 0); 150 215 151 216 // check ap mags for a few radii set by hand … … 172 237 source->type = PM_SOURCE_TYPE_STAR; 173 238 source->pixels = psMemIncrRefCounter (readout->image); 174 source->mask = psMemIncrRefCounter (readout->mask);239 source->maskObj = psMemIncrRefCounter (readout->mask); 175 240 176 241 source->modelPSF->dparams->data.F32[PM_PAR_I0] = 1; … … 178 243 179 244 source->modelPSF->radiusFit = 15.0; 180 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP );245 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP, 0, 0); 181 246 double refMag = source->apMag; 182 247 183 248 source->modelPSF->radiusFit = 10.0; 184 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP );249 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP, 0, 0); 185 250 ok_float_tol(refMag - source->apMag, +0.0000, 0.0001, "growth offset is is %f", refMag - source->apMag); 186 251 187 252 source->modelPSF->radiusFit = 8.0; 188 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP );253 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP, 0, 0); 189 254 ok_float_tol(refMag - source->apMag, +0.0000, 0.0001, "growth offset is is %f", refMag - source->apMag); 190 255 191 256 source->modelPSF->radiusFit = 6.0; 192 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP );257 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP, 0, 0); 193 258 ok_float_tol(refMag - source->apMag, +0.0004, 0.0001, "growth offset is is %f", refMag - source->apMag); 194 259 195 260 source->modelPSF->radiusFit = 4.0; 196 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP );261 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP, 0, 0); 197 262 ok_float_tol(refMag - source->apMag, +0.0026, 0.0001, "growth offset is is %f", refMag - source->apMag); 198 263 199 264 source->modelPSF->radiusFit = 3.0; 200 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP );265 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP, 0, 0); 201 266 ok_float_tol(refMag - source->apMag, -0.0001, 0.0001, "growth offset is is %f", refMag - source->apMag); 202 267 203 268 source->modelPSF->radiusFit = 2.0; 204 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP );269 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP, 0, 0); 205 270 ok_float_tol(refMag - source->apMag, -0.0103, 0.0001, "growth offset is is %f", refMag - source->apMag); 206 271 … … 217 282 } 218 283 219 // test allocation 220 diag("offset of 0.4,0.4 wrt growth ref source"); 284 285 // EM test 03: test allocation 286 // offset of 0.4,0.4 wrt growth ref source 221 287 { 222 288 psMemId id = psMemGetId(); … … 248 314 psf->growth = growth; 249 315 250 pmGrowthCurveGenerate (readout, psf, false);316 pmGrowthCurveGenerate(readout, psf, false, 0, 0); 251 317 252 318 // check ap mags for a few radii set by hand … … 273 339 source->type = PM_SOURCE_TYPE_STAR; 274 340 source->pixels = psMemIncrRefCounter (readout->image); 275 source->mask = psMemIncrRefCounter (readout->mask);341 source->maskObj = psMemIncrRefCounter (readout->mask); 276 342 277 343 source->modelPSF->dparams->data.F32[PM_PAR_I0] = 1; … … 279 345 280 346 source->modelPSF->radiusFit = 15.0; 281 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP );347 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP, 0, 0); 282 348 double refMag = source->apMag; 283 349 284 350 source->modelPSF->radiusFit = 10.0; 285 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP );351 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP, 0, 0); 286 352 ok_float_tol(refMag - source->apMag, +0.0000, 0.0001, "growth offset is is %f", refMag - source->apMag); 287 353 288 354 source->modelPSF->radiusFit = 8.0; 289 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP );355 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP, 0, 0); 290 356 ok_float_tol(refMag - source->apMag, +0.0000, 0.0001, "growth offset is is %f", refMag - source->apMag); 291 357 292 358 source->modelPSF->radiusFit = 6.0; 293 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP );359 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP, 0, 0); 294 360 ok_float_tol(refMag - source->apMag, +0.0006, 0.0001, "growth offset is is %f", refMag - source->apMag); 295 361 296 362 source->modelPSF->radiusFit = 4.0; 297 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP );363 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP, 0, 0); 298 364 ok_float_tol(refMag - source->apMag, +0.0038, 0.0001, "growth offset is is %f", refMag - source->apMag); 299 365 300 366 source->modelPSF->radiusFit = 3.0; 301 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP );367 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP, 0, 0); 302 368 ok_float_tol(refMag - source->apMag, +0.0000, 0.0001, "growth offset is is %f", refMag - source->apMag); 303 369 304 370 source->modelPSF->radiusFit = 2.0; 305 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP );371 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP, 0, 0); 306 372 ok_float_tol(refMag - source->apMag, -0.0164, 0.0001, "growth offset is is %f", refMag - source->apMag); 307 373 … … 317 383 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 318 384 } 319 320 return exit_status();321 385 } 386
Note:
See TracChangeset
for help on using the changeset viewer.
