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/psphotRadialProfileByAngle.c

    r25105 r25128  
    55
    66// XXX choices for rMax and Nsec?
    7 // XXX where does the output go?
    8 // XXX how does this fit in context?
    97
    108bool psphotRadialProfilesByAngles (pmPetrosian *petrosian, pmSource *source, int Nsec, float Rmax) {
    119
     10    // we want to have an even number of sectors so we can do 180 deg symmetrizing
     11    Nsec = (Nsec % 2) ? Nsec + 1 : Nsec;
    1212    float dtheta = 2.0*M_PI / Nsec;
    1313
     
    4646            // value is NAN if we run off the image
    4747            float value = psImageInterpolatePixelBilinear(x, y, source->pixels);
    48             if (isnan(value)) continue;
     48
     49            // keep the nan values so all vectors are matched
     50            // if (isnan(value)) continue;
    4951
    5052            psVectorAppend (radius, r);
     
    6264    }
    6365
     66    for (int i = 0; i < Nsec / 2; i++) {
     67
     68        psVector *r1 = petrosian->radii->data[i];
     69        psVector *r2 = petrosian->radii->data[i+Nsec/2];
     70
     71        psVector *f1 = petrosian->fluxes->data[i];
     72        psVector *f2 = petrosian->fluxes->data[i+Nsec/2];
     73
     74        psAssert (r1->n == r2->n, "mis-matched vectors");
     75        psAssert (f1->n == f2->n, "mis-matched vectors");
     76
     77        // we have a pair of vectors i, i+Nsec/2; replace them with the finite minimum of the pair
     78        for (int j = 0; j < r1->n; j++) {
     79           
     80            float flux;
     81
     82            if (!isfinite(f1->data.F32[j]) && !isfinite(f2->data.F32[j])) {
     83                flux = NAN;
     84                goto setflux;
     85            }
     86
     87            if (!isfinite(f1->data.F32[j])) {
     88                flux = f2->data.F32[j];
     89                goto setflux;
     90            }
     91            if (!isfinite(f2->data.F32[j])) {
     92                flux = f1->data.F32[j];
     93                goto setflux;
     94            }
     95
     96            flux = PS_MIN(f1->data.F32[j], f2->data.F32[j]);
     97
     98        setflux:
     99            f1->data.F32[j] = flux;
     100            f2->data.F32[j] = flux;
     101        }
     102    }   
    64103    return true;
    65104}
Note: See TracChangeset for help on using the changeset viewer.