From 92642a14b28d63512ca9099fc41fa3eb71900cb6 Mon Sep 17 00:00:00 2001 From: Puneeth Chaganti Date: Thu, 8 Oct 2009 15:33:41 +0530 Subject: Minor edits to Day2 Session2. --- day2/session2.tex | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'day2/session2.tex') diff --git a/day2/session2.tex b/day2/session2.tex index 07514f7..2f3d73a 100644 --- a/day2/session2.tex +++ b/day2/session2.tex @@ -347,14 +347,14 @@ \frametitle{Interpolation} Try it! \begin{lstlisting} - >>> from scipy import interpolate - >>> interpolate.interp1d? - >>> x = np.arange(0,2*np.pi,np.pi/4) - >>> y = np.sin(x) - >>> fl = interpolate.interp1d(x,y,kind='linear') - >>> fc = interpolate.interp1d(x,y,kind='cubic') - >>> fl(np.pi/3) - >>> fc(np.pi/3) +>>> from scipy import interpolate +>>> interpolate.interp1d? +>>> x = np.arange(0,2*np.pi,np.pi/4) +>>> y = np.sin(x) +>>> fl = interpolate.interp1d(x,y,kind='linear') +>>> fc = interpolate.interp1d(x,y,kind='cubic') +>>> fl(np.pi/3) +>>> fc(np.pi/3) \end{lstlisting} \end{frame} @@ -424,5 +424,3 @@ - random number generation. - Image manipulation: jigsaw puzzle. - Monte-carlo integration. - - -- cgit From c8d383d9b7122c68703129233d11d3ac2c9849fd Mon Sep 17 00:00:00 2001 From: Puneeth Chaganti Date: Thu, 8 Oct 2009 19:05:14 +0530 Subject: Minor edits to SciPy problem in Day2 Session2. --- day2/session2.tex | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'day2/session2.tex') diff --git a/day2/session2.tex b/day2/session2.tex index 2f3d73a..b1104f7 100644 --- a/day2/session2.tex +++ b/day2/session2.tex @@ -351,8 +351,10 @@ >>> interpolate.interp1d? >>> x = np.arange(0,2*np.pi,np.pi/4) >>> y = np.sin(x) ->>> fl = interpolate.interp1d(x,y,kind='linear') ->>> fc = interpolate.interp1d(x,y,kind='cubic') +>>> fl = interpolate.interp1d( + x,y,kind='linear') +>>> fc = interpolate.interp1d( + x,y,kind='cubic') >>> fl(np.pi/3) >>> fc(np.pi/3) \end{lstlisting} @@ -413,7 +415,8 @@ \begin{equation*} \frac{d^2x}{dt^2}+\mu(x^2-1)\frac{dx}{dt}+x= 0 \end{equation*} -\inctime{25} + Make a plot of $\frac{dx}{dt}$ vs. $x$. +\inctime{30} \end{frame} -- cgit From 5735e73af9453f58bbc709e884ff23a7521b688c Mon Sep 17 00:00:00 2001 From: Puneeth Chaganti Date: Thu, 8 Oct 2009 19:10:53 +0530 Subject: Added section and subsections to Day2 Session2. --- day2/session2.tex | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'day2/session2.tex') diff --git a/day2/session2.tex b/day2/session2.tex index b1104f7..67c2939 100644 --- a/day2/session2.tex +++ b/day2/session2.tex @@ -116,6 +116,8 @@ \begin{frame} \maketitle \end{frame} + +\section{Advanced Numpy} \begin{frame}[fragile] \frametitle{Broadcasting} Try it! @@ -226,6 +228,8 @@ \inctime{15} \end{frame} +\section{SciPy} +\subsection{Introduction} \begin{frame} {Intro to SciPy} \begin{itemize} @@ -266,6 +270,7 @@ \end{lstlisting} \end{frame} +\subsection{Linear Algebra} \begin{frame}[fragile] \frametitle{Linear Algebra} Try it! @@ -311,6 +316,7 @@ \inctime{15} \end{frame} +\subsection{Integration} \begin{frame}[fragile] \frametitle{Integrate} \begin{itemize} @@ -343,6 +349,7 @@ \inctime{10} \end{frame} +\subsection{Interpolation} \begin{frame}[fragile] \frametitle{Interpolation} Try it! @@ -375,6 +382,7 @@ \inctime{10} \end{frame} +\subsection{Signal Processing} \begin{frame}[fragile] \frametitle{Signal \& Image Processing} \begin{itemize} -- cgit From 7b477df3d2285020a657193ed92ddccb6f02a193 Mon Sep 17 00:00:00 2001 From: Puneeth Chaganti Date: Thu, 8 Oct 2009 20:22:15 +0530 Subject: Added first cut of Day2 handout; Minor edits to sessions 2 and 3. --- day2/session2.tex | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'day2/session2.tex') diff --git a/day2/session2.tex b/day2/session2.tex index 67c2939..9a02146 100644 --- a/day2/session2.tex +++ b/day2/session2.tex @@ -324,7 +324,7 @@ \item Integrating Functions given fixed samples \item Numerical integrators of ODE systems \end{itemize} - Calculate $\int^1_0(sin(x) + x^2)dx$ + Calculate the area under $(sin(x) + x^2)$ in the range $(0,1)$ \begin{lstlisting} >>> def f(x): return np.sin(x)+x**2 @@ -340,11 +340,11 @@ x(0)&=2 \end{align*} \begin{lstlisting} - def dx_dt(x,t): +>>> def dx_dt(x,t): return -np.exp(-t)*x**2 - x=integrate.odeint(dx_dt, 2, t) - plt.plot(x,t) +>>> x=integrate.odeint(dx_dt, 2, t) +>>> plt.plot(x,t) \end{lstlisting} \inctime{10} \end{frame} @@ -369,15 +369,15 @@ \begin{frame}[fragile] \frametitle{Interpolation - Splines} - Cubic Spline of $sin(x)$ + Plot the Cubic Spline of $sin(x)$ \begin{lstlisting} - x = np.arange(0,2*np.pi,np.pi/4) - y = np.sin(x) - tck = interpolate.splrep(x,y) - X = np.arange(0,2*np.pi,np.pi/50) - Y = interpolate.splev(X,tck,der=0) - plt.plot(x,y,'o',x,y,X,Y) - plt.show() +>>> x = np.arange(0,2*np.pi,np.pi/4) +>>> y = np.sin(x) +>>> tck = interpolate.splrep(x,y) +>>> X = np.arange(0,2*np.pi,np.pi/50) +>>> Y = interpolate.splev(X,tck,der=0) +>>> plt.plot(x,y,'o',x,y,X,Y) +>>> plt.show() \end{lstlisting} \inctime{10} \end{frame} @@ -403,16 +403,16 @@ \frametitle{Signal \& Image Processing} Applying a simple median filter \begin{lstlisting} - from scipy import signal, ndimage - from scipy import lena - A=lena().astype('float32') - B=signal.medfilt2d(A) - imshow(B) +>>> from scipy import signal, ndimage +>>> from scipy import lena +>>> A=lena().astype('float32') +>>> B=signal.medfilt2d(A) +>>> imshow(B) \end{lstlisting} Zooming an array - uses spline interpolation \begin{lstlisting} - b=ndimage.zoom(A,0.5) - imshow(b) +>>> b=ndimage.zoom(A,0.5) +>>> imshow(b) \end{lstlisting} \inctime{5} \end{frame} -- cgit From 0b89a9ad757262323b9bcb1e1c303de4447305a5 Mon Sep 17 00:00:00 2001 From: Shantanu Choudhary Date: Thu, 8 Oct 2009 23:16:13 +0530 Subject: Added links.tex, compilation of various links. --- day2/session2.tex | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'day2/session2.tex') diff --git a/day2/session2.tex b/day2/session2.tex index 9a02146..5af1818 100644 --- a/day2/session2.tex +++ b/day2/session2.tex @@ -426,8 +426,18 @@ Make a plot of $\frac{dx}{dt}$ vs. $x$. \inctime{30} \end{frame} - - +\begin{frame}{Summary} + \begin{itemize} + \item Advanced NumPy + \item SciPy + \begin{itemize} + \item Linear Algebra + \item Integration + \item Interpolation + \item Signal and Image processing + \end{itemize} + \end{itemize} +\end{frame} \end{document} - Numpy arrays (30 mins) -- cgit From eeaeb0b0f0dbd5cd3bf3001cac87ba74eb7fb8b2 Mon Sep 17 00:00:00 2001 From: Puneeth Chaganti Date: Fri, 9 Oct 2009 11:13:37 +0530 Subject: Edited Broadcasting slides. --- day2/session2.tex | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'day2/session2.tex') diff --git a/day2/session2.tex b/day2/session2.tex index 5af1818..3f0184d 100644 --- a/day2/session2.tex +++ b/day2/session2.tex @@ -124,11 +124,12 @@ \begin{lstlisting} >>> a = np.arange(4) >>> b = np.arange(5) - >>> a+b + >>> a+b #Does this work? >>> a+3 >>> c=np.array([3]) - >>> a+c - >>> b+c + >>> a+c #Works! + >>> b+c #But how? + >>> a.shape, b.shape, c.shape \end{lstlisting} \begin{itemize} \item Enter Broadcasting! -- cgit From 48d61aa98995661b7a4cc61b347a08b32af8d57c Mon Sep 17 00:00:00 2001 From: Puneeth Chaganti Date: Fri, 9 Oct 2009 12:26:47 +0530 Subject: Minor edits to Copies and Views. --- day2/session2.tex | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'day2/session2.tex') diff --git a/day2/session2.tex b/day2/session2.tex index 3f0184d..f93b02f 100644 --- a/day2/session2.tex +++ b/day2/session2.tex @@ -150,7 +150,7 @@ \includegraphics[height=0.7in, interpolate=true]{data/broadcast_scalar} \end{columns} \begin{itemize} - \item Allows functions to take inputs not of the same shape + \item Allows functions to take inputs that are not of the same shape \item 2 rules - \begin{enumerate} \item 1 is (repeatedly) prepended to shapes of smaller arrays @@ -177,8 +177,9 @@ \begin{frame}[fragile] \frametitle{Copies \& Views} Try it! + \vspace{-0.1in} \begin{lstlisting} - >>> a = np.array([[1,2,3],[4,5,6]]) + >>> a = np.arange(1,9); a.shape=3,3 >>> b = a >>> b is a >>> b[0,0]=0; print a @@ -195,9 +196,8 @@ \begin{frame}[fragile] \frametitle{Copies \& Views} Try it! + \vspace{-0.1in} \begin{lstlisting} - >>> a = np.arange(1,9) - >>> a.shape=3,3 >>> b = a[0,1:3] >>> c = a[0::2,0::2] >>> a.flags.owndata -- cgit From 0a9ef884da48dbc63e5100287de2b9bc93bce247 Mon Sep 17 00:00:00 2001 From: Puneeth Chaganti Date: Fri, 9 Oct 2009 12:55:34 +0530 Subject: Minor edits to Session2 Day2. --- day2/session2.tex | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'day2/session2.tex') diff --git a/day2/session2.tex b/day2/session2.tex index f93b02f..0f471f5 100644 --- a/day2/session2.tex +++ b/day2/session2.tex @@ -338,12 +338,12 @@ Numerically solve ODEs\\ \begin{align*} \frac{dx}{dt}&=-e^{-t}x^2\\ - x(0)&=2 + x&=2 \quad at \ t=0 \end{align*} \begin{lstlisting} >>> def dx_dt(x,t): return -np.exp(-t)*x**2 - +>>> t=np.linspace(0,2,100) >>> x=integrate.odeint(dx_dt, 2, t) >>> plt.plot(x,t) \end{lstlisting} @@ -372,8 +372,6 @@ \frametitle{Interpolation - Splines} Plot the Cubic Spline of $sin(x)$ \begin{lstlisting} ->>> x = np.arange(0,2*np.pi,np.pi/4) ->>> y = np.sin(x) >>> tck = interpolate.splrep(x,y) >>> X = np.arange(0,2*np.pi,np.pi/50) >>> Y = interpolate.splev(X,tck,der=0) -- cgit