Changeset 17209
- Timestamp:
- Mar 28, 2008, 3:40:11 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/relastro/src/FitChip.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/relastro/src/FitChip.c
r17149 r17209 1 1 # include "relastro.h" 2 # define SCATTER_MAX_ERROR 0.05 3 // XXX make this a user parameters 2 3 // XXX make these user parameters 4 # define FIT_CHIP_MAX_ERROR 0.05 5 # define FIT_CHIP_NITER 3 6 # define FIT_CHIP_NSIGMA 3.0 7 8 // XXX we should test if the fit is sufficiently constrained across the chip, or if the 9 // new positions deviate too much from the old positions 10 11 // XXX add visualization tools: per chip residual plots 12 13 // XXX save the fit[0].Npts value in the image table? 14 15 // XXX save measurements of the fit quality (scatter, chisq) in the image table 4 16 5 17 void FitChip (StarData *raw, StarData *ref, int Nmatch, Coords *coords) { 6 18 7 int i, Nscatter, Niter ;19 int i, Nscatter, Niter, skip; 8 20 CoordFit *fit; 9 21 double dL, dM, dR, dRmax, *values; … … 11 23 ALLOCATE (values, double, Nmatch); 12 24 13 for (Niter = 0; Niter < 3; Niter ++) { 25 for (Niter = 0; Niter < FIT_CHIP_NITER; Niter ++) { 26 14 27 // measure the scatter distribution (use only the bright end detections) 15 28 for (i = Nscatter = 0; i < Nmatch; i++) { 16 29 if (raw[i].mask) continue; 17 if (raw[i].dMag > SCATTER_MAX_ERROR) continue;30 if (raw[i].dMag > FIT_CHIP_MAX_ERROR) continue; 18 31 19 32 dL = raw[i].L - ref[i].L; … … 27 40 // for a 2D Gaussian, 40% of the points are within 1 sigma; dRmax is ~ 3 sigma 28 41 dsort (values, Nscatter); 29 dRmax = 3.0*values[(int)(0.40*Nscatter)];42 dRmax = FIT_CHIP_NSIGMA*values[(int)(0.40*Nscatter)]; 30 43 44 // fit the requested order polynomial 31 45 if (CHIPORDER > 0) { 32 46 coords[0].Npolyterms = CHIPORDER; … … 34 48 fit = fit_init (coords[0].Npolyterms); 35 49 50 // generate the fit matches 36 51 for (i = 0; i < Nmatch; i++) { 37 52 if (raw[i].mask) continue; 38 53 39 // require radius of XXX arcsec54 // only keep objects within dRmax 40 55 dL = raw[i].L - ref[i].L; 41 56 dM = raw[i].M - ref[i].M; 42 57 dR = hypot (dL, dM); 43 44 // XXX ??? why are we not applying the mask? 45 // the detection is not included in the fit 46 if (dR > dRmax) { 47 continue; 48 raw[i].mask = TRUE; 49 } 58 if (dR > dRmax) continue; 50 59 51 60 fit_add (fit, raw[i].X, raw[i].Y, ref[i].L, ref[i].M, raw[i].dPos); 52 61 } 53 fprintf (stderr, "scatter limit: %f based on %d detections; using %d of %d for fit\n",54 dRmax, Nscatter, fit[0].Npts, Nmatch);55 62 56 // XXX this limit should depend on the order of the fit (see psastro) 57 if (fit[0].Npts < 25) { 63 // check if the fit has enough data points for the polynomial order 64 skip = FALSE; 65 switch (coords[0].Npolyterms) { 66 case 0: 67 case 1: 68 skip = (fit[0].Npts < 8); 69 break; 70 case 2: 71 skip = (fit[0].Npts < 11); 72 break; 73 case 3: 74 skip = (fit[0].Npts < 15); 75 break; 76 default: 77 fprintf (stderr, "invalid chip order %d\n", coords[0].Npolyterms); 78 abort (); 79 } 80 if (skip) { 81 fprintf (stderr, "insufficient measurements (%d) for requested order (%d)\n", fit[0].Npts, coords[0].Npolyterms); 58 82 fit_free (fit); 59 83 free (values); 60 84 return; 61 85 } 86 87 fprintf (stderr, "scatter limit: %f based on %d detections; using %d of %d for fit\n", dRmax, Nscatter, fit[0].Npts, Nmatch); 88 89 // measure the fit, update the coords & object coordinates 62 90 fit_eval (fit); 63 91 fit_apply_coords (fit, coords); … … 82 110 P,Q -> L,M (polynomial transformation : DIS) 83 111 L,M -> X,Y (polynomial transformation : WRP) 112 113 Some details about this function: 114 115 - the initial value of the clipping radius is set based on the distribution of the dR 116 values for the bright sources. 117 118 - NITER clipping passes are performed 119 120 - the per-star astrometric errors are included in the fit. The photcode table controls 121 whether only the reported positional errors are used, or if the magnitudes errors are 122 scaled to determine the error, and if there is a systematic floor for all sources. 123 124 - input detections are pre-filtered on the basis of the photFlags, etc, in bcatalog 125 126 - outlying detections are clipped in the iterative passes, but the clipped detections are 127 not recorded 128 84 129 */ 85 130 … … 96 141 fclose (f); 97 142 */ 98 99 /*** XXX this function can be improved in 4 important ways:100 101 1) the initial value of the clipping radius could be set based on the distribution of the102 value (eg, inner 50%) (better to use dL, dM rather than dP, dQ)103 104 2) multiple clipping passes could be performed105 106 3) the per-star astrometric errors could be included in the fit (non-systematic terms at107 least, or scaled values of the mag error, or simply the mag error itself)108 109 4) we could ignore input detections on the basis of the photFlags110 111 */
Note:
See TracChangeset
for help on using the changeset viewer.
