IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 9922


Ignore:
Timestamp:
Nov 9, 2006, 10:14:50 AM (20 years ago)
Author:
magnier
Message:

added tap_pmGrowthCurve.c tap_pmSourcePhotometry.c, updated .cvsignores

Location:
trunk/psModules/test
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/test/objects

    • Property svn:ignore
      •  

        old new  
        55temp
        66tst_pmObjects01
         7tap_pmGrowthCurve
         8tap_pmSourcePhotometry
  • trunk/psModules/test/objects/.cvsignore

    r5310 r9922  
    55temp
    66tst_pmObjects01
     7tap_pmGrowthCurve
     8tap_pmSourcePhotometry
  • trunk/psModules/test/objects/tap_pmGrowthCurve.c

    r9877 r9922  
    55
    66#include "tap.h"
     7#include "pstap.h"
    78
    89int main (void)
    910{
    10     plan_tests(143);
     11    pmModelGroupInit ();
     12
     13    plan_tests(57);
    1114
    1215    diag("pmGrowthCurve tests");
    1316
    1417    // test allocation
    15     diag("pmGrowthCurveAlloc tests");
     18    diag("offset of 0.0,0.0 wrt growth ref source");
    1619    {
    1720        psMemId id = psMemGetId();
     
    2932
    3033        // does the growth curve correctly fix aperture mags?
    31         pmModelGroupInit ();
    3234
    3335        // generate a simple readout
     
    3638        readout->mask  = psImageAlloc (64, 64, PS_TYPE_U8);
    3739
     40        // create an empty reference image
     41        psImageInit (readout->image, 0.0);
     42        psImageInit (readout->mask, 0);
     43
    3844        // generate a simple psf
    3945        pmPSF *psf = pmPSFBuildSimple ("PS_MODEL_GAUSS", 1.5, 1.5, 0.0);
     
    4349
    4450        // check ap mags for a few radii set by hand
    45         ok_float(growth->apMag->data.F32[0],  0.0, "apMag at radius 0: %f", growth->apMag->data.F32[0]);
    46         ok_float(growth->apMag->data.F32[3],  0.0, "apMag at radius 3: %f", growth->apMag->data.F32[3]);
    47         ok_float(growth->apMag->data.F32[10], 0.0, "apMag at radius 10: %f", growth->apMag->data.F32[10]);
    48         ok_float(growth->apMag->data.F32[30], 0.0, "apMag at radius 30: %f", growth->apMag->data.F32[30]);
    49 
    50         ok_float(growth->apRef, 0.0, "apMag at ref radius : %f", growth->apRef);
     51        ok_float_tol(growth->apMag->data.F32[0],   -9.7805, 0.0001, "apMag at radius 0: %f", growth->apMag->data.F32[0]);
     52        ok_float_tol(growth->apMag->data.F32[3],  -10.3722, 0.0001, "apMag at radius 3: %f", growth->apMag->data.F32[3]);
     53        ok_float_tol(growth->apMag->data.F32[10], -10.3759, 0.0001, "apMag at radius 10: %f", growth->apMag->data.F32[10]);
     54        ok_float_tol(growth->apMag->data.F32[30], -10.3759, 0.0001, "apMag at radius 30: %f", growth->apMag->data.F32[30]);
     55
     56        ok_float_tol(growth->apRef,  -10.3759, 0.0001, "apMag at ref radius : %f", growth->apRef);
     57        ok_float_tol(growth->fitMag, -10.3759, 0.0001, "fitMag : %f", growth->fitMag);
    5158        ok_float(growth->apLoss, 0.0, "apLoss : %f", growth->apLoss);
    52         ok_float(growth->fitMag, 0.0, "fitMag : %f", growth->fitMag);
    5359
    5460        // create template model and measure apMag at fractional offsets
     
    6066        modelRef->params->data.F32[PM_PAR_YPOS] = 32.5;
    6167
    62         // create modelPSF from this model
    63         pmModel *model = pmModelFromPSF (modelRef, psf);
    64         model->radiusFit = radius;
     68        // measure growth-corrected photometry:
     69        pmSource *source = pmSourceAlloc ();
     70        source->modelPSF = pmModelFromPSF (modelRef, psf);
     71        source->type = PM_SOURCE_TYPE_STAR;
     72        source->pixels = psMemIncrRefCounter (readout->image);
     73        source->mask = psMemIncrRefCounter (readout->mask);
     74
     75        source->modelPSF->dparams->data.F32[PM_PAR_I0] = 1;
     76        source->mode = PM_SOURCE_MODE_SUBTRACTED;
     77
     78        source->modelPSF->radiusFit = 15.0;
     79        pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP);
     80        double refMag = source->apMag;
     81
     82        source->modelPSF->radiusFit = 10.0;
     83        pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP);
     84        ok_float_tol(refMag - source->apMag, +0.0000, 0.0001, "growth offset is is %f", refMag - source->apMag);
     85
     86        source->modelPSF->radiusFit = 8.0;
     87        pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP);
     88        ok_float_tol(refMag - source->apMag, +0.0000, 0.0001, "growth offset is is %f", refMag - source->apMag);
     89
     90        source->modelPSF->radiusFit = 6.0;
     91        pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP);
     92        ok_float_tol(refMag - source->apMag, +0.0003, 0.0001, "growth offset is is %f", refMag - source->apMag);
     93
     94        source->modelPSF->radiusFit = 4.0;
     95        pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP);
     96        ok_float_tol(refMag - source->apMag, +0.0020, 0.0001, "growth offset is is %f", refMag - source->apMag);
     97
     98        source->modelPSF->radiusFit = 3.0;
     99        pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP);
     100        ok_float_tol(refMag - source->apMag, -0.0001, 0.0001, "growth offset is is %f", refMag - source->apMag);
     101
     102        source->modelPSF->radiusFit = 2.0;
     103        pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP);
     104        ok_float_tol(refMag - source->apMag, -0.0075, 0.0001, "growth offset is is %f", refMag - source->apMag);
     105
     106        // XXX include some apertures outside of growth correction range
     107
     108        psFree(modelRef);
     109        psFree(source);
     110        psFree(readout);
     111        psFree(psf);
     112
     113        skip_end();
     114
     115        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     116    }
     117
     118    // test allocation
     119    diag("offset of 0.2,0.2 wrt growth ref source");
     120    {
     121        psMemId id = psMemGetId();
     122
     123        pmGrowthCurve *growth = pmGrowthCurveAlloc (2.0, 100.0, 15.0);
     124
     125        ok(growth != NULL, "growth curve allocated");
     126        skip_start(growth == NULL, 0, "Skipping tests because pmShutterCorrParsAlloc() failed");
     127
     128        ok(growth->radius->n == (100.0 - 2.0), "correct number of growth radii");
     129        ok(growth->apMag->n == (100.0 - 2.0), "correct number of growth apMags");
     130
     131        ok_float(growth->refRadius, 15.0, "correct refRadius");
     132        ok_float(growth->maxRadius, 100.0, "correct maxRadius");
     133
     134        // does the growth curve correctly fix aperture mags?
     135
     136        // generate a simple readout
     137        pmReadout *readout = pmReadoutAlloc (NULL);
     138        readout->image = psImageAlloc (64, 64, PS_TYPE_F32);
     139        readout->mask  = psImageAlloc (64, 64, PS_TYPE_U8);
    65140
    66141        // create an empty reference image
     
    68143        psImageInit (readout->mask, 0);
    69144
    70         // we generate a subtracted model, pmSourceMagnitude will insert and remove it
    71         // pmModelAdd (readout->image, readout->mask, model, false, false);
     145        // generate a simple psf
     146        pmPSF *psf = pmPSFBuildSimple ("PS_MODEL_GAUSS", 1.5, 1.5, 0.0);
     147        psf->growth = growth;
     148
     149        pmGrowthCurveGenerate (readout, psf, false);
     150
     151        // check ap mags for a few radii set by hand
     152        ok_float_tol(growth->apMag->data.F32[0],   -9.7805, 0.0001, "apMag at radius 0: %f", growth->apMag->data.F32[0]);
     153        ok_float_tol(growth->apMag->data.F32[3],  -10.3722, 0.0001, "apMag at radius 3: %f", growth->apMag->data.F32[3]);
     154        ok_float_tol(growth->apMag->data.F32[10], -10.3759, 0.0001, "apMag at radius 10: %f", growth->apMag->data.F32[10]);
     155        ok_float_tol(growth->apMag->data.F32[30], -10.3759, 0.0001, "apMag at radius 30: %f", growth->apMag->data.F32[30]);
     156
     157        ok_float_tol(growth->apRef,  -10.3759, 0.0001, "apMag at ref radius : %f", growth->apRef);
     158        ok_float_tol(growth->fitMag, -10.3759, 0.0001, "fitMag : %f", growth->fitMag);
     159        ok_float(growth->apLoss, 0.0, "apLoss : %f", growth->apLoss);
     160
     161        // create template model and measure apMag at fractional offsets
     162        // XXX note model is at 0.5,0.5 subpix center
     163        pmModel *modelRef = pmModelAlloc(psf->type);
     164        modelRef->params->data.F32[PM_PAR_SKY] = 0;
     165        modelRef->params->data.F32[PM_PAR_I0] = 1000;
     166        modelRef->params->data.F32[PM_PAR_XPOS] = 32.3;
     167        modelRef->params->data.F32[PM_PAR_YPOS] = 32.3;
    72168
    73169        // measure growth-corrected photometry:
    74170        pmSource *source = pmSourceAlloc ();
    75         source->modelPSF = model;
     171        source->modelPSF = pmModelFromPSF (modelRef, psf);
    76172        source->type = PM_SOURCE_TYPE_STAR;
    77         source->pixels = readout->image;
    78         source->mask = readout->mask;
     173        source->pixels = psMemIncrRefCounter (readout->image);
     174        source->mask = psMemIncrRefCounter (readout->mask);
    79175
    80176        source->modelPSF->dparams->data.F32[PM_PAR_I0] = 1;
    81         source->mode = PM_SOURCE_SUBTRACTED;
    82 
    83         source->modelPSF->radiusFit = 10.0
    84                                       pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP);
    85 
    86         ok_float_tol(source->fitMag, -10.0, 0.1, "source fitMag is %f", source->fitMag);
    87         ok_float_tol(source->apMag,  -10.0, 0.1, "source apMag is %f", source->apMag);
    88         ok_float_tol(source->errMag,   0.1, 0.01, "source errMag is %f", source->errMag);
    89 
    90         source->modelPSF->radiusFit = 8.0
    91                                       pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP);
    92 
    93         ok_float_tol(source->fitMag, -10.0, 0.1, "source fitMag is %f", source->fitMag);
    94         ok_float_tol(source->apMag,  -10.0, 0.1, "source apMag is %f", source->apMag);
    95         ok_float_tol(source->errMag,   0.1, 0.01, "source errMag is %f", source->errMag);
    96 
    97         source->modelPSF->radiusFit = 6.0
    98                                       pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP);
    99 
    100         ok_float_tol(source->fitMag, -10.0, 0.1, "source fitMag is %f", source->fitMag);
    101         ok_float_tol(source->apMag,  -10.0, 0.1, "source apMag is %f", source->apMag);
    102         ok_float_tol(source->errMag,   0.1, 0.01, "source errMag is %f", source->errMag);
    103 
    104         source->modelPSF->radiusFit = 4.0
    105                                       pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP);
    106 
    107         ok_float_tol(source->fitMag, -10.0, 0.1, "source fitMag is %f", source->fitMag);
    108         ok_float_tol(source->apMag,  -10.0, 0.1, "source apMag is %f", source->apMag);
    109         ok_float_tol(source->errMag,   0.1, 0.01, "source errMag is %f", source->errMag);
    110 
    111         source->modelPSF->radiusFit = 2.0
    112                                       pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP);
    113 
    114         ok_float_tol(source->fitMag, -10.0, 0.1, "source fitMag is %f", source->fitMag);
    115         ok_float_tol(source->apMag,  -10.0, 0.1, "source apMag is %f", source->apMag);
    116         ok_float_tol(source->errMag,   0.1, 0.01, "source errMag is %f", source->errMag);
     177        source->mode = PM_SOURCE_MODE_SUBTRACTED;
     178
     179        source->modelPSF->radiusFit = 15.0;
     180        pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP);
     181        double refMag = source->apMag;
     182
     183        source->modelPSF->radiusFit = 10.0;
     184        pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP);
     185        ok_float_tol(refMag - source->apMag, +0.0000, 0.0001, "growth offset is is %f", refMag - source->apMag);
     186
     187        source->modelPSF->radiusFit = 8.0;
     188        pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP);
     189        ok_float_tol(refMag - source->apMag, +0.0000, 0.0001, "growth offset is is %f", refMag - source->apMag);
     190
     191        source->modelPSF->radiusFit = 6.0;
     192        pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP);
     193        ok_float_tol(refMag - source->apMag, +0.0004, 0.0001, "growth offset is is %f", refMag - source->apMag);
     194
     195        source->modelPSF->radiusFit = 4.0;
     196        pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP);
     197        ok_float_tol(refMag - source->apMag, +0.0026, 0.0001, "growth offset is is %f", refMag - source->apMag);
     198
     199        source->modelPSF->radiusFit = 3.0;
     200        pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP);
     201        ok_float_tol(refMag - source->apMag, -0.0001, 0.0001, "growth offset is is %f", refMag - source->apMag);
     202
     203        source->modelPSF->radiusFit = 2.0;
     204        pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP);
     205        ok_float_tol(refMag - source->apMag, -0.0103, 0.0001, "growth offset is is %f", refMag - source->apMag);
    117206
    118207        // XXX include some apertures outside of growth correction range
    119208
     209        psFree(modelRef);
     210        psFree(source);
     211        psFree(readout);
     212        psFree(psf);
     213
    120214        skip_end();
    121         psFree(growth);
     215
    122216        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    123217    }
    124218
     219    // test allocation
     220    diag("offset of 0.4,0.4 wrt growth ref source");
     221    {
     222        psMemId id = psMemGetId();
     223
     224        pmGrowthCurve *growth = pmGrowthCurveAlloc (2.0, 100.0, 15.0);
     225
     226        ok(growth != NULL, "growth curve allocated");
     227        skip_start(growth == NULL, 0, "Skipping tests because pmShutterCorrParsAlloc() failed");
     228
     229        ok(growth->radius->n == (100.0 - 2.0), "correct number of growth radii");
     230        ok(growth->apMag->n == (100.0 - 2.0), "correct number of growth apMags");
     231
     232        ok_float(growth->refRadius, 15.0, "correct refRadius");
     233        ok_float(growth->maxRadius, 100.0, "correct maxRadius");
     234
     235        // does the growth curve correctly fix aperture mags?
     236
     237        // generate a simple readout
     238        pmReadout *readout = pmReadoutAlloc (NULL);
     239        readout->image = psImageAlloc (64, 64, PS_TYPE_F32);
     240        readout->mask  = psImageAlloc (64, 64, PS_TYPE_U8);
     241
     242        // create an empty reference image
     243        psImageInit (readout->image, 0.0);
     244        psImageInit (readout->mask, 0);
     245
     246        // generate a simple psf
     247        pmPSF *psf = pmPSFBuildSimple ("PS_MODEL_GAUSS", 1.5, 1.5, 0.0);
     248        psf->growth = growth;
     249
     250        pmGrowthCurveGenerate (readout, psf, false);
     251
     252        // check ap mags for a few radii set by hand
     253        ok_float_tol(growth->apMag->data.F32[0],   -9.7805, 0.0001, "apMag at radius 0: %f", growth->apMag->data.F32[0]);
     254        ok_float_tol(growth->apMag->data.F32[3],  -10.3722, 0.0001, "apMag at radius 3: %f", growth->apMag->data.F32[3]);
     255        ok_float_tol(growth->apMag->data.F32[10], -10.3759, 0.0001, "apMag at radius 10: %f", growth->apMag->data.F32[10]);
     256        ok_float_tol(growth->apMag->data.F32[30], -10.3759, 0.0001, "apMag at radius 30: %f", growth->apMag->data.F32[30]);
     257
     258        ok_float_tol(growth->apRef,  -10.3759, 0.0001, "apMag at ref radius : %f", growth->apRef);
     259        ok_float_tol(growth->fitMag, -10.3759, 0.0001, "fitMag : %f", growth->fitMag);
     260        ok_float(growth->apLoss, 0.0, "apLoss : %f", growth->apLoss);
     261
     262        // create template model and measure apMag at fractional offsets
     263        // XXX note model is at 0.5,0.5 subpix center
     264        pmModel *modelRef = pmModelAlloc(psf->type);
     265        modelRef->params->data.F32[PM_PAR_SKY] = 0;
     266        modelRef->params->data.F32[PM_PAR_I0] = 1000;
     267        modelRef->params->data.F32[PM_PAR_XPOS] = 32.1;
     268        modelRef->params->data.F32[PM_PAR_YPOS] = 32.1;
     269
     270        // measure growth-corrected photometry:
     271        pmSource *source = pmSourceAlloc ();
     272        source->modelPSF = pmModelFromPSF (modelRef, psf);
     273        source->type = PM_SOURCE_TYPE_STAR;
     274        source->pixels = psMemIncrRefCounter (readout->image);
     275        source->mask = psMemIncrRefCounter (readout->mask);
     276
     277        source->modelPSF->dparams->data.F32[PM_PAR_I0] = 1;
     278        source->mode = PM_SOURCE_MODE_SUBTRACTED;
     279
     280        source->modelPSF->radiusFit = 15.0;
     281        pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP);
     282        double refMag = source->apMag;
     283
     284        source->modelPSF->radiusFit = 10.0;
     285        pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP);
     286        ok_float_tol(refMag - source->apMag, +0.0000, 0.0001, "growth offset is is %f", refMag - source->apMag);
     287
     288        source->modelPSF->radiusFit = 8.0;
     289        pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP);
     290        ok_float_tol(refMag - source->apMag, +0.0000, 0.0001, "growth offset is is %f", refMag - source->apMag);
     291
     292        source->modelPSF->radiusFit = 6.0;
     293        pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP);
     294        ok_float_tol(refMag - source->apMag, +0.0006, 0.0001, "growth offset is is %f", refMag - source->apMag);
     295
     296        source->modelPSF->radiusFit = 4.0;
     297        pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP);
     298        ok_float_tol(refMag - source->apMag, +0.0038, 0.0001, "growth offset is is %f", refMag - source->apMag);
     299
     300        source->modelPSF->radiusFit = 3.0;
     301        pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP);
     302        ok_float_tol(refMag - source->apMag, +0.0000, 0.0001, "growth offset is is %f", refMag - source->apMag);
     303
     304        source->modelPSF->radiusFit = 2.0;
     305        pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP);
     306        ok_float_tol(refMag - source->apMag, -0.0164, 0.0001, "growth offset is is %f", refMag - source->apMag);
     307
     308        // XXX include some apertures outside of growth correction range
     309
     310        psFree(modelRef);
     311        psFree(source);
     312        psFree(readout);
     313        psFree(psf);
     314
     315        skip_end();
     316
     317        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     318    }
     319
    125320    return exit_status();
    126321}
  • trunk/psModules/test/objects/tap_pmSourcePhotometry.c

    r9877 r9922  
    55
    66#include "tap.h"
     7#include "pstap.h"
     8
     9bool pmSourcePhotometry_TestOffsets (double radius, double sigma, double fitMag, double apMag, double err1, double err2);
    710
    811int main (void)
     
    1114    pmModelGroupInit ();
    1215
    13     plan_tests(143);
     16    plan_tests(240);
    1417
    1518    diag("pmSourcePhotometry tests");
    1619
    17     // test allocation, free of pmShutterCorrPars
    18     {
    19         psMemId id = psMemGetId();
     20    // test consistency of interpolated photometry for a range of apertures (for a fixed PSF sigma)
     21    pmSourcePhotometry_TestOffsets (15.0, 2.0, -10.3759, -10.3759, +0.0000, +0.0000);
     22    pmSourcePhotometry_TestOffsets (10.0, 2.0, -10.3759, -10.3759, +0.0000, +0.0000);
     23    pmSourcePhotometry_TestOffsets ( 8.0, 2.0, -10.3759, -10.3759, +0.0000, +0.0000);
     24    pmSourcePhotometry_TestOffsets ( 7.0, 2.0, -10.3759, -10.3759, +0.0000, +0.0001);
     25    pmSourcePhotometry_TestOffsets ( 6.0, 2.0, -10.3759, -10.3758, +0.0001, +0.0004);
     26    pmSourcePhotometry_TestOffsets ( 5.0, 2.0, -10.3759, -10.3733, +0.0003, +0.0011);
     27    pmSourcePhotometry_TestOffsets ( 4.0, 2.0, -10.3759, -10.3520, +0.0006, +0.0018);
     28    pmSourcePhotometry_TestOffsets ( 3.0, 2.0, -10.3759, -10.2626, +0.0001, +0.0002);
     29    pmSourcePhotometry_TestOffsets ( 2.0, 2.0, -10.3759,  -9.7729, -0.0027, -0.0089);
     30    pmSourcePhotometry_TestOffsets ( 1.0, 2.0, -10.3759,  -8.8689, -0.0051, -0.0161);
    2031
    21         diag("pmSourcePhotometry basic tests");
     32    // test consistency of interpolated photometry for a range of apertures (for a fixed PSF sigma)
     33    pmSourcePhotometry_TestOffsets (15.0, 1.5, -10.3759, -10.3759, +0.0000, +0.0000);
     34    pmSourcePhotometry_TestOffsets (10.0, 1.5, -10.3759, -10.3759, +0.0000, +0.0000);
     35    pmSourcePhotometry_TestOffsets ( 8.0, 1.5, -10.3759, -10.3759, +0.0000, +0.0000);
     36    pmSourcePhotometry_TestOffsets ( 7.0, 1.5, -10.3759, -10.3759, +0.0000, +0.0001);
     37    pmSourcePhotometry_TestOffsets ( 6.0, 1.5, -10.3759, -10.3758, +0.0001, +0.0004);
     38    pmSourcePhotometry_TestOffsets ( 5.0, 1.5, -10.3759, -10.3733, +0.0003, +0.0011);
     39    pmSourcePhotometry_TestOffsets ( 4.0, 1.5, -10.3759, -10.3520, +0.0006, +0.0018);
     40    pmSourcePhotometry_TestOffsets ( 3.0, 1.5, -10.3759, -10.2626, +0.0001, +0.0002);
     41    pmSourcePhotometry_TestOffsets ( 2.0, 1.5, -10.3759,  -9.7729, -0.0027, -0.0089);
     42    pmSourcePhotometry_TestOffsets ( 1.0, 1.5, -10.3759,  -8.8689, -0.0051, -0.0161);
    2243
    23         // generate a simple readout
    24         pmReadout *readout = pmReadoutAlloc (NULL);
    25         readout->image = psImageAlloc (64, 64, PS_TYPE_F32);
    26         readout->mask  = psImageAlloc (64, 64, PS_TYPE_U8);
    27 
    28         // create an empty reference image
    29         psImageInit (readout->image, 0.0);
    30         psImageInit (readout->mask, 0);
    31 
    32         // generate a simple psf
    33         pmPSF *psf = pmPSFBuildSimple ("PS_MODEL_GAUSS", 1.5, 1.5, 0.0);
    34 
    35         // create a source
    36         pmSource *source = pmSourceAlloc ();
    37         source->pixels = readout->image;
    38         source->mask   = readout->mask;
    39         source->type   = PM_SOURCE_TYPE_STAR;
    40         source->mode   = PM_SOURCE_SUBTRACTED;
    41 
    42         // create template model and measure apMag at fractional offsets
    43         pmModel *modelRef = pmModelAlloc(psf->type);
    44         modelRef->params->data.F32[PM_PAR_SKY] = 0;
    45         modelRef->params->data.F32[PM_PAR_I0] = 1000;
    46         modelRef->params->data.F32[PM_PAR_XPOS] = 32.5;
    47         modelRef->params->data.F32[PM_PAR_YPOS] = 32.5;
    48 
    49         // create modelPSF from this model
    50         source->modelPSF = pmModelFromPSF (modelRef, psf);
    51         source->modelPSF->radiusFit = radius;
    52         source->modelPSF->dparams->data.F32[PM_PAR_I0] = 1;
    53         source->modelPSF->radiusFit = 10.0
    54 
    55                                       // measure growth-corrected photometry:
    56                                       pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP);
    57 
    58         ok_float_tol(source->fitMag, -10.0, 0.1, "source fitMag is %f", source->fitMag);
    59         ok_float_tol(source->apMag,  -10.0, 0.1, "source apMag is %f", source->apMag);
    60         ok_float_tol(source->errMag,   0.1, 0.01, "source errMag is %f", source->errMag);
    61         float refMag = source->apMag;
    62 
    63         // use a sub-pixel offset position
    64         source->modelPSF->params->data.F32[PM_PAR_XPOS] = 32.3;
    65         source->modelPSF->params->data.F32[PM_PAR_YPOS] = 32.3;
    66 
    67         // measure growth-corrected photometry:
    68         pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP);
    69         ok_float_tol(refMag - source->apMag,  0.0, 0.1, "source apMag is %f", source->apMag);
    70 
    71         psFree (source);
    72         psFree (model);
    73 
    74         psFree (modelRef);
    75         psFree (psf);
    76         psFree (readout);
    77 
    78         ok(pars != NULL, "pmShutterCorrPars successfully allocated");
    79         skip_start(pars == NULL, 0, "Skipping tests because pmShutterCorrParsAlloc() failed");
    80         skip_end();
    81 
    82         skip_end();
    83 
    84         psFree(growth);
    85         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    86     }
    87 
     44    // test consistency of interpolated photometry for a range of apertures (for a fixed PSF sigma)
     45    pmSourcePhotometry_TestOffsets (15.0, 1.0,  -9.4955,  -9.4955, +0.0000, +0.0000);
     46    pmSourcePhotometry_TestOffsets (10.0, 1.0,  -9.4955,  -9.4955, +0.0000, +0.0000);
     47    pmSourcePhotometry_TestOffsets ( 8.0, 1.0,  -9.4955,  -9.4955, +0.0000, +0.0000);
     48    pmSourcePhotometry_TestOffsets ( 7.0, 1.0,  -9.4955,  -9.4955, +0.0000, +0.0000);
     49    pmSourcePhotometry_TestOffsets ( 6.0, 1.0,  -9.4955,  -9.4955, +0.0000, +0.0001);
     50    pmSourcePhotometry_TestOffsets ( 5.0, 1.0,  -9.4955,  -9.4955, +0.0001, +0.0002);
     51    pmSourcePhotometry_TestOffsets ( 4.0, 1.0,  -9.4955,  -9.4968, +0.0006, +0.0022);
     52    pmSourcePhotometry_TestOffsets ( 3.0, 1.0,  -9.4955,  -9.4945, +0.0021, +0.0068);
     53    pmSourcePhotometry_TestOffsets ( 2.0, 1.0,  -9.4955,  -9.3323, -0.0034, -0.0118);
     54    pmSourcePhotometry_TestOffsets ( 1.0, 1.0,  -9.4955,  -8.6844, -0.0141, -0.0440);
    8855
    8956    return exit_status();
    9057}
     58
     59bool pmSourcePhotometry_TestOffsets (double radius, double sigma, double fitMag, double apMag, double err1, double err2)
     60{
     61    psMemId id = psMemGetId();
     62
     63    diag("pmSourcePhotometry test offsets for radius %f", radius);
     64
     65    // generate a simple readout
     66    pmReadout *readout = pmReadoutAlloc (NULL);
     67    skip_start(readout == NULL, 0, "Skipping tests because pmReadoutAlloc failed");
     68
     69    readout->image = psImageAlloc (64, 64, PS_TYPE_F32);
     70    readout->mask  = psImageAlloc (64, 64, PS_TYPE_U8);
     71
     72    // create an empty reference image
     73    psImageInit (readout->image, 0.0);
     74    psImageInit (readout->mask, 0);
     75
     76    // generate a simple psf
     77    pmPSF *psf = pmPSFBuildSimple ("PS_MODEL_GAUSS", sigma, sigma, 0.0);
     78    // psf->growth = pmGrowthCurveAlloc (2.0, 100.0, 15.0);
     79    // pmGrowthCurveGenerate (readout, psf, false);
     80
     81    // create a source
     82    pmSource *source = pmSourceAlloc ();
     83    source->pixels = psMemIncrRefCounter (readout->image);
     84    source->mask   = psMemIncrRefCounter (readout->mask);
     85    source->type   = PM_SOURCE_TYPE_STAR;
     86    source->mode   = PM_SOURCE_MODE_SUBTRACTED;
     87
     88    // create template model and measure apMag at fractional offsets
     89    pmModel *modelRef = pmModelAlloc(psf->type);
     90    modelRef->params->data.F32[PM_PAR_SKY] = 0;
     91    modelRef->params->data.F32[PM_PAR_I0] = 1000;
     92    modelRef->params->data.F32[PM_PAR_XPOS] = 32.5;
     93    modelRef->params->data.F32[PM_PAR_YPOS] = 32.5;
     94
     95    // create modelPSF from this model
     96    source->modelPSF = pmModelFromPSF (modelRef, psf);
     97    source->modelPSF->dparams->data.F32[PM_PAR_I0] = 1;
     98    source->modelPSF->radiusFit = radius;
     99
     100    // measure photometry for centered source (fractional pix : 0.5,0.5)
     101    // pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP);
     102    pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_INTERP);
     103    ok_float_tol(source->psfMag, fitMag, 0.0002, "source fitMag is %f", source->psfMag);
     104    ok_float_tol(source->apMag,  apMag, 0.0002, "source apMag is %f", source->apMag);
     105    ok_float(source->errMag,   0.001, "source errMag is %f", source->errMag);
     106    float refMag = source->apMag;
     107
     108    // these use an offset of 0.2,0.2
     109    // measure photometry for a sub-pixel offset position
     110    source->modelPSF->params->data.F32[PM_PAR_XPOS] = 32.3;
     111    source->modelPSF->params->data.F32[PM_PAR_YPOS] = 32.3;
     112    pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_INTERP);
     113    ok_float_tol(refMag - source->apMag,  err1, 0.0002, "offset error is %f", refMag - source->apMag);
     114
     115    // measure photometry for a sub-pixel offset position
     116    source->modelPSF->params->data.F32[PM_PAR_XPOS] = 32.7;
     117    source->modelPSF->params->data.F32[PM_PAR_YPOS] = 32.3;
     118    pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_INTERP);
     119    ok_float_tol(refMag - source->apMag,  err1, 0.0002, "offset error is %f", refMag - source->apMag);
     120
     121    // measure photometry for a sub-pixel offset position
     122    source->modelPSF->params->data.F32[PM_PAR_XPOS] = 32.3;
     123    source->modelPSF->params->data.F32[PM_PAR_YPOS] = 32.7;
     124    pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_INTERP);
     125    ok_float_tol(refMag - source->apMag,  err1, 0.0002, "offset error is %f", refMag - source->apMag);
     126
     127    // measure photometry for a sub-pixel offset position
     128    source->modelPSF->params->data.F32[PM_PAR_XPOS] = 32.7;
     129    source->modelPSF->params->data.F32[PM_PAR_YPOS] = 32.7;
     130    pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_INTERP);
     131    ok_float_tol(refMag - source->apMag,  err1, 0.0002, "offset error is %f", refMag - source->apMag);
     132
     133    // these use an offset of 0.4,0.4
     134    // measure photometry for a sub-pixel offset position
     135    source->modelPSF->params->data.F32[PM_PAR_XPOS] = 32.1;
     136    source->modelPSF->params->data.F32[PM_PAR_YPOS] = 32.1;
     137    pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_INTERP);
     138    ok_float_tol(refMag - source->apMag,  err2, 0.0002, "offset error is %f", refMag - source->apMag);
     139
     140    // measure photometry for a sub-pixel offset position
     141    source->modelPSF->params->data.F32[PM_PAR_XPOS] = 32.9;
     142    source->modelPSF->params->data.F32[PM_PAR_YPOS] = 32.1;
     143    pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_INTERP);
     144    ok_float_tol(refMag - source->apMag,  err2, 0.0002, "offset error is %f", refMag - source->apMag);
     145
     146    // measure photometry for a sub-pixel offset position
     147    source->modelPSF->params->data.F32[PM_PAR_XPOS] = 32.1;
     148    source->modelPSF->params->data.F32[PM_PAR_YPOS] = 32.9;
     149    pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_INTERP);
     150    ok_float_tol(refMag - source->apMag,  err2, 0.0002, "offset error is %f", refMag - source->apMag);
     151
     152    // measure photometry for a sub-pixel offset position
     153    source->modelPSF->params->data.F32[PM_PAR_XPOS] = 32.9;
     154    source->modelPSF->params->data.F32[PM_PAR_YPOS] = 32.9;
     155    pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_INTERP);
     156    ok_float_tol(refMag - source->apMag,  err2, 0.0002, "offset error is %f", refMag - source->apMag);
     157
     158    psFree (source);
     159    psFree (modelRef);
     160    psFree (psf);
     161    psFree (readout);
     162
     163    skip_end();
     164
     165    ok(!psMemCheckLeaks (id, NULL, stdout, false), "no memory leaks");
     166    return true;
     167}
  • trunk/psModules/test/pstap

    • Property svn:ignore set to
      Makefile
      Makefile.in
  • trunk/psModules/test/pstap/src

    • Property svn:ignore set to
      Makefile
      Makefile.in
      libpstap.la
      pstap.lo
      .deps
      .libs
  • trunk/psModules/test/pstap/src/Makefile.am

    r9876 r9922  
    99        $(top_builddir)/src/libpsmodules.la  \
    1010        $(top_builddir)/test/tap/src/libtap.la \
    11         $(top_builddir)/test/pstap/src/libpstap.la \
    1211        $(PSMODULES_LIBS)
    1312
Note: See TracChangeset for help on using the changeset viewer.