IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 2, 2009, 5:10:19 PM (17 years ago)
Author:
eugene
Message:

merge changes from trunk

Location:
branches/eam_branches/20090820
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20090820

  • branches/eam_branches/20090820/psModules/src/objects/pmModel.c

    r23187 r25766  
    5656
    5757    tmp->type = type;
    58     tmp->chisq = 0.0;
    59     tmp->chisqNorm = 0.0;
     58    tmp->mag = NAN;
     59    tmp->chisq = NAN;
     60    tmp->chisqNorm = NAN;
    6061    tmp->nDOF  = 0;
    6162    tmp->nPix  = 0;
    6263    tmp->nIter = 0;
    63     tmp->radiusFit = 0;
     64    tmp->fitRadius = 0;
    6465    tmp->flags = PM_MODEL_STATUS_NONE;
    6566    tmp->residuals = NULL;              // XXX should the model own this memory?
     
    8687    tmp->modelParamsFromPSF = class->modelParamsFromPSF;
    8788    tmp->modelFitStatus     = class->modelFitStatus;
     89    tmp->modelSetLimits     = class->modelSetLimits;
    8890
    8991    psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__);
     
    108110    new->nIter     = model->nIter;
    109111    new->flags     = model->flags;
    110     new->radiusFit = model->radiusFit;
     112    new->fitRadius = model->fitRadius;
    111113
    112114    for (int i = 0; i < new->params->n; i++) {
     
    189191    psVector *params = model->params;
    190192
    191     psS32 imageCol;
    192     psS32 imageRow;
    193     psF32 pixelValue;
     193    float imageCol;
     194    float imageRow;
     195    float pixelValue;
    194196
    195197    // save original values; restore before returning
     
    232234    psF32 **Rx = NULL;
    233235    psF32 **Ry = NULL;
    234     psImageMaskType **Rm = NULL;
     236    pmResidMaskType **Rm = NULL;
    235237
    236238    if (model->residuals) {
     
    240242        Rx = (model->residuals->Rx)   ? model->residuals->Rx->data.F32 : NULL;
    241243        Ry = (model->residuals->Ry)   ? model->residuals->Ry->data.F32 : NULL;
    242         Rm = (model->residuals->mask) ? model->residuals->mask->data.PS_TYPE_IMAGE_MASK_DATA : NULL;
     244        Rm = (model->residuals->mask) ? model->residuals->mask->data.PM_TYPE_RESID_MASK_DATA : NULL;
    243245        if (Ro) {
    244246            NX = model->residuals->Ro->numCols;
     
    255257                continue;
    256258
    257             // XXX should we use using 0.5 pixel offset?
    258             // Convert to coordinate in parent image, with offset (dx,dy)
    259             imageCol = ix + image->col0 - dx;
    260             imageRow = iy + image->row0 - dy;
    261 
    262             x->data.F32[0] = (float) imageCol;
    263             x->data.F32[1] = (float) imageRow;
     259            // Convert to coordinate in parent image, with offset (dx,dy)
     260            // 0.5 PIX: the model take pixel coordinates so convert the pixel index here
     261            imageCol = ix + 0.5 + image->col0 - dx;
     262            imageRow = iy + 0.5 + image->row0 - dy;
     263
     264            x->data.F32[0] = imageCol;
     265            x->data.F32[1] = imageRow;
    264266
    265267            pixelValue = 0.0;
     
    276278                float rx = xBin*ix + DX;
    277279
    278                 int rx0 = rx - 0.5;
    279                 int rx1 = rx + 0.5;
    280                 int ry0 = ry - 0.5;
    281                 int ry1 = ry + 0.5;
    282 
    283                 if (rx0 < 0) goto skip;
    284                 if (ry0 < 0) goto skip;
    285                 if (rx1 >= NX) goto skip;
    286                 if (ry1 >= NY) goto skip;
    287 
    288                 // these go from 0.0 to 1.0 between the centers of the pixels
    289                 float fx = rx - 0.5 - rx0;
    290                 float Fx = 1.0 - fx;
    291                 float fy = ry - 0.5 - ry0;
    292                 float Fy = 1.0 - fy;
    293 
    294                 // check the residual image mask (if set). give up if any of the 4 pixels are masked.
    295                 if (Rm) {
    296                     if (Rm[ry0][rx0]) goto skip;
    297                     if (Rm[ry0][rx1]) goto skip;
    298                     if (Rm[ry1][rx0]) goto skip;
    299                     if (Rm[ry1][rx1]) goto skip;
    300                 }
    301 
    302                 // a possible further optimization if we re-use these values
    303                 // XXX allow for masked pixels, and add pixel weights
    304                 float V0 = (Ro[ry0][rx0]*Fx + Ro[ry0][rx1]*fx);
    305                 float V1 = (Ro[ry1][rx0]*Fx + Ro[ry1][rx1]*fx);
    306                 float Vo = V0*Fy + V1*fy;
    307                 if (!isfinite(Vo)) goto skip;
    308 
    309                 float Vx = 0.0;
    310                 float Vy = 0.0;
    311 
    312                 // skip Rx,Ry if Ro is masked
    313                 if (Rx && Ry && (mode & PM_MODEL_OP_RES1)) {
    314                     V0 = (Rx[ry0][rx0]*Fx + Rx[ry0][rx1]*fx);
    315                     V1 = (Rx[ry1][rx0]*Fx + Rx[ry1][rx1]*fx);
    316                     Vx = V0*Fy + V1*fy;
    317 
    318                     V0 = (Ry[ry0][rx0]*Fx + Ry[ry0][rx1]*fx);
    319                     V1 = (Ry[ry1][rx0]*Fx + Ry[ry1][rx1]*fx);
    320                     Vy = V0*Fy + V1*fy;
    321                 }
    322                 if (!isfinite(Vx)) goto skip;
    323                 if (!isfinite(Vy)) goto skip;
    324 
    325                 // 2D residual variations are set for the true source position
    326                 pixelValue += Io*(Vo + XoSave*Vx + XoSave*Vy);
     280                int rx0 = rx - 0.5;
     281                int rx1 = rx + 0.5;
     282                int ry0 = ry - 0.5;
     283                int ry1 = ry + 0.5;
     284
     285                if (rx0 < 0) goto skip;
     286                if (ry0 < 0) goto skip;
     287                if (rx1 >= NX) goto skip;
     288                if (ry1 >= NY) goto skip;
     289
     290                // these go from 0.0 to 1.0 between the centers of the pixels
     291                float fx = rx - 0.5 - rx0;
     292                float Fx = 1.0 - fx;
     293                float fy = ry - 0.5 - ry0;
     294                float Fy = 1.0 - fy;
     295
     296                // check the residual image mask (if set). give up if any of the 4 pixels are masked.
     297                if (Rm) {
     298                    if (Rm[ry0][rx0]) goto skip;
     299                    if (Rm[ry0][rx1]) goto skip;
     300                    if (Rm[ry1][rx0]) goto skip;
     301                    if (Rm[ry1][rx1]) goto skip;
     302                }
     303
     304                // a possible further optimization if we re-use these values
     305                // XXX allow for masked pixels, and add pixel weights
     306                float V0 = (Ro[ry0][rx0]*Fx + Ro[ry0][rx1]*fx);
     307                float V1 = (Ro[ry1][rx0]*Fx + Ro[ry1][rx1]*fx);
     308                float Vo = V0*Fy + V1*fy;
     309                if (!isfinite(Vo)) goto skip;
     310
     311                float Vx = 0.0;
     312                float Vy = 0.0;
     313
     314                // skip Rx,Ry if Ro is masked
     315                if (Rx && Ry && (mode & PM_MODEL_OP_RES1)) {
     316                    V0 = (Rx[ry0][rx0]*Fx + Rx[ry0][rx1]*fx);
     317                    V1 = (Rx[ry1][rx0]*Fx + Rx[ry1][rx1]*fx);
     318                    Vx = V0*Fy + V1*fy;
     319
     320                    V0 = (Ry[ry0][rx0]*Fx + Ry[ry0][rx1]*fx);
     321                    V1 = (Ry[ry1][rx0]*Fx + Ry[ry1][rx1]*fx);
     322                    Vy = V0*Fy + V1*fy;
     323                }
     324                if (!isfinite(Vx)) goto skip;
     325                if (!isfinite(Vy)) goto skip;
     326
     327                // 2D residual variations are set for the true source position
     328                pixelValue += Io*(Vo + XoSave*Vx + XoSave*Vy);
    327329            }
    328330
    329         skip:
     331        skip:
    330332            // add or subtract the value
    331333            if (add) {
Note: See TracChangeset for help on using the changeset viewer.