IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 24, 2006, 2:07:03 PM (20 years ago)
Author:
Paul Price
Message:

Changed definition of psVectorAlloc and psArrayAlloc

File:
1 edited

Legend:

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

    r9520 r9734  
    22
    33// 2006.02.02 : no leaks
    4 psArray *psphotSourceStats (pmReadout *readout, psMetadata *recipe, psArray *peaks) 
     4psArray *psphotSourceStats (pmReadout *readout, psMetadata *recipe, psArray *peaks)
    55{
    66    bool     status  = false;
     
    1616    char *breakPt  = psMetadataLookupStr (&status, recipe, "BREAK_POINT");
    1717
    18     sources = psArrayAlloc (peaks->n);
     18    sources = psArrayAllocEmpty (peaks->n);
    1919
    2020    for (int i = 0; i < peaks->n; i++) {
    2121
    22         // create a new source, add peak
    23         pmSource *source = pmSourceAlloc();
    24         source->peak = (pmPeak *)psMemIncrRefCounter(peaks->data[i]);
     22        // create a new source, add peak
     23        pmSource *source = pmSourceAlloc();
     24        source->peak = (pmPeak *)psMemIncrRefCounter(peaks->data[i]);
    2525
    26         // allocate image, weight, mask arrays for each peak (square of radius OUTER)
    27         pmSourceDefinePixels (source, readout, source->peak->x, source->peak->y, OUTER);
    28         if (!strcasecmp (breakPt, "PEAKS")) {
    29             psArrayAdd (sources, 100, source);
    30             psFree (source);
    31             continue;
    32         }
     26        // allocate image, weight, mask arrays for each peak (square of radius OUTER)
     27        pmSourceDefinePixels (source, readout, source->peak->x, source->peak->y, OUTER);
     28        if (!strcasecmp (breakPt, "PEAKS")) {
     29            psArrayAdd (sources, 100, source);
     30            psFree (source);
     31            continue;
     32        }
    3333
    34         // XXX skip faint sources?
     34        // XXX skip faint sources?
    3535
    36         // measure a local sky value
    37         // XXX EAM : this should use ROBUST not SAMPLE median, but it is broken
    38         status = pmSourceLocalSky (source, PS_STAT_SAMPLE_MEDIAN, INNER);
    39         if (!status) {
    40           psFree (source);
    41           continue;
    42         }
     36        // measure a local sky value
     37        // XXX EAM : this should use ROBUST not SAMPLE median, but it is broken
     38        status = pmSourceLocalSky (source, PS_STAT_SAMPLE_MEDIAN, INNER);
     39        if (!status) {
     40          psFree (source);
     41          continue;
     42        }
    4343
    44         // measure the local sky variance (needed if noise is not sqrt(signal))
    45         // XXX EAM : this should use ROBUST not SAMPLE median, but it is broken
    46         status = pmSourceLocalSkyVariance (source, PS_STAT_SAMPLE_MEDIAN, INNER);
    47         if (!status) {
    48           psFree (source);
    49           continue;
    50         }
     44        // measure the local sky variance (needed if noise is not sqrt(signal))
     45        // XXX EAM : this should use ROBUST not SAMPLE median, but it is broken
     46        status = pmSourceLocalSkyVariance (source, PS_STAT_SAMPLE_MEDIAN, INNER);
     47        if (!status) {
     48          psFree (source);
     49          continue;
     50        }
    5151
    52         // measure basic source moments
    53         status = pmSourceMoments (source, RADIUS);
    54         if (status) {
    55             // add to the source array
    56             psArrayAdd (sources, 100, source);
    57             psFree (source);
    58             continue;
    59         }
     52        // measure basic source moments
     53        status = pmSourceMoments (source, RADIUS);
     54        if (status) {
     55            // add to the source array
     56            psArrayAdd (sources, 100, source);
     57            psFree (source);
     58            continue;
     59        }
    6060
    61         // if no valid pixels, or massive swing, likely saturated source,
    62         // try a much larger box
    63         BIG_RADIUS = PS_MIN (INNER, 3*RADIUS);
    64         psTrace ("psphot", 4, "retrying moments for %d, %d\n", source->peak->x, source->peak->y);
    65         status = pmSourceMoments (source, BIG_RADIUS);
    66         if (status) {
    67             // add to the source array
    68             psArrayAdd (sources, 100, source);
    69             psFree (source);
    70             continue;
    71         }
     61        // if no valid pixels, or massive swing, likely saturated source,
     62        // try a much larger box
     63        BIG_RADIUS = PS_MIN (INNER, 3*RADIUS);
     64        psTrace ("psphot", 4, "retrying moments for %d, %d\n", source->peak->x, source->peak->y);
     65        status = pmSourceMoments (source, BIG_RADIUS);
     66        if (status) {
     67            // add to the source array
     68            psArrayAdd (sources, 100, source);
     69            psFree (source);
     70            continue;
     71        }
    7272
    73         psFree (source);
    74         continue;
     73        psFree (source);
     74        continue;
    7575    }
    76      
     76
    7777    psLogMsg ("psphot", 3, "%ld moments: %f sec\n", sources->n, psTimerMark ("psphot"));
    7878
Note: See TracChangeset for help on using the changeset viewer.