IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 2, 2008, 10:45:23 AM (18 years ago)
Author:
gusciora
Message:

Significant changes and additions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/test/objects/tap_pmSourceUtils.c

    r15726 r15985  
    55#include "tap.h"
    66#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*/
    812
    913#define MISC_NUM                32
     
    1418#define VERBOSE                 0
    1519#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)
    1721#define NUM_SOURCES             100
    1822
     
    8387    }
    8488
    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);
    8789    psRegion *region = psRegionAlloc(0.0, 0.0, 0.0, 0.0);
    8890    // You shouldn't have to remove the key from the metadata.  Find out how to simply change the key value.
     
    108110    psTraceSetLevel("err", ERR_TRACE_LEVEL);
    109111    psTraceSetLevel("psModules.objects", 0);
    110     plan_tests(14);
     112    plan_tests(23);
    111113
    112114
    113115    // ----------------------------------------------------------------------
    114116    // pmSourceModelGuess() tests
    115     // pmModel *pmSourceModelGuess(pmSource *source, pmModelType modelType)
    116117    // Call pmSourceModelGuess() with NULL pmSource input parameter
    117     if (1) {
     118    {
    118119        psMemId id = psMemGetId();
    119120        pmSource *src = pmSourceAlloc();
     
    130131
    131132    // Call pmSourceModelGuess() with NULL pmSource->peak input parameter
    132     if (1) {
     133    {
    133134        psMemId id = psMemGetId();
    134135        pmSource *src = pmSourceAlloc();
     
    144145
    145146    // Call pmSourceModelGuess() with NULL pmSource->moments input parameter
    146     if (1) {
     147    {
    147148        psMemId id = psMemGetId();
    148149        pmSource *src = pmSourceAlloc();
     
    159160    // pmModel *pmSourceModelGuess(pmSource *source, pmModelType modelType)
    160161    // 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    {
    163165        psMemId id = psMemGetId();
    164166        pmSource *src = pmSourceAlloc();
     
    174176        src->moments->y = 7.0;
    175177
    176         pmModelType type = pmModelClassGetType ("PS_MODEL_GAUSS");
     178        pmModelType type = pmModelClassGetType("PS_MODEL_GAUSS");
    177179        pmModel *testModel = pmModelAlloc(type);
    178180        testModel->modelGuess(testModel, src);
    179181        pmModel *model = pmSourceModelGuess(src, type);
    180182        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");
    182198        psFree(src);
    183199        psFree(testModel);
     
    190206    // ----------------------------------------------------------------------
    191207    // pmSourceModelGuess() tests
    192     // pmSource *pmSourceFromModel (pmModel *model, pmReadout *readout,
    193     //                              float radius, pmSourceType type)
    194208    // Call pmSourceFromModel() with NULL pmModel input parameter
    195     if (1) {
     209    {
    196210        psMemId id = psMemGetId();
    197211        pmModelType type = pmModelClassGetType ("PS_MODEL_GAUSS");
     
    210224
    211225    // Call pmSourceFromModel() with NULL pmReadout input parameter
    212     if (1) {
     226    {
    213227        psMemId id = psMemGetId();
    214228
     
    227241
    228242    // 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;
    235251        pmCell *cell = generateSimpleCell(NULL);
    236252        pmReadout *readout = cell->readouts->data[0];
    237253        pmSource *src = pmSourceFromModel(model, readout, 10.0, PM_SOURCE_TYPE_STAR);
    238254        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
    239260        psFree(model);
    240261        // XXX: We get psMemory aborts if the following is not done.
    241262        // There is probably an issue with psMemIncrRefCounter() in pmSourceUtils.c
     263
    242264        src->modelPSF = NULL;
    243265        src->modelEXT = NULL;
    244266        psFree(src);
     267        psFree(tmpPeak);
    245268        myFreeCell(cell);
    246269        pmModelClassCleanup();
    247270        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    248271    }
    249 
    250 
    251 }
    252 
     272}
Note: See TracChangeset for help on using the changeset viewer.