Changeset 5993 for trunk/psphot/src/psphotEnsemblePSF.c
- Timestamp:
- Jan 15, 2006, 8:30:16 AM (21 years ago)
- File:
-
- 1 edited
-
trunk/psphot/src/psphotEnsemblePSF.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphotEnsemblePSF.c
r5980 r5993 1 1 # 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 }48 2 49 3 bool psphotEnsemblePSF (eamReadout *imdata, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky) { … … 107 61 } 108 62 109 // XXX EAM : add option to use FLT or PSF form63 // XXX EAM : add option to use EXT or PSF form 110 64 // use the source moments, etc to guess basic model parameters 111 pmModel *model FLT = pmSourceModelGuess (inSource, psf->type);65 pmModel *modelEXT = pmSourceModelGuess (inSource, psf->type); 112 66 if (inSource->mode & PM_SOURCE_SATSTAR) { 113 model FLT->params->data.F32[2] = inSource->moments->x;114 model FLT->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; 115 69 } else { 116 70 // peak-up on peak (for non-sat objects) … … 123 77 124 78 psTrace ("psphotEnsemblePSF", 5, "peak coord: %f %f -> %f %f\n", 125 model FLT->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); 126 80 127 81 // if min point is too deviant, keep the old value 128 82 if ((fabs(min.x) < 1.5) && (fabs(min.y) < 1.5)) { 129 model FLT->params->data.F32[2] = min.x + ix;130 model FLT->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; 131 85 } 132 86 psFree (bicube); … … 134 88 135 89 // set PSF parameters for this model 136 pmModel *model = pmModelFromPSF (model FLT, psf);137 psFree (model FLT);90 pmModel *model = pmModelFromPSF (modelEXT, psf); 91 psFree (modelEXT); 138 92 139 93 // save the original coords … … 185 139 186 140 // diagonal element (auto-cross-product) 187 f = p sphotCrossProduct (Mi, Mi);141 f = pmSourceCrossProduct (Mi, Mi); 188 142 psSparseMatrixElement (sparse, i, i, f); 189 143 190 144 // find the image x model value 191 f = p sphotCrossProduct (Fi, Mi);145 f = pmSourceCrossProduct (Fi, Mi); 192 146 psSparseVectorElement (sparse, i, f); 193 147 … … 203 157 204 158 // got an overlap; calculate cross-product and add to output array 205 f = p sphotCrossProduct (Mi, Mj);159 f = pmSourceCrossProduct (Mi, Mj); 206 160 psSparseMatrixElement (sparse, j, i, f); 207 161 } … … 235 189 return true; 236 190 } 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.
