Indice
1. In parole semplici
Questa è l'API pubblica del backend del viewer Dataset Curve Fit. Coordina Dataset canonicali, filtri, Native 2D point selection e NUMERIC_API. Non è un nuovo solver: il calcolo numerico viene delegato al servizio condiviso.
2. Provider
| Modulo | viewer.dataset_curve_fit 0.1.0 |
|---|---|
| Capability | viewer_backend; dataset_filters; native2d; numeric_models; csv_export |
3. Operazioni pubbliche principali
datasets, variables, filterMatch, new, close, loadSource, selectPoint, clearSelection, selectedIndices, sourcePoints, preview, accept, setFitVisible, deleteFit, exportCsv, formula, parameterReport, redraw, open, viewerDispatch
4. Workflow
datasets/variablesscoprono sorgenti compatibili.newcrea un workspace.loadSourcecarica X/Y e filtri.- selection operations scelgono i punti.
previewinvoca il fitting numerico.acceptconserva il fit separato dalla sorgente.exportCsvesporta un accepted fit.
5. Modelli
linear, polynomial degree 1–12, exponential, power law e Gaussian. I nonlinear models richiedono initial parameter guesses.
6. Script Bridge
Questa API è una API di viewer/host e non compare nella coverage Script Bridge dev-031. Gli script devono usare le API scientifiche sottostanti, soprattutto NUMERIC_API_v1, Dataset APIs e publication/plot APIs.
Riferimento tecnico completo
Dataset Curve Fit — manuale completo
Dataset Curve Fit
Open Dataset Curve Fit from the Viewer menu in a GX-TXT Session. If you open it from a Dataset context, that Dataset is offered first. Choose a Dataset and numeric X and Y variables, then select Load Dataset curve. The variable labels include units when the Dataset supplies them.
Filter the Dataset
Add any number of conditions on any Dataset variable. Conditions are
combined with AND. Numeric variables support =,
!=, <, <=,
>, >=, and inclusive
between (enter lower,upper). Text variables
support =, !=, case-sensitive
contains, and SQL-style LIKE (%
matches any span; _ matches one character). No variable has
a special family role.
Changing the Dataset, X, Y, or applied filters makes the loaded curve stale. Load the Dataset curve again before previewing, accepting, or exporting. The viewer also checks whether the underlying Dataset or Session changed after loading. Reloading the source starts a new fit workspace and clears accepted fits from the previous source configuration.
Select fit points and navigate
The blue curve is the immutable Native 2D CORE source. Red markers show selected data points. Click a point to select it. Shift or Control toggles a clicked point within the selection. Drag a rectangle to select points; the orange outline shows its extent while dragging. The Rectangle control chooses Replace, Add, or Subtract. Shift or Control while dragging adds, and Alt subtracts. Remove last rectangle reverses the newest rectangular selection block; Clear selection removes all selected points and blocks.
Rectangle selection operates on a separate CORE point set with the same data coordinates as the source curve. This keeps fit-point selection restricted to points inside the rectangle even when a connecting source segment crosses it. The canvas uses CORE nearest-object and hit-test results for clicks, CORE selection blocks for rectangles, and CORE selected-point export for the fit input.
The canvas has numeric X/Y ticks and Dataset variable labels with units. Use the mouse wheel to zoom around the pointer, drag with the middle mouse button to pan, or choose Reset view. These controls change only the view, not data or selection.
Preview and accept a fit
Choose all or selected fit points. Choose an output domain independently: source uses the sorted, distinct source X values; range uses minimum X, maximum X, and sample count. The original source order and repeated observations remain intact for fitting and residuals. Changing the output domain does not change fit points.
Models are linear, polynomial (degree 1–12), exponential
a exp(b x)+c, power law a x^b, and Gaussian
a exp(-0.5 ((x-mu)/sigma)^2)+c. Polynomial degree is active
only for that model. Nonlinear models expose initial parameter guesses
in the displayed order; power law requires positive X and Gaussian width
must be nonzero. Range fields are active only for a range output domain.
Custom expressions are not offered because the current data-only
Numerical worker cannot bind arbitrary callbacks. For Gaussian data, set
the initial center near the observed peak and the initial width near its
visible spread. A solver can report convergence at a poor local solution
when the generic initial guess is far from the data; inspect RMSE and R²
before accepting.
Preview fit uses the public Numerical API for fitting, evaluation, residuals, and fit statistics. The report shows a formatted formula, named fitted coefficients, training-point and full-source RMSE/R², and solver status. The table shows each source X, observed Y, fitted Y, and residual. A dashed preview curve appears on the canvas.
Accept creates a separate CORE curve and leaves the source unchanged. Accepted fits appear in the list with model, scope, fit size, statistics, and a distinct color. Select a fit to show, hide, delete, or export it. Several accepted fits can coexist.
Export and resume
Export accepted fit CSV writes the selected accepted
CORE curve with x_<X> and
fitted_<Y> columns, plus Dataset ID, model, fit
scope, and CORE object ID as provenance. The export uses the accepted
result, not a newer preview.
The viewer saves the chosen Dataset, variables, filters, view, selected points, and accepted fits in the Session Interactive Document. Reopen the Session and viewer to resume them. If the Dataset content changed, reload the source before fitting again.
The Tcl viewer streams canonical Dataset rows for filters because the
public Graph Series filter does not provide the required text
contains or LIKE predicates. Numerical
calculations use the GX-TXT Numerical API, and geometry and selection
use Native 2D CORE. The native C/Tcl adapter is installed with the
viewer on supported builds; GX2D_TCL_LIBRARY can point to a
development build. A compiler is needed only to build the adapter, not
to use an installed viewer. GNU Octave is required by the Numerical API
worker.
From the dev-031 framework root, run the API and Tk check with a fresh output directory:
xvfb-run -a tclsh plugins/modules/viewer.dataset_curve_fit/tests/test_dataset_curve_fit.tcl "$PWD" /tmp/gxtxt-dataset-curve-fit-check