IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 24, 2006, 2:00:17 PM (20 years ago)
Author:
Paul Price
Message:

Changed definition of psVectorAlloc.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/src/models/pmModel_SGAUSS.c

    r9529 r9733  
    2020
    2121psF32 pmModelFunc_SGAUSS(psVector *deriv,
    22                         const psVector *params,
    23                         const psVector *x)
     22                        const psVector *params,
     23                        const psVector *x)
    2424{
    2525    psF32 *PAR = params->data.F32;
     
    3131    psF32 z  = PS_MAX((0.5*PS_SQR(px) + 0.5*PS_SQR(py) + PAR[PM_PAR_SXY]*X*Y), 1e-8);
    3232    // note that if z -> 0, dPAR[PM_PAR_7] -> -inf
    33     // also z^(PAR[PM_PAR_7]-1) -> Inf 
     33    // also z^(PAR[PM_PAR_7]-1) -> Inf
    3434
    3535    psF32 pr = z*PAR[PM_PAR_8];
     
    4242        // note difference from a pure gaussian: q = params->data.F32[1]*r
    4343        psF32 t = PAR[PM_PAR_I0]*r*r;
    44         psF32 q = t*(PAR[PM_PAR_7]*p + 4*PAR[PM_PAR_8]*pr3);
     44        psF32 q = t*(PAR[PM_PAR_7]*p + 4*PAR[PM_PAR_8]*pr3);
    4545
    4646        deriv->data.F32[0] = +1.0;
     
    111111    xo = xc - image->col0;
    112112    yo = yc - image->row0;
    113    
    114     psVector *contour = psVectorAlloc (Nt, PS_TYPE_F32);
     113
     114    psVector *contour = psVectorAllocEmpty (Nt, PS_TYPE_F32);
    115115    for (t = 0, N = 0; (t < 2*M_PI) && (N < Nt); t += dt) {
    116         x = ct*axes.major*cos(t) + st*axes.minor*sin(t) + xo;
    117         y = ct*axes.minor*sin(t) + st*axes.major*cos(t) + yo;
    118         value = p_psImageGetElementF64(image, x, y);
    119         if (isfinite(value)) {
    120             contour->data.F32[N] = value;
    121             N++;
    122         }
     116        x = ct*axes.major*cos(t) + st*axes.minor*sin(t) + xo;
     117        y = ct*axes.minor*sin(t) + st*axes.major*cos(t) + yo;
     118        value = p_psImageGetElementF64(image, x, y);
     119        if (isfinite(value)) {
     120            contour->data.F32[N] = value;
     121            N++;
     122        }
    123123    }
    124124    contour->n = N;
     
    134134    return (value);
    135135}
    136    
     136
    137137bool pmModelGuess_SGAUSS (pmModel *model, pmSource *source) {
    138138
     
    144144    EllipseShape shape;
    145145    EllipseMoments moments;
    146    
     146
    147147    moments.x2 = PS_SQR(sMoments->Sx);
    148148    moments.y2 = PS_SQR(sMoments->Sy);
     
    161161    params[6] = shape.sxy;
    162162
    163 # if (0)   
     163# if (0)
    164164    f1 = psImageEllipseContour (axes, peak->x, peak->y, source->pixels);
    165165    axes.major *= 2.0;
     
    168168
    169169    if (f1 > f2) {
    170         params[7] = PS_MIN (3.0, PS_MAX (0.5, log(2.0*(f1/f2) - 1.0) / log(2.0)));
     170        params[7] = PS_MIN (3.0, PS_MAX (0.5, log(2.0*(f1/f2) - 1.0) / log(2.0)));
    171171    } else {
    172         params[7] = 0.5;
     172        params[7] = 0.5;
    173173    }
    174174# endif
     
    192192    EllipseShape shape;
    193193    EllipseMoments moments;
    194    
     194
    195195    moments.x2 = PS_SQR(sMoments->Sx);
    196196    moments.y2 = PS_SQR(sMoments->Sy);
     
    215215
    216216    if (f1 > f2) {
    217         params[7] = PS_MIN (3.0, PS_MAX (0.5, log(2.0*(f1/f2) - 1.0) / log(2.0)));
     217        params[7] = PS_MIN (3.0, PS_MAX (0.5, log(2.0*(f1/f2) - 1.0) / log(2.0)));
    218218    } else {
    219         params[7] = 0.5;
     219        params[7] = 0.5;
    220220    }
    221221    params[8] = 0.1;
     
    240240    for (z = 0.005; z < 50; z += 0.01) {
    241241      psF32 pr = PAR[PM_PAR_8]*z;
    242         f = 1.0 / (1 + pow(z, PAR[PM_PAR_7]) + SQ(SQ(pr)));
    243         norm += f;
     242        f = 1.0 / (1 + pow(z, PAR[PM_PAR_7]) + SQ(SQ(pr)));
     243        norm += f;
    244244    }
    245245    norm *= 0.01;
    246    
     246
    247247    psF64 Flux = PAR[PM_PAR_I0] * Area * norm;
    248248
     
    276276    // XXX : we can do this faster with an intelligent starting choice
    277277    for (r = 0.0; r < 20.0; r += dr) {
    278         z = SQ(r);
    279         pr = PAR[PM_PAR_8]*z;
    280         f = 1.0 / (1 + pow(z, PAR[PM_PAR_7]) + SQ(SQ(pr)));
    281         if (f < limit) break;
     278        z = SQ(r);
     279        pr = PAR[PM_PAR_8]*z;
     280        f = 1.0 / (1 + pow(z, PAR[PM_PAR_7]) + SQ(SQ(pr)));
     281        if (f < limit) break;
    282282    }
    283283    psF64 radius = 2.0 * axes.major * sqrt (z);
    284284    if (isnan(radius)) {
    285         fprintf (stderr, "error in code\n");
     285        fprintf (stderr, "error in code\n");
    286286    }
    287287    return (radius);
     
    292292    psF32 *out = modelPSF->params->data.F32;
    293293    psF32 *in  = modelFLT->params->data.F32;
    294    
     294
    295295    out[0] = in[0];
    296296    out[1] = in[1];
     
    299299
    300300    for (int i = 4; i < 9; i++) {
    301         psPolynomial2D *poly = psf->params->data[i-4];
    302         out[i] = psPolynomial2DEval (poly, out[2], out[3]);
     301        psPolynomial2D *poly = psf->params->data[i-4];
     302        out[i] = psPolynomial2DEval (poly, out[2], out[3]);
    303303    }
    304304    return(true);
     
    311311    EllipseAxes axes;
    312312    EllipseShape shape;
    313  
     313
    314314    psF32 *PAR  = model->params->data.F32;
    315315    psF32 *dPAR = model->dparams->data.F32;
Note: See TracChangeset for help on using the changeset viewer.