Re: Batch
- To: mathgroup at smc.vnet.net
- Subject: [mg60396] Re: [mg60364] Batch
- From: Maria Cristina Dias Tavares <cristina at dsce.fee.unicamp.br>
- Date: Thu, 15 Sep 2005 05:16:16 -0400 (EDT)
- References: <20050914095734.AD3B7B36B@mfep7.connect.com.au>
- Sender: owner-wri-mathgroup at wolfram.com
Hi again
I will put my question in a different way.
What I do now is to read the data directories/file names in a loop
and then I start the calculation. The calculation is performed inside a
Do, where I generate my tables, save them in the appropriate
directories, and generate the graphics and save them also in different
directories. That works, but this is not a well-organized procedure
because I have all the calculations inside a very large Do loop, that
means that my notebook is almost a single large Do cell.
I think it would be much better if I could have my calculation
inside another notebook and if I call this notebook inside the Do loop.
My first try was to have a notebook to read the data file and
directory names and the call a second notebook. In this notebook I have
part of my calculation, rather documented and it called the last
notebook which would finish the calculation and return to the next data.
In the front end I manage to call the second notebook but it was only
opened, not evaluated, I have to evaluate it manually. Perhaps the
problem does not involve batch, but rather one notebook calling and
evaluating another notebook.
Thank for your your fast help.
Regards
>Hi Maria,
>
>
>
>> I need to run a batch in Mathematica, so that I read data
>>from several files and execute the calculations and generate
>>the graphics.
>>Then I read another group of data and perform the same
>>calculation and that goes on until the data finish.
>>
>> I just manage to do this by putting all the calculation
>>in a single cell, inside a Do. My cases are rather large, I
>>am dealing with experimental data and I have to manipulate
>>files with 1,000,000 points.
>>I cannot just read all of them at once and start the calculus.
>>
>> My first go was to separate the calculations in notebooks
>>and one nb called the next one. The first notebook called the
>>following without a problem, but it did not evaluate it. I
>>had to do it manually. And I have around 100 cases to
>>analyse. I really need to automatize the procedure.
>>
>>
>
>My suggestion is to save each notebook as a package (File->Save as
>special->Package format). This will leave you with a series of files that
>you can happily batch, either from your operating system, or through
>Mathematica.
>
>For example, we can generate some files using
>
> (
> ount = OpenWrite[onam[[#]]];
> ostr = "Print[\"Hi from file : \", ";
> ostr = StringJoin[ostr, ToString[#], "];"];
> Write[ount, OutputForm[ostr]];
> Close[ount];
> ) & /@ Range[Length@onam]
>
>Then, under Windows, we can run them sequentially using the batch file
>
> c:\Mathematica\5.0.1\math < File_0001.m
> c:\Mathematica\5.0.1\math < File_0002.m
> c:\Mathematica\5.0.1\math < File_0003.m
> c:\Mathematica\5.0.1\math < File_0004.m
> c:\Mathematica\5.0.1\math < File_0005.m
>
>You will probably have to change the path to math.exe. Note that this is
>not the front end, nor even the kernel, but a text-mode front end.
>
>It is also worth noting that we can use Mathematica to run the batch process
>using the following code
>
> ifil = FileNames["*.m"]
> (
> Print["Working on file : ", ifil[[#]]];
> Get[ifil[[#]]];
> ) & /@ Range[Length@ifil]
>
>Regards,
>
>Dave.
>
>
--
Profa Maria Cristina Tavares
Faculdade de Engenharia Elétrica e de Computação
UNICAMP / FEEC / DSCE
CP 6101 - CEP 13083-970
tel : (19) 3788 3738
fax : (19) 3289 1395
http://www.dsce.fee.unicamp.br/~cristina