IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 26, 2007, 9:43:28 AM (19 years ago)
Author:
eugene
Message:

setting up the extended source fitting functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/src/psphotModelWithPSF.c

    r13976 r13983  
    11# include "psphot.h"
    2 
    3 // XXX elevate the p_psMinLM_ functions to psMinLM_...
    4 
    52
    63bool psphotModelWithPSF_LMM (
     
    6966
    7067        // set a new guess for Alpha, Beta, Params
    71         if (!p_psMinLM_GuessABP(Alpha, Beta, Params, alpha, beta, params, paramMask, checkLimits, lambda)) {
     68        if (!psMinLM_GuessABP(Alpha, Beta, Params, alpha, beta, params, paramMask, checkLimits, lambda)) {
    7269            min->iter ++;
    7370            lambda *= 10.0;
     
    7673
    7774        // measure linear model prediction
    78         psF32 dLinear = p_psMinLM_dLinear(Beta, beta, lambda);
     75        psF32 dLinear = psMinLM_dLinear(Beta, beta, lambda);
    7976
    8077        // dump some useful info if trace is defined
     
    8885
    8986        // calculate Chisq for new guess, update Alpha & Beta
    90         Chisq = p_psMinLM_SetABX(Alpha, Beta, Params, paramMask, source, func);
     87        Chisq = psphotModelWithPSF_SetABX(Alpha, Beta, Params, paramMask, source, psf, func);
    9188        if (isnan(Chisq)) {
    9289            min->iter ++;
     
    112109        /* if (Chisq < min->value) {  */
    113110        if (rho > 0.0) {
    114             min->lastDelta = (min->value - Chisq) / (dy->n - params->n);
     111            min->lastDelta = (min->value - Chisq) / (source->pixels->numCols*source->pixels->numRows - params->n);
    115112            min->value = Chisq;
    116113            alpha  = psImageCopy(alpha, Alpha, PS_TYPE_F32);
     
    127124    // construct & return the covariance matrix (if requested)
    128125    if (covar != NULL) {
    129         if (!p_psMinLM_GuessABP(covar, Beta, Params, alpha, beta, params, paramMask, NULL, 0.0)) {
     126        if (!psMinLM_GuessABP(covar, Beta, Params, alpha, beta, params, paramMask, NULL, 0.0)) {
    130127            psTrace ("psLib.math", 5, "failure to calculate covariance matrix\n");
    131128        }
     
    172169    }
    173170
    174     psF32 chisq;
    175     psF32 delta;
    176     psF32 weight;
    177     psF32 ymodel;
    178171    psVector *deriv = psVectorAlloc(params->n, PS_TYPE_F32);
    179172
     
    191184
    192185    // fill in the coordinate and value entries
    193     nPix = 0;
    194186    for (psS32 i = 0; i < source->pixels->numRows; i++) {
    195187        for (psS32 j = 0; j < source->pixels->numCols; j++) {
     
    239231    psImageInit (alpha, 0.0);
    240232    psVectorInit (beta, 0.0);
    241     chisq = 0.0;
     233    float chisq = 0.0;
    242234
    243235    for (psS32 i = 0; i < source->pixels->numRows; i++) {
     
    257249            }
    258250
    259             ymodel  = modelConv->data.F32[i][j];
    260             yweight = 1.0 / source->weight->data.F32[i][j];
    261             delta = ymodel - source->pixels->data.F32[i][j];
    262 
    263             chisq += PS_SQR(delta) * var;
     251            float ymodel  = modelConv->data.F32[i][j];
     252            float yweight = 1.0 / source->weight->data.F32[i][j];
     253            float delta = ymodel - source->pixels->data.F32[i][j];
     254
     255            chisq += PS_SQR(delta) * yweight;
    264256
    265257            if (isnan(delta))
     
    273265              }
    274266              psImage *dmodel = dmodelsConv->data[n1];
    275               weight = dmodel->data.F32[i][j] * yweight;
     267              float weight = dmodel->data.F32[i][j] * yweight;
    276268              for (psS32 n2 = 0; n2 <= n1; n2++) {
    277269                if ((paramMask != NULL) && (paramMask->data.U8[n2])) {
     
    281273                alpha->data.F32[n1][n2] += weight * dmodel->data.F32[i][j];
    282274              }
    283               beta->data.F32[jn] += weight * delta;
     275              beta->data.F32[n1] += weight * delta;
    284276            }
    285277        }
Note: See TracChangeset for help on using the changeset viewer.