IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 14347


Ignore:
Timestamp:
Jul 20, 2007, 2:04:54 PM (19 years ago)
Author:
eugene
Message:

keep model pixels in masked region (could be optimized)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/src/psphotModelWithPSF.c

    r14338 r14347  
    185185    psVector *coord = psVectorAlloc(2, PS_TYPE_F32);
    186186
     187    psImageInit (pcm->model, 0.0);
     188    for (int n = 0; n < params->n; n++) {
     189        if (!pcm->dmodels->data[n]) continue;
     190        psImageInit (pcm->dmodels->data[n], 0.0);
     191    }
     192
    187193    // fill in the coordinate and value entries
    188194    for (psS32 i = 0; i < source->pixels->numRows; i++) {
    189195        for (psS32 j = 0; j < source->pixels->numCols; j++) {
     196
     197            // XXX can we skip some of the data points where the model
     198            // is not going to be fitted??
     199
    190200            // skip masked points
    191201            // XXX probably should not skipped masked points:
    192202            // XXX skip if convolution of unmasked pixels will not see this pixel
    193             if (source->maskObj->data.U8[i][j]) {
    194                 continue;
    195             }
     203            // if (source->maskObj->data.U8[i][j]) {
     204            // continue;
     205            // }
     206
    196207            // skip zero-weight points
    197208            // XXX why is this not masked?
    198             if (source->weight->data.F32[i][j] == 0) {
    199                 continue;
    200             }
     209            // if (source->weight->data.F32[i][j] == 0) {
     210            // continue;
     211            // }
    201212            // skip nan value points
    202213            // XXX why is this not masked?
    203             if (!isfinite(source->pixels->data.F32[i][j])) {
    204                 continue;
    205             }
     214            // if (!isfinite(source->pixels->data.F32[i][j])) {
     215            // continue;
     216            // }
    206217
    207218            // Convert i/j to image space:
     
    221232    psFree(deriv);
    222233
    223     psphotSaveImage (NULL, pcm->model, "model1.fits");
    224234
    225235    // convolve model and dmodel arrays with PSF
     
    233243
    234244    // XXX TEST : SAVE IMAGES
     245# if (1)
     246    psphotSaveImage (NULL, psf->image, "psf.fits");
    235247    psphotSaveImage (NULL, pcm->model, "model.fits");
    236248    psphotSaveImage (NULL, pcm->modelConv, "modelConv.fits");
     
    238250    psphotSaveImage (NULL, source->maskObj, "mask.fits");
    239251    psphotSaveImage (NULL, source->weight, "weight.fits");
    240     exit (0);
     252# endif
    241253
    242254    // zero alpha and beta for summing below
     
    330342
    331343    // Allocate storage images for raw model and derivative images
    332     pcm->model = psImageAlloc (source->pixels->numCols, source->pixels->numRows, PS_TYPE_F32);
     344    pcm->model = psImageCopy (NULL, source->pixels, PS_TYPE_F32);
    333345    pcm->dmodels = psArrayAlloc (params->n);
    334346    for (psS32 n = 0; n < params->n; n++) {
    335347      if ((paramMask != NULL) && (paramMask->data.U8[n])) { continue; }
    336       pcm->dmodels->data[n] = psImageAlloc (source->pixels->numCols, source->pixels->numRows, PS_TYPE_F32);
     348      pcm->dmodels->data[n] = psImageCopy (NULL, source->pixels, PS_TYPE_F32);
    337349    }
    338350
    339351    // Allocate storage images for convolved model and derivative images
    340     pcm->modelConv = psImageAlloc (source->pixels->numCols, source->pixels->numRows, PS_TYPE_F32);
     352    pcm->modelConv = psImageCopy (NULL, source->pixels, PS_TYPE_F32);
    341353    pcm->dmodelsConv = psArrayAlloc (params->n);
    342354    for (psS32 n = 0; n < params->n; n++) {
    343355      if ((paramMask != NULL) && (paramMask->data.U8[n])) { continue; }
    344       pcm->dmodelsConv->data[n] = psImageAlloc (source->pixels->numCols, source->pixels->numRows, PS_TYPE_F32);
     356      pcm->dmodelsConv->data[n] = psImageCopy (NULL, source->pixels, PS_TYPE_F32);
    345357    }
    346358
     
    350362psImage *pmPCMDataSaveImage (pmPCMData *pcm) {
    351363
    352     psImage *model = psImageCopy (NULL, pcm->model, PS_TYPE_F32);
     364    psImage *model = psImageCopy (NULL, pcm->modelConv, PS_TYPE_F32);
     365   
    353366    return model;
    354367}
Note: See TracChangeset for help on using the changeset viewer.