IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 19, 2009, 12:16:54 PM (17 years ago)
Author:
eugene
Message:

updates to make radial profiles a bit more robust

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20090715/psphot/src/psphotRadiiFromProfiles.c

    r25105 r25128  
    3030
    3131    // examine data in the two ranges Fm - Fo and Fo - Fp to define the bin size
     32    // XXX reconsider the fractional isophote value
    3233    float Fm = fluxMin + 0.25*fluxRange;
    3334    float Fp = fluxMin + 0.75*fluxRange;
    3435    float Fo = fluxMin + 0.50*fluxRange;
     36    int Rbin = 1;
    3537     
    36     // find the mean radius of the points in the flux range Fm - Fp:
    37     float Rsum = 0;
    38     float Rnpt = 0;
    39     for (int i = 0; i < flux->n; i++) {
    40         if (flux->data.F32[i] < Fm) continue;
    41         if (flux->data.F32[i] > Fp) continue;
    42      
    43         Rsum += radius->data.F32[i];
    44         Rnpt ++;
    45     }
     38    // find the median radius of the points in the flux range Fm - Fp:
     39    {
     40        // storage vector for stats
     41        psVector *values = psVectorAllocEmpty (flux->n, PS_TYPE_F32);
     42        psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEDIAN);
    4643
    47     // rebin with bins 1/2 the size of the mean radius
    48     int Rbin = 0;
    49     if (Rnpt == 0) {
    50         Rbin = 1;
    51     } else {
    52         Rbin = MAX(1, 0.5*(Rsum / Rnpt));
     44        for (int i = 0; i < flux->n; i++) {
     45            if (!isfinite(flux->data.F32[i])) continue;
     46            if (flux->data.F32[i] < Fm) continue;
     47            if (flux->data.F32[i] > Fp) continue;
     48           
     49            psVectorAppend (values, radius->data.F32[i]);
     50        }
     51        psVectorStats (stats, values, NULL, NULL, 0);
     52
     53        // if we have a valid range, rebin with bin size 1/2 of median radius
     54        if (isfinite(stats->sampleMedian)) {
     55            Rbin = MAX(1, 0.5*stats->sampleMedian);
     56        }
    5357    }
    5458
     
    9498                psStatsInit(stats);
    9599            }
     100            if (!isfinite(flux->data.F32[i])) continue;
    96101            psVectorAppend (values, flux->data.F32[i]);
    97102        }
     
    105110    bool above = true;
    106111    for (int i = 0; i < fluxBinned->n; i++) {
     112
     113        if (!isfinite(fluxBinned->data.F32[i])) continue;
    107114
    108115        // find the largest radius that matches the flux transition
Note: See TracChangeset for help on using the changeset viewer.