comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » New in 5.5: SFit, /Irregular, /Max_Degree
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
New in 5.5: SFit, /Irregular, /Max_Degree [message #30227] Mon, 15 April 2002 19:47
Dick Jackson is currently offline  Dick Jackson
Messages: 347
Registered: August 1998
Senior Member
Hi all,

I just realized today that a couple of dandy additions to SFit.pro came in
with IDL 5.5 (due to some well-placed nagging to a receptive RSI), but this
was not documented in the What's New PDF. What you get are the ability to:

- fit a set of arbitrary XYZ values (rather than Z values for a regular
2D XY grid)
- requesting a 'regression fitting' polynomial (rather than a complete
polynomial of degree n in X and Y)

I had hacked up something called SFitXYZ some time back to do some of this
(which can be ignored now), so I was happy to see these added into SFit. For
reference, here is the header for the new version.

function sfit, z, degree, KX=kx, IRREGULAR=irreg_p, MAX_DEGREE=max_p
;+
; NAME:
; SFIT
;
; PURPOSE:
; This function determines a polynomial fit to a surface sampled
; over a regular or irregular grid.
;
; CATEGORY:
; Curve and surface fitting.
;
; CALLING SEQUENCE:
; Result = SFIT(Data, Degree) ;Regular input grid
; Result = SFIT(Data, Degree, /IRREGULAR) ;Irregular input grid
;
; INPUTS:
; Data: The array of data to fit. If IRREGULAR
; is not set, the data are assumed to be sampled over a regular 2D
; grid, and should be in an Ncolumns by Nrows array. In this case, the
; column and row subscripts implicitly contain the X and Y
; location of the point. The sizes of the dimensions may be unequal.
; If IRREGULAR is set, Data is a [3,n] array containing the X,
; Y, and Z location of each point sampled on the surface.
;
; Degree: The maximum degree of fit (in one dimension).
;
; KEYWORDS:
; IRREGULAR: If set, Data is [3,n] array, containing the X, Y,
; and Z locations of n points sampled on the surface. See
; description above.
; MAX_DEGREE: If set, the Degree parameter represents the
; maximum degree of the fitting polynomial of all dimensions
; combined, rather than the maximum degree of the polynomial
; in a single variable. For example, if Degree is 2, and
; MAX_DEGREE is not set, then the terms returned will be
; [[K, y, y^2], [x, xy, xy^2], [x^2, x^2 y, x^2 y^2]].
; If MAX_DEGREE is set, the terms returned will be in a
; vector, [K, y, y^2, x, xy, x^2], in which no term has a
; power higher than two in X and Y combined, and the powers
; of Y vary the fastest.
;
;
; OUTPUT:
; This function returns the fitted array. If IRREGULAR is not
; set, the dimensions of the result are the same as the
; dimensions of the Data input parameter, and contain the
; calculated fit at the grid points. If IRREGULAR is set, the
; result contains n points, and contains the value of the
; fitting polynomial at the sample points.
;
; OUTPUT KEYWORDS:
; Kx: The array of coefficients for a polynomial function
; of x and y to fit data. If MAX_DEGREE is not set, this
; parameter is returned as a (Degree+1) by (Degree+1)
; element array. If MAX_DEGREE is set, this parameter
; is returned as a (Degree+1) * (Degree+2)/2 element
; vector.
;
; PROCEDURE:
; Fit a 2D array Z as a polynomial function of x and y.
; The function fitted is:
; F(x,y) = Sum over i and j of kx[j,i] * x^i * y^j
; where kx is returned as a keyword. If the keyword MAX_DEGREE
; is set, kx is a vector, and the total of the X and Y powers will
; not exceed DEGREE, with the Y powers varying the fastest.
;
; MODIFICATION HISTORY:
; July, 1993, DMS Initial creation
; July, 2001 Added MAX_DEGREE and IRREGULAR keywords.

Cheers,
--
-Dick

Dick Jackson / dick@d-jackson.com
D-Jackson Software Consulting / http://www.d-jackson.com
Calgary, Alberta, Canada / +1-403-242-7398 / Fax: 241-7392
[Message index]
 
Read Message
Previous Topic: Bugfix/workaround for Mac directory names with spaces?
Next Topic: Re: tall SURFACE plots don't work?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 19:04:05 PDT 2025

Total time taken to generate the page: 0.00453 seconds