|
|
clamping the index argument in multi-data-set file
i deal with multi-data-set files and use index to plot the different
data sets one at a time ... the number of data sets is however *not*
known in advance ...
a generic plot command that i use is as follows
plot "datafile" index ind u 1:2 w p
before issuing the above command i set ind to 0
i bind the `home' key as follows
bind home "ind=ind+1 ; set title sprintf(\"ind = %d\", ind) ; replot "
and the `end' key as follows
bind end "ind=ind<=0?0:ind-1 ; set title sprintf(\"ind = %d\", ind) ;
replot "
then i simply hit `home` and `end' to cycle between the data sets in a
serial fashion.
notice that the binding for `end' has a mechanism to clamp the value
of ind to 0 if i happen to hit `end' too often
however i was unable to clamp ind to its upper limit as i do not know
in advance how many data sets will be in the datafile.
i do notice that gnuplot warns me with
warning: Skipping data file with no valid points
when i hit `home' more than necessary ... i was hoping to be able to
catch some error flag set by gnuplot when this happened and then to
clamp the value of ind at its maximum for the datafile in question.
is it possible ?
r there other ways of achieving the same effect ?
thanks in advance
|
|
0
|
|
|
|
Reply
|
awimagic (10)
|
3/15/2010 3:21:05 AM |
|
Awhan Patnaik wrote:
> i deal with multi-data-set files and use index to plot the different
> data sets one at a time ... the number of data sets is however *not*
> known in advance ...
>
> a generic plot command that i use is as follows
>
> plot "datafile" index ind u 1:2 w p
>
> before issuing the above command i set ind to 0
> i bind the `home' key as follows
>
> bind home "ind=ind+1 ; set title sprintf(\"ind = %d\", ind) ; replot "
>
> and the `end' key as follows
>
> bind end "ind=ind<=0?0:ind-1 ; set title sprintf(\"ind = %d\", ind) ;
> replot "
>
> then i simply hit `home` and `end' to cycle between the data sets in a
> serial fashion.
>
> notice that the binding for `end' has a mechanism to clamp the value
> of ind to 0 if i happen to hit `end' too often
> however i was unable to clamp ind to its upper limit as i do not know
> in advance how many data sets will be in the datafile.
>
> i do notice that gnuplot warns me with
>
> warning: Skipping data file with no valid points
>
> when i hit `home' more than necessary ... i was hoping to be able to
> catch some error flag set by gnuplot when this happened and then to
> clamp the value of ind at its maximum for the datafile in question.
>
> is it possible ?
The most recent error message is stored in GPVAL_ERRMSG.
But your empty file message is only a warning, not an error, so that
doesn't help in your case.
> r there other ways of achieving the same effect ?
Maybe.
First idea
----------
In the case that the plot is autoscaled and this is the only data
being plotted, an empty data set will also trigger a true error
message:
gnuplot> reset error
gnuplot> plot 'silver.dat' index 1
warning: Skipping data file with no valid points
x range is invalid
gnuplot> print GPVAL_ERRMSG
x range is invalid
Second idea
-----------
If you can autoscale this data set even though there are other things
on the same plot, it might still work. Plot everything else using the
y1 axis. Plot your indexed data set using the y2 axis. If the data set
is empty, it should trigger an error like "invalid y2range".
Third idea
----------
[\me hunts around a bit]
I thought I recalled a contributed patch that allowed you to somehow
request specifically the last dataset in a file. But now I can't find
that patch to see if the mechanism also reported back what was the index
of that last data set. Maybe I'm not looking for it under the right name.
Final thought
-------------
It might be possible to tweak the existing code that lets you
use a name rather than a number for the index of the data set you want.
Currently it only looks for the name if you request it by name.
But I imagine it would be possible to look for and store the name
of the data set even if it was requested by number rather than by name.
For example, if your data file looked like this
# == first ==
1 1 1
# == second ==
2 2 2
# == last ==
999 999 999
We could arrange things so that after a plotting a data set that
had a name, you could retrieve that name from a variable:
plot 'foo' index 2
if (GPVAL_DATASETNAME eq "== last ==") <do whatever>
I'm think thinking as I type here. No such code currently exists.
But if you think this would be useful, perhaps you can develop the
idea a bit further and file a "Feature Request" describing it.
Better yet you could file a patch implementing it :-)
Anyhow a well thought-out request would be sufficient to put it on
a TODO list for development even in the absence of a preliminary patch.
>
> thanks in advance
|
|
0
|
|
|
|
Reply
|
sfeam
|
3/15/2010 6:52:36 AM
|
|
On Mar 15, 4:21=A0am, Awhan Patnaik <awima...@gmail.com> wrote:
> i deal with multi-data-set files and use index to plot the different
> data sets one at a time ... the number of data sets is however *not*
> known in advance ...
>
> r there other ways of achieving the same effect ?
>
> thanks in advance
You could use an external program (like perl or awk) to count the
number of contiguous blocks in the data file, for example
filename =3D "datafile"
perlcommand =3D"perl -ne'if(/^\\s+$/){$f++}else{$i++if$f>1;$f=3D0}}{print$i
+1' ".filename
maxindex =3D system(perlcommand)
Then you can use the value of maxindex to test whether you've reached
the end of the file.
Caveat: obviously the above works only if you have perl. On windows
you may have to modify the command a bit because of the retarded quote-
related behavior of cmd.exe.
P=E9ter Juh=E1sz
|
|
0
|
|
|
|
Reply
|
ISO
|
3/15/2010 9:19:24 PM
|
|
|
2 Replies
180 Views
(page loaded in 0.08 seconds)
Similiar Articles: how to access multi-dimensional array input in C mex file - comp ...Hi, I am using a C mex file to operate on a multi ... the fact that MATLAB stores data by ... and I ... modified the input argument and returned from the mex file ... what is native texture image format on graphics card? - comp ...... mean one of GL_RGB, GL_RGBA, GL_COLOR_INDEX, etc.) ... and like methods with the internalformat argument set ... Wikipedia, the free encyclopedia An image file format may store data ... Finding ERRORs in SASLOG - comp.soft-sys.sas... must precede" "no body file" "no body" "no by" "no cards" "no data set" "no data ... text" > > "are not allowed" > > "argument ... Proc GPLOT - Centering multi-line y-axis ... Could anyone give me the spice-mode.el - comp.emacsFrom the website, I found a package called spice-mode.el. But I could not access to it. Could anyone kindly help me send that file to me? Regards Roger FAQ -- assembly-language/x86/general/part1 - comp.lang.asm.x86 ...Command Line Arguments 34. Free 32 ... areas: string/integer data manipulation screen mode subroutines text-mode multi-window subroutines disk & file ... New features added to development gawk - comp.lang.awkThe gawk.texi file documents a possible use of FPAT - in ... r{roll}d f 2/m{moveto}d -1 r 230 350 m 0 1 179{ 1 index ... in C, they seem to be the common subset of both sets of ... Sockets in gfortran? - comp.lang.fortran... and servers * and are in a separate file ... Solaris 9 */ #define CMSG_LEN(x) _CMSG_DATA ... for (result = 0; result < sockets_index; result++) FD_SET ... input & output in assembly - comp.lang.asm.x86... pointing to the right place in a ...COM file, so it doesn't need to be set ... You push your arguments, make the call, and pop ... Shaving ten percent off a multi-Meb ... top 10 uses for random data compression?? anyone? - comp ...IF compression of random data by 90% were indeed ... THe counting argument is valid, trying to get around it is ... Demaris writes that he was in the midst of a multi-city ... Neatest way to get the end pointer? - comp.lang.c... have to worry about including the necessary header file ... use i and N as your variable names, even if you set ... Macros like clamp(), lerp(), uniform(), and so on are ... Working with Spry XML Data Sets - Adobe Labs | Previews ...... in the dsSpecials data set. When the URL or XPath argument in ... in the specified XML file. The data set ... zero, so if a data set contains 10 rows, the index of ... SHELLdorado - Good Shell Coding Practices - Heiner's SHELLdoradoto set the arguments. `getopt ...` means "the output of the ... process data unbuffered. sort -u cat -u-v: print ... One major disadvantage is that argument names and file names ... 7/27/2012 11:12:07 PM
|
|
|
|
|
|
|
|
|