IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 18, 2009, 6:24:53 AM (17 years ago)
Author:
eugene
Message:

updates for petrosian analysis study

Location:
branches/eam_branches/20090715/psphot/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20090715/psphot/src

    • Property svn:ignore
      •  

        old new  
        1818psphotVersionDefinitions.h
        1919psphotMomentsStudy
         20psphotPetrosianStudy
  • branches/eam_branches/20090715/psphot/src/psphotPetrosianRadialBins.c

    r25032 r25105  
    22
    33// convert the flux vs elliptical radius to annular bins
    4 bool psphotPetrosianRadialBins (pmSource *source, pmPetrosian *petrosian) {
    54
    6     psVector *radius = petrosian->radiusElli;
    7     psVector *flux = petrosian->fluxElli;
     5// we are guaranteed to be limited by either the seeing (1 - few pixels) or by the pixels
     6// themselves.  this function does not attempt to measure the radial profiles accurately
     7// for radii that are smaller than a minimum (currently 1.0 pixels). 
    88
    9     sort (radius, flux);
     9// for small radii, we are measuring the mean surface brightness in non-overlapping radial
     10// bins.  for large radii (r > 2 pixels), we are measuring the surface brightness for a
     11// radius range \alpha r_i < i < \beta r_i, but performing this measurement for radii more
     12// finely spaced than r_{i+1} = r_i * \beta / \alpha.  for the integration, we need to
     13// track the non-overlapping radius values.
     14
     15# define PETROSIAN_ALPHA 0.8
     16# define PETROSIAN_BETA 1.25
     17
     18bool psphotPetrosianRadialBins (pmSource *source, pmPetrosian *petrosian, float radiusMax) {
     19
     20    psVector *radius = petrosian->radiusElliptical;
     21    psVector *flux = petrosian->fluxElliptical;
     22
     23    // sort incoming vectors by radius
     24    psphotPetrosianSortPair (radius, flux);
     25
     26    int nMax = radiusMax;
    1027
    1128    // radBin stores the centers of the radial bins,
    1229    // radMin, radMax store the bounds
    13     psVector *radBin = psVectorAllocEmpty(100, PS_TYPE_F32);
    14     psVector *radMin = psVectorAllocEmpty(100, PS_TYPE_F32);
    15     psVector *radMax = psVectorAllocEmpty(100, PS_TYPE_F32);
     30    psVector *radMin  = psVectorAllocEmpty(nMax, PS_TYPE_F32);
     31    psVector *radMax  = psVectorAllocEmpty(nMax, PS_TYPE_F32);
     32    psVector *radAlp  = psVectorAllocEmpty(nMax, PS_TYPE_F32);
     33    psVector *radBet  = psVectorAllocEmpty(nMax, PS_TYPE_F32);
     34
     35    psVector *fluxBin = psVectorAllocEmpty(nMax, PS_TYPE_F32);
     36    psVector *radBin  = psVectorAllocEmpty(nMax, PS_TYPE_F32);
     37    psVector *area    = psVectorAllocEmpty(nMax, PS_TYPE_F32);
     38
     39    psVectorInit (fluxBin, 0.0);
     40    psVectorInit (radBin, 0.0);
    1641
    1742    // generate radial bin bounds
    1843    radMin->data.F32[0] = 0.0;
    1944    radMax->data.F32[0] = 1.0;
     45    radAlp->data.F32[0] = 0.0;
     46    radBet->data.F32[0] = 1.0;
    2047   
    2148    radMin->data.F32[1] = 1.0;
    2249    radMax->data.F32[1] = 1.5;
     50    radAlp->data.F32[1] = 1.0;
     51    radBet->data.F32[1] = 1.5;
    2352   
    2453    radMin->data.F32[2] = 1.5;
    2554    radMax->data.F32[2] = 2.0;
     55    radAlp->data.F32[2] = 1.5;
     56    radBet->data.F32[2] = 2.0;
    2657   
    27     for (int i = 3; i < rmax; i++) {
    28         radMin->data.F32[i] = (i - 1);
    29         radMax->data.F32[i] = i;
     58    int nPts = 3;
     59    for (int i = 3; i < radiusMax; i++) {
     60        radMin->data.F32[nPts] = (i - 1);
     61        radMax->data.F32[nPts] = i;
     62        nPts++;
    3063    }
     64    radMin->n = radMax->n = radAlp->n = radBet->n = nPts;
    3165
    3266    // generate radial area-weighted mean radius & non-overlapping areas
    33     float Rprev = 0.0;
    3467    for (int i = 0; i < radMin->n; i++) {
    3568        float rMin = radMin->data.F32[i];
     
    4275        float rMax3 = rMax2*rMax;
    4376
    44         float rBin = (rMax3 - rMin3) / (rMax2 - rMin2) / 3.0;
     77        float rBin = 2.0 * (rMax3 - rMin3) / (rMax2 - rMin2) / 3.0;
    4578       
     79        // XXX calculate area-weighted radius rather than asserting?
    4680        radBin->data.F32[i] = rBin;
     81        area->data.F32[i] = M_PI * (rMax2 - rMin2);
    4782
    48         area->data.F32[i] =
     83        if (i > 2) {
     84            radAlp->data.F32[i] = rBin*PETROSIAN_ALPHA;
     85            radBet->data.F32[i] = rBin*PETROSIAN_BETA;
     86        }
    4987    }
     88
     89    // storage vector for stats
     90    psVector *values = psVectorAllocEmpty (flux->n, PS_TYPE_F32);
     91    psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEDIAN);
     92
     93    // integrate flux, radius for each of these bins.  since flux is sorted by radius,
     94    // we can do this fairly quickly
     95
     96    bool done = false;
     97    int nOut = 0;
     98    float Rmin = radAlp->data.F32[nOut];
     99    float Rmax = radBet->data.F32[nOut];
     100    float Rnxt = radAlp->data.F32[nOut+1];  // minimum radius for next range
     101    int iNext = 0;
     102    for (int i = 0; !done && (i < radius->n); i++) {
     103        if (radius->data.F32[i] < Rnxt) {
     104          iNext = i;
     105        }
     106        if (radius->data.F32[i] > Rmax) {
     107            // calculate the value for the nOut bin
     108            psVectorStats (stats, values, NULL, NULL, 0);
     109            fluxBin->data.F32[nOut] = stats->sampleMedian;
     110            nOut ++;
     111            if (nOut >= nMax) break;
     112            Rmin = radAlp->data.F32[nOut];
     113            Rmax = radBet->data.F32[nOut];
     114            Rnxt = (nOut < nMax - 1) ? radAlp->data.F32[nOut+1] : Rmax;  // minimum radius for next range
     115            values->n = 0;
     116            psStatsInit(stats);
     117            i = iNext;
     118        }
     119        if (radius->data.F32[i] < Rmin) {
     120            continue;
     121        }
     122        psVectorAppend (values, flux->data.F32[i]);
     123    }
     124    fluxBin->n = radBin->n = area->n = nOut;
     125    // XXX I think this misses the last radial bin -- do we care?
     126
     127    // save the vectors
     128    petrosian->radialBins = radBin;
     129    petrosian->area = area;
     130    petrosian->binnedFlux = fluxBin;
     131
     132    psphotPetrosianVisualProfileRadii (radius, flux, radBin, fluxBin, 0.0);
     133
     134    psFree(radMin);
     135    psFree(radMax);
     136    psFree(radAlp);
     137    psFree(radBet);
     138    psFree(values);
     139    psFree(stats);
     140
     141    return true;
    50142}
    51143
Note: See TracChangeset for help on using the changeset viewer.