# HG changeset patch # User Shantanu # Date 1256294770 -19800 # Node ID 069a9aed10271fdcd6a55b204f44af6988964b3c # Parent 66b117b7edc733dbf26629fe68cf31b92e3ff666# Parent dc0da25b788bff337d152fcf1bc364fcdda8344a Merged branch with puneeth's branch. diff -r 66b117b7edc7 -r 069a9aed1027 day1/data/pendulum.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/day1/data/pendulum.txt Fri Oct 23 16:16:10 2009 +0530 @@ -0,0 +1,90 @@ +1.0000e-01 6.9004e-01 +1.1000e-01 6.9497e-01 +1.2000e-01 7.4252e-01 +1.3000e-01 7.5360e-01 +1.4000e-01 8.3568e-01 +1.5000e-01 8.6789e-01 +1.6000e-01 8.4182e-01 +1.7000e-01 8.5379e-01 +1.8000e-01 8.5762e-01 +1.9000e-01 8.8390e-01 +2.0000e-01 8.9985e-01 +2.1000e-01 9.8436e-01 +2.2000e-01 1.0244e+00 +2.3000e-01 1.0572e+00 +2.4000e-01 9.9077e-01 +2.5000e-01 1.0058e+00 +2.6000e-01 1.0727e+00 +2.7000e-01 1.0943e+00 +2.8000e-01 1.1432e+00 +2.9000e-01 1.1045e+00 +3.0000e-01 1.1867e+00 +3.1000e-01 1.1385e+00 +3.2000e-01 1.2245e+00 +3.3000e-01 1.2406e+00 +3.4000e-01 1.2071e+00 +3.5000e-01 1.2658e+00 +3.6000e-01 1.2995e+00 +3.7000e-01 1.3142e+00 +3.8000e-01 1.2663e+00 +3.9000e-01 1.2578e+00 +4.0000e-01 1.2991e+00 +4.1000e-01 1.3058e+00 +4.2000e-01 1.3478e+00 +4.3000e-01 1.3506e+00 +4.4000e-01 1.4044e+00 +4.5000e-01 1.3948e+00 +4.6000e-01 1.3800e+00 +4.7000e-01 1.4480e+00 +4.8000e-01 1.4168e+00 +4.9000e-01 1.4719e+00 +5.0000e-01 1.4656e+00 +5.1000e-01 1.4399e+00 +5.2000e-01 1.5174e+00 +5.3000e-01 1.4988e+00 +5.4000e-01 1.4751e+00 +5.5000e-01 1.5326e+00 +5.6000e-01 1.5297e+00 +5.7000e-01 1.5372e+00 +5.8000e-01 1.6094e+00 +5.9000e-01 1.6352e+00 +6.0000e-01 1.5843e+00 +6.1000e-01 1.6643e+00 +6.2000e-01 1.5987e+00 +6.3000e-01 1.6585e+00 +6.4000e-01 1.6317e+00 +6.5000e-01 1.7074e+00 +6.6000e-01 1.6654e+00 +6.7000e-01 1.6551e+00 +6.8000e-01 1.6964e+00 +6.9000e-01 1.7143e+00 +7.0000e-01 1.7706e+00 +7.1000e-01 1.7622e+00 +7.2000e-01 1.7260e+00 +7.3000e-01 1.8089e+00 +7.4000e-01 1.7905e+00 +7.5000e-01 1.7428e+00 +7.6000e-01 1.8381e+00 +7.7000e-01 1.8182e+00 +7.8000e-01 1.7865e+00 +7.9000e-01 1.7995e+00 +8.0000e-01 1.8296e+00 +8.1000e-01 1.8625e+00 +8.2000e-01 1.8623e+00 +8.3000e-01 1.8383e+00 +8.4000e-01 1.8593e+00 +8.5000e-01 1.8944e+00 +8.6000e-01 1.9598e+00 +8.7000e-01 1.9000e+00 +8.8000e-01 1.9244e+00 +8.9000e-01 1.9397e+00 +9.0000e-01 1.9440e+00 +9.1000e-01 1.9718e+00 +9.2000e-01 1.9383e+00 +9.3000e-01 1.9555e+00 +9.4000e-01 2.0006e+00 +9.5000e-01 1.9841e+00 +9.6000e-01 2.0066e+00 +9.7000e-01 2.0493e+00 +9.8000e-01 2.0503e+00 +9.9000e-01 2.0214e+00 diff -r 66b117b7edc7 -r 069a9aed1027 day1/session1.tex --- a/day1/session1.tex Fri Oct 23 10:35:10 2009 +0530 +++ b/day1/session1.tex Fri Oct 23 16:16:10 2009 +0530 @@ -1,8 +1,8 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Tutorial slides on Python. +%Tutorial slides on Python. % -% Author: Prabhu Ramachandran -% Copyright (c) 2005-2009, Prabhu Ramachandran +% Author: FOSSEE +% Copyright (c) 2009, FOSSEE, IIT Bombay %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \documentclass[14pt,compress]{beamer} @@ -150,6 +150,9 @@ ...: Hello, World! Hello, World!^C(Ctrl-C) + ------------------------------------ + KeyboardInterrupt + \end{lstlisting} \end{frame} @@ -159,12 +162,12 @@ \column{0.25\textwidth} \hspace*{-0.5in} \includegraphics[height=2in, interpolate=true]{data/firstplot} - \column{0.7\textwidth} - \begin{block}{Code} + \column{0.8\textwidth} + \begin{block}{} \small \begin{lstlisting} -In []: x=linspace(0,2*pi,51) -In []: plot(x,sin(x)) +In []: x = linspace(0, 2*pi, 51) +In []: plot(x, sin(x)) \end{lstlisting} \small \end{block} @@ -242,9 +245,9 @@ \frametitle{Changing Legend Placement} \vspace*{-0.1in} \begin{lstlisting} -In []: legend(['sin(2y)'], loc=(0.75,0.1)) +In []: legend(['sin(2y)'], loc=(.8,.1)) #(x,y) is position of lower-left -#corner of legend. +#corner of legend box. \end{lstlisting} %\vspace*{-0.2in} \begin{center} @@ -298,11 +301,13 @@ \frametitle{Multiple Figures} \begin{lstlisting} In []: figure(1) -In []: plot(x, sin(x)) +In []: plot(y, sin(y)) In []: figure(2) -In []: plot(x, cos(x)) +In []: plot(y, cos(y)) In []: figure(1) -In []: title('sin(x)') +In []: title('sin(y)') +In []: close() +In []: close() \end{lstlisting} \end{frame} @@ -311,14 +316,13 @@ \vspace{-0.15in} \begin{lstlisting} In []: plot(y, sin(y), 'g') -# plots the curve using green color +In []: clf() In []: plot(y, sin(y), linewidth=2) -# sets the linewidth to 2 \end{lstlisting} \vspace*{-0.2in} \begin{center} - \includegraphics[height=2in, interpolate=true]{data/green} + \includegraphics[height=2.2in, interpolate=true]{data/green} \end{center} \end{frame} @@ -327,8 +331,8 @@ \vspace*{-0.15in} \begin{lstlisting} In []: annotate('local max', - xy=(2, 1), - xytext=(3, 1.5), + xy=(1.5, 1), + xytext=(2.5, .8), arrowprops=dict( shrink=0.05),) \end{lstlisting} @@ -345,6 +349,7 @@ In []: xmin, xmax = xlim() In []: ymin, ymax = ylim() +In []: xmax = 2*pi #Set the axes limits In []: xlim(xmin, xmax) In []: ylim(ymin, ymax) @@ -352,6 +357,43 @@ \end{frame} \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 Add a legend +\item Annotate the origin +\item Set axis limits to the range of x +\end{enumerate} +\begin{lstlisting} +In []: x=linspace(-5*pi, 5*pi, 501) +In []: plot(x, x, 'b') +In []: plot(x, -x, 'b') +\end{lstlisting} +$\vdots$ +\end{frame} + +\begin{frame}[fragile] +\frametitle{Review Problem \ldots} +\small{ +\begin{lstlisting} +In []: plot(x, sin(x), 'g', linewidth=2) +In []: plot(x, x*sin(x), 'r', linewidth=3) +\end{lstlisting} + +\begin{lstlisting} +In []: legend(['x', '-x', 'sin(x)', 'xsin(x)']) +In []: annotate('origin', + xy=(0, 0), + xytext=(0, -7), + arrowprops=dict( + shrink=0.05)) +In []: xlim(5*pi, 5*pi) +In []: ylim(5*pi, 5*pi) +\end{lstlisting} +} +\end{frame} + +\begin{frame}[fragile] \begin{center} End of Session-1\\ \alert{Don't Close \typ{IPython}} diff -r 66b117b7edc7 -r 069a9aed1027 day1/session2.tex --- a/day1/session2.tex Fri Oct 23 10:35:10 2009 +0530 +++ b/day1/session2.tex Fri Oct 23 16:16:10 2009 +0530 @@ -1,8 +1,8 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Tutorial slides on Python. % -% Author: The FOSSEE Group -% Copyright (c) 2009, The FOSSEE Group, IIT Bombay +% Author: FOSSEE +% Copyright (c) 2009, FOSSEE, IIT Bombay %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \documentclass[14pt,compress]{beamer} @@ -73,9 +73,9 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Title page -\title[Basic Python]{Basic Overview\\} +\title[Plotting using Python]{Plotting experimental data\\} -\author[FOSSEE Team] {The FOSSEE Group} +\author[FOSSEE] {FOSSEE} \institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay} \date[] {31, October 2009\\Day 1, Session 2} @@ -123,49 +123,85 @@ % You might wish to add the option [pausesections] \end{frame} -\section{Functions} -\begin{frame}{Functions: Definition} +\section{Creating and running scripts} +\begin{frame}[fragile] +\frametitle{Python Scripts} \begin{itemize} - \item \kwrd{def} keyword +\item Let us now put all the commands used in the review problem into a file. +\item The following commands of IPython help us do this. +\end{itemize} +\begin{lstlisting} + In []: %hist + In []: %hist -n +\end{lstlisting} +\end{frame} + +\begin{frame} +\frametitle{Python Scripts\ldots} + \begin{itemize} + \item Open a new file in an \alert{editor} + \item Copy and paste required lines from the output of \typ{\%hist -n} + \item Save the file as \typ{first_plot.py} + \end{itemize} + \begin{itemize} + \item run the file in IPython using \typ{\%run first_plot.py}\\ + \end{itemize} +\end{frame} + +\section{Plotting Points} +\begin{frame}[fragile] +\frametitle{Simple Pendulum - L and T} + \begin{itemize} + \item Given data of Length and Time-period of a Simple pendulum + \item We wish to plot L vs. \alert{$T^2$} + \end{itemize} +\begin{lstlisting} +In []: L = [0.1, 0.2, 0.3, + 0.4, 0.5, 0.6, + 0.7, 0.8, 0.9] +In []: T = [0.6529, 0.8485, 1.0590, + 1.2390, 1.4124, 1.5061, + 1.6441, 1.7949, 1.8758] +\end{lstlisting} +\end{frame} + +\begin{frame}[fragile] +\frametitle{Simple Pendulum \ldots} +\begin{itemize} +\item Let us begin with $L$ vs. \alert{$T$} +\end{itemize} +\begin{lstlisting} + In []: plot(L, T) +\end{lstlisting} +\begin{itemize} +\item But we wish to plot points! \end{itemize} \end{frame} \begin{frame}[fragile] -\frametitle{Functions: Example 1} - \begin{lstlisting} -In []: def plot_sinx(): - ....: x = linspace(0, 2*pi, 100) - ....: plt.plot(x, sin(x)) - ....: plt.show() - ....: +\frametitle{Plotting points} +\begin{lstlisting} + In []: clf() -In []: plot_sinx() - \end{lstlisting} + In []: plot(L, T, 'o') + Out[]: [] + + In []: clf() + In []: plot(L, T, '.') + Out[]: [] +\end{lstlisting} \end{frame} \begin{frame}[fragile] -\frametitle{Functions: Example 2} - \begin{lstlisting} -In []: def f(x): - ....: return sin(x*x*x)+(3*x*x) - -In []: x = linspace(0,2*pi, 1000) - -In []: plt.plot(x, f(x)) - \end{lstlisting} - \inctime{10} +\frametitle{Plotting Attributes} +\begin{itemize} + \item \kwrd{'o'} - Dots + \item \kwrd{'-'} - Lines + \item \kwrd{'- -'} - Dashed lines +\end{itemize} \end{frame} -\section{Creating and running scripts} -\begin{frame} - {Creating python files} - \begin{itemize} - \item use your editor - \item extension \typ{.py} - \item in IPython using \kwrd{\%run} - \end{itemize} -\inctime{5} -\end{frame} + \section{File Handling} \begin{frame}[fragile] @@ -203,20 +239,6 @@ \end{frame} \section{Plotting points} -\begin{frame}[fragile] -\frametitle{How to plot points?} -\begin{lstlisting} -In []: plt.plot(x, sin(x), 'ro') -Out[]: [] -\end{lstlisting} -\begin{itemize} - \item \kwrd{'r'},\kwrd{'g'},\kwrd{'b'} for red, green and blue - \item \kwrd{'o'} - Dots - \item \kwrd{'-'} - Lines - \item \kwrd{'- -'} - Dashed lines -\end{itemize} -\inctime{5} -\end{frame} \section{Lists} @@ -256,15 +278,4 @@ \inctime{10} \end{frame} -\section{Modules and import} -\begin{frame}{Modules and \typ{import}} - \begin{itemize} - \item \kwrd{import} x - \item \kwrd{from} x \kwrd{import} y - \end{itemize} -\pause -Whats the difference?? -\inctime{5} -\end{frame} - \end{document} diff -r 66b117b7edc7 -r 069a9aed1027 day1/session3.tex --- a/day1/session3.tex Fri Oct 23 10:35:10 2009 +0530 +++ b/day1/session3.tex Fri Oct 23 16:16:10 2009 +0530 @@ -1,8 +1,8 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Tutorial slides on Python. +%Tutorial slides on Python. % -% Author: Prabhu Ramachandran -% Copyright (c) 2005-2009, Prabhu Ramachandran +% Author: FOSSEE +% Copyright (c) 2009, FOSSEE, IIT Bombay %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \documentclass[14pt,compress]{beamer} @@ -158,8 +158,8 @@ In []: L = [] In []: T = [] In []: for line in open('pendulum.txt'): - .... len, t = line.split() - .... L.append(float(len)) + .... ln, t = line.split() + .... L.append(float(ln)) .... T.append(float(t)) \end{lstlisting} We now have two lists L and T diff -r 66b117b7edc7 -r 069a9aed1027 day1/session4.tex --- a/day1/session4.tex Fri Oct 23 10:35:10 2009 +0530 +++ b/day1/session4.tex Fri Oct 23 16:16:10 2009 +0530 @@ -1,8 +1,8 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Tutorial slides on Python. % -% Author: The FOSSEE Group -% Copyright (c) 2009, The FOSSEE Group, IIT Bombay +% Author: FOSSEE +% Copyright (c) 2009, FOSSEE, IIT Bombay %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \documentclass[14pt,compress]{beamer} @@ -76,7 +76,7 @@ % Title page \title[Basic Python]{Matrices, Solution of equations and Integration\\} -\author[FOSEE Team] {The FOSSEE Group} +\author[FOSSEE] {FOSSEE} \institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay} \date[] {31, October 2009\\Day 1, Session 4} diff -r 66b117b7edc7 -r 069a9aed1027 day1/session6.tex --- a/day1/session6.tex Fri Oct 23 10:35:10 2009 +0530 +++ b/day1/session6.tex Fri Oct 23 16:16:10 2009 +0530 @@ -1,8 +1,8 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Tutorial slides on Python. +%Tutorial slides on Python. % -% Author: Prabhu Ramachandran -% Copyright (c) 2005-2009, Prabhu Ramachandran +% Author: FOSSEE +% Copyright (c) 2009, FOSSEE, IIT Bombay %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \documentclass[14pt,compress]{beamer}