If a fit goes wrong, a running user script just stops and falls back to the console.
It´d be great if "fit" could be instructed to not raise an exception, e.g.
"set fit [no]stoponerror"
That´d make it possible to let the script evaluate GPVAL_ERRNO and GPVAL_ERRMSG to e.g. repeat the fit with less variables or newly determined starting values or just skip that one and do the next dataset, without user interaction.
Just noticed this request from last year...
As it happens, I've been working with a fitting script that does exactly what you want. No changes required from the current cvs version. My script has:
Does this not work for you?
Seems not. Could this depend on the kind of error? With an
"Undefined value during function evaluation", the script always falls back to the console immediately, for me. Attached is a (stupid) test problem, can you try if you reach the part after the "fit" command, evaluating GPVAL_ERRNO?
Last edit: Karl Ratzsch 2015-05-27
Your test script did not upload correctly (0 bytes).
Maybe a key difference is that I am driving gnuplot via a pipe from a perl script. Can you try
(I replaced the test script above, it now downloads correctly.)
You were right, it only works when piping the script in. Unfortunately that is not an option for me, because it breaks if the offending "fit" command is inside a command block {fit ...}, see attachment.
That is because the entire content of a bracketed clause is treated as one long input line. But you can isolate the contents by placing them in a loaded file.
wrap.gp:
fit.gp:
cat wrap.gp | gnuplot
Update: Hmmm. That doesn't seem to work as I remembered. There must have been something else involved when I used this trick before.
Last edit: Ethan Merritt 2015-05-28
Solution would of course be to not implement critical programming structures in gnuplot but in an overlying perl/python/etc. script. Gnuplot is no general purpose data evaluation language, something i keep forgetting. ;-)
Still, the GPVAL_ error variables don't make a lot of sense if i cannot evaluate them in a given script. Not only for fitting. A general "un/set haltonerror" would be useful in many ways.
Version 5.5 now traps and returns from fit errors.
From the documentation: