IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 17, 2009, 2:26:32 PM (17 years ago)
Author:
eugene
Message:

change radius for extended sources to use footprint; clean up some of the visualizations; plug some leaks

File:
1 edited

Legend:

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

    r25275 r25433  
    33// Given the Petrosian data (radii, fluxes) determine the radius for each profile at the desisred isophote
    44
    5 bool psphotRadiiFromProfiles (pmPetrosian *petrosian, float fluxMin, float fluxMax) {
     5bool psphotRadiiFromProfiles (pmSource *source, pmPetrosian *petrosian, float fluxMin, float fluxMax) {
    66
    77  petrosian->isophotalRadii = psVectorAlloc(petrosian->theta->n, PS_TYPE_F32);
     
    1010      psVector *radii = petrosian->radii->data[i];
    1111      psVector *fluxes = petrosian->fluxes->data[i];
    12       float radius = psphotRadiusFromProfile (radii, fluxes, fluxMin, fluxMax);
     12      float radius = psphotRadiusFromProfile (source, radii, fluxes, fluxMin, fluxMax);
    1313
    1414      // psphotPetrosianVisualProfileByAngle (radii, fluxes, radius);
     
    2020}
    2121
    22 float psphotRadiusFromProfile (psVector *radius, psVector *flux, float fluxMin, float fluxMax) {
     22float psphotRadiusFromProfile (pmSource *source, psVector *radius, psVector *flux, float fluxMin, float fluxMax) {
    2323
    2424    // 'flux' is a noisy sample of the galaxy radial profile at points 'radius'
     
    4949            psVectorAppend (values, radius->data.F32[i]);
    5050        }
    51         psVectorStats (stats, values, NULL, NULL, 0);
     51        if (values->n > 1) {
     52            psVectorStats (stats, values, NULL, NULL, 0);
    5253
    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);
     54            // if we have a valid range, rebin with bin size 1/2 of median radius
     55            if (isfinite(stats->sampleMedian)) {
     56                Rbin = MAX(1, 0.5*stats->sampleMedian);
     57            }
    5658        }
     59        psFree (values);
     60        psFree (stats);
    5761    }
    5862    Rbin = 3;
     
    9094                // calculate the value for the nOut bin
    9195                // XXX need to fix this as well psStats (stats, values);
    92                 psVectorStats (stats, values, NULL, NULL, 0);
    93                 fluxBinned->data.F32[nOut] = stats->sampleMedian;
     96                float value;
     97                if (values->n > 0) {
     98                    psVectorStats (stats, values, NULL, NULL, 0);
     99                    value = stats->sampleMedian;
     100                } else {
     101                    value = NAN;
     102                }
     103                fluxBinned->data.F32[nOut] = value;
    94104                nOut ++;
    95105                radiusBinned->data.F32[nOut] = (nOut + 0.5)*Rbin;
     
    118128            // XXX is there a macro in psLib that does this interpolation?
    119129            if (i == 0) {
    120                 psWarning ("impossible condition f[0] < Fo");
    121                 continue;
    122             } else {
    123                 Ro = radiusBinned->data.F32[i-1] + (radiusBinned->data.F32[i] - radiusBinned->data.F32[i-1]) * (Fo - fluxBinned->data.F32[i-1]) / (fluxBinned->data.F32[i] - fluxBinned->data.F32[i-1]);
    124             }
     130                psLogMsg ("psphot", 3, "bogus radial profile for ..., skipping");
     131                psFree (fluxBinned);
     132                psFree (radiusBinned);
     133                return NAN;
     134            }
     135            Ro = radiusBinned->data.F32[i-1] + (radiusBinned->data.F32[i] - radiusBinned->data.F32[i-1]) * (Fo - fluxBinned->data.F32[i-1]) / (fluxBinned->data.F32[i] - fluxBinned->data.F32[i-1]);
    125136            above = FALSE;
    126137        }
Note: See TracChangeset for help on using the changeset viewer.