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

    r25178 r25433  
    11# include "psphotInternal.h"
    2 
    3 // XXX consistency : theta in radians here and in calling functions
    42
    53// model parameters
     
    75psF32 psphotEllipticalContourFunc (psVector *deriv, const psVector *params, const psVector *coord);
    86
    9 bool psphotEllipticalContour (pmPetrosian *petrosian) {
     7bool psphotEllipticalContour (pmSource *source, pmPetrosian *petrosian) {
    108
    119    // use LMM to fit theta vs radius to an ellipse
     
    1917    // arrays to hold the data to be fitted
    2018    // we fit x and y vs theta in separate passes.
    21     psArray *x = psArrayAlloc(2*radius->n);
    22     psVector *y = psVectorAlloc(2*radius->n, PS_TYPE_F32);
    23     psVector *yErr = psVectorAlloc(2*radius->n, PS_TYPE_F32);
     19    psArray *x = psArrayAllocEmpty(2*radius->n);
     20    psVector *y = psVectorAllocEmpty(2*radius->n, PS_TYPE_F32);
     21    psVector *yErr = psVectorAllocEmpty(2*radius->n, PS_TYPE_F32);
    2422
    2523    int n = 0;
    2624    for (int i = 0; i < radius->n; i++) {
     25        if (!isfinite(radius->data.F32[i])) continue;
    2726
    2827        psVector *coord = NULL;
     
    5049        Rmax = MAX (Rmax, radius->data.F32[i]);
    5150    }   
    52     assert (x->n == n);
    53     assert (y->n == n);
     51    x->n = n;
     52    y->n = n;
     53    yErr->n = n;
     54
     55    if (n < 4) {
     56        psFree (x);
     57        psFree (y);
     58        psFree (yErr);
     59        return false;
     60    }
    5461
    5562    psVector *params = psVectorAlloc (3, PS_TYPE_F32);
     
    6168
    6269    // XXX for now, no parameter masks, skip checkLimits
     70    // XXX might help to add a limit to the angle or re-parameterize the ellipse in terms of Rxx, Ryy, Rxy
    6371    // constraint->checkLimits = psastroModelBoresiteLimits;
    6472
     
    8492    }
    8593
    86     fprintf (stderr, "# fitted values:\n");
    87     fprintf (stderr, "Po:  %f\n", params->data.F32[PAR_PHI]*PS_DEG_RAD);
    88     fprintf (stderr, "Ep:  %f\n", params->data.F32[PAR_EPSILON]);
    89     fprintf (stderr, "Rm:  %f\n", params->data.F32[PAR_RMIN]);
    90 
     94    psTrace ("psphot", 4, "# fitted values:\n");
     95    psTrace ("psphot", 4, "Phi:   %f\n", petrosian->axes.theta*PS_DEG_RAD);
     96    psTrace ("psphot", 4, "Rmaj:  %f\n", petrosian->axes.major);
     97    psTrace ("psphot", 4, "Rmin:  %f\n", petrosian->axes.minor);
     98   
    9199    // show the results
    92     psphotPetrosianVisualEllipticalContour (petrosian);
     100    // psphotPetrosianVisualEllipticalContour (petrosian);
    93101
    94102    psFree (x);
    95103    psFree (y);
    96104    psFree (yErr);
     105    psFree (params);
     106    psFree (covar);
     107    psFree (myMin);
     108    psFree (constraint);
    97109
    98110    return true;
Note: See TracChangeset for help on using the changeset viewer.