Data Model
Frida is a collection of methods that operate on data files and curve files held in memory.
Data files
A data file is an ordered array of spectra. Each spectrum contains x, y data pairs, or x, y, dy triples when measurement errors are provided.
The physical meaning of x and y is stored as coordinate
metadata: a name and a unit, e.g. energy (meV) or counts (Hz).
Z coordinates
If a data file contains more than one spectrum, each spectrum must have one or more z coordinates (denoted z0, z1, …). These carry per-spectrum scalar metadata such as scattering angle or temperature. Each z coordinate also has a name and a unit.
File-level metadata
Each data file also carries:
- File name — a short identifier
- Documentation (doc) — a cumulative log of operations applied to the data
- File constants (r0, r1, …) — named scalar parameters, each a
coordinate-value pair, e.g. r0 =
T (K)= 320
Example
A neutron scattering experiment might produce a file where:
- x is energy transfer E (μeV)
- y is the scattering law S(E, q)
- z0 is the momentum transfer q (Å⁻¹)
- one spectrum per q value
Curve files
A curve file stores a fit model together with its fitted results. It contains:
- A curve definition — an expression,
e.g.
p0 * gnn(t-p1, p2). - A set of curves, one per spectrum in the associated data file. Each curve carries parameters, parameter flags, and quality metrics.
The running variable t
In a curve expression, t is the independent variable — the equivalent
of x in data. When Frida evaluates the curve for plotting, t runs
over an equidistant grid. When Frida fits the curve to data, t is
equated with the x values of the data points.
All other expression syntax (file constants, z coordinates, parameters) works exactly as in data expressions.
Parameter flags
Each parameter p0, p1, … carries a flag that controls its role during fitting:
- Free — the parameter is adjusted by the least-squares solver to minimise the residuals. This is the default.
- Fixed — the parameter is held at its current value and not
changed by the solver. Use
cx <n>to fix parameter n;cu <n>to release it.
Fixing a parameter is useful when its value is known from physics or when a preliminary fit has converged and you want to refine only the remaining parameters.
Quality metrics
After a fit, three quality metrics are stored:
-
cq0 — the weighted sum of squared residuals (χ² = Σ ((y_data − y_curve) / dy)²). A smaller value means a better fit to the data.
-
cq1 — the number of data points included in the fit (after any range restriction set by
cr). -
cq2 — the number of free parameters (those not fixed).
The reduced chi-squared χ²_red = cq0 / (cq1 − cq2) should be close to 1 for a statistically good fit. A value much larger than 1 indicates the model does not describe the data well (or the error bars are underestimated); a value much smaller than 1 suggests the error bars are overestimated.
Use ci * to extract the quality metrics into a new workspace for
further analysis.
History
The data model has been stable for decades. Major changes were:
- 1996 — Added multi-z coordinates
- 2006 — Inserted abstraction layer for x-y-dy
- 2010 — Full support for file constants (r parameters)
Backward compatibility is always maintained by providing import methods for older file formats.