/[escript]/trunk/doc/cookbook/escpybas.tex
ViewVC logotype

Diff of /trunk/doc/cookbook/escpybas.tex

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2877 by gross, Mon Jan 25 08:34:15 2010 UTC revision 2878 by gross, Thu Jan 28 00:59:30 2010 UTC
# Line 35  in this tutorial \esys includes the foll Line 35  in this tutorial \esys includes the foll
35  Further explanations on each of these is available in the \esc user guide or in the API documentation\footnote{Available from \url{https://launchpad.net/escript-finley/+download}}.  Further explanations on each of these is available in the \esc user guide or in the API documentation\footnote{Available from \url{https://launchpad.net/escript-finley/+download}}.
36  \esc is also dependent on a few other open-source packages which are not maintained by the \esc development team. These are \modnumpy an array and matrix handling package, \modmpl \footnote{\modnumpy and \modmpl are part of the SciPy package, see \url{http://www.scipy.org/}} a simple plotting tool, \modvtk \footnote{See \url{http://www.vtk.org/}} an advanced visualisation package and \verb gmsh \footnote{See \url{http://www.geuz.org/gmsh/}} which is required by \modpycad. These packages (\textbf{except} for \verb gmsh ) are included with the support bundles.  \esc is also dependent on a few other open-source packages which are not maintained by the \esc development team. These are \modnumpy an array and matrix handling package, \modmpl \footnote{\modnumpy and \modmpl are part of the SciPy package, see \url{http://www.scipy.org/}} a simple plotting tool, \modvtk \footnote{See \url{http://www.vtk.org/}} an advanced visualisation package and \verb gmsh \footnote{See \url{http://www.geuz.org/gmsh/}} which is required by \modpycad. These packages (\textbf{except} for \verb gmsh ) are included with the support bundles.
37    
 \subsection{File Commands and Operations in \esc}  
 A number of common file operations and commands are used throughout this cookbook. It is often advantageous to implement these commands when large numbers of output files are generated or dependencies are located in other locations.  
   
 To develop an incrementing file name we can use the following convention. For this example we are going to use the \verb|os.path.join| command to join a subdirectory which already exists with the file name which we want to use for our output. The command is;  
 \begin{python}  
 os.path.join(save_path, "data%03d.xml"%i )  
 \end{python}  
 There are two arguments to the \verb join  command. The \verb save_path  variable is a predefined string pointing to the directory we want to save our data in, for example a single subfolder called \verb data  would be defined by;  
 \begin{verbatim}  
 save_path = "data"  
 \end{verbatim}  
 while a subfolder of \verb data  called \verb ans_one  would be defined by;  
 \begin{verbatim}  
 save_path = "data/ans_one"  
 \end{verbatim}  
 The second argument of \verb join \xspace contains a string which is the filename. We can use the operator \verb|%| to increment our file names with the value \verb|i| denoting a incrementing counter. The substring \verb %03d  does this by defining the following parameters;  
 \begin{itemize}  
  \item \verb 0  becomes the padding number;  
  \item \verb 3  tells us the amount of padding numbers that are required; and  
  \item \verb d  indicates the end of the \verb %  operator.  
 \end{itemize}  
 To increment the file name a \verb %i  is required directly after the operation the string is involved in. When correctly implemented the output files from this command would be place in the directory defined by \verb save_path  as;  
 \begin{verbatim}  
 data001.xml  
 data002.xml  
 data003.xml  
 ...  
 \end{verbatim}  
 and so on.  
   
 A subfolder check/constructor is available in the cookbook \verb cblib  library called \verb needdirs . The command;  
 \begin{verbatim}  
 needdirs(save_path)  
 \end{verbatim}  
 will check for the existence of \verb save_path  and if missing, make the required directories.  
   
   
 \subsection{Visualisation and Plotting}  
 \esc does not include its own plotting capabilities. However, it is possible to use a variety of free \pyt packages for visualisation.  
 Two types will be demonstrated in this cookbook; \mpl\footnote{\url{http://matplotlib.sourceforge.net/}} and \verb VTK \footnote{\url{http://www.vtk.org/}} visualisation.  
 The \mpl package is a component of SciPy\footnote{\url{http://www.scipy.org}} and is good for basic graphs and plots. The \verb VTK  toolkit allows the \esc data to be exported in a standardised format with powerful visualisation capabilities. This format can be interpreted by many programs, \mayavi \footnote{\url{http://code.enthought.com/projects/mayavi/}} as an example.  

Legend:
Removed from v.2877  
changed lines
  Added in v.2878

  ViewVC Help
Powered by ViewVC 1.1.26