Merged with mainline.
Binary file day1/data/position.png has changed
--- a/day1/session1.tex Mon Oct 26 19:18:04 2009 +0530
+++ b/day1/session1.tex Mon Oct 26 19:48:59 2009 +0530
@@ -215,11 +215,13 @@
\frametitle{Another example}
\begin{lstlisting}
In []: clf()
+#Clears the plot area.
In []: y = linspace(0, 2*pi, 51)
In []: plot(y, sin(2*y))
In []: xlabel('y')
In []: ylabel('sin(2y)')
\end{lstlisting}
+\emphbar{By default plots would be overlayed!}
\end{frame}
\begin{frame}[fragile]
@@ -231,7 +233,6 @@
In []: title('Sinusoids')
#Sets the title of the figure
In []: legend(['sin(2y)'])
-# When no label, or to change
\end{lstlisting}
% \small
% \end{block}
@@ -243,30 +244,17 @@
\begin{frame}[fragile]
\frametitle{Changing Legend Placement}
-\vspace*{-0.1in}
-\begin{lstlisting}
-In []: legend(['sin(2y)'], loc=(.8,.1))
-#(x,y) is position of lower-left
-#corner of legend box.
-\end{lstlisting}
-%\vspace*{-0.2in}
-\begin{center}
- \includegraphics[height=2in, interpolate=true]{data/loc}
-\end{center}
-\end{frame}
-
-\begin{frame}[fragile]
-\frametitle{Changing Legend Placement}
\begin{columns}
\column{0.6\textwidth}
\begin{block}{}
\small
\begin{lstlisting}
In []: legend(['sin(2y)'],
- loc='right')
+ loc='center')
\end{lstlisting}
\small
\end{block}
+ \includegraphics[height=2in, interpolate=true]{data/position}
\column{0.45\textwidth}
\vspace{-0.2in}
\begin{lstlisting}
@@ -287,6 +275,19 @@
\end{columns}
\end{frame}
+\begin{frame}[fragile]
+\frametitle{For placing legend at $(x,y)$}
+\vspace*{-0.1in}
+\begin{lstlisting}
+In []: legend(['sin(2y)'], loc=(.8,.1))
+#(x,y) is position of lower-left
+#corner of legend box.
+\end{lstlisting}
+%\vspace*{-0.2in}
+\begin{center}
+ \includegraphics[height=2in, interpolate=true]{data/loc}
+\end{center}
+\end{frame}
\begin{frame}[fragile]
\frametitle{Saving \& Closing}
@@ -298,7 +299,7 @@
\end{frame}
\begin{frame}[fragile]
-\frametitle{Multiple Figures}
+\frametitle{Plotting seprate figures}
\begin{lstlisting}
In []: figure(1)
In []: plot(y, sin(y))
@@ -359,7 +360,7 @@
\begin{frame}[fragile]
\frametitle{Review Problem}
\begin{enumerate}
-\item Plot x, -x, sin(x), xsin(x) in the range $-5\pi$ to $5\pi$
+\item Plot x, -x, sin(x), xsin(x) in range $-5\pi$ to $5\pi$
\item Add a legend
\item Annotate the origin
\item Set axis limits to the range of x
@@ -392,7 +393,14 @@
\end{lstlisting}
}
\end{frame}
-
+\begin{frame}
+ \frametitle{Things we have learned}
+ \begin{itemize}
+ \item Creating plots.
+ \item Handling labels and legends.
+ \item Changing properties of plot.
+ \end{itemize}
+\end{frame}
\begin{frame}[fragile]
\begin{center}
End of Session-1\\
--- a/day1/session3.tex Mon Oct 26 19:18:04 2009 +0530
+++ b/day1/session3.tex Mon Oct 26 19:48:59 2009 +0530
@@ -311,8 +311,8 @@
\item In this problem let the value of a \emph{key} be another dictionary.
\item This dictionary contains:
\begin{itemize}
- \item 'marks': A \emph{list} of NumPy arrays
- \item 'total': Total marks of each student
+ \item 'marks': A \emph{List} of \emph{Lists} containing all marks
+ \item 'total': A \emph{List} of total marks of each student
\item 'P': Number of passes
\item 'F': Number of failures
\item 'W': Number of withdrawls
@@ -362,11 +362,6 @@
or score_str == ''
else int(fields[8])
data[fields[0]]['total'].append(total)
-
-pfw_key = fields[9]
- or fields[10]
- or 'F'
-data[fields[0]][pfw_key] += 1
\end{lstlisting}
\end{frame}
@@ -381,13 +376,25 @@
\end{frame}
\begin{frame}[fragile]
+ \frametitle{NumPy arrays}
+ \centerline{\alert{But I lied!?!?!?}}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Calculations}
+ \begin{lstlisting}
+for k in data:
+ data[k]['marks'] = array(
+ data[k]['marks'])
+ data[k]['total'] = array(
+ data[k]['total'])
+ \end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
\frametitle{Calculations}
\small
\begin{lstlisting}
-for k in data:
- data[k]['marks'] = array(data[k]['marks'])
- data[k]['total'] = array(data[k]['total'])
-
data[k]['avg'] = average(
data[k]['total'])
marks = data[k]['marks']
@@ -408,7 +415,7 @@
\item New type of conditional
\item NumPy arrays
\item Slicing NumPy arrays
- \item NumPy array operations - square, average, sqrt
+ \item NumPy array functions - square, average, sqrt
\end{itemize}
\end{frame}
--- a/day2/3Dplotting.tex Mon Oct 26 19:18:04 2009 +0530
+++ b/day2/3Dplotting.tex Mon Oct 26 19:48:59 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!}
Binary file day2/data/3832.jpg has changed
Binary file day2/data/hyperboloid.png has changed
Binary file day2/data/torus.png has changed