Scripting Resources for DigitalMicrograph™ |
Function: Polynomial Fit |
|
Function |
Fits an nth order polynomial to a 1D dataset. |
Version |
version:20230105, v1.0 |
Author |
D. R. G. Mitchell |
Acknowledgements |
Dervied from a script by Webster et al. in Ultramicroscopy, 217 (2020), 113069. |
Comments |
This uses an undocumented FitPolynomial() function to do the polynomial fitting. It can fit to very high orders (eg 20+), although the benefits of so doing are questionable. In this demonstration, the fit range of the function is constrained between 2nd and 20th order. The script creates some nice curvy data and then fits and overlays the 2nd to 8th order polynomials, the latter providing the best fit. The function returns (by reference) images containing the best fit to the data and the polynomial coefficients. The function returns a boolean value indicating the success or failure of the fit. |
System Requirements |
Should be compatible with all recent versions of DigitalMicrograph. Tested on GMS 2.32. |
Known Issues |
Polynomial fits can be very good over the range of fitted data. However, extrapolation is fraught with danger, as such curves can become highly erratic. |
Supported |
Yes |
Included Files |
Main script file. |
Source Code |
See attached script file. |