IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 7, 2005, 6:32:40 PM (21 years ago)
Author:
eugene
Message:

cleanup, organization

File:
1 edited

Legend:

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

    r4949 r4977  
    11# include "psphot.h"
    22
    3 // test PSF models and select best option
     3// try PSF models and select best option
    44
    55pmPSF *psphotChoosePSF (psMetadata *config, psArray *sources, psStats *skystats)
     
    77    bool            status;
    88    char           *modelName;
    9     pmPSF_Test     *test  = NULL;
     9    pmPSFtry       *try   = NULL;
    1010    psArray        *stars = NULL;
    1111    psMetadataItem *item  = NULL;
     
    3434    psListIterator *iter = psListIteratorAlloc (list, PS_LIST_HEAD, FALSE);
    3535
    36     // set up an array to store the test results
    37     psArray *tests = psArrayAlloc (list->n);
     36    // set up an array to store the results
     37    psArray *models = psArrayAlloc (list->n);
    3838
    39     // test each model option listed in config
    40     for (int i = 0; i < tests->n; i++) {
     39    // try each model option listed in config
     40    for (int i = 0; i < models->n; i++) {
    4141
    4242        item = psListGetAndIncrement (iter);
    4343        modelName = item->data.V;
    4444
    45         tests->data[i] = pmPSF_TestModel (stars, modelName, RADIUS);
     45        models->data[i] = pmPSFtryModel (stars, modelName, RADIUS);
    4646        psFree (modelName);
    4747        psFree (item);
     
    5151    psFree (stars);
    5252
    53     // select the best of the test models
     53    // select the best of the models
    5454    // here we are using the clippedStdev on the metric as the indicator
    55     test = tests->data[0];
     55    try = models->data[0];
    5656    int bestN = 0;
    57     float bestM = test->dApResid;
    58     for (int i = 1; i < tests->n; i++) {
    59         test = tests->data[i];
    60         float M = test->dApResid;
     57    float bestM = try->dApResid;
     58    for (int i = 1; i < models->n; i++) {
     59        try = models->data[i];
     60        float M = try->dApResid;
    6161        if (M < bestM) {
    6262            bestM = M;
     
    6565    }
    6666
    67     // keep only the selected test:
    68     test = tests->data[bestN];
    69     modelName = pmModelGetType (test->modelType);
    70     psLogMsg ("psphot.pspsf", 3, "selected psf model %s, ApResid: %f +/- %f\n", modelName, test->ApResid, test->dApResid);
     67    // keep only the selected model:
     68    try = models->data[bestN];
     69    modelName = pmModelGetType (try->modelType);
     70    psLogMsg ("psphot.pspsf", 3, "selected psf model %s, ApResid: %f +/- %f\n", modelName, try->ApResid, try->dApResid);
    7171
    72     // XXX I am having trouble tracking down the double frees vs leaks
    73     # if (0)
    74     // we are keeping the modelPSF fits from the PSF test,
    75     // but we replace these later on (apply_psf_model)
    76     // set source->model based on best psf model fit
    77     for (int i = 0; i < test->sources->n; i++) {
    78         pmSource *source = test->sources->data[i];
    79         // drop masked sources from PSFSTAR list
    80         if (test->mask->data.U8[i]) {
    81           source->type = PS_SOURCE_OTHER;
    82           source->modelPSF = NULL;
    83         } else {
    84           // source->modelPSF = psMemCopy(test->modelPSF->data[i]);
    85           source->modelPSF = test->modelPSF->data[i];
    86         }
    87     }
    88     # endif
    89 
    90     pmPSF *psf = psMemCopy(test->psf);
    91     psFree (tests);
     72    // keep only the pmPSF resulting from this analysis
     73    pmPSF *psf = psMemCopy(try->psf);
     74    psFree (models);
    9275    return (psf);
    9376}
Note: See TracChangeset for help on using the changeset viewer.