|
From: pau <all...@gm...> - 2006-08-24 19:40:10
|
Hi, I would like to make a lot of plots and don't know how. I have a directory with about 500 data files with the same structure and I want to plot always the same columns. I don't know how to make gnuplot to produce a, say, gif plot of the columns 3 and 4 of Splotch4_0380_part.asc.gz (yes, it's gzipped!) and do the same for the rest of files (500 in total or so) Any hint? I know how to write a small script with all the gnuplot commands for a SINGLE data file but I don't know how to do this for 500 files... thanks -- View this message in context: http://www.nabble.com/automated-plotting-tf2160717.html#a5971081 Sent from the Gnuplot - User forum at Nabble.com. |
|
From: <br...@ph...> - 2006-08-24 20:07:08
|
pau wrote:
> I know how to write a small script with all the gnuplot commands for a
> SINGLE data file but I don't know how to do this for 500 files...
By not doing it from inside gnuplot, but rather from the outside. Use
whatever scripting or programming language you like to print commands
into gnuplot's standard input stream. E.g. using Bourne shell as the
scripting language, if you're on Unix, a HERE script would do most of
the job:
--- myscript.sh ---
#! /bin/sh
gnuplot <<EOF
set term gif
set output "$2"
plot "$2" using 3:4 with lines
unset output
exit
EOF
to be run as
for f in *.dat ; do
/some/where/myscript.sh "$f" `basename $f .dat`.gif ;
done
|
|
From: pau <all...@gm...> - 2006-08-24 20:29:53
|
Hi!
thanks a lot for the quick answer!
Seemingly something went wrong. I got this kind of message:
gnuplot> plot "Splotch4_0010_part.asc.gif" using 3:4 with dots
^
line 0: no data point found in specified file
And what I did is
elachistos| for f in *.asc ; do
/home/pau/temporal/FRED/PROVA/kkk.sh "$f" `basename $f .dat`.gif ;
done
where kkk.sh looks like
#!/usr/bin/env zsh
gnuplot <<EOF
set term gif
set output "$2"
plot "$2" using 3:4 with dots
unset output
exit
EOF
The result is a lot of empty gifs.
My data names are like "Splotch4_0012_part.asc.gz", and they span from
Splotch4_0000_part.asc.gz
to Splotch4_0500_part.asc.gz.
Of course I gunzipped them before using your script... Is there a faster way
of coping with gzipped data?
Any hint?
in any case, thanks a lot!
BTW do you know how to combine the for blabla and put it into the kkk.sh
script?
--
View this message in context: http://www.nabble.com/automated-plotting-tf2160717.html#a5972128
Sent from the Gnuplot - User forum at Nabble.com.
|
|
From: <br...@ph...> - 2006-08-24 20:56:22
|
pau wrote:
> Seemingly something went wrong. I got this kind of message:
>
> gnuplot> plot "Splotch4_0010_part.asc.gif" using 3:4 with dots
At least two things did go wrong, actually. First, you didn't notice
that I had assumed your data files are called *.dat, whereas yours are
actually called *.asc.
> #!/usr/bin/env zsh
> gnuplot <<EOF
> set term gif
> set output "$2"
> plot "$2" using 3:4 with dots
And there are $2 in here, but no $1. But there should be.
> unset output
> exit
> EOF
>
> The result is a lot of empty gifs.
>
> My data names are like "Splotch4_0012_part.asc.gz", and they span from
> Splotch4_0000_part.asc.gz
> to Splotch4_0500_part.asc.gz.
Second shot, this time in a single construct, which you can either type
in verbatim or save as a script file:
for f in *.asc.gz ; do
gif_file=`basename $f .asc.gz`.gif
gnuplot <<EOF
set term gif ; set output "$gif_file"
plot "< gzcat $f" using 3:4 with dots
unset output
EOF
done
|
|
From: pau <all...@gm...> - 2006-08-24 21:18:52
|
>At least two things did go wrong, actually. First, you didn't notice >that I had assumed your data files are called *.dat, whereas yours are >actually called *.asc. No, I did and changed it to *.asc; the point was the missing $1... and I had to use zcat because gzcat was not installed and not in the repository but the final result is just perfect! Thanks a lot! -- View this message in context: http://www.nabble.com/automated-plotting-tf2160717.html#a5972987 Sent from the Gnuplot - User forum at Nabble.com. |
|
From: pau <all...@gm...> - 2006-08-25 20:24:39
|
Hi,
following the conversation, I now try to use a replot command in the script
but whilst the command perfectly works passing it to single data files, in
the script it crashes.
The problem is that I have to plot the whole data and then plot the row
starting with 60001 because I use a different symbol for it. Therefore I
look in my data files for a particular row starting with 60001. As you can
see below in my script, I do this with gawk. My data files look like
-----------------------------------------
##comment
##comment
45601 value1 value2 etc ...
34210 value1 value2 etc ...
21345 value1 value2 etc ...
.
.
60001 value1 value2 etc ...
34213 value1 value2 etc ...
--------------------------------------------
The row starting with 60001 changes its position in the different data
files, so that I have to gawk it out.
The script is:
-----------------------------------------------------
#!/usr/bin/env zsh
for f in *.asc.gz ; do
eps_file=`basename $f .asc.gz`.eps
gnuplot <<EOF
unset key
set xrange [-15:15]
set yrange [-15:15]
set xlabel "X (pc)" font "Helvetica,12"
set ylabel "Y (pc)" font "Helvetica,12"
set terminal postscript eps enhanced ; set output "$eps_file"
set pointsize 1
plot "< zcat $f" using 3:4 with dots lt 8;
set pointsize 2;
replot "< zcat $f | gawk -v NAME=60001 '/AS/ {TIME=$4} $1==NAME {print
TIME,$2,$3,$4,$5,$6,$7,$8,$11; exit}'" using 3:4 with points pt 6 lt -1 ;
unset output
EOF
done
---------------------------------------------------
(I print more columns that I need but this is not the problem)
When I give gnuplot the commands for a single data file I get what I want;
when I execute the script in the directory with 500 files, I get
--------------------------------------
gawk: /AS/ {TIME=} ==NAME {print TIME,,,,; exit}
gawk: ^ syntax error
gawk: /AS/ {TIME=} ==NAME {print TIME,,,,; exit}
gawk: ^ syntax error
gawk: /AS/ {TIME=} ==NAME {print TIME,,,,; exit}
gawk: ^ syntax error
gawk: /AS/ {TIME=} ==NAME {print TIME,,,,; exit}
gawk: ^ syntax error
gawk: /AS/ {TIME=} ==NAME {print TIME,,,,; exit}
gawk: ^ syntax error
gawk: /AS/ {TIME=} ==NAME {print TIME,,,,; exit}
gawk: ^ syntax error
zcat: stdout: Broken pipe
gnuplot> plot "< zcat Splotch4_0010_part.asc.gz" using 3:4 with dots lt 8,
"< zcat Splotch4_0010_part.asc.gz | gawk -v NAME=60001 '/AS/ {TIME=} ==NAME
{print TIME,,,,; exit}'" using 3:4 with points pt 6 lt -1 ;
^
line 0: no data point found in specified file
------------------------------------------
and so on and so forth...
Can anybody help me?
Thanks in any case
--
View this message in context: http://www.nabble.com/automated-plotting-tf2160717.html#a5990721
Sent from the Gnuplot - User forum at Nabble.com.
|
|
From: <br...@ph...> - 2006-08-25 20:46:45
|
pau wrote:
> following the conversation, I now try to use a replot command
Erm, I don't think I saw any mention of replot anywhere in this
conversation. It's quite counter-productive in for what you're doing
here. Among other things, it causes each data file to be gunzipped
*three* times, instead of twice.
> set pointsize 1
> plot "< zcat $f" using 3:4 with dots lt 8;
> set pointsize 2;
> replot "< zcat $f | gawk -v NAME=60001 '/AS/ {TIME=$4} $1==NAME {print
> TIME,$2,$3,$4,$5,$6,$7,$8,$11; exit}'" using 3:4 with points pt 6 lt -1 ;
Check out 'help plot' to understand how to plot more than one data set
in a single 'plot' command. Modify pointsize by 'plot' option, rather
than by 'set pointsize'.
But all of that is a side issue. The real stumbling stone is this
question: which of the many programs used by this script: zsh, gnuplot,
zcat or gnuplot, will evaluate the $4 in "{TIME=$4}", and all the other
$<number> thingies further down the line?
|
|
From: pau <all...@gm...> - 2006-08-25 21:04:10
|
Hi Hans-Bernhard,
> Erm, I don't think I saw any mention of replot anywhere in this
> conversation. It's quite counter-productive in for what you're doing
no, you didn't... sorry maybe it's just my English. Vielleicht lieber auf
Deutsch? I think it's better English
if somebody else is going to read the post.
I just meant: "going back again to the discussion of yesterday about my
problems with gnuplot" :)
> here. Among other things, it causes each data file to be gunzipped
> *three* times, instead of twice.
why three? sorry, I think I'm too tired tonight...
> Check out 'help plot' to understand how to plot more than one data set
> in a single 'plot' command. Modify pointsize by 'plot' option, rather
> than by 'set pointsize'.
gosh, I think it's going to take me years... I already found it puzzling the
set pointsize issues and colours etc... I cannot figure out what you're
talking about but I guess I should read the manual...
> But all of that is a side issue. The real stumbling stone is this
> question: which of the many programs used by this script: zsh, gnuplot,
> zcat or gnuplot, will evaluate the $4 in "{TIME=$4}", and all the other
> $<number> thingies further down the line?
As I said, doing it for a _single_ data file is not problem at all, it just
works fine... When using the shell script everything is spoiled. I don't
think it's zsh (it's like enhanced ksh). I would say it's gnuplot because
gawk does its work fine but I don't know why!
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job
easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Gnuplot-info mailing list
Gnu...@li...
https://lists.sourceforge.net/lists/listinfo/gnuplot-info
--
View this message in context: http://www.nabble.com/automated-plotting-tf2160717.html#a5991271
Sent from the Gnuplot - User forum at Nabble.com.
|
|
From: pau <all...@gm...> - 2006-08-27 14:33:00
|
Hi Hans-Bernard,
I did what you suggested and do the extra-gawk thing out of gnuplot. Now for
each data file named "Splotch4_0010_part.asc" I have an additional one
containing only the information of the row I looked for with gawk:
"Splotch4_0010_part_b.asc"
Now it turns out that I am so silly that I don't know how to tell the script
to plot first Splotch4_0010_part.asc and then immediately
"Splotch4_0010_part_b.asc" :(
It must be easy but I am not good at all in scripting... The script looks
like
------------------------------------------
for f in Splotch4* ; do
eps_file=`basename $f .asc.gz`.eps
gnuplot <<EOF
unset key
set xrange [-15:15]
set yrange [-15:15]
set xlabel "X (pc)" font "Helvetica,12"
set ylabel "Y (pc)" font "Helvetica,12"
set terminal postscript eps enhanced ; set output "$eps_file"
set pointsize 1
plot "< zcat $f" using 3:4 with dots lt 8, plot "< zcat $f | gawk -v
NAME=60001 '/AS/ {TIME=$4} $1==NAME {print TIME,$2,$3,$4,$5,$6,$7,$8,$11;
exit}'" using 3:4 with points pt 6 lt -1
unset output
EOF
done
---------------------------------
The part containing "plot "< zcat $f | gawk -v NAME=60001 '/AS/ {TIME=$4}
$1==NAME {print TIME,$2,$3,$4,$5,$6,$7,$8,$11; exit}'" using 3:4 with points
pt 6 lt -1"
should be replaced with "gnuplot please now plot the file
Splotch4_0010_part_b.asc before you plot the following one,
Splotch4_0011_part.asc"
I know this is not a gnuplot question, but since you've been in this story
since the beginning and you seem to be good at scripting too, I resort to
you :)
heeelp! I'm very close to the final result!
--
View this message in context: http://www.nabble.com/automated-plotting-tf2160717.html#a6007346
Sent from the Gnuplot - User forum at Nabble.com.
|
|
From: <br...@ph...> - 2006-08-25 21:33:54
|
pau wrote:
>> here. Among other things, it causes each data file to be gunzipped
>> *three* times, instead of twice.
>
> why three? sorry, I think I'm too tired tonight...
Read "help replot".
plot 'foo'
replot 'bar'
is equivalent to
plot 'foo'
plot 'foo', 'bar'
and since you almost certainly don't need the page of output generated
by the single-file 'plot', it's a waste of CPU cycles to gunzip the file
for it.
> I guess I should read the manual...
Drop the "I guess", and replace "should" by "must", and you'll get a
statement closer to the truth.
>> But all of that is a side issue. The real stumbling stone is this
>> question: which of the many programs used by this script: zsh, gnuplot,
>> zcat or gnuplot, will evaluate the $4 in "{TIME=$4}", and all the other
>> $<number> thingies further down the line?
>
> As I said, doing it for a _single_ data file is not problem at all, it just
> works fine... When using the shell script everything is spoiled.
And what does that tell you? That it's the shell that expands that $4.
Why shouldn't it? It expanded $f and $epsfile, too, after all ;-)
Which takes us into the sometimes confusing world of quoting, escaping,
and variable expansion and how exactly the various tools handle them.
The easiest way of avoiding that particular shock would be to rip the
awk stuff out of the gnuplot HERE-script and move it into a stand-alone
awk script.
|
|
From: <br...@ph...> - 2006-08-27 21:38:18
|
pau wrote:
> Hi Hans-Bernard,
>
> I did what you suggested and do the extra-gawk thing out of gnuplot. Now for
> each data file named "Splotch4_0010_part.asc" I have an additional one
> containing only the information of the row I looked for with gawk:
> "Splotch4_0010_part_b.asc"
You went a bit too far. You should just remove the awk command line
from gnuplot's view, not create an intermediate data file. The idea was
to can that awk command into a separate script and then replace
> plot "< zcat $f" using 3:4 with dots lt 8, plot "< zcat $f | gawk -v
> NAME=60001 '/AS/ {TIME=$4} $1==NAME {print TIME,$2,$3,$4,$5,$6,$7,$8,$11;
> exit}'" using 3:4 with points pt 6 lt -1
by
plot "< zcat $f" using 3:4 with dots lt 8, \
"< zcat $f | gawk -f myscript.awk NAME=60001" using 3:4 \
with points pt 6 lt -1
[A side note: there was a superfluous "plot" keyword lurking in your
posted version]
|
|
From: pau <all...@gm...> - 2006-08-28 10:45:30
|
>You went a bit too far. You should just remove the awk command line
>from gnuplot's view, not create an intermediate data file. The idea was
>to can that awk command into a separate script and then replace
that did the trick and this way I don't have to gunzip the files. Semingly
the gawk commands wrapped by gnuplot were the source of the problems.
Now I have a lot of eps files but have noticed that even if I specified
plot "< zcat $f" using 3:4 with dots lt 8,\
^^^^^^^^^
"< zcat $f | gawk -f gnuplot.awk \
NAME=60001" using 3:4 with points pt 6 lt -1 ;
all the plots are black and white... ??? Why is that? I wrote "set terminal
postscript eps enhanced "
Is there a way I can set pointsize 2 before "< zcat $f | gawk -f gnuplot.awk
etc..." without having to resort to replot?
--
View this message in context: http://www.nabble.com/automated-plotting-tf2160717.html#a6017866
Sent from the Gnuplot - User forum at Nabble.com.
|
|
From: pau <all...@gm...> - 2006-08-28 12:17:34
|
set terminal postscript eps color ...
>Now I have a lot of eps files but have noticed that even if I specified
> plot "< zcat $f" using 3:4 with dots lt 8,\
^^^^^^^^^
--
View this message in context: http://www.nabble.com/automated-plotting-tf2160717.html#a6019128
Sent from the Gnuplot - User forum at Nabble.com.
|
|
From: <br...@ph...> - 2006-08-28 21:21:12
|
pau wrote: > all the plots are black and white... ??? Why is that? I wrote "set terminal > postscript eps enhanced " That's why, exactly. Read "help postscript" to understand it. > Is there a way I can set pointsize 2 before "< zcat $f | gawk -f gnuplot.awk > etc..." without having to resort to replot? No. But there's a way to specify it after the "< zcat", but still inside the 'plot' command. Read "help plot with" and watch out for "pointsize". |