day2/3Dplotting.tex
changeset 171 29c0c504750c
parent 154 66b117b7edc7
--- a/day2/3Dplotting.tex	Mon Oct 26 14:23:49 2009 +0530
+++ b/day2/3Dplotting.tex	Mon Oct 26 16:48:14 2009 +0530
@@ -156,6 +156,24 @@
     \end{center}
 \end{frame}
 
+
+\begin{frame}
+    \frametitle{Is this new?}    
+    \begin{center}
+    We have moved from:
+    \end{center}
+    \begin{columns}
+    \column{}
+    \hspace*{-1in}    
+    \includegraphics[width=1.75in,height=1.75in, interpolate=true]{data/3832}      
+    \column{}\hspace*{-0.25in}
+    To
+    \column{}
+    \hspace*{-1in}
+    \includegraphics[width=1.75in, height=1.75in, interpolate=true]{data/torus}  
+    \end{columns}
+\end{frame}
+
 \begin{frame}
     \frametitle{3D visualization}
     \Large
@@ -189,7 +207,212 @@
 \inctime{10}
 \end{frame}
 
-\section{Tools at your disposal}
+\section{Tools available}
+
+\subsection{mlab}
+
+\begin{frame}
+    {Overview}
+    \Large
+    \begin{itemize}
+        \item Simple
+        \item Convenient
+        \item Full-featured
+    \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+
+    \frametitle{Getting started}
+    \myemph{\Large Vanilla:}
+    \begin{lstlisting}[language=bash]
+        $ ipython -wthread
+    \end{lstlisting}
+    \myemph{\Large with Pylab:}
+    \begin{lstlisting}[language=bash]
+        $ ipython -pylab -wthread
+    \end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+    \frametitle{Using mlab}
+
+    \begin{lstlisting}
+>>> from enthought.mayavi import mlab
+    \end{lstlisting}
+
+    \vspace*{0.5in}
+
+    \myemph{\Large Try these}
+
+    \vspace*{0.25in}
+
+    \begin{lstlisting}
+>>> mlab.test_<TAB>
+>>> mlab.test_contour3d()
+>>> mlab.test_contour3d??
+    \end{lstlisting}
+\end{frame}
+
+\begin{frame}
+    {Exploring the view}
+    \begin{columns}
+        \column{0.6\textwidth}
+    \pgfimage[width=3in]{MEDIA/m2/contour3d}
+        \column{0.4\textwidth}
+        \begin{itemize}
+            \item Mouse
+            \item Keyboard
+            \item Toolbar
+            \item Mayavi icon\pgfimage[width=0.2in]{MEDIA/m2/m2_icon}
+        \end{itemize}
+    \end{columns}
+\end{frame}
+
+\begin{frame}[fragile]
+    \frametitle{plotting 3-D Surface: $x^2+y^2-z^2=1$}
+    \begin{lstlisting}
+u,v = mgrid[-2:2:100j, -pi:pi:100j]
+x=sqrt(u*u+1)*cos(v)
+y=sqrt(u*u+1)*sin(v)
+z=u
+mlab.mesh(x,y,z)
+    \end{lstlisting}
+\begin{figure}
+\includegraphics[width=1in, height=1in, interpolate=true]{data/hyperboloid}
+\end{figure}
+\end{frame}
+
+\begin{frame}[fragile]
+    \frametitle{mgrid}    
+    \begin{itemize}
+      \item Creates a multidimensional ``meshgrid''
+      
+      \item In this particular case, creates 2 2D arrays: u,v.
+    \end{itemize}      
+    \begin{lstlisting}
+In []: mgrid[0:3,0:3]
+Out[]: 
+array([[[0, 0, 0],
+        [1, 1, 1],
+        [2, 2, 2]],
+
+       [[0, 1, 2],
+        [0, 1, 2],
+        [0, 1, 2]]])
+    \end{lstlisting}    
+\end{frame}
+
+\begin{frame}[fragile]
+    \frametitle{mesh}
+      \begin{itemize}
+        \item Plots a surface from data supplied as 2D arrays.
+      \end{itemize}      
+\end{frame}
+
+\begin{frame}[fragile]
+    \frametitle{\mlab\ plotting functions}
+    \begin{columns}
+        \column{0.25\textwidth}
+        \myemph{Points in 3D space}
+        \column{0.5\textwidth}
+    \pgfimage[width=2in]{MEDIA/m2/mlab/points3d_ex}
+    \end{columns}
+
+    \begin{lstlisting}
+>>> from numpy import *
+>>> t = linspace(0, 2*pi, 50)
+>>> u = cos(t)*pi
+>>> x, y, z = sin(u), cos(u), sin(t)
+    \end{lstlisting}
+    \emphbar{\PythonCode{>>> mlab.points3d(x, y, z)}}
+\end{frame}
+
+\begin{frame}
+  \begin{columns}
+        \column{0.25\textwidth}
+        \myemph{Connected points in 3D space}
+        \column{0.5\textwidth}
+        \pgfimage[width=2.5in]{MEDIA/m2/mlab/plot3d_ex}
+  \end{columns}
+  \emphbar{\PythonCode{>>> mlab.plot3d(x, y, z, t)}}
+
+    Plots lines between the points
+    
+\end{frame}
+
+\begin{frame}[fragile]
+    \begin{columns}
+        \column{0.25\textwidth}
+        \myemph{\Large 2D data}
+        \column{0.5\textwidth}
+        \pgfimage[width=2in]{MEDIA/m2/mlab/surf_ex}
+    \end{columns}            
+    \begin{lstlisting}
+>>> x, y = mgrid[-3:3:100j,-3:3:100j]
+>>> z = sin(x*x + y*y)
+    \end{lstlisting}
+
+    \emphbar{\PythonCode{>>> mlab.surf(x, y, z)}}
+
+    \alert{Assumes the points are rectilinear}
+
+\end{frame}
+
+\begin{frame}[fragile]
+    \myemph{\Large 2D data: \texttt{mlab.mesh}}
+    \vspace*{0.25in}
+
+    \emphbar{\PythonCode{>>> mlab.mesh(x, y, z)}}
+
+    \alert{Points needn't be regular}
+
+    \vspace*{0.25in}
+\begin{lstlisting}
+>>> phi, theta = numpy.mgrid[0:pi:20j, 
+...                         0:2*pi:20j]
+>>> x = sin(phi)*cos(theta)
+>>> y = sin(phi)*sin(theta)
+>>> z = cos(phi)
+>>> mlab.mesh(x, y, z, 
+...           representation=
+...           'wireframe')
+\end{lstlisting}
+
+\end{frame}
+
+\begin{frame}[fragile]
+
+  \begin{columns}
+        \column{0.25\textwidth}
+        \myemph{\Large 3D data}
+        \column{0.5\textwidth}
+        \pgfimage[width=1.5in]{MEDIA/m2/mlab/contour3d}\\        
+    \end{columns}
+\begin{lstlisting}
+>>> x, y, z = ogrid[-5:5:64j, 
+...                -5:5:64j, 
+...                -5:5:64j]
+>>> mlab.contour3d(x*x*0.5 + y*y + 
+                   z*z*2)
+\end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+
+    \myemph{\Large 3D vector data: \PythonCode{mlab.quiver3d}}
+    \vspace*{0.25in}
+
+    \pgfimage[width=2in]{MEDIA/m2/mlab/quiver3d_ex}\\
+    
+\begin{lstlisting}
+>>> mlab.test_quiver3d()
+\end{lstlisting}
+
+\emphbar{\PythonCode{obj = mlab.quiver3d(x, y, z, u, v, w)}}
+\inctime{20}
+\end{frame}
+
 
 \subsection{Mayavi2}
 
@@ -259,169 +482,6 @@
 
 \end{frame}
 
-\subsection{mlab}
-
-\begin{frame}
-    {Overview}
-    \Large
-    \begin{itemize}
-        \item Simple
-        \item Convenient
-        \item Full-featured
-    \end{itemize}
-\end{frame}
-
-\begin{frame}[fragile]
-
-    \frametitle{Getting started}
-    \myemph{\Large Vanilla:}
-    \begin{lstlisting}[language=bash]
-        $ ipython -wthread
-    \end{lstlisting}
-    \myemph{\Large with Pylab:}
-    \begin{lstlisting}[language=bash]
-        $ ipython -pylab -wthread
-    \end{lstlisting}
-\end{frame}
-
-\begin{frame}[fragile]
-    \frametitle{Using mlab}
-
-    \begin{lstlisting}
->>> from enthought.mayavi import mlab
-    \end{lstlisting}
-
-    \vspace*{0.5in}
-
-    \myemph{\Large Try these}
-
-    \vspace*{0.25in}
-
-    \begin{lstlisting}
->>> mlab.test_<TAB>
->>> mlab.test_contour3d()
->>> mlab.test_contour3d??
-    \end{lstlisting}
-\end{frame}
-
-\begin{frame}
-    {Exploring the view}
-    \begin{columns}
-        \column{0.6\textwidth}
-    \pgfimage[width=3in]{MEDIA/m2/contour3d}
-        \column{0.4\textwidth}
-        \begin{itemize}
-            \item Mouse
-            \item Keyboard
-            \item Toolbar
-            \item Mayavi icon\pgfimage[width=0.2in]{MEDIA/m2/m2_icon}
-        \end{itemize}
-    \end{columns}
-\end{frame}
-
-\begin{frame}[fragile]
-    \frametitle{\mlab\ plotting functions}
-    \begin{columns}
-        \column{0.25\textwidth}
-        \myemph{\Large 0D data}
-        \column{0.5\textwidth}
-    \pgfimage[width=2in]{MEDIA/m2/mlab/points3d_ex}
-    \end{columns}
-
-    \begin{lstlisting}
->>> from numpy import *
->>> t = linspace(0, 2*pi, 50)
->>> u = cos(t)*pi
->>> x, y, z = sin(u), cos(u), sin(t)
-    \end{lstlisting}
-    \emphbar{\PythonCode{>>> mlab.points3d(x, y, z)}}
-\end{frame}
-
-\begin{frame}
-  \begin{columns}
-        \column{0.25\textwidth}
-        \myemph{\Large 1D data}
-        \column{0.5\textwidth}
-        \pgfimage[width=2.5in]{MEDIA/m2/mlab/plot3d_ex}
-  \end{columns}
-  \emphbar{\PythonCode{>>> mlab.plot3d(x, y, z, t)}}
-
-    Plots lines between the points
-    
-\end{frame}
-
-\begin{frame}[fragile]
-    \begin{columns}
-        \column{0.25\textwidth}
-        \myemph{\Large 2D data}
-        \column{0.5\textwidth}
-        \pgfimage[width=2in]{MEDIA/m2/mlab/surf_ex}
-    \end{columns}            
-    \begin{lstlisting}
->>> x = mgrid[-3:3:100j,-3:3:100j]
->>> z = sin(x*x + y*y)
-    \end{lstlisting}
-
-    \emphbar{\PythonCode{>>> mlab.surf(x, y, z)}}
-
-    \alert{Assumes the points are rectilinear}
-
-\end{frame}
-
-\begin{frame}[fragile]
-    \myemph{\Large 2D data: \texttt{mlab.mesh}}
-    \vspace*{0.25in}
-
-    \emphbar{\PythonCode{>>> mlab.mesh(x, y, z)}}
-
-    \alert{Points needn't be regular}
-
-    \vspace*{0.25in}
-\begin{lstlisting}
->>> phi, theta = numpy.mgrid[0:pi:20j, 
-...                         0:2*pi:20j]
->>> x = sin(phi)*cos(theta)
->>> y = sin(phi)*sin(theta)
->>> z = cos(phi)
->>> mlab.mesh(x, y, z, 
-...           representation=
-...           'wireframe')
-\end{lstlisting}
-
-\end{frame}
-
-\begin{frame}[fragile]
-
-  \begin{columns}
-        \column{0.25\textwidth}
-        \myemph{\Large 3D data}
-        \column{0.5\textwidth}
-        \pgfimage[width=1.5in]{MEDIA/m2/mlab/contour3d}\\        
-    \end{columns}
-\begin{lstlisting}
->>> x, y, z = ogrid[-5:5:64j, 
-...                -5:5:64j, 
-...                -5:5:64j]
->>> mlab.contour3d(x*x*0.5 + y*y + 
-                   z*z*2)
-\end{lstlisting}
-\end{frame}
-
-\begin{frame}[fragile]
-
-    \myemph{\Large 3D vector data: \PythonCode{mlab.quiver3d}}
-    \vspace*{0.25in}
-
-    \pgfimage[width=2in]{MEDIA/m2/mlab/quiver3d_ex}\\
-    
-\begin{lstlisting}
->>> mlab.test_quiver3d()
-\end{lstlisting}
-
-\emphbar{\PythonCode{obj = mlab.quiver3d(x, y, z, u, v, w)}}
-\inctime{20}
-\end{frame}
-
 \begin{frame}
     {Getting hands dirty!}