Skip to content

Fit

Interactive curve fitting for Linux, Windows and macOS

User guide

Projects and files

Projects

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 project is your whole piece of work in one file, so that you can close Fit and later carry on fitting from where you stopped.

A project holds the data, everything you marked on it, the model, the values the last fit found and how the window was set up. Opening it again does not merely redraw what you had: the fitted values stay attached to the curves they belong to, so the next fit continues from them.

Project files end in .fitproj. The File menu holds the commands for them:

Saving and exporting are different things. A saved project can be opened again and is how you keep your work. An export is a one-way copy of a table for a spreadsheet or a script: Fit cannot open it again, and exporting does not count as saving.

The project open when you last closed Fit opens by itself at the next start.

Limitations

See also: What a project file holds · Save Project · Import Profile · Unsaved changes

New Project

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

File > New Project closes what is open and leaves an empty window, ready for a profile to be imported.

The profile, the background points, the fit intervals, the curve positions and the model are all removed from the window, and the title bar shows the program's name again. The new project has no file yet: the first File > Save Project asks for a name.

It also means no project will open by itself at the next start, until you open or save one.

The shortcut is Ctrl+N. The command is always offered.

With unsaved work in the window, it first asks whether to save the project, as closing the window does: Yes saves and then clears, No clears without saving, and Cancel - or a save that does not happen - leaves everything as it was.

See also: Save Project · Import Profile

Open Project

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

File > Open Project asks for a .fitproj file and restores the work it holds.

The dialog shows project files (*.fitproj), and can be switched to all files for a project that was renamed. Opening restores the profile, the background points, the fit intervals, the curve positions, the settings and the fitted values, and then the working context: the argument axis, the picking mode, the table in front, the chart tab in front, the selected curve and, if you had zoomed in, the part of the chart you were looking at. The title bar shows the project's file name.

The R-factor is not recalculated on opening. Until you fit again it reads as not calculated; the value the project recorded stays in the file.

If the file cannot be used, a message says why and the work already in the window is left as it was. Typical reasons: there is no file at that path, the file is not a Fit project, or it needs a newer version of Fit - the message then names the format version it needs and the one this build reads.

If the project names a curve type this build does not have, for example peaks opened in a build without them, the project still opens with its data, its fit intervals and its settings, but without its model: the curves, their positions and their fitted values belong to that curve type, and built with another one they would be a model the file never held. The models in its history are left out for the same reason. The file still holds them all, and the project opens as a new one: the title still names the file it came from, but saving it asks for a new file name, so the original keeps its model. What a module of that pack keeps is kept in the file as it was, so a build with the module reads it again. A message says which of these the project held.

The shortcut is Ctrl+O. The command is always offered. A project can also be opened from the command line with /PROJECT, and on Windows by double-clicking a .fitproj file when the installer was allowed to associate the extension with Fit.

With unsaved work in the window, it first asks whether to save it, before the file dialog opens - the same question and the same answers as File > New Project. File > Open Recent asks it too.

Limitations

See also: Open Recent · What a project file holds · Where the data came from · Command-line options

Open Recent

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

File > Open Recent lists the projects you opened or saved most recently, newest first, and opens one with a click.

Each line is the whole path of a project, because two projects in different folders often have the same name. At most eight are kept. Opening or saving a project already in the list moves it to the top instead of listing it twice; two spellings of one path that differ only in capital letters count as the same project.

With no project remembered, the submenu shows one greyed line, (none), so that you can see the list is empty rather than missing.

The project at the top - the one open when Fit was last closed - opens by itself at the next start. If it has been moved or deleted in the meantime, Fit starts with nothing open, writes a warning to the log, and drops that project from the list.

The list belongs to this computer, because a path names a file on one machine. It is the recent section of settings.json, the one file in which Fit keeps what it remembers on this computer (see What Fit remembers on this computer), and it is written as soon as a project is opened or saved. On Linux that file is in ~/.local/state/fit, the folder the XDG Base Directory Specification names for state such as recently used files.

Limitations

Sources

See also: Open Project · What Fit remembers on this computer

Save Project

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

File > Save Project writes the project to its file, and asks for a name the first time.

A project that has never been saved has no file yet, so the first save behaves exactly like File > Save Project As. After that, File > Save Project writes to the same file without asking.

When the save succeeds, the title bar shows the project's file name, the project becomes the one that opens at the next start, and it moves to the top of File > Open Recent. If it fails - no such folder, no permission, a full disk - a message says why, the project still counts as unsaved, and the file already there is left exactly as it was: the new file is written beside it and takes its name only once it is complete.

The shortcut is Ctrl+S. The command is greyed out until a profile has been imported or a project opened: there is nothing to save before that.

See also: Save Project As · What a project file holds · Unsaved changes

Save Project As

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

File > Save Project As always asks for a file name and saves the project there.

Use it to keep a copy under another name, for example before trying a different model. From then on the window works on the new file: File > Save Project writes there.

If you type a name with no extension, .fitproj is added. A name you give with your own extension is kept as you typed it.

If a file of that name already exists, Fit asks whether to replace it, naming the file. The question is asked after the extension has been added, so it is about the file that would really be written. Answering No writes nothing and changes nothing.

The shortcut is Ctrl+Shift+S. The command is greyed out until a profile has been imported or a project opened.

See also: Save Project · The .fitproj file format

What a project file holds

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 project holds the data and everything needed to continue fitting it, but nothing that can be recalculated from those.

Stored in the file:

Not stored: the calculated profile, the difference, the curves' own points and where the fitted curves sit. They are recalculated from what is stored, so a project cannot disagree with its own model. Also not stored: the window's size and layout, and the settings that belong to your installation rather than to the work, such as the compute server's address or Animation Mode.

The original data file is not needed to open a project: the profile is inside it. The file's path is recorded, but only so that you can tell where the data came from.

Limitations

See also: The .fitproj file format · Where the data came from · What Fit remembers on this computer

The .fitproj file format

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 .fitproj file is a ZIP archive of JSON parts, which any archive tool can open.

It is the same arrangement that .xlsx and OpenDocument files use. If something goes wrong you can unpack a project and read what it holds. The parts are:

Old and new versions of Fit get along. When an older version opens a project written by a newer one and saves it, the parts and the entries it does not understand are written back unchanged, so passing a file between versions does not quietly lose work. A project that truly needs a newer reader is refused with a message saying so, rather than opened half understood.

Numbers are written at full precision, so a value comes back exactly as it was saved.

Limitations

Sources

See also: What a project file holds

Where the data came from

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 project remembers which data file it was imported from, and notes in the log when that file no longer says the same thing.

When a profile is imported, Fit records the file's path, its size, a fingerprint of its contents (an MD5 hash) and the kind of file it was. All of it is saved with the project.

When the project is opened again, Fit reads the file at that path, if it is still there, and compares its contents with the fingerprint. If they differ, a warning goes to the log naming the file. Nothing in the project changes: it still holds the data it was fitted to. The notice is there so that a result which no longer matches its input can be noticed rather than puzzled over months later.

The contents are compared rather than the file's date, because copying or restoring a file changes its date without changing the data, and an edit can leave the date as it was.

Limitations

See also: Log files · Reload Profile

Unsaved changes

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

Closing Fit, starting a new project or opening another with unsaved work asks whether to save the project first, and a save that does not happen stops the command.

Whether you close the window, use File > Quit, or replace the project with File > New Project, File > Open Project or File > Open Recent, Fit asks "Project has been modified. Save?" when there is unsaved work, and does not ask when there is none.

Work counts as unsaved when anything a save would write has changed since the project was last opened, saved or started from an imported file: the points picked for the background, the fit intervals or the curve positions, the model, a fit result, a setting. Choosing an axis counts, since the project keeps it; the table in front, the chart tab in front, the selected curve and the zoom do not, and neither does exporting a table.

File > Import Profile and File > Reload Profile ask a question of their own, about the model they discard.

See also: Save Project · Quit

Import Profile

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

File > Import Profile reads a data file and makes it the profile of the current project.

The dialog, Open Profile Data, starts in the folder Fit is installed in. It offers the formats this build can read: All supported, then one entry per format, then All files. The file's extension decides how it is read, whatever its capitals:

A file with any other extension is refused with a message naming the extension no reader handles. An analysis module can add formats of its own; the dialog then lists them too.

Importing starts the model again: the curves, the picks and the fitted parameters describe the data being replaced. So when the project has curves or unsaved work, Fit first asks, naming the file, whether to replace the data and discard the current model. With nothing to lose it does not ask.

Afterwards the profile is on the chart and in the Data tab, and the title bar shows the data file's name. The project keeps its own file: File > Save Project saves the new data into it. The data file's path, size and fingerprint are recorded for the project.

The shortcut is F2, and the first toolbar button does the same. The command is always offered.

Limitations

See also: Two-column data files (.dat) · Reload Profile · Sample data · Where the data came from

Two-column data files (.dat)

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 .dat file is plain text with the argument and the measured value on each line, and Fit reads the first two numbers of every line.

Each line should hold two numbers: first the argument (for a diffraction pattern, the angle), then the value (the intensity). Anything that is not part of a number separates numbers, so spaces, tabs and semicolons all work. For example:

116.0000 773.00

A number may have a sign (-1.5, +2) and an exponent (1.5e3, 2E-2). Its decimal mark may be a full stop or a comma. A comma is read as a decimal mark only on a line that writes no full stop, and only while that still leaves two numbers: 1,5;2,5 is one and a half and two and a half, while 12,40 and 12.5,40.0 are both pairs.

What the reader does without saying so:

Limitations

See also: Import Profile · Sample data

Reload Profile

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

File > Reload Profile reads the data file the open project came from again, for when it has changed on disk.

It re-reads the file the project records as its source - the one imported last, or for a project opened from disk the one it was built from - in the same way it was read the first time, and replaces the profile with what it finds.

Like importing, it starts the model again, so when the project has curves or unsaved work Fit first asks whether to go on.

When the project names no data file, or the file is no longer where it was, Fit says so and reads nothing; use File > Import Profile to choose the file.

The command is greyed out until a profile has been imported or a project opened. It has no shortcut.

See also: Import Profile · Where the data came from

Export Curve Parameters

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

File > Export > Curve Parameters writes the Curve Attributes table to a tab-separated text file.

What is written is the table's content, headings included: one line per curve, the cells separated by tabs, with no tab after the last cell. A spreadsheet or a script reads it directly. It does not matter which table is in front when you use the command.

The numbers are written with every digit, not as the table rounds them, and with a full stop as the decimal mark whatever the computer's language settings. Where the fit estimated an uncertainty, it gets a column of its own beside its value, headed with the parameter's name and "error".

The dialog, Select File to Save Data, offers text files. A name typed with no extension gets .txt; one typed with an extension keeps it. If the file exists, Fit asks whether to overwrite it: Yes overwrites, No lets you choose another name, and Cancel writes nothing. An empty name asks whether to choose again.

The command is greyed out while the Curve Attributes table is empty.

Limitations

See also: Export Summary Table · Save Project

Export Summary 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.

File > Export > Summary Table writes the Summary table - data, model and difference point by point - to a tab-separated text file.

The Summary table has, for every point inside every fit interval, the argument, the measured value, the model's value, the difference and each curve's contribution, with a heading row for each interval. A curve that covers only part of an interval leaves the rest of its column blank.

The file is written exactly as for File > Export > Curve Parameters: headings included, every digit of each number, a full stop as the decimal mark, cells separated by tabs, .txt added to a name with no extension, and the same questions about an existing file or an empty name.

The command is greyed out while the Summary table is empty.

Limitations

See also: Export Curve Parameters

Quit

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

File > Quit closes Fit, asking first whether to save unsaved work.

It does the same as closing the window. If the project has unsaved changes you are asked whether to save them, and the window stays open if you cancel or the save does not happen.

On closing, Fit writes its settings file: the project that was open, the recent projects and your other preferences.

The compute server is not stopped: it stays running so that the next start is immediate and other windows keep their engine.

The shortcut is Ctrl+Q, on macOS Command+Q.

See also: Unsaved changes · What Fit remembers on this computer · The window and the compute server

Sample data

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

Fit comes with a few data files to try it on, in a folder called Data.

Which files they are depends on the analysis modules this build contains: each module installs examples of its own kind of data, and its chapter of this guide says what each file holds.

Where the folder is: on Windows, beside Fit.exe in the folder Fit was installed to, which is where File > Import Profile starts; on Linux, /usr/share/fit/Data (the package's own name in place of fit for another package); on macOS, in the Resources folder inside the application bundle.

See also: Import Profile · A first fit

Command-line options

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

Fit's window accepts a few options that say what to open at start-up and how much to log.

An option starts with two dashes and takes its value after an equals sign, for example --project=C:\work\sample.fitproj. Put quotes around a path with spaces. A relative path that is not found is tried again relative to the folder Fit is installed in. Fit --help prints the list below, and Fit --version the version.

With neither --project nor --infile, the project open when Fit was last closed is opened again.

The window ignores an argument that is not an option, such as a bare file name. The installed launchers turn a bare file name into --project for a .fitproj file and --infile for any other file, which is how opening a project from the desktop works.

An option the program does not have, one written without the value it needs or with one it does not take, and one given twice are each reported in the log and on the console, all at once. The window still opens; a run nobody watches - the window checking itself, a recording - stops instead, with exit code 2.

The old spelling, /PROJECT=file with the name in capitals, still works in this release and writes a warning naming the new one. It stops working in the next release.

The compute server, fit_server, has options of its own: --host and --port for where it listens (127.0.0.1 and 8787 by default), --log-level, and --verbose to echo its log to the console.

Limitations

See also: Log files · Open Recent · The window and the compute server

Log files

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 window and the compute server each keep a log file, which is where to look when something went wrong.

Both files are in Fit's log folder for the current user, where each system keeps the logs of the programs you run:

The window writes fit_client.log and the server writes fit_server_log.txt - when the server runs on this computer under your account, which is how the launchers start it - and the Python engine, when a fit uses it, writes fit_sidecar_log.txt beside them.

By default the logs record what you did, what the window asked the server and how long each call took, warnings and errors with the program location where they happened. Some notices go only to the log, among them a remembered project that could not be found at start-up, a data file that has changed since a project was saved, and rows skipped while reading a price file.

A log that reaches 32 MB is renamed with .1 added to its name, replacing the previous .1 file, and a new one is started. So the two most recent files of each log are kept, and nothing older.

The launchers on Linux and macOS also keep what the server prints to its console: on Linux in ~/.local/state/<package>/server.log, on macOS in ~/Library/Logs/<application>/server.log.

Earlier versions kept the logs, together with the settings, in a folder called Fit in your home folder (%APPDATA%\Fit on Windows). The first start of a later version moves both to their own folders and removes the old one once nothing else is left in it. Where every kind of file is now, on each system, is in Where Fit keeps its files.

A copy started by the build script of a source tree writes its logs into the same folder as an installed copy, so each computer has one log folder; the build's Clean empties it.

When you report a problem, attach both log files: each tells one side of the story, and a call can be matched on both sides by its time.

See also: Command-line options · What Fit remembers on this computer · Where Fit keeps its files

What Fit remembers on this computer

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

Choices that belong to you and to this computer rather than to a project are kept in one file, settings.json.

settings.json is in a folder of this computer's own (see Where Fit keeps its files). It is not copied between computers: on Windows it is in the local part of your profile, which does not roam with your account, because much of what it holds - the paths of your projects, the address of a compute server - means nothing on another machine.

The file is JSON, with one section for each part of Fit that keeps something in it:

SectionWhat it holdsWritten
appthe compute server's address; the curve type, minimizer, loss function and weighting last chosen; whether Animation Mode is on; how large the report tabs and the Explain pane are drawn; the folder you chose for downloaded datawhen the window closes
recentthe project open last, which opens by itself at the next start, and the list behind File > Open Recentas soon as a project is opened or saved
preferenceswhat modules remember, each under keys beginning with its own name, and Fit's own update and notice choices (fit.update-auto, fit.update-feed, fit.acknowledged-notices and the like)as soon as a choice is made
layoutthe size and place of the main window, whether it filled the screen, and how much room each of its parts was given; View > Reset Layout empties itwhen the window closes

A section Fit does not know - written by a newer version, or by a module this build does not contain - is kept as it is whenever the file is written, and so is a key it does not know inside a known section. Each part of Fit writes only its own section, reading the file again first, so two windows open at once do not undo each other's changes.

A project carries its own copy of the fit settings, so opening a project sets them as they were when it was saved. The axes are the project's alone and are not in this file.

Versions before this one kept these choices in three files - config.xml, module-preferences.txt and recent-projects.txt. The first start of a version with settings.json carries what they held into it and removes them - those of an installed copy, and those a copy started by the build script kept in var/profile, which win where both say something; one it cannot read is left where it was. Once settings.json exists, an old file found beside it is left alone, because it was written by an older version run since.

A copy started by the build script of a source tree uses the same settings.json as a copy installed on the same computer. When the window checks itself (the --check-ui option), it reads and writes no settings file at all.

Limitations

See also: Where Fit keeps its files · What a project file holds · Open Recent

Where Fit keeps its files

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

Fit keeps your settings, your own curve types, its logs and the data it downloads in the folders each system names for them, never in your home folder itself.

For the current user, on each system:

WhatWindowsmacOSLinuxCopy built from source
Settings: settings.json%LOCALAPPDATA%\Fit~/Library/Application Support/Fit~/.local/state/fitthe same as an installed copy
Curve types you defined: *.cpr%APPDATA%\Fit~/Library/Application Support/Fit~/.config/fitthe same as an installed copy
Logs%LOCALAPPDATA%\Fit\Logs~/Library/Logs/Fit~/.local/state/fitthe same as an installed copy
Downloaded data%LOCALAPPDATA%\Fit\downloads~/.local/share/fit/downloads~/.local/share/fit/downloadsvar/profile/data/downloads
Python engine, when built from source%LOCALAPPDATA%\Fit\py~/.local/share/fit/py~/.local/share/fit/pythe same as an installed copy

On Linux, $XDG_STATE_HOME, $XDG_CONFIG_HOME and $XDG_DATA_HOME replace ~/.local/state, ~/.config and ~/.local/share when they are set; on macOS $XDG_DATA_HOME replaces ~/.local/share for the downloaded data and the Python engine. The environment variable FIT_PY_HOME names a different folder for the Python engine.

The last column is for a copy started by the build script of a source tree. What its runs produce - logs and downloaded data - is kept inside that tree, so that building and testing leave none of it in your home folder. What you chose and made - the settings and your curve types - is the same for it as for an installed copy: curve types it kept in var/profile before are moved to the one folder when it starts.

The settings are kept apart from the logs on purpose: the build's Clean removes the logs and keeps everything else, and a problem report attaches the logs alone.

Limitations

See also: What Fit remembers on this computer · Log files · Open Recent