From 0015ac8a1d79210cb34aaae32fb230d8c7615cb9 Mon Sep 17 00:00:00 2001
From: Puneeth Chaganti
Date: Sat, 3 Oct 2009 16:18:26 +0530
Subject: Added a problem after initial numpy section in session1.

---
 day2/session1.tex | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

(limited to 'day2/session1.tex')

diff --git a/day2/session1.tex b/day2/session1.tex
index 91fc3d6..812d257 100644
--- a/day2/session1.tex
+++ b/day2/session1.tex
@@ -70,7 +70,6 @@
 %    postbreak = \space\dots
 % }
 
-
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 % Title page
 \title[]{Matrices and Arrays\\ \& \\2D Plotting}
@@ -286,7 +285,15 @@ array([[ 0.96276665,  0.77174861],
 \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 $
+    \end{enumerate}
 \inctime{15}
 \end{frame}
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-- 
cgit 


From d5bee84c48193e2f002b4561f0f66207dc14f86d Mon Sep 17 00:00:00 2001
From: Shantanu Choudhary
Date: Sat, 3 Oct 2009 19:08:47 +0530
Subject: Made changes in plotting section.

---
 day2/session1.tex | 72 ++++++++++++++++++++-----------------------------------
 1 file changed, 26 insertions(+), 46 deletions(-)

(limited to 'day2/session1.tex')

diff --git a/day2/session1.tex b/day2/session1.tex
index 812d257..0bdae0a 100644
--- a/day2/session1.tex
+++ b/day2/session1.tex
@@ -327,11 +327,12 @@ array([[ 0.96276665,  0.77174861],
 \begin{itemize}
   \item Also: PNG, PDF, PS, EPS, SVG, PDF
 \end{itemize}
+\inctime{5}
 \end{frame}
        
-\subsection{Plots - Lines, Labels and Legends}
+\subsection{Plots - Lines, Labels}
 \begin{frame}[fragile]
-  \frametitle{Basic plotting \ldots}
+  \frametitle{Basic plotting}
 \begin{lstlisting}
 # Set properties of objects:
 >>> l, = plot(x, sin(x))
@@ -345,6 +346,26 @@ array([[ 0.96276665,  0.77174861],
 \end{lstlisting}
 \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{Multiple figures}
 
@@ -359,48 +380,6 @@ array([[ 0.96276665,  0.77174861],
     
 \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]
     \frametitle{Note: \typ{pylab} in Python scripts}
 \begin{lstlisting}
@@ -411,6 +390,7 @@ pylab.plot(x, pylab.sin(x))
 # Can also use:
 from pylab import linspace, sin, plot
 \end{lstlisting}
+\inctime{5}
 \end{frame}
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -708,6 +688,7 @@ title('triangular head; scale '\
     \tiny
     For details see \url{http://matplotlib.sourceforge.net/screenshots/plotmap.py}
   \end{center}
+\inctime{5}
 \end{frame}
 
 
@@ -719,7 +700,6 @@ title('triangular head; scale '\
   \item \url{http://matplotlib.sf.net/screenshots.html}
   \end{itemize}
 
-  \inctime{25}
 \end{frame}
 
 \begin{frame}
@@ -766,6 +746,6 @@ title('triangular head; scale '\
       \item Show rate of convergence for a first and second order finite
           difference of sin(x)
 \end{enumerate}
-\inctime{30}
+\inctime{20}
 \end{frame}
 \end{document}
-- 
cgit 


From 953697ceeecda0dcc299df28d578afe4d2d6d04e Mon Sep 17 00:00:00 2001
From: Puneeth Chaganti
Date: Sat, 3 Oct 2009 19:39:06 +0530
Subject: Edited Problem Sets - Added cobweb plot; Removed Koch.

---
 day2/session1.tex | 51 +++++++++++++++++++--------------------------------
 1 file changed, 19 insertions(+), 32 deletions(-)

(limited to 'day2/session1.tex')

diff --git a/day2/session1.tex b/day2/session1.tex
index 812d257..75cfee1 100644
--- a/day2/session1.tex
+++ b/day2/session1.tex
@@ -170,7 +170,6 @@ array([5, 8, 11, 14])
   \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}
 
@@ -192,8 +191,6 @@ dtype('float64')
 >>> print x[0], x[-1]
 10.0 4.0
 \end{lstlisting}
-    
-\inctime{10}
 \end{frame}
 
 \begin{frame}[fragile]
@@ -223,10 +220,9 @@ array([10,11,12,-1])
     \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}
@@ -257,6 +253,8 @@ array([[5, 6],
        [8, 9]])
 >>> a[:,2]
 array([3, 6, 9])
+>>> a[...,2]
+array([3, 6, 9])
 \end{lstlisting}
 \end{frame}
 
@@ -293,6 +291,8 @@ array([[ 0.96276665,  0.77174861],
   \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}
@@ -723,7 +723,7 @@ title('triangular head; scale '\
 \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
@@ -731,9 +731,12 @@ title('triangular head; scale '\
 \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:
@@ -744,28 +747,12 @@ title('triangular head; scale '\
               \item Draw line to $(x_i, x_i)$
               \item Repeat from 2 for as long as you want 
           \end{enumerate}
-    \end{enumerate}
+    \end{enumerate}}
+    \column{0.35\textwidth}
+    \hspace*{-0.5in}
+  \includegraphics[height=1.6in, interpolate=true]{data/cobweb}  
+\end{columns}
+\inctime{20}
 \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{frame}
 \end{document}
-- 
cgit 


From df8bc4b816c9f15af81cc9d3ab6c601fa78a9f69 Mon Sep 17 00:00:00 2001
From: Shantanu Choudhary
Date: Sat, 3 Oct 2009 19:39:49 +0530
Subject: Added legend() section.

---
 day2/session1.tex | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

(limited to 'day2/session1.tex')

diff --git a/day2/session1.tex b/day2/session1.tex
index 0bdae0a..af5e7c2 100644
--- a/day2/session1.tex
+++ b/day2/session1.tex
@@ -330,7 +330,7 @@ array([[ 0.96276665,  0.77174861],
 \inctime{5}
 \end{frame}
        
-\subsection{Plots - Lines, Labels}
+\subsection{Plots - Lines, Labels, Legend}
 \begin{frame}[fragile]
   \frametitle{Basic plotting}
 \begin{lstlisting}
@@ -366,6 +366,20 @@ array([[ 0.96276665,  0.77174861],
 \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}
 
@@ -683,7 +697,7 @@ title('triangular head; scale '\
 \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}
-- 
cgit 


From eaa8c97934ecda633a0f9f7602fd23f9aac2982a Mon Sep 17 00:00:00 2001
From: Shantanu Choudhary
Date: Sat, 3 Oct 2009 20:02:38 +0530
Subject: Corrected screwed up merge.

---
 day2/session1.tex | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

(limited to 'day2/session1.tex')

diff --git a/day2/session1.tex b/day2/session1.tex
index b36b3c2..9fce148 100644
--- a/day2/session1.tex
+++ b/day2/session1.tex
@@ -222,7 +222,6 @@ array([10,11,12,-1])
       exp(x), sqrt(x)} etc.
   \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}
@@ -327,11 +326,12 @@ array([[ 0.96276665,  0.77174861],
 \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}
+  \frametitle{Tweaking plots}
 \begin{lstlisting}
 # Set properties of objects:
 >>> l, = plot(x, sin(x))
@@ -369,6 +369,7 @@ array([[ 0.96276665,  0.77174861],
 \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--', 
@@ -376,8 +377,6 @@ array([[ 0.96276665,  0.77174861],
 >>> legend() 
 # Or use:
 >>> legend(['cosine', 'sine'])
-# Annotation:
->>> text(1,0, '(1,0)')
 \end{lstlisting}
 \end{frame}
 
@@ -406,6 +405,7 @@ pylab.plot(x, pylab.sin(x))
 # Can also use:
 from pylab import linspace, sin, plot
 \end{lstlisting}
+\inctime{5}
 \end{frame}
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -703,6 +703,7 @@ title('triangular head; scale '\
     \tiny
     For details see \url{http://matplotlib.sourceforge.net/screenshots/plotmap.py}
   \end{center}
+\inctime{5}
 \end{frame}
 
 
@@ -713,8 +714,6 @@ title('triangular head; scale '\
   \item \url{http://matplotlib.sf.net/tutorial.html}
   \item \url{http://matplotlib.sf.net/screenshots.html}
   \end{itemize}
-
-  \inctime{25}
 \end{frame}
 
 \begin{frame}
@@ -749,5 +748,4 @@ title('triangular head; scale '\
 \end{columns}
 \inctime{20}
 \end{frame}
-
 \end{document}
-- 
cgit 


From ac1f681846575b25ef481034225de8de40ce0f02 Mon Sep 17 00:00:00 2001
From: Shantanu Choudhary
Date: Sat, 3 Oct 2009 23:20:03 +0530
Subject: Modified numpy array parts.

---
 day2/session1.tex | 79 ++++++++++++++++++++++++++++++++++++++++---------------
 1 file changed, 58 insertions(+), 21 deletions(-)

(limited to 'day2/session1.tex')

diff --git a/day2/session1.tex b/day2/session1.tex
index 9fce148..47a6a76 100644
--- a/day2/session1.tex
+++ b/day2/session1.tex
@@ -51,7 +51,7 @@
 \setcounter{time}{0}
 \newcommand{\inctime}[1]{\addtocounter{time}{#1}{\tiny \thetime\ m}}
 
-\newcommand{\typ}[1]{\texttt{#1}}
+\newcommand{\typ}[1]{\lstinline{#1}}
 
 \newcommand{\kwrd}[1]{ \texttt{\textbf{\color{blue}{#1}}}  }
 
@@ -74,7 +74,7 @@
 % Title page
 \title[]{Matrices and Arrays\\ \& \\2D Plotting}
 
-\author[Asokan \& Prabhu] {Asokan Pichai\\Prabhu Ramachandran}
+\author[FOSSEE Team] {Asokan Pichai\\Prabhu Ramachandran}
 
 \institute[FOSSEE] {FOSSEE Team}
 \date[] {11, October 2009}
@@ -214,29 +214,64 @@ array([10,11,12,-1])
   \begin{itemize}
   \item Basic \alert{elementwise} math (given two arrays \typ{a, b}):
       \typ{+, -, *, /, \%}
-  \item Inplace operators: \typ{a += b}, or \typ{add(a, b,
-      a)} etc.
+  \item Inplace operators: \typ{a += b}, or \typ{add(a, b, a)} etc. 
+  \item \typ{sum(x, axis=0)}, 
+        \typ{product(x, axis=0)},
+        \typ{dot(a, bp)}   
+  \end{itemize}
+\end{frame}
+
+\end{frame}
+\begin{frame}[fragile]
+  \frametitle{Array math cont.}
+  \begin{itemize}
   \item Logical operations: \typ{equal (==)}, \typ{not\_equal (!=)},
     \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), dot(a, bp)}   \inctime{10}
+  \item Trig and other functions: \typ{sin(x),}
+        \typ{arcsin(x), sinh(x),}
+      \typ{exp(x), sqrt(x)} etc.
   \end{itemize}
+\inctime{10}
 \end{frame}
 
 \subsection{Array Creation \& Slicing, Striding Arrays}
 \begin{frame}[fragile]
   \frametitle{Array creation functions}
+  \begin {block}{\typ{array(object, dtype=None, ...)}}
+  \begin{lstlisting}
+  >>> array( [2,3,4] )  
+  array([2, 3, 4])
+  \end{lstlisting}
+  \end {block}
+  \begin{block}{\typ{linspace(start, stop, num=50, ...)}}
+  \begin{lstlisting}
+  >>> linspace( 0, 2, 4 )   
+  array([0.,0.6666667,1.3333333,2.])
+  \end{lstlisting}
+  \end{block}
   \begin{itemize}
-  \item \typ{array(object, dtype=None, \ldots)}
-  \item \typ{arange(start, stop=None, step=1 \ldots)}
-  \item \typ{linspace(start, stop, num=50, \ldots)}
-  \item \typ{ones(shape, dtype=None, \ldots)}
-  \item \typ{zeros(shape, dtype=float,\ldots)}
-  \item \typ{identity(n)}
-  \item \typ{empty(shape, dtype=float,\ldots)}
-  \item \typ{ones\_like(x)}, 
-  \item \typ{zeros\_like(x)}, \typ{empty\_like(x)}
+  \item also try \typ{arange} command
+  \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+  \frametitle{Array creation functions cont.}
+  \begin{itemize}  
+  \item \typ{ones(shape, dtype=None, ...)}  
+  \begin{lstlisting} 
+  >>>ones([2,2])
+  array([[ 1.,  1.],
+       [ 1.,  1.]])
+  \end{lstlisting}  
+  \item \typ{identity(n)} 
+  \item \typ{ones\_like(x)}  
+  \begin{lstlisting} 
+  >>>a = array([[1,2,3],[4,5,6]])
+  >>>ones_like(a)
+    array([[1, 1, 1],
+           [1, 1, 1]])
+  \end{lstlisting}
+  \item check out \typ{zeros, zeros\_like, empty}
   \end{itemize}
 \end{frame}
 
@@ -302,9 +337,11 @@ array([[ 0.96276665,  0.77174861],
 
 \begin{frame}
     {IPython's \typ{pylab} mode}
+\begin{block}{Immediate use:}
+ \typ{\$ ipython -pylab}
+\end{block}
 \begin{itemize}
-    \item \typ{pylab}: convenient 2D plotting interface to MPL
-    \item Immediate use: \typ{ipython -pylab}
+    \item \typ{pylab}: convenient 2D plotting interface to MPL    
     \item Imports all of pylab for you!
     \item Allows for interactive plotting
 \end{itemize}
@@ -339,7 +376,7 @@ array([[ 0.96276665,  0.77174861],
 >>> setp(l, linewidth=2.0, color='r')
 >>> l.set_linewidth(2.0)
 >>> draw() # Redraw.
->>> setp(l) # Print properties
+>>> setp(l) # Print properties.
 >>> clf() # Clear figure.
 >>> close() # Close figure.
 \end{lstlisting}
@@ -719,9 +756,9 @@ title('triangular head; scale '\
 \begin{frame}
   \frametitle{Problem Set}
   \begin{enumerate}
-      \item Write a function that plots any n-gon given \typ{n}.
+      \item Write a function that plots any regular n-gon given \typ{n}.
       \item Consider the logistic map, $f(x) = kx(1-x)$, plot it for
-          $k=2.5, 3.5$ and $4$
+          $k=2.5, 3.5$ and $4$ in the same plot.
 \end{enumerate}
 \end{frame}
 
-- 
cgit 

