|
From: Dan T. <dan...@gm...> - 2009-02-02 01:07:28
|
Hi,
1:
This bug report describes how gnuplot's (x,y,z)-fit may erroneously
fail on "undefined variable" when fitting it against a certain data
file, and how the problem may go away if changing the name of this
file. (I'm only able to make the problem go away on gnuplot version
4.2.2; conversely, on 4.2.4 the problem persists.)
As data file names are involved, I'm afraid you'd be unable to
reproduce the above if I not supply data files. I'm therefore
attaching a gzipped tar containing what's required. The tar contains
two identical data files with different names (carefully chosen
through experimentation), and two gnuplot scripts (inlined below) that
respectively use them, such that one triggers the problem and the
other works-around it:
- identical data file (containing x y z triplets):
123456789012345.dat
1234567890123456.dat
- associated gnuplot scripts (differ on only one character):
fit-bug.gp
fit-bug-goes-away-on-4.2.2.gp
2:
The following is the content of fit-bug.gp (the seemingly unnecessary
lines like defining unused variables will be shortly addressed; the
script is in fact "minimal", despite appearances):
set terminal postscript eps
set output '1.eps'
xsiz=0;ysiz=0;xoff=0;yoff=0;xnum=0;ynum=0;xall=0;yall=0
set size 2,1
set multiplot
set size 1,1
kb(n) = (n/1024.0)
w=4; i=1; j=0;
set style line 1 lt 1
set style line 2 lt 2
set style line 3 lt 3
set origin 0,0
splot '1234567890123456.dat' u 1:2:(kb($3)) t 'r', \
'123456789012345.dat' u 1:2:(kb($3)) t 'o'
set origin 1,0
g(x,y) = d*x*y
fit g(x,y) '123456789012345.dat' using 1:2:3:(1) via d
splot '123456789012345.dat' u 1:2:(kb($3)) t 'o', \
kb(g(x,y)) t 'm'
Running this generates the error "line 17: undefined variable: d".
But if instead of using '1234567890123456.dat' (ends with a "6") we
use '123456789012345.dat' (ends with "5"), then the problem goes away
and a reasonable fit is generated. As noted, this trick only works on
gnuplot 4.2.2, not on 4.2.4.
3:
The suggested fix stops working if you introduce even negligible
changes to the above script. This includes: (a) deleting the unneeded
definitions of any of the unused variables or styles; (b) changing the
order of the lines (e.g., trying to put the line that starts with
"w=4" right below the line that starts with "xsiz=0"); (c) removing
any of the 'o' / 'r' / 'm' curve titles; (d) not using the kb()
functions; etc.
4:
"Show version long" on the (Debian) machine where the workaround
works:
G N U P L O T
Version 4.2 patchlevel 2
last modified 31 Aug 2007
System: Linux 2.6.20-1-686-bigmem
Copyright (C) 1986 - 1993, 1998, 2004, 2007
Thomas Williams, Colin Kelley and many others
Compile options:
+READLINE -LIBREADLINE +HISTORY +BACKWARDS_COMPATIBILITY
+BINARY_DATA +GD_PNG +GD_JPEG +GD_TTF +GD_GIF +ANIMATION
+NOCWDRC +X11 +X11_POLYGON +MULTIBYTE +USE_MOUSE
+HIDDEN3D_QUADTREE +DATASTRINGS +HISTOGRAMS +OBJECTS
+STRINGVARS +MACROS +IMAGE
DRIVER_DIR = "/usr/lib/gnuplot"
GNUPLOT_PS_DIR = "/usr/share/gnuplot/gnuplot/4.2/PostScript"
HELPFILE = "/usr/share/gnuplot/gnuplot.gih"
gnuplot's show version long where the fix works:
5:
The workaround doesn't work on an identical machine on which Debian's
latest gnuplot package was installed:
G N U P L O T
Version 4.2 patchlevel 4
last modified Sep 2008
System: Linux 2.6.20-1-686-bigmem
Copyright (C) 1986 - 1993, 1998, 2004, 2007, 2008
Thomas Williams, Colin Kelley and many others
Compile options:
-READLINE +LIBREADLINE +HISTORY +BACKWARDS_COMPATIBILITY
+BINARY_DATA +GD_PNG +GD_JPEG +GD_TTF +GD_GIF +ANIMATION
+NOCWDRC +X11 +X11_POLYGON +MULTIBYTE +USE_MOUSE
+HIDDEN3D_QUADTREE +DATASTRINGS +HISTOGRAMS +OBJECTS
+STRINGVARS +MACROS +IMAGE
DRIVER_DIR = "/usr/lib/gnuplot"
GNUPLOT_PS_DIR = "/usr/share/gnuplot/gnuplot/4.2/PostScript"
HELPFILE = "/usr/share/gnuplot/gnuplot.gih"
A fix would be appreciated.
Thanks,
--Dan
|