nscl_logo_small.gif (2463 bytes)

fit

HH00706_.jpg (6530 bytes)

Syntax

fit create fitname spectrum low high type
fit update ?pattern?
fit delete name
fit list ?pattern?
fit proc fitname

Detailed Description

The fit command is an ensemble of commands that allows you to create and manipulate fits. The SpecTcl fitting subsystem, at this time supports fits on all types of spectra that have a 1-d display (e.g. gamma1 spectra are fittable). A fit is a named entity that is bound to a region of interest of a specific spectrum. While fits are not automatically updated, it is possible to ask fit to update itself based on the current state of a spectrum. Fits are also displayed in Xamine.

The SpecTcl fitting subsystem is exentsible. See the programming guide section on Extending SpecTcl's Fitting subsystemfor information about how to add a fit type to SpecTcl.

fit create name spectrum low high type

Creates a fit and performs it based on the data currently in spectrum.

fit update ?pattern?

Performs the specified set of fits again using the current data in a spectrum. If the optional pattern is supplied, only the fits with names that match it will be performed. Pattern can contain the wild-card characters used by unix in filename matching. If the pattern is not provided, then it defaults to "*" which updates all fits.

When a fit is updated, its new fitline is propagated to Xamine for display.

fit delete name

Deletes the specified fit. If the fit was displayed in Xamine, the fitline is removed from the corresponding spectrum.

fit list ?pattern?

Lists fits and their properties. The result is a properly formatted Tcl list. Each element of the list is itself a list as follows:
ElementContents
0The name of the fit
1The name of the spectrum the fit is defined on
2The type of the fit (e.g. "gaussian")
3A 2 element sublist that describes the region of interest over which the fit was performed and will be displayed. The low channel limit will be first followed by the high channel limit of the area of interest
4A property list that describes the fit parameters. A property list is a list of two item sublists. Each item contains a keyword and a value (keyword is element 0). The parameters returned by each fit will depend on its fit type as each fit type will have a different set of variable parameters. For example, the gaussian fit has a "centroid" parameter, the linear fit a "slope" parameter. See the section "Parameters of supported fits" below for the parameters of fits that are a standard part of SpecTcl. for others either list them and look at the fit property list or consult with the author of the fit. Note that all fits should produce a property named "chisquare" that is the chi-square measure of the goodness of the fit.

fit proc name

Produces a Tcl proc named fitline that is capable of evaluating the fit at any point in the fit's region of interest. The proc has a single parameter, the channel coordinate of the point to evaluate. Note that you can use the Tcl "rename" command to rename the fit to something meaningful. The script below uses this to create a proc named for each existing fit that is named after the fit:

foreach fit [fit list] {
  set name [lindex $fit 0]
  eval     [fit proc $name]
  rename fitline $name
}

Properties of supported fits

This section describes the properties of fits that are supported by SpecTcl.

Gaussian Fit Parameters

A gaussian fit produces a functional form as follows:

    y = baseline + height * exp(-0.5*((x-centroid)/sigma)**2)

The fit parameters are therefore "baseline", "height", "centroid", "sigma", and "chisquare".

Linear Fit Parameters

The linear fit produces a functional form as follows:

      y  = offset + slope*x

Therefore the fit parameters are called: "offset", "slope", and of course "chisquare".


Last Modified: October 23, 2006
by: fox@nscl.msu.edu Copyright NSCL 1999, All rights reserved