Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Catalog · How the catalog works
Anything · Lazarus or Delphi
Random projectRandom project

fit

Interactive multi-peak curve fitting for spectroscopy, diffraction and other 1-D data. Place peaks, fit them, compare models by a number. Desktop client plus compute server; 13 built-in lineshapes, user-defined formulas, and new models added by registration.

View on GitHub

Member rating

No ratings yet.

Sign in to rate this project.

README

Fit

An interactive curve-fitting application. Load a data set, place curves on it, and fit them — one peak or a hundred, by hand or automatically. Save the whole session as a project and reopen it later to carry on from where you stopped.

Automatic decomposition (Fit → Automatically) needs no curve count from you. It seeds a curve on every point of every peak, then removes curves for as long as the fit stays within the accuracy you set, so what remains is the fewest curves that accuracy allows. See the Fitting chapter of the user guide and how it decides.

Data from where it is published (File → New Project from Data Source) finds a data set in a public repository, downloads it, previews it and starts a project from it. Published data (DOI) takes a DOI (10.5281/zenodo.4892237 opens that record's files) or words (calcite XRD searches Zenodo and figshare for datasets); Data catalog browses the same repositories by the kind of file Fit reads. Only datasets and files Fit can read are listed, archives open like folders, and a table's value column can be chosen in the preview. It searches those two repositories only, a page at a time, and a dataset is listed for the names of its files - the preview is where its contents are seen. A web address and the installed samples are sources too, and Modules/open-data-spectra/ adds the NIST Chemistry WebBook as its own build variant. A project embeds its data, so fitting and reopening never need the network.

Free Pascal / Lazarus. Runs on Linux, Windows and macOS: installers for Linux and Windows, one script for macOS.

dvmorozov.github.io/fit — downloads, the user guide, and the developers' pages for anyone extending it.

Two programs

Fit is a client and a compute server. The desktop client has no fitting engine of its own; it talks to fit_server over HTTP+JSON — an API the server documents itself, at /docs, which ./scripts/build-app.ps1 -Task api-docs opens for you. The installers hide all of it: what they put in the menu is a launcher, which starts the server when nothing is answering and reuses one that is. Started by hand, the server goes first. The two can run on the same machine or on different ones.

An optional Python sidecar adds the lmfit engine beside the native ones. Without it, a fit that chose lmfit runs on the native Downhill Simplex engine and says so; with it set up but failing to start, such a fit is refused with the reason rather than quietly run on another engine.

Get it

Prebuilt downloads for Linux (a portable archive, a .deb and an .rpm) and Windows (an installer) are on the Releases page. The packages install the client, the compute server and a launcher that starts both. macOS is built from source with one script.

To build it yourself:

pascal
./scripts/build-app.ps1

That checks the toolchain, builds both programs, runs the tests and writes an archive into dist/. It needs Lazarus 3.0+, PowerShell 7 and the two sibling repositories — see building from source, which also covers the Lazarus IDE route.

Documentation

Using it — the user guide is inside the application, under Help → Explain Everything, and the same text is published as the user guide: every menu command, pane, file and curve type. Its source is the explanation registry (Desktop/guide_*.pas), so the program and the site cannot disagree. Setting up the optional Python engine: Setting up the Python engine · building from source

Extending it — architecture · module architecture · writing a module · adding a curve model · adding an axis mode · client and server · loss functions · findings

Fit is becoming a framework for fitting any data to any class of models, for research and for teaching: each field is a module that owns its interface, its models, its rules and its computations, and everything it adds explains itself - select a curve type or a row of the Model panel and the Explain pane says what it is, what it rests on and what it does not cover.

A new curve type, data loader, optimiser, objective or whole analysis vertical is added by registration: a directory plus one entry on a project's unit search path. No framework file changes. Modules/example-linear/ is a complete working example: one curve type, one rule, one menu entry and their tests.

What is registered, and every extension seam, is on the project site — generated from the code on each publication, so it is never a description of an older version. Nothing here restates it.

AGENTS.md states the invariants and the traps, for AI agents working on this code.

Contributing

This repository is published as a snapshot, so a pull request cannot be merged directly. See CONTRIBUTING.md for what works instead.

Built on the sibling packages fitgrids and fitminimizers.

GPLv3-or-later; see LICENSE and THIRD-PARTY.md. Documentation is CC BY 4.0.