IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 9867 for trunk/psphot/src


Ignore:
Timestamp:
Nov 5, 2006, 4:15:42 PM (20 years ago)
Author:
eugene
Message:

testing bicubic interpolation for aperture

File:
1 edited

Legend:

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

    r9839 r9867  
    4848        pmModel *model = pmModelFromPSF (modelRef, psf);
    4949
    50         psRegion region = {180, 220, 180, 220};
     50        // psRegion region = {180, 220, 180, 220};
     51        psRegion region = {0, 0, 0, 0};
    5152        psImage *imageView = psImageSubset (readout->image, region);
    5253        psImage *maskView = psImageSubset (readout->mask, region);
    53         pmModelAdd (imageView, maskView, model, false, false);
    54         // imageView->data.F32[20][20] = 1000;
     54
     55        psImageInit (imageView, 0.0);
     56        psImageInit (maskView, 0);
     57        pmModelAdd (imageView, maskView, model, false, false);
    5558        float dx = 0.5 - model->params->data.F32[PM_PAR_XPOS] + (int)model->params->data.F32[PM_PAR_XPOS];
    5659        float dy = 0.5 - model->params->data.F32[PM_PAR_YPOS] + (int)model->params->data.F32[PM_PAR_YPOS];
     
    5861
    5962        psFits *fits;
     63        fits = psFitsOpen ("unshift_tmp.fits", "w");
     64        psFitsWriteImage (fits, NULL, imageView, 0, NULL);
     65        psFitsClose (fits);
     66       
     67        fits = psFitsOpen ("shift_tmp.fits", "w");
     68        psFitsWriteImage (fits, NULL, tmpImage, 0, NULL);
     69        psFitsClose (fits);
     70    }
     71
     72    // test of psImageShift (Bilinear)
     73    {
     74        // assign the x and y coords to the image center
     75        // create an object with center intensity of 1000
     76        modelRef->params->data.F32[PM_PAR_XPOS] = 200+0.2;
     77        modelRef->params->data.F32[PM_PAR_YPOS] = 200+0.6;
     78       
     79        // create modelPSF from this model
     80        pmModel *model = pmModelFromPSF (modelRef, psf);
     81
     82        // psRegion region = {180, 220, 180, 220};
     83        psRegion region = {0, 0, 0, 0};
     84        psImage *imageView = psImageSubset (readout->image, region);
     85        psImage *maskView = psImageSubset (readout->mask, region);
     86
     87        psImageInit (imageView, 0.0);
     88        psImageInit (maskView, 0);
     89        pmModelAdd (imageView, maskView, model, false, false);
     90        float dx = 0.5 - model->params->data.F32[PM_PAR_XPOS] + (int)model->params->data.F32[PM_PAR_XPOS];
     91        float dy = 0.5 - model->params->data.F32[PM_PAR_YPOS] + (int)model->params->data.F32[PM_PAR_YPOS];
     92        psImage *tmpImage = psImageShift (NULL, imageView, dx, dy, 0.0, PS_INTERPOLATE_BILINEAR);
     93
     94        psFits *fits;
    6095        fits = psFitsOpen ("unshift.fits", "w");
    6196        psFitsWriteImage (fits, NULL, imageView, 0, NULL);
     
    6499        fits = psFitsOpen ("shift.fits", "w");
    65100        psFitsWriteImage (fits, NULL, tmpImage, 0, NULL);
     101        psFitsClose (fits);
     102
     103        modelRef->params->data.F32[PM_PAR_XPOS] = 200+0.5;
     104        modelRef->params->data.F32[PM_PAR_YPOS] = 200+0.5;
     105        model = pmModelFromPSF (modelRef, psf);
     106        psImageInit (imageView, 0.0);
     107        psImageInit (maskView, 0);
     108        pmModelAdd (imageView, maskView, model, false, false);
     109
     110        fits = psFitsOpen ("center.fits", "w");
     111        psFitsWriteImage (fits, NULL, imageView, 0, NULL);
     112        psFitsClose (fits);
     113    }
     114
     115    // test of psImageShift
     116    {
     117        // assign the x and y coords to the image center
     118        // create an object with center intensity of 1000
     119        modelRef->params->data.F32[PM_PAR_XPOS] = 200+0.2;
     120        modelRef->params->data.F32[PM_PAR_YPOS] = 200+0.6;
     121       
     122        // create modelPSF from this model
     123        pmModel *model = pmModelFromPSF (modelRef, psf);
     124
     125        // psRegion region = {180, 220, 180, 220};
     126        psRegion region = {0, 0, 0, 0};
     127        psImage *imageView = psImageSubset (readout->image, region);
     128        psImage *maskView = psImageSubset (readout->mask, region);
     129
     130        psImageInit (imageView, 0.0);
     131        psImageInit (maskView, 0);
     132        pmModelAdd (imageView, maskView, model, false, false);
     133        float dx = 0.5 - model->params->data.F32[PM_PAR_XPOS] + (int)model->params->data.F32[PM_PAR_XPOS];
     134        float dy = 0.5 - model->params->data.F32[PM_PAR_YPOS] + (int)model->params->data.F32[PM_PAR_YPOS];
     135        psImage *tmpImage = psImageShift (NULL, imageView, dx, dy, 0.0, PS_INTERPOLATE_BICUBE);
     136
     137        psFits *fits;
     138        fits = psFitsOpen ("unshift_2.fits", "w");
     139        psFitsWriteImage (fits, NULL, imageView, 0, NULL);
     140        psFitsClose (fits);
     141       
     142        fits = psFitsOpen ("shift_2.fits", "w");
     143        psFitsWriteImage (fits, NULL, tmpImage, 0, NULL);
     144        psFitsClose (fits);
     145
     146        modelRef->params->data.F32[PM_PAR_XPOS] = 200+0.5;
     147        modelRef->params->data.F32[PM_PAR_YPOS] = 200+0.5;
     148        model = pmModelFromPSF (modelRef, psf);
     149        psImageInit (imageView, 0.0);
     150        psImageInit (maskView, 0);
     151        pmModelAdd (imageView, maskView, model, false, false);
     152
     153        fits = psFitsOpen ("center_2.fits", "w");
     154        psFitsWriteImage (fits, NULL, imageView, 0, NULL);
     155        psFitsClose (fits);
     156
     157        psImageInit (maskView, 0);
     158        psImageKeepCircle (maskView, model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS], 2, "OR", PM_MASK_MARK);
     159        fits = psFitsOpen ("mask_2.fits", "w");
     160        psFitsWriteImage (fits, NULL, maskView, 0, NULL);
     161        psFitsClose (fits);
     162
     163        psImageInit (maskView, 0);
     164        psImageKeepCircle (maskView, model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS], 3, "OR", PM_MASK_MARK);
     165        fits = psFitsOpen ("mask_3.fits", "w");
     166        psFitsWriteImage (fits, NULL, maskView, 0, NULL);
    66167        psFitsClose (fits);
    67168    }
     
    164265                float dX = 0.5 - model->params->data.F32[PM_PAR_XPOS] + (int)model->params->data.F32[PM_PAR_XPOS];
    165266                float dY = 0.5 - model->params->data.F32[PM_PAR_YPOS] + (int)model->params->data.F32[PM_PAR_YPOS];
    166                 psImage *tmpImage = tmp_psImageShift (imageView, dX, dY);
     267                psImage *tmpImage = psImageShift (NULL, imageView, dX, dY, 0.0, PS_INTERPOLATE_BICUBE);
     268                // psImage *tmpImage = tmp_psImageShift (imageView, dX, dY);
    167269
    168270                psImageKeepCircle (maskView, 200+dx+dX, 200+dy+dY, radius, "OR", PM_MASK_MARK);
    169                 pmSourcePhotometryAper (&apMag, model, imageView, maskView);
    170 
    171                 # if 0
    172                 char name[64];
    173                 psFits *fits;
    174                 sprintf (name, "im.%.1f.fits", dx);
    175                 fits = psFitsOpen (name, "w");
    176                 psFitsWriteImage (fits, NULL, tmpImage, 0, NULL);
    177                 psFitsClose (fits);
    178 
    179                 sprintf (name, "mk.%.1f.fits", dx);
    180                 fits = psFitsOpen (name, "w");
    181                 psFitsWriteImage (fits, NULL, maskView, 0, NULL);
    182                 psFitsClose (fits);
    183                 # endif
    184 
     271                pmSourcePhotometryAper (&apMag, model, tmpImage, maskView);
    185272                psImageKeepCircle (maskView, 200+dx+dX, 200+dy+dY, radius, "AND", PS_NOT_U8(PM_MASK_MARK));
    186273
Note: See TracChangeset for help on using the changeset viewer.