Skip to content

Fit

Interactive curve fitting for Linux, Windows and macOS

User guide

Peaks and diffraction

The background

This software's choice — A decision made by this software rather than by the field's sources; the explanation says why it was made.

The background is the slowly varying level under the peaks; the program can fit it as a curve of the model, or mark it with background points and subtract it.

There are two ways to deal with it, and a model has one or the other, never both. The first leaves the profile as it was measured: a background curve in the model (Model > Background > Curve), fitted with the peaks on the data outside the fit intervals. The second is points that you or the program selected, which are interpolated and subtracted from the profile (Model > Background > Subtract) and are never fitted. A new model starts with a curve; Model > Background > Curve > None leaves the model without one, which is what selecting points needs. Fit > Automatically uses the curve, and does not add one to a model you left without.

Background points are points of the profile that lie on the background rather than on a peak. Once they are marked, the background they describe can be subtracted from the profile. The Model > Background > Points submenu sets them:

The points are listed in the Background Points table (Position and Amplitude) and drawn as the Background points series. The small toolbar above that table has buttons for computing the points, subtracting automatically, subtracting by the selected points and removing them all. Typing into the table does not change the points.

The Tools tab carries the same commands as buttons under Background: Pick, Auto and Clear run Model > Background > Points > Start Manual Selection, Compute Automatically and Remove All; Subtract runs Model > Background > Subtract > Automatically. The Pick button stays pressed while its picking mode runs, and the menu entry reads Stop Visual Selection.

The Background submenu and the Background buttons are greyed until a profile is loaded, and while a fit runs.

While a background curve is the model's background there are no points to select: the Background buttons under Tools are taken away, and Points, Subtract > Automatically and Subtract > By Selected Points are greyed. The Background Points table then lists the curve's values instead (see the table's topic). Choose Model > Background > Curve > None to select points; the same refusals are made in words to a script, and a curve cannot be chosen while points are selected - remove them first with Model > Background > Points > Remove All.

Limitations

See also: The background curve · Subtracting the background · Picking points on the chart

The background curve

This software's choice — A decision made by this software rather than by the field's sources; the explanation says why it was made.

A new model of peaks has one background curve under them, fitted with them, drawn and saved with the project - and the profile is left as it was measured. It is a Chebyshev background unless Model > Background > Curve chooses another shape, or None.

A curve is saved as its parameters, like every curve, and its values are computed from them each time they are needed - so the Background Points table, which lists them while the curve is the background, is never saved and cannot disagree with the curve.

None is a choice: a model may be left without a background curve, and then keeps none until you choose one. Deleting the background's row in the Model panel is the same choice. A model with background points selected must have none (the points are the background), so a curve is refused while points are selected.

The submenu lists every background shape: Constant, Linear and Quadratic backgrounds, an Exponential background for a tail that decays, a Power-law background, and a Chebyshev background that follows a baseline bending several times across the whole pattern. The tick shows the one the model has. Choosing a shape replaces the model's background by ONE curve of it under the whole profile, starting from the level of the data's own baseline. There is no choice of none: a background is always there, and the Constant is the flattest one.

It is one curve, not one per fit interval, so the background stays one smooth line under every interval. A fit takes turns: the background is fitted to the whole profile with the peaks held - including the data between the intervals, where there is nothing but background - and then each interval fits its peaks on it, side by side as before. The turns repeat while the model still improves by a thousandth, twenty at most; the Run Log says how many there were. Fit > Automatically first fits the background to the floor of the data, before the reduction, then takes the same turns.

It is fitted by every fit, drawn with the curves, them, listed in the Model tab and the Curve Attributes table like them, and saved in the project with what the fit found - so a project reopens with the same background, still fitted. Deleting its row in the Model tab (Model > Delete Curve) is refused, and says to choose another shape instead.

Its coefficients are measured from xr, the first sample of the data: b0 is the background there, b1 the slope, b2 the curvature; tau is an exponential's decay length and p a power law's exponent; a Chebyshev background's c0, c1, ... weigh its terms (the parameter "terms" says how many: six at first, up to sixty-four) over the range xl to xh of the data. Reducing the number of curves never removes it, and a model of only a background can be drawn and fitted.

A background is not below zero anywhere in the profile when the data are not: one that would dip below is lifted until its lowest point touches zero, and its level b0 carries the lift. Over data that go below zero it may follow them. See Limits on parameter values.

A curve type may say that its curves take no separate background - its curves describing the whole of the data, level included. Such a model has no background curve at all, and Model > Background > Curve is greyed for it, saying why.

Fit > Automatically keeps the model's background curve, the one you chose or the default Chebyshev. It subtracts nothing from the profile. It fits the curve to the floor of the data: the samples standing more than three noise units above it are left out and it is fitted through the rest, before any peak curve is reduced, so a hump the curve can follow is background and not peaks. The fit intervals are what is left above it. A Chebyshev background starts at twelve terms there and has the number chosen by BIC against the floor; the Run Log says how many it ended with and every change.

Curve scaling multiplies the peaks of each interval and never the background: one curve scaled differently in each interval would no longer be one curve. Its coefficients are the curve that is drawn.

Limitations

See also: The background · Subtracting the background · Deleting a curve

Subtracting the background

This software's choice — A decision made by this software rather than by the field's sources; the explanation says why it was made.

Model > Background > Subtract joins the background points by straight lines and subtracts those lines from the profile.

Between each two neighbouring background points the straight line through them is subtracted from the amplitudes, so every background point itself ends at zero. The profile on the chart and in the Data table is replaced by the result and the background points are cleared. With a data interval selected, only that interval is changed.

Subtract is greyed until a profile is loaded, and while a fit runs.

Limitations

See also: The background · The background curve · Reload Profile

Background fraction

This software's choice — A decision made by this software rather than by the field's sources; the explanation says why it was made.

The background fraction decides how small a peak the automatic searches still count: a point below 1/N of the highest point, for the factor N you set, is treated as background.

Model > Background > Set Background Fraction opens the Background Factor dialog, whose field is labelled Background factor value 1 /. It must be a number greater than 1; anything else is refused with a message. The default is 30, so anything lower than one thirtieth of the highest point is not searched for peaks.

The factor is used by Model > Curve Positions > Compute Automatically, by Model > Fit Intervals > Compute Automatically, and by a fit that proposes positions or intervals itself, Fit > Automatically included. A larger factor finds smaller peaks; a smaller one keeps only the tall ones.

The factor is saved with the project.

Limitations

See also: Curve positions · Fit intervals · Subtracting the background

The Background Points table

This software's choice — A decision made by this software rather than by the field's sources; the explanation says why it was made.

Lists the background points by Position and Amplitude, beside the buttons that find, subtract and remove them - or, while a background curve is the model's background, the curve's values at every sample.

Each row is one point of the background, picked on the chart or found from the data.

While a background curve is the background, each row is the value of the curve at one sample of the profile, computed by the compute server from the curve as it is now and refreshed whenever the curve changes. They are not points anyone selected, so they are not drawn as a series (the curve already is), they cannot be moved, deleted or subtracted, and they are not saved: they go when the curve does, with Model > Background > Curve > None.

The toolbar, from the top:

A point can also be moved by typing: change its Position or its Amplitude and leave the cell, and the point moves, on the chart and in the engine.

See also: The tables at the bottom

Diffraction angles: Theta, 2 Theta and sin(Theta)/lambda

Convention — Common practice or a guideline in the field, not a rule its sources require.

For a diffraction pattern the stored argument is read as the scattering angle 2 Theta in degrees, and the axis can show it as 2 Theta, as Theta, or as sin(Theta)/lambda.

Diffraction patterns are usually recorded against the scattering angle 2 Theta, and the program takes the stored argument to be 2 Theta in degrees whenever one of these three rules is in force:

The value of a diffraction profile is the measured Intensity, and Data > Value Transformation > Use Rule > Intensity names it so; a model of the peak shapes the program ships is shown against it by Automatic.

By Bragg's law, lambda = 2 d sin(Theta), the value sin(Theta)/lambda equals 1/(2d), where d is the spacing of the diffracting planes. Peaks recorded at different wavelengths therefore line up on this axis, which is why it is common in crystallography.

Only Sin Theta / Lambda needs a wavelength. The first time you choose it with no wavelength known, the program asks for one before switching; Theta and 2 * Theta need none.

Limitations

See also: Argument axes and units · Wavelength

Wavelength

This software's choice — A decision made by this software rather than by the field's sources; the explanation says why it was made.

The wavelength of the radiation, in angstrom, is the number the Sin Theta / Lambda axis divides by.

Set it with Data > Argument Transformation > Set Rule Parameters > Wavelength. A dialog titled Wavelength asks for Wavelength (angstrom). It accepts only a positive number - 1.5406, for example - and keeps asking until it gets one or you cancel. On OK the wavelength is stored and the axis switches to Sin Theta / Lambda.

Set Rule Parameters is greyed unless the axis in force is a diffraction angle - Theta, 2 * Theta or Sin Theta / Lambda, or Automatic while it resolves to one. To give a wavelength for the first time you can also choose Data > Argument Transformation > Use Rule > Sin Theta / Lambda: with none known, it asks for one first.

The wavelength is saved with the project.

Limitations

See also: Diffraction angles: Theta, 2 Theta and sin(Theta)/lambda · Argument axes and units

Diffractometer and refinement files

Convention — Common practice or a guideline in the field, not a rule its sources require.

Besides plain columns, Fit reads a powder pattern from the files diffractometers and refinement programs write: .xrdml, .uxd, GSAS files, a powder CIF, .xye and .chi.

Each is read as 2 Theta, in degrees, against intensity, and the axes are labelled so:

Limitations

Sources

See also: Diffraction angles: Theta, 2 Theta and sin(Theta)/lambda · Wavelength

Sample diffraction profiles

This software's choice — A decision made by this software rather than by the field's sources; the explanation says why it was made.

Nine diffraction profiles come with the peaks, in the Data folder, to try a fit on.

A .dat file is read as a diffraction profile - its argument an angle - and File > Import Profile names the format so.

Limitations

See also: Sample data · Import Profile

A first fit of peaks

This software's choice — A decision made by this software rather than by the field's sources; the explanation says why it was made.

Two overlapping peaks in 2.dat, fitted automatically in a few clicks.

Limitations

See also: A first fit · Sample diffraction profiles · Automatic decomposition

Limits on the peaks, the backgrounds and your own formulas

This software's choice — A decision made by this software rather than by the field's sources; the explanation says why it was made.

How wide each peak shape may be, how the backgrounds keep above zero, and what the parameters of a formula you define may take.

A peak's width limit is on the peak, not on the number, because a width means different things in different curve types. A pseudo-Voigt's or a Pearson VII's sigma is its full width at half maximum, so it may be as wide as the interval; a Gaussian's sigma is a standard deviation, and the peak is 2.35 of them wide at half its maximum, so it may be the interval divided by 2.35. A Voigt's gamma and a Doniach-Sunjic sigma are half widths; an exponentially modified Gaussian's tail tau falls to half in ln 2 of its length; how wide a Moffat or a Doniach-Sunjic line is per unit of sigma depends on its shape, and the limit follows the shape the fit has reached. A Voigt's two widths are held together, so the peak they make fits. Both widths of a two-branch pseudo-Voigt are held, and the difference of an asymmetric pseudo-Voigt's two side widths too.

Where it is held, the level of an Exponential or a Power-law background is kept at zero or above. A Constant, Linear or Quadratic or Chebyshev background, whose sign no single coefficient decides, is lifted after every calculation until its lowest point in the profile touches zero, and its level b0 or c0 carries the lift - so the coefficients in the table describe the curve that is drawn. A lift rather than a cut at zero, because a cut background has parts no coefficient can move, and rather than a penalty, because a penalty only discourages going below zero.

Limitations

See also: Limits on parameter values · The background curve · Parameter roles and starting values

The Residual Spectrum

This software's choice — A decision made by this software rather than by the field's sources; the explanation says why it was made.

The Residual Spectrum tab of the chart area maps where, and at which length of rhythm, the difference between the data and the model holds more than noise.

It draws the wavelet transform the program judges the difference with after every fit (see "Is the difference only noise?") as a map: the model's positions across, the length of a rhythm upwards - 4, 8, 16 points per cycle and so on - and at each place and rhythm what the difference holds there. A cell in the colour of the shaded stretches is a wave the model misses: exactly the cells that judgement named, so the map and the stretches always agree, and a patch says both where the model falls short and what length of wave it left out. A dark grey cell is as strong as noise is only one time in twenty, but among hundreds of cells some are that strong by chance, so it is not named; a light grey one is noise above its average, and the background is noise. The key under the map names every colour, and the line under its title says how to read it.

THE MODEL'S CHART AND THE RESIDUAL SPECTRUM SHOW ONE VIEW of the model's x. Zooming or scrolling either does the same to the other, and making either show everything again shows everything on both, values included. Up and down is each chart's own: the model's values on its chart, the wave lengths on the map.

Below the map a scroll bar moves the view along x, always agreeing with the one below the model's chart; the one to its right moves it along the wave lengths.

Limitations

See also: Is the difference only noise? · The chart · Zooming and scrolling the chart

User-defined curves

This software's choice — A decision made by this software rather than by the field's sources; the explanation says why it was made.

You can fit a shape of your own by typing its formula; the program turns it into a curve type that is saved and offered like the built-in ones.

Choose Model > Curve Type > User > New User Curve, or New User Curve in the Tools list. Two dialogs follow: Create New Curve Type, where you name the curve and write its formula, and Set Curve Type Properties, where you say which parameter plays which role and give starting values.

When you press Done the curve type is saved and selected. It appears under Model > Curve Type > User, below New User Curve, and is ticked while it is in use. It is kept between sessions: each one is stored as a file in the program's settings folder.

A user-defined curve is fitted like any other: place positions, set fit intervals, fit. Its formula is saved with the project. It says nothing about its axes, so under the Automatic axis rules it is shown against what the data says, or a plain Position.

New User Curve does not name a shape: it opens the dialogs that define one. Cancelling them leaves the previous type in use. The User group comes last in Model > Curve Type and in the Tools list.

Cancelling either dialog creates nothing: a curve type saved when its formula was accepted is removed again if you then cancel the second dialog.

Limitations

See also: Writing the formula of a user-defined curve · Parameter roles and starting values · Selecting and deleting user-defined curves · Choosing a curve type

Writing the formula of a user-defined curve

This software's choice — A decision made by this software rather than by the field's sources; the explanation says why it was made.

In the Create New Curve Type dialog you give the curve a name and a formula in x; every other name in the formula becomes a parameter.

Name is what the curve type is called in the menu (MyCurve until you change it). Expression is the formula, filled in with a bell curve to start from: A*exp(-((x-x0)/SIGMA)^2).

x is the argument, the variable running along the axis. Some names mean something, whatever their case: x0 is the position, where the curve is placed, and the fit does not move it; A is taken as the amplitude and SIGMA as the width, and SIGMA starts at 0.25 rather than 0 so that a formula dividing by it can be evaluated. Every other name is an ordinary fitted value starting at 0. The next dialog can change all of this.

The keypad inserts at the cursor. A function is inserted with its brackets, and the cursor left between them. It offers Sin, Cos, Tg, Ctg, the hyperbolic Sh, Ch, Th, Cth, Sch and Csch, the inverses Arcsin, Arccos, Arctg, Arcctg, Arsh, Arch, Arth and Arcth, Ln (natural logarithm), Log (base 10), Exp, Abs and Sqrt, the digits, the operators + - * / ^, brackets and a decimal point. Names are not case-sensitive, a comma typed on the keyboard becomes a decimal point, and sqr and pi can be typed though they have no button.

Continue >> checks the formula before anything is saved. If it cannot be used a message says why and the dialog opens again for you to correct it:

Cancel abandons the definition.

Limitations

See also: Parameter roles and starting values · User-defined curves

Parameter roles and starting values

This software's choice — A decision made by this software rather than by the field's sources; the explanation says why it was made.

The Set Curve Type Properties dialog says which parameter of a user-defined curve is its argument, position, amplitude and width, which are held, and where each starts.

Expression shows the formula. Four lists give the roles, and each role is held by at most one parameter - giving it to one takes it from any other:

Amplitude and Width offer (none), which leaves the role unheld.

Shared parameters lists the position and the ordinary parameters - not the argument, the amplitude or the width. Ticking the position parameter makes the fit leave it where it was picked; unticking it lets the fit move it. Ticking any other parameter makes it shared: one value, varied by the fit and held equal across the curves of an interval.

Held parameters lists the shared and the ordinary parameters. Ticking one holds it at its starting value: the fit does not vary it. The tick is kept with the curve and in the project.

To give a starting value, select a parameter in Shared parameters, type the value in Initial value and press Apply. A value that is not a number is refused with a message.

Done saves the roles and selects the curve type. << Backtrack discards this draft and returns to the formula dialog. Cancel closes the dialog and removes the draft.

Once the curves are placed, a value can also be typed into the Curve Attributes table.

See also: Parameter kinds: fitted, shared, fixed and computed · Writing the formula of a user-defined curve · User-defined curves

Selecting and deleting user-defined curves

This software's choice — A decision made by this software rather than by the field's sources; the explanation says why it was made.

The curve types you have defined are chosen and deleted under Model > Curve Type > User.

Below New User Curve and a separator, the User group lists every curve type you have defined. Choosing one selects it, and it is ticked while in use. New User Curve itself is never ticked: it names no curve, it makes one.

Model > Curve Type > User > Delete User Curve opens a list of the same curve types. Choosing one deletes it, and its file, at once and without asking. The entry is there only while at least one curve type of your own exists.

If you delete the curve type in use, the program says so: the model is left with no curve type, and a fit is refused until you choose another under Model > Curve Type.

A curve type saved without a formula - by an older version, or by a session interrupted while defining it - cannot be selected; choosing it says so and suggests deleting it and making it again.

Limitations

See also: User-defined curves · Choosing a curve type