;+ ; function returns the sum of the set of orthogonal polynomials ; described by the polyfit argument evaluated at x.; ; ;
This code came from Tom Bania's GBT_IDL work. Local ; modifications include: ;
; p^(m) = x*p^(m-1)*polyfit(2,m) + p^(m-1)*polyfit(1,m) + p^(m-2)*polyfit(0,m) ;;
; p^(1) = polyfit(1,1)*x + polyfit(0,1) ;;
; yy = *(!g.s[0].data_ptr) ; xx = dindgen(n_elements(yy)) ; poly = ortho_fit(xx, yy, 7, cfit, rms) ; thefit = ortho_poly(xx,poly) ; *(!g.s[0].data_ptr) = *(!g.s[0].data_ptr) - thefit ;; ; ; @version $Id: ortho_poly.pro,v 1.2 2004/12/08 03:50:36 bgarwood Exp $ ;- function ortho_poly,x,polyfit compile_opt idl2 n = n_elements(x) b = size(polyfit) if (b[0] ne 2) then begin if (b[0] eq 1 and b[1] eq 4) then begin ; most likely its nfit=0, recast polyfit = reform(polyfit, 4, 1) b = size(polyfit) endif else begin message, 'polyfit must be a 2-D array' endelse endif if (b[1] ne 4) then message, 'First dimension of polyfit must have 4 elements' nfit = b[2]-1 if (nfit lt 0) then message, 'Second dimension of polyfit must have more than 1 element' fit = dblarr(n) pnm1 = dblarr(n) pn = pnm1 pnp1 = pnm1 pnm1[0:n-1] = polyfit[0,0] fit = polyfit[3,0]*pnm1 if (nfit eq 0) then begin return, fit endif pn = x*polyfit[1,1] + polyfit[0,1] fit = fit + polyfit[3,1]*pn for m=2,nfit do begin pnp1 = pn*(x*polyfit[2,m] + polyfit[1,m]) + pnm1*polyfit[0,m] fit = fit + polyfit[3,m]*pnp1 pnm1 = pn pn = pnp1 endfor return,fit end