Changeset 5828 for trunk/psphot/src/psphotEnsemblePSF.c
- Timestamp:
- Dec 22, 2005, 4:20:27 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psphot/src/psphotEnsemblePSF.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphotEnsemblePSF.c
r5802 r5828 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 } 2 48 3 49 bool psphotEnsemblePSF (eamReadout *imdata, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky) { … … 27 73 index->n = 0; 28 74 75 bool UseAnalysisRegion = false; 76 psRegion AnalysisRegion; 77 char *region = psMetadataLookupPtr (&status, config, "ANALYSIS_REGION"); 78 if (status) { 79 UseAnalysisRegion = true; 80 AnalysisRegion = psRegionFromString (region); 81 psLogMsg ("psphotEnsemblePSF", 4, "using region %f,%f - %f,%f\n", 82 AnalysisRegion.x0, AnalysisRegion.y0, 83 AnalysisRegion.x1, AnalysisRegion.y1); 84 } 85 29 86 for (int i = 0; i < sources->n; i++) { 30 87 pmSource *inSource = sources->data[i]; … … 35 92 if (inSource->type == PM_SOURCE_DEFECT) continue; 36 93 if (inSource->type == PM_SOURCE_SATURATED) continue; 94 95 if (UseAnalysisRegion) { 96 if (inSource->moments->x < AnalysisRegion.x0) continue; 97 if (inSource->moments->y < AnalysisRegion.y0) continue; 98 if (inSource->moments->x > AnalysisRegion.x1) continue; 99 if (inSource->moments->y > AnalysisRegion.y1) continue; 100 } 37 101 38 102 pmSource *otSource = pmSourceAlloc (); … … 51 115 modelFLT->params->data.F32[2] = inSource->moments->x; 52 116 modelFLT->params->data.F32[3] = inSource->moments->y; 53 } 54 // XXX EAM : add option to peak-up on peak (for non-sat objects) 117 } else { 118 // peak-up on peak (for non-sat objects) 119 120 int ix = inSource->peak->x; 121 int iy = inSource->peak->y; 122 123 psPolynomial2D *bicube = psImageBicubeFit (inSource->pixels, ix, iy); 124 psPlane min = psImageBicubeMin (bicube); 125 126 psTrace ("psphotEnsemblePSF", 5, "peak coord: %f %f -> %f %f\n", 127 modelFLT->params->data.F32[2], modelFLT->params->data.F32[3], min.x + ix, min.y + iy); 128 129 // if min point is too deviant, keep the old value 130 if ((fabs(min.x) < 1.5) && (fabs(min.y) < 1.5)) { 131 modelFLT->params->data.F32[2] = min.x + ix; 132 modelFLT->params->data.F32[3] = min.y + iy; 133 } 134 psFree (bicube); 135 } 55 136 56 137 // set PSF parameters for this model … … 149 230 // subtract object 150 231 pmSourceSubModel (Fi->pixels, Fi->mask, Fi->modelPSF, false, false); 232 Fi->mode |= PM_SOURCE_SUBTRACTED; 233 Fi->mode |= PM_SOURCE_TEMPSUB; 151 234 } 152 235 153 236 // XXX EAM : need to free up many things here 154 237 155 psLogMsg ("psphot.emsemble", 4, "apply models: %f\n", psTimerMark ("psphot"));238 psLogMsg ("psphot.emsemble", 3, "measure ensemble of PSFs: %f\n", psTimerMark ("psphot")); 156 239 return true; 157 240 }
Note:
See TracChangeset
for help on using the changeset viewer.
