Changeset 3105
- Timestamp:
- Jan 28, 2005, 5:17:26 AM (21 years ago)
- Location:
- trunk/Ohana/src/opihi
- Files:
-
- 1 added
- 5 edited
-
cmd.astro/imfit.c (modified) (2 diffs)
-
cmd.data/Makefile (modified) (1 diff)
-
cmd.data/dot.c (added)
-
cmd.data/init.c (modified) (2 diffs)
-
cmd.data/plot.c (modified) (1 diff)
-
mana/fitcontour.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/cmd.astro/imfit.c
r3030 r3105 246 246 dchisq = ochisq; 247 247 248 for (i = 0; (i < 50) && ((dchisq <= 0.0) || (dchisq > 0.001*(Npts - Npar))); i++) {248 for (i = 0; (i < 25) && ((dchisq <= 0.0) || (dchisq > 0.01*(Npts - Npar))); i++) { 249 249 chisq = mrq2dmin (x, y, z, dz, Npts, par, Npar, fitfunc, VERBOSE); 250 250 dchisq = ochisq - chisq; 251 251 ochisq = chisq; 252 252 } 253 set_int_variable ("Niter", i); 254 253 255 254 256 if (ShapeVariation) { … … 407 409 set_variable ("ChiSq", chisq/(Npts - Npar)); 408 410 409 for (i = 0; i < Npar; i++) { 410 fprintf (stderr, "%g ", par[i]); 411 } 412 fprintf (stderr, "\n"); 411 if (VERBOSE) { 412 for (i = 0; i < Npar; i++) { 413 fprintf (stderr, "%g ", par[i]); 414 } 415 fprintf (stderr, "\n"); 416 } 413 417 414 418 free (x); -
trunk/Ohana/src/opihi/cmd.data/Makefile
r2843 r3105 72 72 $(SDIR)/peak.$(ARCH).o \ 73 73 $(SDIR)/plot.$(ARCH).o \ 74 $(SDIR)/dot.$(ARCH).o \ 74 75 $(SDIR)/point.$(ARCH).o \ 75 76 $(SDIR)/ps.$(ARCH).o \ -
trunk/Ohana/src/opihi/cmd.data/init.c
r2843 r3105 53 53 int peak PROTO((int, char **)); 54 54 int plot PROTO((int, char **)); 55 int dot PROTO((int, char **)); 55 56 int point PROTO((int, char **)); 56 57 int pop PROTO((int, char **)); … … 152 153 {"peak", peak, "find vector peak in range"}, 153 154 {"plot", plot, "plot a pair of vectors"}, 155 {"dot", dot, "plot a single point"}, 154 156 {"point", point, "load overlay with single point"}, 155 157 {"ps", ps, "define labels for plot"}, -
trunk/Ohana/src/opihi/cmd.data/plot.c
r2843 r3105 123 123 124 124 } 125 126 -
trunk/Ohana/src/opihi/mana/fitcontour.c
r3030 r3105 36 36 r = hypot (x, y); 37 37 38 /* 39 t = 2*atan2(y,x); 40 sn = sin(t); 41 cs = cos(t); 42 */ 38 /* calculate sin(2t), cos(2t) using 1/2 angle tri relationship above */ 43 39 sn1 = y / r; 44 40 cs1 = x / r; … … 63 59 gaussj (C, NTERM, B, 1); 64 60 61 /** this is somewhat weak: if the object is too elongated, Rmin can be < 0 **/ 65 62 dR = hypot (B[1][0], B[2][0]); 66 63 Rmaj = B[0][0] + dR; … … 101 98 } 102 99 100 101 /* this routine fits a single sine and cosine to the value of dr as a function of the angle around the central 102 * point, theta. this is NOT an exact fit, an is increasingly in error for more eccentric ellipses. however, 103 * it does a reasonable job of approximating the value of the major and minor axes, and it gets the angle of 104 * orientation right at well. We then assume the values of major and minor axis and angle are correct to get 105 * the parameters for the elliptical gaussian fit: 106 107 z = (x^2) / (2 Rx^2) + (y^2) / (2 Ry^2) + Rxy x y 108 109 the functions above give the correct relationship between these: 110 111 R1 = SQ(Rmaj) + SQ(Rmin); 112 R2 = SQ(Rmaj) - SQ(Rmin); 113 R3 = Rmaj*Rmin; 114 115 Rx = R3 / sqrt (R1 - R2*cs); 116 Ry = R3 / sqrt (R1 + R2*cs); 117 Rxy = -sn*R2 / SQ(R3); 118 119 to derive these relationships, write the equation for an ellipse with major axis in the x-dir and minor in 120 the y-dir: 121 122 z = (x^2) / (2 Rmaj^2) + (y^2) / (2 Rmin^2) 123 124 apply the rotation matrix: 125 126 (x)' = (cos, -sin)(x,y) 127 (y)' = (sin, +cos)(x,y) (modulo the sign on the sine) 128 129 then group the x^2 terms, the y^2 terms, and the xy terms to find the three coeffs. 130 131 NOTE: I spent a while having trouble deriving this from the polar form of an ellipse: 132 133 x = Rmaj*cos(theta) 134 y = Rmin*sin(theta) 135 136 it turns out that 'theta' above is NOT the angle (0,1)-(0,0)-(x,y). rather, it should be viewed as a 137 paraterization of the ellipse. 138 139 */
Note:
See TracChangeset
for help on using the changeset viewer.
