IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 15, 2006, 8:30:16 AM (21 years ago)
Author:
eugene
Message:

API cleanup, removed old test files, some re-organization, changed FLT/GAL to EXT

File:
1 edited

Legend:

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

    r5980 r5993  
    11# include "psphot.h"
    2 
    3 psPolynomial2D *psImageBicubeFit (psImage *image, int x, int y) {
    4 
    5     int ix = x - image->col0;
    6     int iy = y - image->row0;
    7 
    8     psF32 *Fm = &image->data.F32[iy - 1][ix];
    9     psF32 *Fo = &image->data.F32[iy + 0][ix];
    10     psF32 *Fp = &image->data.F32[iy + 1][ix];
    11 
    12     double Fxm = Fm[-1] + Fo[-1] + Fp[-1];
    13     double Fxp = Fm[+1] + Fo[+1] + Fp[+1];
    14     double Fym = Fm[-1] + Fm[+0] + Fm[+1];
    15     double Fyp = Fp[-1] + Fp[+0] + Fp[+1];
    16     double Foo = Fym + Fyp + Fo[-1] + Fo[+0] + Fo[+1];
    17 
    18     psPolynomial2D *poly = psPolynomial2DAlloc (2, 2, PS_POLYNOMIAL_ORD);
    19     poly->mask[2][2] = 1;
    20     poly->mask[1][2] = 1;
    21     poly->mask[2][1] = 1;
    22 
    23     poly->coeff[0][0] = Foo*(5.0/9.0) - (Fxp + Fxm)/3.0 - (Fyp + Fym)/3.0 ;
    24 
    25     poly->coeff[1][0] = (Fxp - Fxm)/6.0;
    26     poly->coeff[0][1] = (Fyp - Fym)/6.0;
    27    
    28     poly->coeff[2][0] = (Fxp + Fxm)/2.0 - Foo/3.0;
    29     poly->coeff[0][2] = (Fyp + Fym)/2.0 - Foo/3.0;
    30    
    31     poly->coeff[1][1] = (Fp[+1] + Fm[-1] - Fm[+1] - Fp[-1])/4.0;
    32    
    33     return (poly);
    34 }
    35 
    36 psPlane psImageBicubeMin (psPolynomial2D *poly) {
    37 
    38     psPlane min;
    39 
    40     min.xErr = min.yErr = 0;
    41 
    42     double det = 4*poly->coeff[2][0]*poly->coeff[0][2] - PS_SQR(poly->coeff[1][1]);
    43 
    44     min.x = (poly->coeff[1][1]*poly->coeff[0][1] - 2*poly->coeff[0][2]*poly->coeff[1][0]) / det;
    45     min.y = (poly->coeff[1][1]*poly->coeff[1][0] - 2*poly->coeff[2][0]*poly->coeff[0][1]) / det;
    46     return (min);
    47 }
    482
    493bool psphotEnsemblePSF (eamReadout *imdata, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky) {
     
    10761        }
    10862
    109         // XXX EAM : add option to use FLT or PSF form
     63        // XXX EAM : add option to use EXT or PSF form
    11064        // use the source moments, etc to guess basic model parameters
    111         pmModel *modelFLT = pmSourceModelGuess (inSource, psf->type);
     65        pmModel *modelEXT = pmSourceModelGuess (inSource, psf->type);
    11266        if (inSource->mode &  PM_SOURCE_SATSTAR) {
    113             modelFLT->params->data.F32[2] = inSource->moments->x;
    114             modelFLT->params->data.F32[3] = inSource->moments->y;
     67            modelEXT->params->data.F32[2] = inSource->moments->x;
     68            modelEXT->params->data.F32[3] = inSource->moments->y;
    11569        } else {
    11670            // peak-up on peak (for non-sat objects)
     
    12377
    12478            psTrace ("psphotEnsemblePSF", 5, "peak coord: %f %f -> %f %f\n",
    125                      modelFLT->params->data.F32[2], modelFLT->params->data.F32[3], min.x + ix, min.y + iy);
     79                     modelEXT->params->data.F32[2], modelEXT->params->data.F32[3], min.x + ix, min.y + iy);
    12680           
    12781            // if min point is too deviant, keep the old value
    12882            if ((fabs(min.x) < 1.5) && (fabs(min.y) < 1.5)) {
    129                 modelFLT->params->data.F32[2] = min.x + ix;
    130                 modelFLT->params->data.F32[3] = min.y + iy;
     83                modelEXT->params->data.F32[2] = min.x + ix;
     84                modelEXT->params->data.F32[3] = min.y + iy;
    13185            }
    13286            psFree (bicube);
     
    13488
    13589        // set PSF parameters for this model
    136         pmModel *model = pmModelFromPSF (modelFLT, psf);
    137         psFree (modelFLT);
     90        pmModel *model = pmModelFromPSF (modelEXT, psf);
     91        psFree (modelEXT);
    13892
    13993        // save the original coords
     
    185139
    186140        // diagonal element (auto-cross-product)
    187         f = psphotCrossProduct (Mi, Mi);
     141        f = pmSourceCrossProduct (Mi, Mi);
    188142        psSparseMatrixElement (sparse, i, i, f);
    189143
    190144        // find the image x model value
    191         f = psphotCrossProduct (Fi, Mi);
     145        f = pmSourceCrossProduct (Fi, Mi);
    192146        psSparseVectorElement (sparse, i, f);
    193147
     
    203157           
    204158            // got an overlap; calculate cross-product and add to output array
    205             f = psphotCrossProduct (Mi, Mj);
     159            f = pmSourceCrossProduct (Mi, Mj);
    206160            psSparseMatrixElement (sparse, j, i, f);
    207161        }
     
    235189    return true;
    236190}
    237 
    238 
    239 float psphotCrossProduct (pmSource *Mi, pmSource *Mj) {
    240 
    241     int Xs, Xe, Ys, Ye;
    242     int xi, xj, yi, yj;
    243     int xIs, xJs, yIs, yJs;
    244     int xIe, yIe;
    245     float flux;
    246 
    247     psImage *Pi = Mi->pixels;
    248     psImage *Pj = Mj->pixels;
    249 
    250     psImage *Ti = Mi->mask;
    251     psImage *Tj = Mj->mask;
    252 
    253     Xs = PS_MAX (Pi->col0, Pj->col0);
    254     Xe = PS_MIN (Pi->col0 + Pi->numCols, Pj->col0 + Pj->numCols);
    255    
    256     Ys = PS_MAX (Pi->row0, Pj->row0);
    257     Ye = PS_MIN (Pi->row0 + Pi->numRows, Pj->row0 + Pj->numRows);
    258    
    259     xIs = Xs - Pi->col0;
    260     xJs = Xs - Pj->col0;
    261     yIs = Ys - Pi->row0;
    262     yJs = Ys - Pj->row0;
    263 
    264     xIe = Xe - Pi->col0;
    265     yIe = Ye - Pi->row0;
    266 
    267     flux = 0;
    268     for (yi = yIs, yj = yJs; yi < yIe; yi++, yj++) {
    269         for (xi = xIs, xj = xJs; xi < xIe; xi++, xj++) {
    270             if (Ti->data.U8[yi][xi]) continue;
    271             if (Tj->data.U8[yj][xj]) continue;
    272             flux += Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj];
    273         }
    274     }
    275     return (flux);
    276 }
Note: See TracChangeset for help on using the changeset viewer.