IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 13, 2019, 1:01:49 PM (7 years ago)
Author:
eugene
Message:

bringing test/objects code up-to-date (work in progress)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20191011/psModules/test/objects/tap_pmSourceFitModel.c

    r23259 r40941  
    1818int main (void)
    1919{
    20     pmModelGroupInit ();
    21     pmSourceFitModelInit (15, 0.01, 1.0, true);
     20    pmModelClassInit ();
     21    // pmSourceFitModelInit (15, 0.01, 1.0, true);
    2222
    2323    // psTraceSetLevel ("psModules.objects.pmSourceFitModel", 10);
     
    108108{
    109109
     110  psImageMaskType maskVal = 0x01;
     111
    110112    psVector *rnd = psVectorAlloc (1000, PS_TYPE_F32);
    111113    for (int i = 0; i < rnd->n; i++) {
     
    128130    source->modelEXT->params->data.F32[6] = 0;
    129131
    130     source->pixels = psImageAlloc (100, 100, PS_TYPE_F32);
    131     source->weight = psImageAlloc (100, 100, PS_TYPE_F32);
    132     source->mask   = psImageAlloc (100, 100, PS_TYPE_U8);
     132    source->pixels   = psImageAlloc (100, 100, PS_TYPE_F32);
     133    source->variance = psImageAlloc (100, 100, PS_TYPE_F32);
     134    source->maskObj  = psImageAlloc (100, 100, PS_TYPE_IMAGE_MASK);
    133135    psImageInit (source->pixels, 0.0);
    134     psImageInit (source->weight, 0.0);
    135     psImageInit (source->mask, 0);
     136    psImageInit (source->variance, 0.0);
     137    psImageInit (source->maskObj, 0);
    136138
    137139    // create an image with the model, and add noise: gain is 1, subtracted sky is 100, readnoise is 5
    138     pmModelAdd (source->pixels, source->mask, source->modelEXT, PM_MODEL_OP_FULL);
     140    pmModelAdd (source->pixels, source->maskObj, source->modelEXT, PM_MODEL_OP_FULL, maskVal);
    139141    int npix = 0;
    140142    for (int j = 0; j < source->pixels->numRows; j++) {
     
    143145            float var = flux + 100 + PS_SQR(5);
    144146            source->pixels->data.F32[j][i] += rnd->data.F32[npix]*sqrt(var);
    145             source->weight->data.F32[j][i] = var;
     147            source->variance->data.F32[j][i] = var;
    146148            npix ++;
    147149            if (npix == rnd->n)
     
    162164    guess->params->data.F32[5] *= 0.9;
    163165
    164     psImageKeepCircle (source->mask, 50, 50, radius, "OR", PM_MASK_MARK);
    165     bool status = pmSourceFitModel (source, guess, PM_SOURCE_FIT_EXT);
     166    pmSourceFitOptions *fitOptions = pmSourceFitOptionsAlloc();
     167    fitOptions->mode          = PM_SOURCE_FIT_EXT;
     168    fitOptions->covarFactor   = 1.0;
     169
     170    // use maskVal to exclude pixels outside the circle
     171    psImageKeepCircle (source->maskObj, 50, 50, radius, "OR", maskVal);
     172
     173    bool status = pmSourceFitModel (source, guess, fitOptions, maskVal);
    166174    if (!status) {
    167175        psFree (rnd);
     
    170178        return false;
    171179    }
    172     psImageKeepCircle (source->mask, 50, 50, radius, "AND", PS_NOT_U8(PM_MASK_MARK));
     180    psImageMaskPixels (source->maskObj, "AND", PS_NOT_IMAGE_MASK(maskVal));
    173181
    174182    par1->data.F32[par1->n] = (source->modelEXT->params->data.F32[1] / guess->params->data.F32[1]);
Note: See TracChangeset for help on using the changeset viewer.