|
From: seb_kramm <seb...@ya...> - 2013-04-26 14:18:14
|
Hello, Currently, when chaining different plot commands in a script, it seems that gnuplot aborts when encountering a error (unreadable data file, in my case). Is there any way to tell gnuplot not to abort and to move on to the next 'plot' command ? I searched the manual but found nothing about error handling. I use 4.6 on Ubuntu. The situation is as follows: I have many plots to draw from many computer-generated data files. The script file is itself generated. Now, some data files are ill formed or non-existent, due to some experimental error (say, the program that generates the data crashes). But I would like to have the plots for all the other datafiles. I could manually edit the generated script file and remove the "bad" plot commands, but this will be tedious (I have many of these). Thanks for any advice on the best way to handle this. |
|
From: Ethan A M. <eam...@gm...> - 2013-04-27 03:55:03
|
On Friday, 26 April 2013, seb_kramm wrote:
> Hello,
>
> Currently, when chaining different plot commands in a script, it seems that gnuplot
> aborts when encountering a error (unreadable data file, in my case).
>
> Is there any way to tell gnuplot not to abort and to move on to the next 'plot'
> command ? I searched the manual but found nothing about error handling.
There is no general mechanism for continuing to execute a script after an error.
> I use 4.6 on Ubuntu.
>
> The situation is as follows: I have many plots to draw from many computer-generated
> data files. The script file is itself generated. Now, some data files are ill formed
> or non-existent, due to some experimental error (say, the program that generates the
> data crashes).
> But I would like to have the plots for all the other datafiles.
How about
expected_file = "filename"
stat = system("wc ".expected_file)
if (stat ne "") {
plot expected_file
}
If you want to test for a file that exists but is too short to
contain the expected data:
stat = system("wc ".expected_file)
if (stat ne "" && int(word(stat,1)) > min_size) {
plot expected_file
}
Ethan
--
Tradition is not the worship of ashes, but the preservation of fire.
- Gustav Mahler
|
|
From: seb_kramm <seb...@ya...> - 2013-04-27 14:28:02
|
On 04/27/2013 05:54 AM, Ethan A Merritt wrote:
> On Friday, 26 April 2013, seb_kramm wrote:
>> Currently, when chaining different plot commands in a script, it seems that gnuplot
>> aborts when encountering a error (unreadable data file, in my case).
>> Is there any way to tell gnuplot not to abort and to move on to the next 'plot'
>> command ? I searched the manual but found nothing about error handling.
>
> There is no general mechanism for continuing to execute a script after an error.
Thanks, indeed this would be a non trivial thing to adress.
>> The situation is as follows: I have many plots to draw from many computer-generated
>> data files. The script file is itself generated. Now, some data files are ill formed
>> or non-existent, due to some experimental error (say, the program that generates the
>> data crashes).
>> But I would like to have the plots for all the other datafiles.
>
> How about
>
> expected_file = "filename"
> stat = system("wc ".expected_file)
> if (stat ne "") {
> plot expected_file
> }
>
> If you want to test for a file that exists but is too short to
> contain the expected data:
>
> stat = system("wc ".expected_file)
> if (stat ne "" && int(word(stat,1)) > min_size) {
> plot expected_file
> }
Woaw, really clever trick, I didn't realize you could call shell commands from within
gnuplot. I will implement this, but the second version will not apply, as my data
files don't always have the same number of data points.
Thank you Ethan.
Sebastien Kramm
|
|
From: walter h. <wh...@bf...> - 2013-04-27 14:36:56
|
Am 27.04.2013 16:26, schrieb seb_kramm:
> On 04/27/2013 05:54 AM, Ethan A Merritt wrote:
>> On Friday, 26 April 2013, seb_kramm wrote:
>>> Currently, when chaining different plot commands in a script, it seems that gnuplot
>>> aborts when encountering a error (unreadable data file, in my case).
>>> Is there any way to tell gnuplot not to abort and to move on to the next 'plot'
>>> command ? I searched the manual but found nothing about error handling.
>>
>> There is no general mechanism for continuing to execute a script after an error.
>
> Thanks, indeed this would be a non trivial thing to adress.
>
>>> The situation is as follows: I have many plots to draw from many computer-generated
>>> data files. The script file is itself generated. Now, some data files are ill formed
>>> or non-existent, due to some experimental error (say, the program that generates the
>>> data crashes).
>>> But I would like to have the plots for all the other datafiles.
>>
>> How about
>>
>> expected_file = "filename"
>> stat = system("wc ".expected_file)
>> if (stat ne "") {
>> plot expected_file
>> }
>>
>> If you want to test for a file that exists but is too short to
>> contain the expected data:
>>
>> stat = system("wc ".expected_file)
>> if (stat ne "" && int(word(stat,1)) > min_size) {
>> plot expected_file
>> }
>
> Woaw, really clever trick, I didn't realize you could call shell commands from within
> gnuplot. I will implement this, but the second version will not apply, as my data
> files don't always have the same number of data points.
> Thank you Ethan.
>
> Sebastien Kramm
>
>
hi,
just in case you simply want to check that you have a filesize > 0
test -s FILE would do the trick.
An other funny trick is to use stat.
stat -c "%s" FILE
It read the file system information instead of scanning the whole file.
just my 2 cents.
re,
wh
|
|
From: Tait <gnu...@t4...> - 2013-04-30 07:08:40
|
> How about
>
> expected_file = "filename"
> stat = system("wc ".expected_file)
> if (stat ne "") {
> plot expected_file
> }
>
> If you want to test for a file that exists but is too short to
> contain the expected data:
>
> stat = system("wc ".expected_file)
> if (stat ne "" && int(word(stat,1)) > min_size) {
> plot expected_file
> }
>
> Ethan
You don't happen to have any similarly clever tricks that would work on
Windows, do you? (Gnuplot on windows does not support capturing system(),
``, etc.)
I've seen requests before for an option to disable gnuplot warnings (not
errors, necessarily, as recovery could be tricky). The noise can be
excessive when running in batch mode to create a large number of plots,
where empty data files or single-value ranges (for example) are not
worrisome.
(Sorry if this comes through twice.)
|