IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 23, 2009, 5:12:22 PM (17 years ago)
Author:
Paul Price
Message:

Added multiple sets of limits for models. Involved reorganisation of how the models are sucked into the pmModelClasses: now using header files instead of including the source for each model. This allows static variables to be properly respected.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/pap/psModules/src/objects/pmModel.c

    r23187 r25521  
    8686    tmp->modelParamsFromPSF = class->modelParamsFromPSF;
    8787    tmp->modelFitStatus     = class->modelFitStatus;
     88    tmp->modelSetLimits     = class->modelSetLimits;
    8889
    8990    psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__);
     
    235236
    236237    if (model->residuals) {
    237         DX = xBin*(image->col0 - xCenter - dx) + model->residuals->xCenter + 0.5;
    238         DY = yBin*(image->row0 - yCenter - dy) + model->residuals->yCenter + 0.5;
    239         Ro = (model->residuals->Ro)   ? model->residuals->Ro->data.F32 : NULL;
    240         Rx = (model->residuals->Rx)   ? model->residuals->Rx->data.F32 : NULL;
    241         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;
    243         if (Ro) {
    244             NX = model->residuals->Ro->numCols;
    245             NY = model->residuals->Ro->numRows;
    246         }           
     238        DX = xBin*(image->col0 - xCenter - dx) + model->residuals->xCenter + 0.5;
     239        DY = yBin*(image->row0 - yCenter - dy) + model->residuals->yCenter + 0.5;
     240        Ro = (model->residuals->Ro)   ? model->residuals->Ro->data.F32 : NULL;
     241        Rx = (model->residuals->Rx)   ? model->residuals->Rx->data.F32 : NULL;
     242        Ry = (model->residuals->Ry)   ? model->residuals->Ry->data.F32 : NULL;
     243        Rm = (model->residuals->mask) ? model->residuals->mask->data.PS_TYPE_IMAGE_MASK_DATA : NULL;
     244        if (Ro) {
     245            NX = model->residuals->Ro->numCols;
     246            NY = model->residuals->Ro->numRows;
     247        }
    247248    }
    248249
     
    256257
    257258            // XXX should we use using 0.5 pixel offset?
    258             // Convert to coordinate in parent image, with offset (dx,dy)
     259            // Convert to coordinate in parent image, with offset (dx,dy)
    259260            imageCol = ix + image->col0 - dx;
    260261            imageRow = iy + image->row0 - dy;
     
    276277                float rx = xBin*ix + DX;
    277278
    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);
     279                int rx0 = rx - 0.5;
     280                int rx1 = rx + 0.5;
     281                int ry0 = ry - 0.5;
     282                int ry1 = ry + 0.5;
     283
     284                if (rx0 < 0) goto skip;
     285                if (ry0 < 0) goto skip;
     286                if (rx1 >= NX) goto skip;
     287                if (ry1 >= NY) goto skip;
     288
     289                // these go from 0.0 to 1.0 between the centers of the pixels
     290                float fx = rx - 0.5 - rx0;
     291                float Fx = 1.0 - fx;
     292                float fy = ry - 0.5 - ry0;
     293                float Fy = 1.0 - fy;
     294
     295                // check the residual image mask (if set). give up if any of the 4 pixels are masked.
     296                if (Rm) {
     297                    if (Rm[ry0][rx0]) goto skip;
     298                    if (Rm[ry0][rx1]) goto skip;
     299                    if (Rm[ry1][rx0]) goto skip;
     300                    if (Rm[ry1][rx1]) goto skip;
     301                }
     302
     303                // a possible further optimization if we re-use these values
     304                // XXX allow for masked pixels, and add pixel weights
     305                float V0 = (Ro[ry0][rx0]*Fx + Ro[ry0][rx1]*fx);
     306                float V1 = (Ro[ry1][rx0]*Fx + Ro[ry1][rx1]*fx);
     307                float Vo = V0*Fy + V1*fy;
     308                if (!isfinite(Vo)) goto skip;
     309
     310                float Vx = 0.0;
     311                float Vy = 0.0;
     312
     313                // skip Rx,Ry if Ro is masked
     314                if (Rx && Ry && (mode & PM_MODEL_OP_RES1)) {
     315                    V0 = (Rx[ry0][rx0]*Fx + Rx[ry0][rx1]*fx);
     316                    V1 = (Rx[ry1][rx0]*Fx + Rx[ry1][rx1]*fx);
     317                    Vx = V0*Fy + V1*fy;
     318
     319                    V0 = (Ry[ry0][rx0]*Fx + Ry[ry0][rx1]*fx);
     320                    V1 = (Ry[ry1][rx0]*Fx + Ry[ry1][rx1]*fx);
     321                    Vy = V0*Fy + V1*fy;
     322                }
     323                if (!isfinite(Vx)) goto skip;
     324                if (!isfinite(Vy)) goto skip;
     325
     326                // 2D residual variations are set for the true source position
     327                pixelValue += Io*(Vo + XoSave*Vx + XoSave*Vy);
    327328            }
    328329
    329         skip:
     330        skip:
    330331            // add or subtract the value
    331332            if (add) {
Note: See TracChangeset for help on using the changeset viewer.