Exclude LEM and HAL from automatic prompt-peak t0
Skip musrt0 -g for LEM and HAL/HIFI using both the selected instrument and the MSR's RUN/ADDRUN entries. Preserve manual t0 values entered through the GUI or editor. Update the preference text and documentation, cover portable and legacy filenames plus mixed-instrument MSRs, and register the t0 regression test in the Electron suite.
This commit is contained in:
1 parent
20cd71840a
commit
cf1fcdb184
7 files changed
+77
-32
No files matched your search
+4
-3
@@ -79,10 +79,11 @@ release path documented in [`TODO.md`](TODO.md).
|
||||
thread-count preference in musredit and is useful on shared workstations.
|
||||
|
||||
- The Electron **Preferences** dialog now includes an **Estimate t0 from the
|
||||
prompt peak (non-LEM data)** option (on by default). For local fits of
|
||||
non-LEM instruments, muSRFlow runs `musrt0 --getT0FromPromptPeak` before
|
||||
prompt peak (except LEM/HAL)** option (on by default). For eligible local bulk
|
||||
fits, muSRFlow runs `musrt0 --getT0FromPromptPeak` before
|
||||
`musrfit` to write explicit `t0` lines from the histogram peak into the
|
||||
generated MSR; the step is skipped automatically for LEM data.
|
||||
generated MSR. LEM and HAL/HIFI are always excluded, checking both the GUI
|
||||
selection and actual RUN/ADDRUN entries in the MSR.
|
||||
|
||||
### Bundled ROOT + musrfit runtime
|
||||
- muSRFlow can now run against a relocatable ROOT + musrfit runtime instead of
|
||||
|
||||
@@ -57,12 +57,14 @@ Initial parameters
|
||||
sensible starting values (for example an approximate frequency or
|
||||
asymmetry) instead of generic defaults.
|
||||
|
||||
**Estimate t0 from the prompt peak (non-LEM data)** (on by default): before a
|
||||
**Estimate t0 from the prompt peak (except LEM/HAL)** (on by default): before a
|
||||
local fit, muSRFlow runs ``musrt0 --getT0FromPromptPeak`` to write explicit
|
||||
``t0`` lines into the generated MSR. This forces musrfit to use the
|
||||
histogram peak as the time-zero for instruments whose data-file header t0 is
|
||||
unreliable; the step is skipped automatically for LEM data. Uncheck it to
|
||||
preserve the MSR as generated.
|
||||
unreliable; the step is never applied to LEM or HAL/HIFI data, regardless
|
||||
of this preference. RUN and ADDRUN entries are also checked so an expert
|
||||
MSR cannot bypass the exclusion through a different GUI selection.
|
||||
Uncheck it to preserve the MSR as generated for other instruments too.
|
||||
|
||||
Output file suffixes
|
||||
The suffixes appended to generated artifacts: **Asymmetry** (default
|
||||
|
||||
+2
-2
@@ -779,9 +779,9 @@ pairs of a multi-run (global) fit.">
|
||||
</label>
|
||||
<label class="preferences-check-row" for="estimateT0FromPromptPeak">
|
||||
<input type="checkbox" id="estimateT0FromPromptPeak" checked>
|
||||
<span>Estimate t0 from the prompt peak (non-LEM data)</span>
|
||||
<span>Estimate t0 from the prompt peak (except LEM/HAL)</span>
|
||||
</label>
|
||||
<span class="preferences-hint" id="estimateT0FromPromptPeakHint">Before a local fit, run <code>musrt0 --getT0FromPromptPeak</code> so t0 is written from the histogram peak. Applies to every instrument except LEM, whose data file already carries a reliable t0.</span>
|
||||
<span class="preferences-hint" id="estimateT0FromPromptPeakHint">Before a local fit, run <code>musrt0 --getT0FromPromptPeak</code> so t0 is written from the histogram peak. Never applied to LEM or HAL/HIFI data.</span>
|
||||
<div class="preferences-section-title">Output file suffixes</div>
|
||||
<div class="settings-grid settings-grid-2 preferences-suffix-grid">
|
||||
<label class="settings-field" for="asymmetrySuffix">
|
||||
|
||||
+30
-7
@@ -2129,17 +2129,17 @@ async function runMSRFileLocal(fullPath, options = {}) {
|
||||
// converge. Parameter export and GUI synchronization only apply to a
|
||||
// successful fit, whose MSR contains the fitted values.
|
||||
|
||||
// For instruments whose data-file header t0 is unreliable (everything except
|
||||
// LEM), force t0 to the prompt peak before fitting. musrt0 writes explicit
|
||||
// For eligible bulk instruments, force t0 to the prompt peak before fitting.
|
||||
// LEM and HAL/HIFI must keep their existing t0. musrt0 writes explicit
|
||||
// `t0` lines into the generated MSR, which musrfit then always honors. This is
|
||||
// a best-effort pre-step: if musrt0 fails, musrfit still runs and reports the
|
||||
// real problem.
|
||||
let instrumentNameForT0 = (typeof activeInstrumentName === "function")
|
||||
? activeInstrumentName() : ((typeof All !== "undefined" && All && All.instrName) ? All.instrName : "");
|
||||
if (typeof shouldEstimateT0FromPromptPeak === "function" && shouldEstimateT0FromPromptPeak(instrumentNameForT0)) {
|
||||
if (typeof shouldEstimateT0FromPromptPeak === "function" && shouldEstimateT0FromPromptPeak(instrumentNameForT0, resolvedPath)) {
|
||||
let musrt0 = resolveLocalCommand("musrt0");
|
||||
if (typeof appendJobLog === "function") {
|
||||
appendJobLog("Estimating t0 from the prompt peak for non-LEM data.");
|
||||
appendJobLog("Estimating t0 from the prompt peak for bulk data (excluding LEM and HAL).");
|
||||
}
|
||||
try {
|
||||
let t0Result = await runLocalProcess("musrt0", musrt0, [fitName, "-g"], fitDir, logFile, {
|
||||
@@ -2435,14 +2435,37 @@ function activeInstrumentName() {
|
||||
return "";
|
||||
}
|
||||
|
||||
function shouldEstimateT0FromPromptPeak(instrumentName) {
|
||||
function shouldEstimateT0FromPromptPeak(instrumentName, msrPath) {
|
||||
if (typeof getConfiguredT0FromPromptPeak === "function" && !getConfiguredT0FromPromptPeak()) {
|
||||
return false;
|
||||
}
|
||||
let name = String(instrumentName || "").toUpperCase();
|
||||
if (name === "LEM") {
|
||||
let name = String(instrumentName || "").trim().toUpperCase();
|
||||
if (name === "LEM" || name === "HAL" || name === "HIFI") {
|
||||
return false;
|
||||
}
|
||||
|
||||
// An expert MSR can refer to a different instrument than the GUI selection.
|
||||
// musrt0 changes the entire file, so exclude it if any RUN/ADDRUN is LEM or
|
||||
// HAL, including portable filenames and older HIFI campaign names.
|
||||
if (msrPath) {
|
||||
let content;
|
||||
try {
|
||||
content = nodeFs.readFileSync(msrPath, 'utf8');
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
for (let line of content.split(/\r?\n/)) {
|
||||
let run = /^\s*(?:RUN|ADDRUN)\s+(\S+)\s+(\S+)/i.exec(line);
|
||||
if (!run) continue;
|
||||
let identity = parseMSRRunFileToken(run[1]);
|
||||
if (identity.instrument === 'LEM' || identity.instrument === 'HAL'
|
||||
|| run[2].toUpperCase() === 'MUE4'
|
||||
|| /(?:^|[\\/])(?:lem|hal|hifi)(?:[\\/]|$)/i.test(run[1])
|
||||
|| /(?:^|_)hifi_/i.test(run[1].split(/[\\/]/).pop())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
+3
-3
@@ -28,7 +28,7 @@ var binDirStorageKey = "musrflow.binDir";
|
||||
// so this stays a renderer-only Electron preference.
|
||||
var musrfitThreadsStorageKey = "musrflow.musrfitThreads";
|
||||
// Whether a local fit first forces t0 to the prompt peak for instruments whose
|
||||
// data-file header t0 is unreliable (everything except LEM). Enabled by default;
|
||||
// data-file header t0 needs estimating. Never applies to LEM or HAL/HIFI. Enabled by default;
|
||||
// web runs fit server-side and never apply it.
|
||||
var estimateT0FromPromptPeakStorageKey = "musrflow.estimateT0FromPromptPeak";
|
||||
// The first model follows the first-run field until the user, an imported MSR,
|
||||
@@ -8911,8 +8911,8 @@ function initializeInitialParameterGuessPreference() {
|
||||
setConfiguredInitialParameterGuess(enabled, false);
|
||||
}
|
||||
|
||||
// Prompt-peak t0 preference. Enabled by default so non-LEM data gets t0 from
|
||||
// the histogram peak before a local fit; users can opt out, and LEM data is
|
||||
// Prompt-peak t0 preference. Enabled by default so eligible bulk data gets t0
|
||||
// from the histogram peak before a local fit; users can opt out. LEM and HAL are
|
||||
// never affected (see shouldEstimateT0FromPromptPeak in the Electron adapter).
|
||||
function setConfiguredT0FromPromptPeak(enabled, persist) {
|
||||
let value = Boolean(enabled);
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
"checksums:md5": "sh -c 'd=dist; [ -d \"$d\" ] || exit 0; for f in \"$d\"/*; do [ -f \"$f\" ] || continue; case \"$f\" in *.rpm|*.AppImage) base=$(basename \"$f\"); (cd \"$d\" && md5sum \"$base\" > \"$base.md5\");; esac; done'",
|
||||
"checksums:sha256": "sh -c 'd=dist; [ -d \"$d\" ] || exit 0; for f in \"$d\"/*; do [ -f \"$f\" ] || continue; case \"$f\" in *.rpm|*.AppImage) base=$(basename \"$f\"); (cd \"$d\" && sha256sum \"$base\" > \"$base.sha256\");; esac; done'",
|
||||
"checksums": "npm run checksums:md5 && npm run checksums:sha256",
|
||||
"test:electron": "node tests/log-highlighting.test.js && node tests/action-state.test.js && node tests/electron-missing-data.test.js && node tests/electron-run-data.test.js && node tests/electron-msr-title.test.js && node tests/electron-musrfit-threads.test.js && node tests/window-layering.test.js && node tests/msr-generation.test.js && node tests/root-plot-clean.test.js && node tests/parameter-plot.test.js && node tests/help-window.test.js && node tests/release-packaging.test.js && node tests/addrun.test.js && node tests/fit-statistic.test.js && node tests/series-fit-planner.test.js && node tests/series-fit-result.test.js && node tests/series-fit-inventory.test.js && node tests/series-fit-msr-preparation.test.js && node tests/series-artifact-contract.test.js && node tests/series-global-merge.test.js && node tests/series-fit-staging.test.js && node tests/series-fit-runner.test.js && node tests/series-runner-adapters.test.js && node tests/series-fit-routing.test.js && node tests/series-action-chips.test.js && node tests/singlehist-parity.test.js && node tests/url-parameters.test.js && node tests/run-naming.test.js && node tests/electron-portable-naming.test.js && node tests/shared-configuration.test.js && node tests/session-persistence.test.js && node tests/reference-fixtures.test.js && node tests/electron-bridge.test.js && node tests/electron-bundled-runtime.test.js && node tests/wsl-runtime.test.js"
|
||||
"test:electron": "node tests/log-highlighting.test.js && node tests/action-state.test.js && node tests/electron-missing-data.test.js && node tests/electron-run-data.test.js && node tests/electron-msr-title.test.js && node tests/electron-musrfit-threads.test.js && node tests/electron-t0-prompt-peak.test.js && node tests/window-layering.test.js && node tests/msr-generation.test.js && node tests/root-plot-clean.test.js && node tests/parameter-plot.test.js && node tests/help-window.test.js && node tests/release-packaging.test.js && node tests/addrun.test.js && node tests/fit-statistic.test.js && node tests/series-fit-planner.test.js && node tests/series-fit-result.test.js && node tests/series-fit-inventory.test.js && node tests/series-fit-msr-preparation.test.js && node tests/series-artifact-contract.test.js && node tests/series-global-merge.test.js && node tests/series-fit-staging.test.js && node tests/series-fit-runner.test.js && node tests/series-runner-adapters.test.js && node tests/series-fit-routing.test.js && node tests/series-action-chips.test.js && node tests/singlehist-parity.test.js && node tests/url-parameters.test.js && node tests/run-naming.test.js && node tests/electron-portable-naming.test.js && node tests/shared-configuration.test.js && node tests/session-persistence.test.js && node tests/reference-fixtures.test.js && node tests/electron-bridge.test.js && node tests/electron-bundled-runtime.test.js && node tests/wsl-runtime.test.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// Regression coverage for the prompt-peak t0 preference. When enabled and the
|
||||
// instrument is non-LEM, runMSRFileLocal() runs musrt0 --getT0FromPromptPeak
|
||||
// instrument is eligible bulk data, runMSRFileLocal() runs musrt0 --getT0FromPromptPeak
|
||||
// before musrfit so explicit t0 lines are written into the MSR. When the
|
||||
// instrument is LEM, or the preference is disabled, musrt0 must not run.
|
||||
// instrument is LEM or HAL/HIFI, or the preference is disabled, musrt0 must not run.
|
||||
|
||||
const assert = require("assert");
|
||||
const events = require("events");
|
||||
@@ -115,8 +115,9 @@ function runFit(sandbox, msrPath) {
|
||||
const guiMsr = "# Run Numbers: 514 2453 2454\n# Chisq ...\nFITPARAM ...";
|
||||
|
||||
Promise.resolve().then(function() {
|
||||
// Default preference (on), non-LEM instrument: musrt0 runs before musrfit.
|
||||
let env = buildSandbox(guiMsr, { instrName: { value: "GPS" } });
|
||||
// Default preference (on), eligible bulk data: musrt0 runs before musrfit.
|
||||
let env = buildSandbox(guiMsr + '\nRUN deltatbc_tdc_gps_2026_0514 PIM3 PSI MUSR-ROOT\n',
|
||||
{ instrName: { value: "GPS" } });
|
||||
loadLibraries(env.sandbox);
|
||||
assert.strictEqual(env.sandbox.getConfiguredT0FromPromptPeak(), true);
|
||||
return runFit(env.sandbox, "/tmp/gps-fit.msr").then(function() {
|
||||
@@ -126,18 +127,36 @@ Promise.resolve().then(function() {
|
||||
assert.strictEqual(env.spawnedCommands[1].command, "musrfit");
|
||||
return "default-nonlem-runs-musrt0";
|
||||
});
|
||||
}).then(function() {
|
||||
// LEM instrument: musrt0 must not run even if preference is default on.
|
||||
let env = buildSandbox(guiMsr, { instrName: { value: "LEM" } });
|
||||
loadLibraries(env.sandbox);
|
||||
assert.strictEqual(env.sandbox.getConfiguredT0FromPromptPeak(), true);
|
||||
return runFit(env.sandbox, "/tmp/lem-fit.msr").then(function() {
|
||||
}).then(async function() {
|
||||
// Exclusions must hold for GUI settings, portable and legacy filenames,
|
||||
// and mixed/global documents even when the GUI still selects bulk data.
|
||||
const cases = [
|
||||
{ instrument: 'LEM', text: guiMsr },
|
||||
{ instrument: 'HAL', text: guiMsr },
|
||||
{ instrument: 'HIFI', text: guiMsr },
|
||||
{ instrument: ' hal ', text: guiMsr },
|
||||
{ instrument: ' lEm ', text: guiMsr },
|
||||
{ instrument: 'GPS', text: guiMsr + '\nRUN lem/his/2026/lem26_his_0514 MUE4 PSI MUSR-ROOT' },
|
||||
{ instrument: 'GPS', text: guiMsr + '\nRUN arbitrary_name MUE4 PSI MUSR-ROOT' },
|
||||
{ instrument: 'GPS', text: guiMsr + '\nRUN deltat_tdc_hifi_2026_0514 PIE3 PSI MUSR-ROOT' },
|
||||
{ instrument: 'GPS', text: guiMsr + '\nRUN tdc_hifi_2015_00514 PIE3 PSI PSI-MDU' },
|
||||
{ instrument: 'GPS', text: guiMsr + '\nRUN deltat_hifi_0514.bin PIE3 PSI PSI-MDU' },
|
||||
{ instrument: 'GPS', text: guiMsr + '\nRUN /data/hal/his/2015/custom PIE3 PSI PSI-MDU' },
|
||||
{ instrument: 'GPS', text: guiMsr + '\nRUN deltat_tdc_gps_0514 PIM3 PSI PSI-BIN'
|
||||
+ '\nADDRUN lem26_his_0515 MUE4 PSI MUSR-ROOT' },
|
||||
{ instrument: 'GPS', text: guiMsr + '\nRUN deltat_tdc_gps_0514 PIM3 PSI PSI-BIN'
|
||||
+ '\nRUN deltat_tdc_hifi_2026_0515 PIE3 PSI MUSR-ROOT' }
|
||||
];
|
||||
for (const entry of cases) {
|
||||
const env = buildSandbox(entry.text, { instrName: { value: entry.instrument } });
|
||||
loadLibraries(env.sandbox);
|
||||
env.sandbox.setConfiguredT0FromPromptPeak(true, true);
|
||||
await runFit(env.sandbox, '/tmp/excluded-t0.msr');
|
||||
const musrt0 = env.spawnedCommands.find(function(entry) { return entry.command === "musrt0"; });
|
||||
const musrfit = env.spawnedCommands.find(function(entry) { return entry.command === "musrfit"; });
|
||||
assert.strictEqual(musrt0, undefined, "musrt0 must not run for LEM");
|
||||
assert.strictEqual(musrt0, undefined, 'musrt0 must not run: ' + JSON.stringify(entry));
|
||||
assert.ok(musrfit, "musrfit must still run");
|
||||
return "lem-skips-musrt0";
|
||||
});
|
||||
}
|
||||
}).then(function() {
|
||||
// Preference disabled, non-LEM: musrt0 must not run.
|
||||
let env = buildSandbox(guiMsr, { instrName: { value: "GPS" } });
|
||||
|
||||
Reference in new issue
Block a user