IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 7, 2004, 3:38:05 PM (22 years ago)
Author:
Paul Price
Message:

Working, but not getting faint CRs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/stac/src/stacCombine.c

    r2500 r2661  
    1616    psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEAN | PS_STAT_SAMPLE_STDEV);
    1717    (void)psVectorStats(stats, values, masks, 1);
     18    float mean = stats->sampleMean;
    1819    psFree(stats);
    19     return stats->sampleMean;
     20    return mean;
    2021#else
    2122    // Instead, do it ourselves
     
    4546{
    4647    psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEDIAN);
    47     (void)psVectorStats(stats, values, masks, 1);
     48    (void)psVectorStats(stats, values, masks, 0);
     49    float median = stats->sampleMedian;
    4850    psFree(stats);
    49     return stats->sampleMedian;
     51    return median;
    5052}
    5153
     
    113115        }
    114116    }
    115    
     117
     118#ifdef TESTING
     119    // chi^2 image
     120    psImage *chi2 = psImageAlloc(numCols, numRows, PS_TYPE_F32);
     121    static int iteration = 0;           // Number of times function has been called
     122#endif
    116123   
    117124    for (int y = 0; y < numRows; y++) {
     
    131138            }
    132139           
    133             float average = stacCombineMean(pixels, deltas, mask); // Combined value
     140            float average = stacCombineMedian(pixels, deltas, mask); // Combined value
     141
     142#ifdef TESTING
     143            // Calculate chi^2
     144            chi2->data.F32[y][x] = 0.0;
     145            int numGoodPix = 0;
     146            for (int i = 0; i < nImages; i++) {
     147                if (mask->data.U8[i]) {
     148                    chi2->data.F32[y][x] += SQUARE((pixels->data.F32[i] - average) / deltas->data.F32[i]);
     149                    numGoodPix++;
     150                }
     151            }
     152            chi2->data.F32[y][x] /= (float)numGoodPix;
     153#endif
    134154           
    135155            // Rejection iterations
    136156            for (int rejNum = 0; rejNum < nReject; rejNum++) {
    137157                float max = 0.0;
    138                 int maxIndex = 0;
     158                int maxIndex = -1;
    139159                for (int i = 0; i < nImages; i++) {
    140                     if (mask->data.U8[i] && (ABS(pixels->data.F32[i] - average) / deltas->data.F32[i] > max)) {
    141                         max = ABS(pixels->data.F32[i] - average) / deltas->data.F32[i];
     160                    if (mask->data.U8[i] && ((pixels->data.F32[i] - average) / deltas->data.F32[i] > max)) {
     161                        max = (pixels->data.F32[i] - average) / deltas->data.F32[i];
    142162                        maxIndex = i;
    143163                    }
     
    152172            } // Rejection iterations
    153173           
    154             combined->data.F32[y][x] = average;
     174            combined->data.F32[y][x] = stacCombineMean(pixels, deltas, mask);
    155175        }
    156176    } // Iterating over output pixels
     
    160180    if (nReject > 0) {
    161181        for (int i = 0; i < nImages; i++) {
    162             char rejfile[MAXCHAR];              // Filename of rejection image
     182            char rejfile[MAXCHAR];      // Filename of rejection image
    163183            sprintf(rejfile,"%s.shiftrej",config->inputs->data[i]);
    164184            psImageWriteSection((psImage*)((*rejected)->data[i]),0,0,0,NULL,0,rejfile);
    165185        }
    166186    }
     187    // Write chi^2 image
     188    iteration++;
     189    char chifile[MAXCHAR];              // Filename of chi^2 image
     190    sprintf(chifile,"chi2_%d.fits",iteration);
     191    psImageWriteSection(chi2,0,0,0,NULL,0,chifile);
     192    psFree(chi2);
    167193#endif
    168194
Note: See TracChangeset for help on using the changeset viewer.