ViewVC logotype

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

Parent Directory Parent Directory | Revision Log Revision Log

Revision 2494 - (show annotations)
Thu Jun 25 05:00:57 2009 UTC (11 years, 6 months ago) by ahallam
Original Path: trunk/doc/cookbook/TEXT/escpybas.tex
File MIME type: application/x-tex
File size: 4622 byte(s)
Many updates to onedheatdiff in example and documentation. Still in need of some TLC however.
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % Copyright (c) 2003-2009 by University of Queensland
5 % Earth Systems Science Computational Center (ESSCC)
6 % http://www.uq.edu.au/esscc
7 %
8 % Primary Business: Queensland, Australia
9 % Licensed under the Open Software License version 3.0
10 % http://www.opensource.org/licenses/osl-3.0.php
11 %
12 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14 \section{Escript and Python Basics} \label{sec:escpybas}
16 \begin{enumerate}
17 \item Important functions.
18 \item Library tree!!! (Where to find stuff!!)
19 \item os commands for file operations load save etc
20 \item information on plotting depending on path chosen,
21 \end{enumerate}
23 The Python scripting language is a powerful and easy to learn tool with a wide variety of applications. \ESCRIPT.has been developed as a packaged module for Python specifically to solve complex partial differential equations. As a result, all the conventions and programming syntaxes associated with Python are coherrent with \ESCRIPT. If you are unfamiliar with Python there are a large number of simple to advanced guides and tutorials availabe which provide a good introduction. These should enable you to understand both this cookbook and the guide for \ESCRIPT. Some of these python tutorials are, for instance
24 \begin{itemize}
25 \item This is a very crisp introduction \url{http://hetland.org/writing/instant-python.html}. It covers everthing you need to get started with \ESCRIPT.
26 \item A nice and easy to follow introduction: \url{http://www.sthurlow.com/python/}
27 \item Another crisp tutorial \url{http://www.zetcode.com/tutorials/pythontutorial/}.
28 \item A very comprehensive tutorial from the python authors: \url{http://www.python.org/doc/2.5.2/tut/tut.html}. It covers much more than what you will ever need for \ESCRIPT.
29 \item Another comprehensive tutorial: \url{http://www.tutorialspoint.com/python/index.htm}
30 \end{itemize}
32 The \verb esys library tree has \textbf{3} main modules.\verb escript , \verb finley and \verb pycad .
33 \begin{enumerate}
34 \item \verb escript is the PDE solving module.
35 \item \verb finley is the discretisation tool and is the finite element package.
36 \item \verb pycad is a special development for creating irregular domains and models.
37 \end{enumerate}
38 Further explanations on each of these is available in the user guide. \ESCRIPT is also dependent on a few other open-source packages. These are \verb numpy an array and matrix handling package, \verb matplotlib a simple plotting and visualisation tool, \verb vtk the advanced plotting and visualisation package and ......
40 \subsection{File Commands and Opperations in \ESCRIPT}
41 A number of common file opperations 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.
43 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;
44 \begin{verbatim}
45 os.path.join(save_path,"data%03d.xml") %i
46 \end{verbatim}
47 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;
48 \begin{verbatim}
49 save_path = "data"
50 \end{verbatim}
51 while a subfolder of \verb data called \verb ans_one would be defined by;
52 \begin{verbatim}
53 save_path = "data/ans_one"
54 \end{verbatim}
55 The second argument of \verb join \xspace contains a string which is the filename. We can use the opperator \verb|%| to increment our file names with the value \verb|i| our incrementing counter. The substring \verb %03d does this by defining the following parameters;
56 \begin{itemize}
57 \item \verb 0 becomes the padding number;
58 \item \verb 3 tells us the amount of padding numbers that are required; and
59 \item \verb d indicates the end of the \verb % operator.
60 \end{itemize}
61 To increment a \verb %i is required directly after the operation the string is involed in. When correctly implemented the output files from this command would be place in the directory defined by \verb save_path as;
62 \begin{verbatim}
63 data001.xml
64 data002.xml
65 data003.xml
66 ...
67 \end{verbatim}
68 and so on.
70 Visualisation is then implemented through \verb mayavi which provides a command line of gui interface to develop plots to suit our output data. For this example a surface plot is appropriate.

  ViewVC Help
Powered by ViewVC 1.1.26