IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 19, 2006, 7:26:08 PM (20 years ago)
Author:
eugene
Message:

working on global linear fit with sky level

File:
1 edited

Legend:

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

    r10076 r10096  
    1010// the analysis is performed wrt the simulated pixel values
    1111
    12 static bool SetBorderT (psSparseBorder *border, pmReadout *readout, psArray *refSources, psArray *fitSources, psVector *index, bool fitSlope);
     12static bool SetBorderT (psSparseBorder *border, pmReadout *readout, psArray *refSources, psArray *fitSources, psVector *index, bool fitSlope, bool constant_weights);
    1313
    1414bool psphotEnsemblePSF (pmReadout *readout, psArray *refSources, psMetadata *recipe, pmPSF *psf, bool final) {
     
    162162    // set the sky, sky_x, sky_y components of border matrix
    163163    // XXX ignore sky slope terms for now
    164     SetBorderT (border, readout, refSources, fitSources, index, false);
     164    SetBorderT (border, readout, refSources, fitSources, index, false, CONSTANT_PHOTOMETRIC_WEIGHTS);
    165165
    166166    psSparseConstraint constraint;
     
    170170
    171171    // solve for normalization terms (need include local sky?)
    172     # if (0)
     172    # if (1)
    173173    psVector *norm = NULL;
    174174    psVector *skyfit = NULL;
    175175    psSparseBorderSolve (&norm, &skyfit, constraint, border, 3);
     176    fprintf (stderr, "skyfit: %f\n", skyfit->data.F32[0]);
    176177    # else
    177178    psVector *norm = psSparseSolve (NULL, constraint, sparse, 3);
     
    226227
    227228// calculate the weight terms for the sky fit component of the matrix
    228 static bool SetBorderT (psSparseBorder *border, pmReadout *readout, psArray *refSources, psArray *fitSources, psVector *index, bool fitSlope) {
     229static bool SetBorderT (psSparseBorder *border, pmReadout *readout, psArray *refSources, psArray *fitSources, psVector *index, bool fitSlope, bool constant_weights) {
    229230
    230231    // generate the image-wide weight terms
     
    251252    psU8 **mask = readout->mask->data.U8;
    252253
    253     double w, x, y, x2, xy, y2, xc, yc;
    254     w = x = y = x2 = xy = y2 = 0;
     254    double w, x, y, x2, xy, y2, xc, yc, wt, f, fo, fx, fy;
     255    w = x = y = x2 = xy = y2 = fo = fx = fy = 0;
    255256   
    256257    int col0 = readout->image->col0;
     
    260261        for (int i = 0; i < readout->image->numCols; i++) {
    261262            if (mask[j][i]) continue;
    262             w  +=       image[j][i]/weight[j][i];
     263            if (constant_weights) {
     264                wt = 1.0;
     265            } else {
     266                wt = weight[j][i];
     267            }
     268            f = image[j][i];
     269            w   += 1/wt;
     270            fo  += f/wt;
     271
    263272            if (!fitSlope) continue;
    264273            xc = i + col0;
    265274            yc = j + row0;
    266             x  +=    xc*image[j][i]/weight[j][i];
    267             y  +=    yc*image[j][i]/weight[j][i];
    268             x2 += xc*xc*image[j][i]/weight[j][i];
    269             xy += xc*yc*image[j][i]/weight[j][i];
    270             y2 += yc*yc*image[j][i]/weight[j][i];
     275            x  +=    xc/wt;
     276            y  +=    yc/wt;
     277            x2 += xc*xc/wt;
     278            xy += xc*yc/wt;
     279            y2 += yc*yc/wt;
     280            fx +=  f*xc/wt;
     281            fy +=  f*yc/wt;
    271282        }
    272283    }
     
    276287
    277288    // set the Border T elements
     289    psSparseBorderElementG (border, 0, fo);
    278290    psSparseBorderElementT (border, 0, 0, w);
    279291    if (fitSlope) {
     292        psSparseBorderElementG (border, 0, fx);
     293        psSparseBorderElementG (border, 0, fy);
    280294        psSparseBorderElementT (border, 1, 0, x);
    281295        psSparseBorderElementT (border, 2, 0, y);
Note: See TracChangeset for help on using the changeset viewer.