IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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/objects
Files:
2 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/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}
Note: See TracChangeset for help on using the changeset viewer.