Merged Mainline repo with my branch.
authorMadhusudan.C.S <madhusudancs@gmail.com>
Sat, 03 Oct 2009 20:34:18 +0530
changeset 17 b61816289439
parent 16 4d743a5e1881 (current diff)
parent 12 996fb264fbe2 (diff)
child 18 2a70a7ef7e62
Merged Mainline repo with my branch.
Binary file day2/data/cobweb.png has changed
--- a/day2/session1.tex	Sat Oct 03 20:33:56 2009 +0530
+++ b/day2/session1.tex	Sat Oct 03 20:34:18 2009 +0530
@@ -70,7 +70,6 @@
 %    postbreak = \space\dots
 % }
 
-
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 % Title page
 \title[]{Matrices and Arrays\\ \& \\2D Plotting}
@@ -171,7 +170,6 @@
   \item \alert{Note:} \typ{len(arr) != arr.size} in general
   \item \alert{Note:} By default array operations are performed
     \alert{elementwise}
-  \item Indices, slicing: just like lists 
   \end{itemize}
 \end{frame}
 
@@ -193,8 +191,6 @@
 >>> print x[0], x[-1]
 10.0 4.0
 \end{lstlisting}
-    
-\inctime{10}
 \end{frame}
 
 \begin{frame}[fragile]
@@ -224,10 +220,8 @@
     \typ{less (<)}, \typ{greater (>)} etc.
   \item Trig and other functions: \typ{sin(x), arcsin(x), sinh(x),
       exp(x), sqrt(x)} etc.
-  \item \typ{sum(x, axis=0), product(x, axis=0)} 
-  \item \typ{dot(a, bp)}
+  \item \typ{sum(x, axis=0), product(x, axis=0), dot(a, bp)}   \inctime{10}
   \end{itemize}
-  \inctime{10}
 \end{frame}
 
 \subsection{Array Creation \& Slicing, Striding Arrays}
@@ -258,6 +252,8 @@
        [8, 9]])
 >>> a[:,2]
 array([3, 6, 9])
+>>> a[...,2]
+array([3, 6, 9])
 \end{lstlisting}
 \end{frame}
 
@@ -286,7 +282,17 @@
 \end{frame}
 
 \begin{frame}[fragile]
-  \frametitle{Problem set 1.0}
+  \frametitle{Problem Set}
+  \begin{lstlisting}
+    >>> from scipy import misc
+    >>> A=misc.imread(name)
+    >>> misc.imshow(A)
+  \end{lstlisting}
+    \begin{enumerate}
+    \item Convert an RGB image to Grayscale. $ Y = 0.5R + 0.25G + 0.25B $
+    \item Scale the image to 50\%
+    \item Introduce some random noise?
+    \end{enumerate}
 \inctime{15}
 \end{frame}
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -320,11 +326,12 @@
 \begin{itemize}
   \item Also: PNG, PDF, PS, EPS, SVG, PDF
 \end{itemize}
+\inctime{5}
 \end{frame}
        
 \subsection{Plots - Lines, Labels and Legends}
 \begin{frame}[fragile]
-  \frametitle{Basic plotting \ldots}
+  \frametitle{Tweaking plots}
 \begin{lstlisting}
 # Set properties of objects:
 >>> l, = plot(x, sin(x))
@@ -339,6 +346,41 @@
 \end{frame}
 
 \begin{frame}[fragile]
+   \frametitle{Working with text \ldots}
+%\begin{itemize}
+%  \item We already saw LaTeX markup support!
+%\end{itemize}
+\begin{lstlisting}
+>>> w = arange(-2,2,.1)
+>>> plot(w,exp(-(w*w))*cos)
+>>> ylabel('$f(\omega)$')
+>>> xlabel('$\omega$')
+>>> title(r"$f(\omega)=e^{-\omega^2}
+            cos({\omega^2})$")
+>>> annotate('maxima',xy=(0, 1), 
+             xytext=(1, 0.8), 
+             arrowprops=dict(
+             facecolor='black', 
+             shrink=0.05))
+\end{lstlisting}
+    
+\end{frame}
+
+\begin{frame}[fragile]
+  \frametitle{Legends}
+\begin{lstlisting}
+>>> x = linspace(0, 2*pi, 1000)
+>>> plot(x, cos(5*x), 'r--', 
+         label='cosine')
+>>> plot(x, sin(5*x), 'g--', 
+         label='sine')
+>>> legend() 
+# Or use:
+>>> legend(['cosine', 'sine'])
+\end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
     \frametitle{Multiple figures}
 
 \begin{lstlisting}
@@ -350,48 +392,7 @@
 >>> title('Easy as 1,2,3')
 \end{lstlisting}
     
-\end{frame}
 
-\begin{frame}[fragile]
-  \frametitle{Legends and Annotation}
-\begin{lstlisting}
->>> plot(x, cos(5*x), 'r--', 
-         label='cosine')
->>> plot(x, sin(5*x), 'g--', 
-         label='sine')
->>> legend() 
-# Or use:
->>> legend(['cosine', 'sine'])
-# Annotation:
->>> text(1,0, '(1,0)')
-\end{lstlisting}
-\end{frame}
-
-\begin{frame}[fragile]
-    \frametitle{More commands \ldots}
-    \begin{lstlisting}
-# semilog, loglog 
->>> x = 10.**(-arange(100)*0.1)
->>> semilogx(x, x)
->>> semilogy(x, x)
->>> loglog(x, x)
->>> loglog(x, x*x)
-    \end{lstlisting}
-\end{frame}
-
-\begin{frame}[fragile]
-    \frametitle{More plots \ldots}
-    \begin{lstlisting}
->>> clf()
->>> t = arange(0.1, 4, 0.1)
->>> s = exp(-t)
->>> e = 0.1*abs(randn(len(s)))
->>> errorbar(t, s, e)
-# Scatter plots
->>> clf()
->>> t = randn(len(e))
->>> scatter(t, e, c=s)
-    \end{lstlisting}
 \end{frame}
 
 \begin{frame}[fragile]
@@ -404,6 +405,7 @@
 # Can also use:
 from pylab import linspace, sin, plot
 \end{lstlisting}
+\inctime{5}
 \end{frame}
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -696,11 +698,12 @@
 \end{frame}
 
 \begin{frame}[fragile] \frametitle{Maps}
-  \includegraphics[height=2.5in, interpolate=true]{data/plotmap}  
+  \includegraphics[height=2.3in, interpolate=true]{data/plotmap}  
   \begin{center}
     \tiny
     For details see \url{http://matplotlib.sourceforge.net/screenshots/plotmap.py}
   \end{center}
+\inctime{5}
 \end{frame}
 
 
@@ -711,12 +714,10 @@
   \item \url{http://matplotlib.sf.net/tutorial.html}
   \item \url{http://matplotlib.sf.net/screenshots.html}
   \end{itemize}
-
-  \inctime{25}
 \end{frame}
 
 \begin{frame}
-  \frametitle{Problem set 1.0}
+  \frametitle{Problem Set}
   \begin{enumerate}
       \item Write a function that plots any n-gon given \typ{n}.
       \item Consider the logistic map, $f(x) = kx(1-x)$, plot it for
@@ -724,9 +725,12 @@
 \end{enumerate}
 \end{frame}
 
-\begin{frame}
-  \frametitle{Problem set 1.1}
-  \begin{enumerate}
+\begin{frame}[fragile] 
+\frametitle{Problem Set}
+  \begin{columns}
+    \column{0.6\textwidth}
+    \small{
+    \begin{enumerate}
       \item Consider the iteration $x_{n+1} = f(x_n)$ where $f(x) =
           kx(1-x)$.  Plot the successive iterates of this process.
       \item Plot this using a cobweb plot as follows:
@@ -737,28 +741,11 @@
               \item Draw line to $(x_i, x_i)$
               \item Repeat from 2 for as long as you want 
           \end{enumerate}
-    \end{enumerate}
-\end{frame}
-
-\begin{frame}
-  \frametitle{Problem set 1.2}
-  \begin{enumerate}
-
-      \item Plot the Koch snowflake.  Write a function to generate the
-          necessary points given the two points constituting a line.
-          \pause
-          \begin{enumerate}
-              \item Split the line into 4 segments.
-              \item The first and last segments are trivial.
-              \item To rotate the point you can use complex numbers,
-                  recall that $z e^{j \theta}$ rotates a point $z$ in 2D
-                  by $\theta$.
-              \item Do this for all line segments till everything is
-                  done.
-          \end{enumerate}
-      \item Show rate of convergence for a first and second order finite
-          difference of sin(x)
-\end{enumerate}
-\inctime{30}
+    \end{enumerate}}
+    \column{0.35\textwidth}
+    \hspace*{-0.5in}
+  \includegraphics[height=1.6in, interpolate=true]{data/cobweb}  
+\end{columns}
+\inctime{20}
 \end{frame}
 \end{document}