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