Add fitted SingleHist reference fixture for beta.3 baseline

Capture the real production SingleHist fit result (fittype 0, GaussianCos
model, 16 fitted parameters, converged maxLH/NDF 1.04011, NDF 3644) as
singlehist.fitted.msr. Unlike the generated goldens it is not re-produced by
buildMSR(); it anchors the reverse-parsing path in the reference test:
parseMSRFitStatistic, parseMSRParameters, parseMSRTheoryModel and
parseMSRGUISettings must all read it back into GUI state.
This commit is contained in:
salman committed 2026-08-31 17:20:40 +02:00
1 parent ff0a856d72
commit ca0936e94b
3 files changed
+144

No files matched your search

+6
View File
@@ -13,6 +13,12 @@ The naming records the workflow:
block disabled.
- `t0background.generated.msr` — Asymmetry fit with fixed forward/backward t0
and fixed background values.
- `singlehist.fitted.msr` — a real SingleHist **fit result** (fittype 0,
`GaussianCos` model, 16 fitted parameters, converged `STATISTIC` block with
`maxLH/NDF 1.04011`, NDF 3644) captured from production. It is the anchor for
the reverse-parsing path: `tests/reference-fixtures.test.js` verifies that
muSRFlow reads it back into GUI state (`parseMSRFitStatistic`,
`parseMSRParameters`, `parseMSRTheoryModel`, `parseMSRGUISettings`).
- *Pending:* `singlehist.generated.msr` (needs a detector-normalization model
to avoid `norm undefined`), `global.generated.msr`, `functions.generated.msr`,
`missingdata.generated.msr`.
+91
View File
@@ -0,0 +1,91 @@
100nm Li/Li6PS5Cl - 15 months aged, T=290.02 K, E=2.02 keV, B=~100(G)/17.30(A), Tr/Sa=15.00/12.29 kV, SR=-20.00
# Run Numbers: 2452
###############################################################
FITPARAMETER
###############################################################
# No Name Value Step PosErr Min Max
1 Asy_2452 0.09040 0.00079 none
2 Sgm_2452 0.1441 0.0063 none
3 NBg1_2452 1.464 0.046 none
4 No1_2452 338.34 0.34 none
5 NBg2_2452 1.406 0.042 none
6 No2_2452 276.58 0.31 none
7 NBg3_2452 2.146 0.045 none
8 NBg4_2452 1.686 0.045 none
9 Ph_2452 -59.2 5.8 none
10 Field_2452 100.859 0.057 none
11 RelPh_L_2452 74.1 5.9 none
12 RelPh_T_2452 -10.4 5.9 none
13 RelPh_R_2452 -103.2 5.9 none
14 alpha_LR_2452 0.9001 0.0013 none
15 RelPh_B_2452 -193.8 5.9 none
16 alpha_TB_2452 1.1391 0.0018 none
###############################################################
THEORY
asymmetry 1
simpleGss 2 (rate)
TFieldCos fun1 fun2 (phase frequency)
###############################################################
FUNCTIONS
fun1 = par9 + map1
fun2 = par10 * gamma_mu
fun3 = par14 * par4
fun4 = par16 * par6
###############################################################
GLOBAL
fittype 0 (single histogram fit)
fit 0.07 9
packing 50
###############################################################
RUN /mnt/fake/lem/his/2026/lem26_his_2452 MUE4 PSI MUSR-ROOT (name beamline institute data-file-format)
norm 4
forward 21 25
map 11 0 0 0 0 0 0 0 0 0
backgr.fit 3
RUN /mnt/fake/lem/his/2026/lem26_his_2452 MUE4 PSI MUSR-ROOT (name beamline institute data-file-format)
norm 6
forward 22 26
map 12 0 0 0 0 0 0 0 0 0
backgr.fit 5
RUN /mnt/fake/lem/his/2026/lem26_his_2452 MUE4 PSI MUSR-ROOT (name beamline institute data-file-format)
norm fun3
forward 23 27
map 13 0 0 0 0 0 0 0 0 0
backgr.fit 7
RUN /mnt/fake/lem/his/2026/lem26_his_2452 MUE4 PSI MUSR-ROOT (name beamline institute data-file-format)
norm fun4
forward 24 28
map 15 0 0 0 0 0 0 0 0 0
backgr.fit 8
###############################################################
COMMANDS
MAX_LIKELIHOOD
MINIMIZE
HESSE
SAVE
###############################################################
PLOT 0 (single histo plot)
lifetimecorrection
runs 1 2 3 4
range 0 11 -0.3 0.3
view_packing 500
###############################################################
FOURIER
units Gauss # units either 'Gauss', 'Tesla', 'MHz', or 'Mc/s'
fourier_power 12
dc-corrected false
apodization STRONG # NONE, WEAK, MEDIUM, STRONG
plot POWER # REAL, IMAG, REAL_AND_IMAG, POWER, PHASE, PHASE_OPT_REAL
range 0 11
###############################################################
# Created by muSRFlow (ZS https://bitbucket.org/zaher-salman/musrfit-gui)
###############################################################
STATISTIC --- 2026-08-31 17:06:34
maxLH = 3790.2, NDF = 3644, maxLH/NDF = 1.040110
+47
View File
@@ -120,4 +120,51 @@ for (const name of Object.keys(fixtures)) {
"buildMSR() must reproduce the captured " + name + " reference fixture exactly. "
+ "If the generator intentionally changed, regenerate the fixture and re-run.");
}
// ----- Fitted reference fixtures -----
//
// A `.fitted.msr` is a real musrfit result captured as a reference. Unlike the
// generated goldens it is not regenerated by buildMSR(); instead it anchors the
// reverse-parsing path: muSRFlow must be able to read the fitted MSR back into
// the GUI state (fit statistic, parameters, theory, single-histogram settings).
function testFittedSingleHist(lib) {
const msr = fs.readFileSync(referenceFixturePath("singlehist.fitted.msr"), "utf8");
// The fit converged and the STATISTIC block parsed to a maxLH result.
const stat = lib.parseMSRFitStatistic(msr);
assert.strictEqual(stat.found, true);
assert.strictEqual(stat.converged, true);
assert.strictEqual(stat.kind, "maxLH");
assert.strictEqual(stat.ndf, "3644");
assert.strictEqual(stat.value, "1.040110");
// All 16 fitted parameters round-trip with run-suffixed names.
const params = lib.parseMSRParameters(msr);
assert.strictEqual(params.length, 16);
const names = params.map(function(p) { return p.name; });
for (const expected of ["Asy_2452", "Sgm_2452", "NBg1_2452", "No1_2452", "Ph_2452",
"alpha_LR_2452", "Field_2452"]) {
assert.ok(names.includes(expected), "expected fitted parameter " + expected);
}
// The model reconstructs to the GUI GaussianCos catalogue with its four
// single-histogram constraints (phase, frequency, and two normalizations).
const theory = lib.parseMSRTheoryModel(msr);
assert.strictEqual(theory.ok, true);
assert.strictEqual(theory.components.join(","), "GaussianCos");
const constraintTargets = theory.constraints.map(function(c) { return c.target; });
assert.strictEqual(constraintTargets.join(","), "Phi,Frq,No3,No4");
// The GUI settings recover a SingleHist, maximum-likelihood fit.
const gui = lib.parseMSRGUISettings(msr);
assert.strictEqual(gui.values.fitAsyType, "SingleHist");
assert.strictEqual(gui.values.fitObjective, "MAX_LIKELIHOOD");
assert.strictEqual(gui.values.runNumbers, "2452");
assert.strictEqual(gui.values.selYear, "2026");
assert.strictEqual(gui.values.instrName, "LEM");
assert.strictEqual(gui.values.fftUnits, "Gauss");
}
testFittedSingleHist(lib);
console.log("reference fixture tests passed");