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

    r25275 r25433  
    77// structure to something the pmRadialProfile
    88
    9 bool psphotPetrosianProfile (pmSource *source, float skynoise) {
     9bool psphotPetrosianProfile (pmReadout *readout, pmSource *source, float skynoise) {
    1010
    11   // container to hold results from the radial profile analysis
    12   pmPetrosian *petrosian = pmPetrosianAlloc();
     11    // container to hold results from the radial profile analysis
     12    pmPetrosian *petrosian = pmPetrosianAlloc();
    1313
    14   int Nsec = 24;
    15   float Rmax = 200;
    16   float fluxMin = 0.0;
    17   float fluxMax = source->peak->flux;
     14    int Nsec = 24;
     15    float Rmax = 200;
     16    float fluxMin = 0.0;
     17    float fluxMax = source->peak->flux;
    1818
    19   // generate a series of radial profiles at Nsec evenly spaced angles.  the profile flux
    20   // is measured by interpolation for small radii; for large radii, the pixels in a box
    21   // are averaged to increase the S/N (XXX not yet done)
    22   if (!psphotRadialProfilesByAngles (petrosian, source, Nsec, Rmax)) {
    23     psError (PS_ERR_UNKNOWN, false, "failed to measure radial profile for petrosian");
    24     return false;
    25   }
     19    // generate a series of radial profiles at Nsec evenly spaced angles.  the profile flux
     20    // is measured by interpolation for small radii; for large radii, the pixels in a box
     21    // are averaged to increase the S/N (XXX not yet done)
     22    if (!psphotRadialProfilesByAngles (source, petrosian, Nsec, Rmax)) {
     23        psError (PS_ERR_UNKNOWN, false, "failed to measure radial profile for petrosian");
     24        psFree (petrosian);
     25        return false;
     26    }
    2627
    27   // use the radial profiles to determine the radius of a given isophote.  this isophote
    28   // is used to determine the elliptical shape of the object, so it has a relatively high
    29   // value (nominally 50% of the peak)
    30   if (!psphotRadiiFromProfiles (petrosian, fluxMin, fluxMax)) {
    31     psError (PS_ERR_UNKNOWN, false, "failed to measure isophotal radii from profiles");
    32     return false;
    33   }
     28    // use the radial profiles to determine the radius of a given isophote.  this isophote
     29    // is used to determine the elliptical shape of the object, so it has a relatively high
     30    // value (nominally 50% of the peak)
     31    if (!psphotRadiiFromProfiles (source, petrosian, fluxMin, fluxMax)) {
     32        psError (PS_ERR_UNKNOWN, false, "failed to measure isophotal radii from profiles");
     33        psFree (petrosian);
     34        return false;
     35    }
    3436
    35   // convert the isophotal radius vs angle measurements to an elliptical contour
    36   if (!psphotEllipticalContour (petrosian)) {
    37     psError (PS_ERR_UNKNOWN, false, "failed to measure elliptical contour");
    38     return false;
    39   }
     37    // convert the isophotal radius vs angle measurements to an elliptical contour
     38    if (!psphotEllipticalContour (source, petrosian)) {
     39        psLogMsg ("psphot", 3, "failed to measure elliptical contour");
     40        psFree (petrosian);
     41        return false;
     42    }
    4043 
    41   // generate a single, normalized radial profile following the elliptical contours.
    42   // the radius is normalized by the axis ratio so that on the major axis, 1 pixel = 1 pixel
    43   if (!psphotEllipticalProfile (source, petrosian)) {
    44     psError (PS_ERR_UNKNOWN, false, "failed to generate elliptical profile");
    45     return false;
    46   }
     44    // generate a single, normalized radial profile following the elliptical contours.
     45    // the radius is normalized by the axis ratio so that on the major axis, 1 pixel = 1 pixel
     46    if (!psphotEllipticalProfile (source, petrosian)) {
     47        psError (PS_ERR_UNKNOWN, false, "failed to generate elliptical profile");
     48        psFree (petrosian);
     49        return false;
     50    }
    4751 
    48   // integrate the radial profile for radial bins defined for the petrosian measurement:
    49   // SB_i (r_i) where \alpha r_i < r < \beta r_i
    50   if (!psphotPetrosianRadialBins (source, petrosian, Rmax, skynoise)) {
    51     psError (PS_ERR_UNKNOWN, false, "failed to generate elliptical profile");
    52     return false;
    53   }
     52    // integrate the radial profile for radial bins defined for the petrosian measurement:
     53    // SB_i (r_i) where \alpha r_i < r < \beta r_i
     54    if (!psphotPetrosianRadialBins (source, petrosian, Rmax, skynoise)) {
     55        psError (PS_ERR_UNKNOWN, false, "failed to generate elliptical profile");
     56        psFree (petrosian);
     57        return false;
     58    }
    5459 
    55   // use the SB_i from above to calculate the petrosian radius and the flux within that radius
    56   if (!psphotPetrosianStats (petrosian)) {
    57     psError (PS_ERR_UNKNOWN, false, "failed to generate elliptical profile");
    58     return false;
    59   }
     60    // use the SB_i from above to calculate the petrosian radius and the flux within that radius
     61    if (!psphotPetrosianStats (source, petrosian)) {
     62        psError (PS_ERR_UNKNOWN, false, "failed to generate elliptical profile");
     63        psFree (petrosian);
     64        return false;
     65    }
    6066 
    61   // XXX this will only work in the psphot context, not the psphotPetrosianStudy...
    62   // XXX add the petrosian to the pmSource structure...
    63   psphotVisualShowPetrosian (source, petrosian);
     67    // XXX this will only work in the psphot context, not the psphotPetrosianStudy...
     68    // XXX add the petrosian to the pmSource structure...
     69    // psphotVisualShowResidualImage (readout);
     70    psphotVisualShowPetrosian (source, petrosian);
    6471
    65   psphotPetrosianFreeVectors(petrosian);
     72    psphotPetrosianFreeVectors(petrosian);
    6673
    67   fprintf (stdout, "\n petrosian radius: %f\n flux: %f\n axis ratio: %f\n angle: %f\n",
    68            petrosian->petrosianRadius, petrosian->petrosianFlux, petrosian->axes.minor/petrosian->axes.major, PS_DEG_RAD*petrosian->axes.theta);
     74    psTrace ("psphot", 3, "source at %f,%f: petrosian radius: %f, flux: %f, axis ratio: %f, angle: %f",
     75             source->peak->xf, source->peak->yf, petrosian->petrosianRadius, petrosian->petrosianFlux, petrosian->axes.minor/petrosian->axes.major, PS_DEG_RAD*petrosian->axes.theta);
    6976
    70   return true;
     77    psFree (petrosian);
     78    return true;
    7179}
Note: See TracChangeset for help on using the changeset viewer.