|
From: Scott L. <sl...@sl...> - 2005-11-05 17:30:03
|
I'm using the latest gnuplot CVS. I'd like to plot time data with
subsecond precision from a binary file. Is this possible?
I've been able to pass in a text file with subsecond time since the
epoch in this kludgey way:
My Python generator uses something like this to make the datafile:
now = time.time() # seconds since epoch
subsec, sec = math.modf(now) # split fractional and whole parts
datafile.write("%d %g %g\n" % (sec, subsec, data))
and feeds something like this to gnuplot's stdin:
set xdata time
set timefmt "%s"
plot "datafile" using (timecolumn(1)+$2):3
since apparently there are no subsecond formats available, and I can't
see a way to directly feed gnuplot its internal format in column 1. It
seems to expect a timefmt-formatted value there once I set "xdata time".
Strangely, I couldn't get the same commands to work with datafiles like
this:
datafile.write("0 %g %g\n" % (now, data))
...which I'd think would be equivalent. The output is all...weird. Data
points only come in bursts every couple hours or so.
In any case, what I'd really like to do is to just go to a binary format
to save a few CPU cycles. Something like this would be ideal:
datafile.write(struct.struct('d d', now, data))
I.e., simply a double with the entire time followed by a double with my
y axis data.
but I could do the second/subsecond thing if necessary, maybe:
datafile.write(struct.struct('I d d', sec, subsec, data))
(unsigned int of whole seconds, double of fractional seconds, double data)
How would I parse this in gnuplot? I've tried things various commands:
plot "datafile" binary format="%float%float" using 1:2
plot "datafile" binary format="%float%float" using (timecolumn(1)):2
plot "datafile" binary format="%int%float%float" using
(timecolumn(1)+$2):2
but always get this:
warning: Skipping data file with no valid points
x range is invalid
In fact, I can't get time data to plot from a binary even without the
subsecond precision. Is it even possible?
--
Scott Lamb <http://www.slamb.org/>
|