diff options
-rw-r--r-- | .hgtags | 1 | ||||
-rwxr-xr-x | day1/cheatsheet2.tex | 2 | ||||
-rwxr-xr-x | day1/cheatsheet3.tex | 4 | ||||
-rwxr-xr-x | day1/cheatsheet4.tex | 2 | ||||
-rw-r--r-- | day1/data/after-filter.png | bin | 0 -> 153004 bytes | |||
-rw-r--r-- | day1/data/damp.png | bin | 0 -> 22368 bytes | |||
-rw-r--r-- | day1/data/four_plot.png | bin | 0 -> 54760 bytes | |||
-rw-r--r-- | day1/data/fsolve.png | bin | 0 -> 20617 bytes | |||
-rw-r--r-- | day1/data/image.png | bin | 0 -> 19554 bytes | |||
-rw-r--r-- | day1/data/location.txt (renamed from day1/data/pos.txt) | 0 | ||||
-rwxr-xr-x | day1/data/neighbour.png | bin | 0 -> 1157 bytes | |||
-rw-r--r-- | day1/data/ode.png | bin | 0 -> 59610 bytes | |||
-rw-r--r-- | day1/data/points.png | bin | 0 -> 19613 bytes | |||
-rw-r--r-- | day1/data/roots.png | bin | 0 -> 20654 bytes | |||
-rw-r--r-- | day1/data/smoothing.png | bin | 0 -> 200973 bytes | |||
-rw-r--r-- | day1/exercises.tex | 138 | ||||
-rw-r--r-- | day1/session1.tex | 60 | ||||
-rw-r--r-- | day1/session2.tex | 6 | ||||
-rw-r--r-- | day1/session3.tex | 36 | ||||
-rw-r--r-- | day1/session4.tex | 18 | ||||
-rw-r--r-- | day1/session5.tex | 2 | ||||
-rwxr-xr-x | day1/session6.tex | 30 | ||||
-rw-r--r-- | day1quiz1.tex | 40 | ||||
-rwxr-xr-x | day2/cheatsheet1.tex | 2 | ||||
-rw-r--r-- | day2/cheatsheet2.tex | 2 | ||||
-rw-r--r-- | day2/cheatsheet3.tex | 14 | ||||
-rw-r--r-- | day2/exercises.tex | 2 | ||||
-rw-r--r-- | day2/session1.tex | 2 | ||||
-rw-r--r-- | day2/session2.tex | 4 | ||||
-rw-r--r-- | day2/session3.tex | 4 | ||||
-rw-r--r-- | day2/session4.tex | 4 | ||||
-rw-r--r-- | day2/session5.tex | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | day2quiz.tex | 14 | ||||
-rwxr-xr-x | schedule.tex | 48 |
34 files changed, 335 insertions, 102 deletions
@@ -2,3 +2,4 @@ c329c29a9342e46847db19986b638232b573dfb1 iitb-v.25092009 919c93e5aa7113bb111211cfc7fad1ab852fcc4c bprim-v.10102009 896f96b9de3b762e5626a55920b20ccc94d08f8c bprim-v.10102009p1 49bdffe4dca565fed8f7e8ee3899bde0fa2a6b60 goaandcalicut-v.10112009 +2214b5dba4d4ee98f1d7083fee6f34b10111c536 scipy.in-v.14122009 diff --git a/day1/cheatsheet2.tex b/day1/cheatsheet2.tex index 58076f6..acffa20 100755 --- a/day1/cheatsheet2.tex +++ b/day1/cheatsheet2.tex @@ -29,7 +29,7 @@ \section{Plotting Points with Lists} \begin{lstlisting} -In []: x = [0, 1, 2, 3] +In []: x = [0, 1, 2, 3] # Creating a list In []: y = [7, 11, 15, 19] In []: plot(x, y) In []: clf() diff --git a/day1/cheatsheet3.tex b/day1/cheatsheet3.tex index db50de3..244cb86 100755 --- a/day1/cheatsheet3.tex +++ b/day1/cheatsheet3.tex @@ -69,7 +69,7 @@ Drawing Pie Charts \begin{lstlisting} In []: pie(science.values(), labels=science.keys()) \end{lstlisting} -Numpy Arrays +Arrays \begin{lstlisting} In []: a = array([1, 2, 3]) #Creating In []: b = array([4, 5, 6]) @@ -77,7 +77,7 @@ In []: a + b #Sum; Element-wise \end{lstlisting} Numpy statistical operations \begin{lstlisting} -In []: mean(math_scores) +In []: mean(math_scores) In []: median(math_scores) In []: std(math_scores) \end{lstlisting} diff --git a/day1/cheatsheet4.tex b/day1/cheatsheet4.tex index 68257a8..7410368 100755 --- a/day1/cheatsheet4.tex +++ b/day1/cheatsheet4.tex @@ -38,7 +38,7 @@ Out[]: (3, 2) \typ{In []: B = ones_like(C)} \\ B would be array of ones with the same shape and type as C.\\ \typ{In []: A = ones((3,2))} \\ -A would be new array of given shape(arguments), filled with ones.\\ +A would be new matrix of given shape(arguments), filled with ones.\\ \typ{In []: I = identity(3)}\\ I would be identity matrix of shape 3x3 diff --git a/day1/data/after-filter.png b/day1/data/after-filter.png Binary files differnew file mode 100644 index 0000000..ac4d953 --- /dev/null +++ b/day1/data/after-filter.png diff --git a/day1/data/damp.png b/day1/data/damp.png Binary files differnew file mode 100644 index 0000000..5307a5d --- /dev/null +++ b/day1/data/damp.png diff --git a/day1/data/four_plot.png b/day1/data/four_plot.png Binary files differnew file mode 100644 index 0000000..00a3a7a --- /dev/null +++ b/day1/data/four_plot.png diff --git a/day1/data/fsolve.png b/day1/data/fsolve.png Binary files differnew file mode 100644 index 0000000..0108215 --- /dev/null +++ b/day1/data/fsolve.png diff --git a/day1/data/image.png b/day1/data/image.png Binary files differnew file mode 100644 index 0000000..e1c7e08 --- /dev/null +++ b/day1/data/image.png diff --git a/day1/data/pos.txt b/day1/data/location.txt index adf92c8..adf92c8 100644 --- a/day1/data/pos.txt +++ b/day1/data/location.txt diff --git a/day1/data/neighbour.png b/day1/data/neighbour.png Binary files differnew file mode 100755 index 0000000..1bb69a1 --- /dev/null +++ b/day1/data/neighbour.png diff --git a/day1/data/ode.png b/day1/data/ode.png Binary files differnew file mode 100644 index 0000000..c76a483 --- /dev/null +++ b/day1/data/ode.png diff --git a/day1/data/points.png b/day1/data/points.png Binary files differnew file mode 100644 index 0000000..210286e --- /dev/null +++ b/day1/data/points.png diff --git a/day1/data/roots.png b/day1/data/roots.png Binary files differnew file mode 100644 index 0000000..c13a1a4 --- /dev/null +++ b/day1/data/roots.png diff --git a/day1/data/smoothing.png b/day1/data/smoothing.png Binary files differnew file mode 100644 index 0000000..8456e77 --- /dev/null +++ b/day1/data/smoothing.png diff --git a/day1/exercises.tex b/day1/exercises.tex index da88e05..3fe435e 100644 --- a/day1/exercises.tex +++ b/day1/exercises.tex @@ -78,7 +78,7 @@ \author[FOSSEE] {FOSSEE} \institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay} -\date[] {7 November, 2009\\Day 1, Session 5} +\date[] {11 January, 2010\\Day 1, Session 5} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %\pgfdeclareimage[height=0.75cm]{iitmlogo}{iitmlogo} @@ -111,11 +111,37 @@ \end{frame} -\begin{frame} +\begin{frame}[fragile] \frametitle{Problem 1} + \begin{columns} + \column{0.5\textwidth} + \hspace*{-0.5in} + \includegraphics[height=2in, interpolate=true]{data/L-Tsq.png} + \column{0.45\textwidth} + \begin{block}{Example code} + \tiny + \begin{lstlisting} +l = [] +t = [] +for line in open('pendulum.txt'): + point = line.split() + l.append(float(point[0])) + t.append(float(point[1])) +tsq = [] +for time in t: + tsq.append(time*time) +plot(l, tsq, '.') + \end{lstlisting} + \end{block} + \end{columns} + \begin{block}{Problem Statement} + Tweak above code to plot data in file 'location.txt'. + \end{block} +\end{frame} + +\begin{frame} + \frametitle{Problem 1 cont...} \begin{itemize} - \item Open file 'pos.txt', it has X and Y Coordinate of a particle under motion - \item Plot X vs Y Graph. \item Label both the axes. \item What kind of motion is this? \item Title the graph accordingly. @@ -123,13 +149,49 @@ \end{itemize} \end{frame} -\begin{frame} +\begin{frame}[fragile] \frametitle{Problem 2} -Write a Program that plots a regular n-gon(Let n = 5). + \begin{columns} + \column{0.5\textwidth} + \hspace*{-0.5in} + \includegraphics[height=2in, interpolate=true]{data/points} + \column{0.45\textwidth} + \begin{block}{Line between two points} + \tiny + \begin{lstlisting} +In []: x = [1, 5] +In []: y = [1, 4] +In []: plot(x, y) + \end{lstlisting} + \end{block} + \end{columns} + Line can be plotted using arrays of coordinates. + \pause + \begin{block}{Problem statement} + Write a Program that plots a regular n-gon(Let n = 5). + \end{block} \end{frame} + \begin{frame}[fragile] \frametitle{Problem 3} + \begin{columns} + \column{0.5\textwidth} + \hspace*{-0.5in} + \includegraphics[height=2in, interpolate=true]{data/damp} + \column{0.45\textwidth} + \begin{block}{Damped Oscillation} + \tiny + \begin{lstlisting} +In []: x = linspace(0, 4*pi) +In []: plot(x, exp(x/10)*sin(x)) + \end{lstlisting} + \end{block} + \end{columns} +\end{frame} + +\begin{frame}[fragile] + \frametitle{Problem 3 cont...} Create a sequence of images in which the damped oscillator($e^{x/10}sin(x)$) slowly evolves over time. \begin{columns} \column{0.35\textwidth} @@ -147,17 +209,71 @@ savefig('plot'+str(i)+'.png') #i is int variable \end{block} \end{frame} -\begin{frame} +\begin{frame}[fragile] \frametitle{Problem 4} - Legendre polynomials $P_n(x)$ are defined by the following recurrence relation + \begin{lstlisting} +In []: x = imread('smoothing.png') +In []: x.shape +Out[]: (256, 256) +In []: imshow(x,cmap=cm.gray) + \end{lstlisting} +\emphbar{Replace each pixel with mean of neighboring pixels} + \begin{center} + \includegraphics[height=1in, interpolate=true]{data/neighbour} + \end{center} +\end{frame} -\center{$(n+1)P_{n+1}(x) - (2n+1)xP_n(x) + nP_{n-1}(x) = 0$}\\ +\begin{frame} + \begin{center} + \includegraphics[height=3in, interpolate=true]{data/smoothing} + \end{center} +\end{frame} + +\begin{frame}[fragile] + \frametitle{Problem 4: Approach} + For \typ{y} being resultant image: + \begin{lstlisting} +y[1, 1] = x[0, 1]/4 + x[1, 0]/4 + + x[2, 1]/4 + x[1, 2]/4 + \end{lstlisting} + \begin{columns} + \column{0.45\textwidth} + \hspace*{-0.5in} + \includegraphics[height=1.5in, interpolate=true]{data/smoothing} + \column{0.45\textwidth} + \hspace*{-0.5in} + \includegraphics[height=1.5in, interpolate=true]{data/after-filter} + \end{columns} + \begin{block}{Hint:} + Use array Slicing. + \end{block} +\end{frame} -with $P_0(x) = 1$, $P_1(x) = x$ and $P_2(x) = (3x^2 - 1)/2$. Compute the next three - Legendre polynomials and plot all 6 over the interval [-1,1]. +\begin{frame}[fragile] + \frametitle{Solution} + \begin{lstlisting} +In []: y = zeros_like(x) +In []: y[1:-1,1:-1] = x[:-2,1:-1]/4+ + x[2:,1:-1]/4+ + x[1:-1,2:]/4+ + x[1:-1,:-2]/4 +In []: imshow(y,cmap=cm.gray) + \end{lstlisting} \end{frame} + + \end{document} +%% \begin{frame} +%% \frametitle{Problem 4} +%% Legendre polynomials $P_n(x)$ are defined by the following recurrence relation + +%% \center{$(n+1)P_{n+1}(x) - (2n+1)xP_n(x) + nP_{n-1}(x) = 0$}\\ + +%% with $P_0(x) = 1$, $P_1(x) = x$ and $P_2(x) = (3x^2 - 1)/2$. Compute the next three +%% Legendre polynomials and plot all 6 over the interval [-1,1]. +%% \end{frame} + %% \begin{frame}[fragile] %% \frametitle{Problem Set 5} %% \begin{columns} diff --git a/day1/session1.tex b/day1/session1.tex index 47051cc..48cd878 100644 --- a/day1/session1.tex +++ b/day1/session1.tex @@ -77,7 +77,7 @@ \author[FOSSEE] {FOSSEE} \institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay} -\date[] {7 November, 2009\\Day 1, Session 1} +\date[] {11 January, 2010\\Day 1, Session 1} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %\pgfdeclareimage[height=0.75cm]{iitmlogo}{iitmlogo} @@ -125,28 +125,28 @@ \begin{frame} \frametitle{Workshop Schedule: Day 1} \begin{description} - \item[Session 1] Sat 09:00--10:00 - \item[Session 2] Sat 10:05--11:05 - \item[Session 3] Sat 11:20--12:20 - \item[Session 4] Sat 12:25--13:25 - \item[Quiz 1] Sat 14:25--14:40 - \item[Session 5] Sat 14:40--15:25 - \item[Session 6] Sat 15:40--16:40 - \item[Quiz 2] Sat 16:45--17:00 + \item[Session 1] Mon 09:00--10:00 + \item[Session 2] Mon 10:05--11:05 + \item[Session 3] Mon 11:20--12:20 + \item[Session 4] Mon 12:25--13:25 + \item[Quiz 1] Mon 14:25--14:40 + \item[Exercises] Mon 14:40--15:25 + \item[Session 5] Mon 15:40--16:40 + \item[Quiz 2] Mon 16:45--17:00 \end{description} \end{frame} \begin{frame} \frametitle{Workshop Schedule: Day 2} \begin{description} - \item[Session 1] Sun 09:00--10:00 - \item[Session 2] Sun 10:05--11:05 - \item[Session 3] Sun 11:20--12:20 - \item[Session 4] Sun 12:25--13:25 - \item[Quiz 1] Sun 14:25--14:40 - \item[Session 5] Sun 14:40--15:25 - \item[Session 6] Sun 15:40--16:40 - \item[Quiz 2] Sun 16:45--17:00 + \item[Session 1] Tue 09:00--10:00 + \item[Session 2] Tue 10:05--11:05 + \item[Session 3] Tue 11:20--12:20 + \item[Session 4] Tue 12:25--13:25 + \item[Quiz 1] Tue 14:25--14:40 + \item[Exercises] Tue 14:40--15:25 + \item[Session 5] Tue 15:40--16:40 + \item[Quiz 2] Tue 16:45--17:00 \end{description} \end{frame} @@ -189,7 +189,6 @@ \item Images \begin{itemize} \item \typ{lena.png} - \item \typ{smoothing.gif} \end{itemize} \end{enumerate} \end{frame} @@ -197,9 +196,9 @@ \begin{frame}[fragile] \frametitle{Starting up \ldots} \begin{block}{} -\begin{verbatim} +\begin{lstlisting} $ ipython -pylab -\end{verbatim} +\end{lstlisting} %$ \end{block} \begin{lstlisting} In []: print "Hello, World!" @@ -448,25 +447,36 @@ In []: ylim(ymin-0.2, ymax+0.2) \item Annotate the origin \item Set axes limits to the range of x \end{enumerate} +\vspace*{-0.1in} +\begin{center} + \includegraphics[height=2.1in, interpolate=true]{data/four_plot} +\end{center} +\end{frame} + +\begin{frame}[fragile] +\frametitle{Review Problem \ldots} +\alert{Plotting \ldots} \begin{lstlisting} In []: x=linspace(-5*pi, 5*pi, 500) In []: plot(x, x, 'b') In []: plot(x, -x, 'b') +In []: plot(x, sin(x), 'g', linewidth=2) +In []: plot(x, x*sin(x), 'r', + linewidth=3) \end{lstlisting} $\vdots$ \end{frame} \begin{frame}[fragile] \frametitle{Review Problem \ldots} -\begin{lstlisting} -In []: plot(x, sin(x), 'g', linewidth=2) -In []: plot(x, x*sin(x), 'r', - linewidth=3) -\end{lstlisting} +\alert{Legend \& Annotation\ldots} \begin{lstlisting} In []: legend(['x', '-x', 'sin(x)', 'xsin(x)']) In []: annotate('origin', xy = (0, 0)) +\end{lstlisting} +\alert{Setting Axes limits\ldots} +\begin{lstlisting} In []: xlim(-5*pi, 5*pi) In []: ylim(-5*pi, 5*pi) \end{lstlisting} diff --git a/day1/session2.tex b/day1/session2.tex index 73637c9..12dbb58 100644 --- a/day1/session2.tex +++ b/day1/session2.tex @@ -78,7 +78,7 @@ \author[FOSSEE] {FOSSEE} \institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay} -\date[] {7 November, 2009\\Day 1, Session 2} +\date[] {11 January, 2010\\Day 1, Session 2} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %\pgfdeclareimage[height=0.75cm]{iitmlogo}{iitmlogo} @@ -418,12 +418,12 @@ Out[]: ['hello', 'world'] \end{lstlisting} This is what happens with \typ{line} \begin{lstlisting} -In []: line = '1.2000e-01 7.4252e-01' +In []: line = '1.20 7.42' In []: point = line.split() In []: point -Out[]: ['1.2000e-01', '7.4252e-01'] +Out[]: ['1.20', '7.42'] \end{lstlisting} \end{frame} diff --git a/day1/session3.tex b/day1/session3.tex index 3db46b3..c769fe5 100644 --- a/day1/session3.tex +++ b/day1/session3.tex @@ -79,7 +79,7 @@ \institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay} -\date[] {7 November, 2009\\Day 1, Session 3} +\date[] {11 January, 2010\\Day 1, Session 3} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %\pgfdeclareimage[height=0.75cm]{iitmlogo}{iitmlogo} @@ -147,7 +147,7 @@ In []: for line in open('pendulum.txt'): .... point = line.split() .... l = float(point[0]) .... t = float(point[1]) - .... g = 4 * pi * pi * l / t * t + .... g = 4 * pi * pi * l / (t * t) .... G.append(g) \end{lstlisting} \end{frame} @@ -166,8 +166,8 @@ total = 0 for g in G: total += g -g_mean = total / len(g) -print "Mean: ", g_mean +g_mean = total / len(G) +print 'Mean: ', g_mean \end{lstlisting} \end{frame} @@ -175,7 +175,7 @@ print "Mean: ", g_mean \frametitle{Mean ``g''} \begin{lstlisting} g_mean = sum(G) / len(G) -print "Mean: ", g_mean +print 'Mean: ', g_mean \end{lstlisting} \end{frame} @@ -183,7 +183,7 @@ print "Mean: ", g_mean \frametitle{Mean ``g''} \begin{lstlisting} g_mean = mean(G) -print "Mean: ", g_mean +print 'Mean: ', g_mean \end{lstlisting} \inctime{10} \end{frame} @@ -277,11 +277,11 @@ for record in open('sslc1.txt'): \begin{frame}[fragile] \frametitle{Dictionaries \ldots} \begin{lstlisting} -In []: d = {"jpg" : "image file", - "txt" : "text file", - "py" : "python code"} +In []: d = {'jpg' : 'image file', + 'txt' : 'text file', + 'py' : 'python code'} -In []: d["txt"] +In []: d['txt'] Out[]: 'text file' \end{lstlisting} \end{frame} @@ -289,10 +289,10 @@ Out[]: 'text file' \begin{frame}[fragile] \frametitle{Dictionaries \ldots} \begin{lstlisting} -In []: "py" in d +In []: 'py' in d Out[]: True -In []: "cpp" in d +In []: 'cpp' in d Out[]: False \end{lstlisting} \end{frame} @@ -417,11 +417,11 @@ for record in open('sslc1.txt'): \begin{frame}[fragile] \frametitle{Obtaining statistics} \begin{lstlisting} -print "Mean: ", mean(math_scores) +print 'Mean: ', mean(math_scores) -print "Median: ", median(math_scores) +print 'Median: ', median(math_scores) -print "Standard Deviation: ", +print 'Standard Deviation: ', std(math_scores) \end{lstlisting} \inctime{10} @@ -432,11 +432,11 @@ print "Standard Deviation: ", \begin{lstlisting} math_array = array(math_scores) -print "Mean: ", mean(math_array) +print 'Mean: ', mean(math_array) -print "Median: ", median(math_array) +print 'Median: ', median(math_array) -print "Standard Deviation: ", +print 'Standard Deviation: ', std(math_array) \end{lstlisting} \inctime{5} diff --git a/day1/session4.tex b/day1/session4.tex index 3cff99c..bfff165 100644 --- a/day1/session4.tex +++ b/day1/session4.tex @@ -79,7 +79,7 @@ \author[FOSSEE] {FOSSEE} \institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay} -\date[] {7 November, 2009\\Day 1, Session 4} +\date[] {11 January, 2010\\Day 1, Session 4} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %\pgfdeclareimage[height=0.75cm]{iitmlogo}{iitmlogo} @@ -287,8 +287,6 @@ In []: a = imread('lena.png') In []: imshow(a) Out[]: <matplotlib.image.AxesImage object at 0xa0384cc> -In []: a.shape -Out[]: (512, 512, 4) \end{lstlisting} \end{small} \begin{itemize} @@ -317,6 +315,11 @@ Out[]: <matplotlib.image.AxesImage object at 0xb765c8c> \begin{frame}[fragile] \frametitle{Transpose of a Matrix} \begin{lstlisting} +In []: a = array([[ 1, 1, 2, -1], + ...: [ 2, 5, -1, -9], + ...: [ 2, 1, -1, 3], + ...: [ 1, -3, 2, 7]]) + In []: a.T Out[]: array([[ 1, 2, 2, 1], @@ -485,7 +488,14 @@ Out[]: array([-1., 8., -1.]) \frametitle{\typ{lstsq}} \begin{itemize} \item We need to fit a line through points for the equation $T^2 = m \cdot L+c$ -\item In matrix form, the equation can be represented as $T^2 = A \cdot p$, where A is +\item In matrix form, the equation can be represented as $T_{sq} = A \cdot p$, where $T_{sq}$ is + $\begin{bmatrix} + T^2_1 \\ + T^2_2 \\ + \vdots\\ + T^2_N \\ + \end{bmatrix}$ +, A is $\begin{bmatrix} L_1 & 1 \\ L_2 & 1 \\ diff --git a/day1/session5.tex b/day1/session5.tex index 22a274d..326e8fe 100644 --- a/day1/session5.tex +++ b/day1/session5.tex @@ -79,7 +79,7 @@ \author[FOSSEE] {FOSSEE} \institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay} -\date[] {31, October 2009\\Day 1, Session 5} +\date[] {11, January 2010\\Day 1, Session 5} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %\pgfdeclareimage[height=0.75cm]{iitmlogo}{iitmlogo} diff --git a/day1/session6.tex b/day1/session6.tex index 0f1523e..0f2120f 100755 --- a/day1/session6.tex +++ b/day1/session6.tex @@ -78,7 +78,7 @@ \author[FOSSEE] {FOSSEE} \institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay} -\date[] {7 November, 2009\\Day 1, Session 6} +\date[] {11 January, 2010\\Day 1, Session 6} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %\pgfdeclareimage[height=0.75cm]{iitmlogo}{iitmlogo} @@ -150,7 +150,6 @@ Let us now look at how to solve this using \kwrd{matrices} [-1, 0.5, -1]]) In []: b = array([[1], [-2], [0]]) In []: x = solve(A, b) - In []: Ax = dot(A,x) \end{lstlisting} \end{frame} @@ -168,6 +167,7 @@ array([[ 1.], \begin{frame}[fragile] \frametitle{Let's check!} \begin{lstlisting} +In []: Ax = dot(A,x) In []: Ax Out[]: array([[ 1.00000000e+00], @@ -216,11 +216,17 @@ Use \kwrd{solve()} \frametitle{Scipy Methods - \typ{roots}} \begin{itemize} \item Calculates the roots of polynomials +\item To calculate the roots of $x^2-5x+6$ \end{itemize} \begin{lstlisting} - In []: coeffs = [1, 6, 13] + In []: coeffs = [1, -5, 6] In []: roots(coeffs) + Out[]: array([3., 2.]) \end{lstlisting} +\vspace*{-.2in} +\begin{center} +\includegraphics[height=1.6in, interpolate=true]{data/roots} +\end{center} \end{frame} \begin{frame}[fragile] @@ -291,6 +297,9 @@ Find the root of $sin(x)+cos^2(x)$ nearest to $0$ In []: fsolve(f, 0) Out[]: -0.66623943249251527 \end{lstlisting} +\begin{center} +\includegraphics[height=2in, interpolate=true]{data/fsolve} +\end{center} \end{frame} %% \begin{frame}[fragile] @@ -318,6 +327,7 @@ Out[]: -0.66623943249251527 \item Define a function as below \end{itemize} \begin{lstlisting} +In []: from scipy.integrate import odeint In []: def epid(y, t): .... k, L = 0.00003, 25000 .... return k*y*(L-y) @@ -338,6 +348,14 @@ In []: plot(t, y) \end{frame} \begin{frame}[fragile] +\frametitle{Result} +\begin{center} +\includegraphics[height=2in, interpolate=true]{data/image} +\end{center} +\end{frame} + + +\begin{frame}[fragile] \frametitle{ODEs - Simple Pendulum} We shall use the simple ODE of a simple pendulum. \begin{equation*} @@ -392,6 +410,12 @@ In []: pend_sol = odeint(pend_int, \end{lstlisting} \end{frame} +\begin{frame}[fragile] +\frametitle{Result} +\begin{center} +\includegraphics[height=2in, interpolate=true]{data/ode} +\end{center} +\end{frame} \begin{frame} \frametitle{Things we have learned} diff --git a/day1quiz1.tex b/day1quiz1.tex index b2d5f6e..5aa44c3 100644 --- a/day1quiz1.tex +++ b/day1quiz1.tex @@ -154,8 +154,12 @@ is in the rectangle $(0, -1.5)$ (left bottom coordinate) and $(2\pi, %% \end{lstlisting} %% \end{frame} -\begin{frame}[fragile] +\begin{frame} \frametitle{\incqno } +What ipython magic command do you use to obtain the lines of code you have already typed in the interpreter? What command do you use to save them? +\end{frame} + +\begin{frame} \begin{lstlisting} In []: sc = {'A': 10, 'B': 20, 'C': 70} @@ -234,6 +238,38 @@ Given the above marks, how will you calculate the \alert{mean} and Write the code to read a file \texttt{data.txt} and print each line of it? \end{frame} +\begin{frame}[fragile] +\frametitle{\incqno } +What is the output of: +\begin{lstlisting} +In []: x=linspace(0 , 2 * pi) +In []: plot(x, cos(x),'go') +\end{lstlisting} +\end{frame} -\end{document} +\begin{frame} +\frametitle{\incqno } +Draw a plot with line width 3. +\end{frame} +\begin{frame} +\frametitle{\incqno } +Setting x and y axis limits. +\end{frame} + +\begin{frame}[fragile] +\frametitle{\incqno } +The following code snippet has an error/bug: +\begin{lstlisting} +In []: l = [0.1, 0.2, 0.3, 0.4] +In []: t = [0.69, 0.90, 1.19, 1.30] +In []: tsq = [] +In []: for time in t: + ....: tsq.append(time*time) + ....: plot(l, tsq) +\end{lstlisting} + +What is the error? How do you fix it? +\end{frame} + +\end{document} diff --git a/day2/cheatsheet1.tex b/day2/cheatsheet1.tex index 22289b3..6ddb1ee 100755 --- a/day2/cheatsheet1.tex +++ b/day2/cheatsheet1.tex @@ -108,7 +108,7 @@ In []: x, y = 1, 1.234 #initializing two variables In []: 'x is %s, y is %s' %(x, y) Out[]: 'x is 1, y is 1.234' \end{lstlisting} -\textbf{Note:} \typ{\%s} used in above fomatting specifies \typ{'str'} representation of variables. One can also try:\\ +\textbf{Note:} \typ{\%s} used in above formatting specifies \typ{'str'} representation of variables. One can also try:\\ \typ{\%d} for \typ{int} representation\\ \typ{\%f} for \typ{float} representation \begin{lstlisting} diff --git a/day2/cheatsheet2.tex b/day2/cheatsheet2.tex index bb5762a..ece16b8 100644 --- a/day2/cheatsheet2.tex +++ b/day2/cheatsheet2.tex @@ -193,7 +193,7 @@ Tuples are sequences just like Lists, but they are \textbf{immutable}, or items/ \begin{lstlisting} In []: t = (1, 2, 3, 4, 5, 6, 7, 8) \end{lstlisting} -\textbf{Note:} For tupels we use parantheses in place of square brackets, rest is same as lists. +\textbf{Note:} For tuples we use parentheses in place of square brackets, rest is same as lists. \begin{lstlisting} In []: t[0] + t[3] + t[-1] # elements are accessed via indices Out[]: 13 diff --git a/day2/cheatsheet3.tex b/day2/cheatsheet3.tex index 293b95e..808fa6e 100644 --- a/day2/cheatsheet3.tex +++ b/day2/cheatsheet3.tex @@ -50,7 +50,7 @@ In []: signum(-4) Out[]: -1 In []: signum() # ERROR signum() takes exactly 1 argument(0 given) \end{lstlisting} -\textbf{Note:} Arguments passed to a function are passed by-value \textbf{only if} they are basic Python data type(int, float). In case one passes immutable types(String, tupels), they cant be modified in the function, but objects like \typ{list} and dictionary can be manipulated. +\textbf{Note:} Arguments passed to a function are passed by-value \textbf{only if} they are basic Python data type(int, float). In case one passes immutable types(String, tuples), they cant be modified in the function, but objects like \typ{list} and dictionary can be manipulated. \subsection{Default Arguments} This feature allow the functions to take the arguments optionally. For example: \begin{lstlisting} @@ -80,12 +80,12 @@ In []: welcome("Hi", "Guido") #taking name via argument Hi Guido \end{lstlisting} \subsection{Keyword Arguments} -This feature provides the facility of passing arguments by specifying the name of the parameter as defined in the function definition. You dont have to remember the order of the parameters in function definition. For example: +This feature provides the facility of passing arguments by specifying the name of the parameter as defined in the function definition. You don't have to remember the order of the parameters in function definition. For example: \begin{lstlisting} In []: plot(y, sin(y), 'g', linewidth=2) In []: plot(y, cos(y), linewidth=1, color='g') \end{lstlisting} -Both call to \typ{plot} function will work and paramenters are set accordingly.\\ +Both call to \typ{plot} function will work and parameters are set accordingly.\\ One can define a function such that keyword arguments can be used in following way: \begin{lstlisting} def wish(name='World', greetings='Hello'): @@ -97,8 +97,8 @@ In [13]: wish() #default arguments will work Hello World In [14]: wish(greetings='hey', name='madhu') hey madhu -In [15]: wish(name='vattam', greetings = 'get lost') -get lost vattam +In [15]: wish(name='vattam', greetings = 'bye bye') +bye bye vattam \end{lstlisting} % sorry Vattam just a joke :P \section{Self contained python script} @@ -130,13 +130,13 @@ In Python everything is a object! All variables, lists, tuples, dictionaries and \begin{lstlisting} In []: a = str() # initializing a string object. In []: b = "Hello World" -In []: b.split() # calling funciton on object 'b' +In []: b.split() # calling function on object 'b' Out[]: ['Hello', 'World'] \end{lstlisting} ``.'' is a operator used to call functions defined for given object. \section{Links and References} \begin{itemize} -\item Some of inbult functions available with Python are listed at\\ \url{http://docs.python.org/library/functions.html} +\item Some of inbuilt functions available with Python are listed at\\ \url{http://docs.python.org/library/functions.html} \item Reference manual to describe the standard libraries that are distributed with Python is available at \url{http://docs.python.org/library/} \end{itemize} \end{document} diff --git a/day2/exercises.tex b/day2/exercises.tex index 6c3fd19..7cbf437 100644 --- a/day2/exercises.tex +++ b/day2/exercises.tex @@ -78,7 +78,7 @@ \author[FOSSEE] {FOSSEE} \institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay} -\date[] {8 November, 2009\\Day 2} +\date[] {12 January, 2010\\Day 2} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %\pgfdeclareimage[height=0.75cm]{iitmlogo}{iitmlogo} diff --git a/day2/session1.tex b/day2/session1.tex index df67b5c..8d7c70e 100644 --- a/day2/session1.tex +++ b/day2/session1.tex @@ -79,7 +79,7 @@ \author[FOSSEE Team] {The FOSSEE Group} \institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay} -\date[] {8 November, 2009\\Day 2, Session 1} +\date[] {12 January, 2010\\Day 2, Session 1} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %\pgfdeclareimage[height=0.75cm]{iitmlogo}{iitmlogo} diff --git a/day2/session2.tex b/day2/session2.tex index 14fe857..d40f9d2 100644 --- a/day2/session2.tex +++ b/day2/session2.tex @@ -78,7 +78,7 @@ \author[FOSSEE Team] {The FOSSEE Group} \institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay} -\date[] {8 November, 2009\\Day 2, Session 2} +\date[] {12 January, 2010\\Day 2, Session 2} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %\pgfdeclareimage[height=0.75cm]{iitmlogo}{iitmlogo} @@ -535,4 +535,4 @@ def what( n ): \end{itemize} \end{frame} -\end{document}
\ No newline at end of file +\end{document} diff --git a/day2/session3.tex b/day2/session3.tex index 068f17e..97ecf59 100644 --- a/day2/session3.tex +++ b/day2/session3.tex @@ -78,7 +78,7 @@ \author[FOSSEE Team] {The FOSSEE Group} \institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay} -\date[] {8 November, 2009\\Day 2, Session 3} +\date[] {12 January, 2010\\Day 2, Session 3} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %\pgfdeclareimage[height=0.75cm]{iitmlogo}{iitmlogo} @@ -431,4 +431,4 @@ for line in urllib2.urlopen('http://site.com'): \end{itemize} \end{frame} -\end{document}
\ No newline at end of file +\end{document} diff --git a/day2/session4.tex b/day2/session4.tex index f401d8d..7345b7e 100644 --- a/day2/session4.tex +++ b/day2/session4.tex @@ -100,7 +100,7 @@ \author[FOSSEE] {FOSSEE} \institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay} -\date[] {8 November, 2009\\Day 2, Session 4} +\date[] {12 January, 2010\\Day 2, Session 4} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %\pgfdeclareimage[height=0.75cm]{iitblogo}{iitblogo} @@ -553,4 +553,4 @@ We have covered: % %% \end{block} % % %% \inctime{15} -% %% \end{frame}
\ No newline at end of file +% %% \end{frame} diff --git a/day2/session5.tex b/day2/session5.tex index a3e63e8..1d0612c 100644 --- a/day2/session5.tex +++ b/day2/session5.tex @@ -100,7 +100,7 @@ \author[FOSSEE] {FOSSEE} \institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay} -\date[] {8 November, 2009\\Day 2, Session 5} +\date[] {12 January, 2010\\Day 2, Session 5} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/day2quiz.tex b/day2quiz.tex index 413cca8..50f40dd 100644..100755 --- a/day2quiz.tex +++ b/day2quiz.tex @@ -88,18 +88,6 @@ How do you create a complex number with real part 2 and imaginary part 0.5. \end{frame} -\begin{frame}[fragile] -\frametitle{\incqno } - What happens when we run this code? - \begin{lstlisting} -a = False -b = True -c = True -if a and b or c: - print "You are correct!" - \end{lstlisting} -\end{frame} - \begin{frame} \frametitle{\incqno } What is the difference between \kwrd{print} \emph{x} and \kwrd{print} \emph{x,} ? @@ -134,7 +122,7 @@ In []: set([1, 2, 8, 2, 13, 8, 9]) \begin{frame}[fragile] \frametitle{\incqno} \begin{lstlisting} -In []: 47%3 +In []: 47 % 3 \end{lstlisting} What is the output? \end{frame} diff --git a/schedule.tex b/schedule.tex new file mode 100755 index 0000000..02dfc3c --- /dev/null +++ b/schedule.tex @@ -0,0 +1,48 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Tutorial slides on Python. +% +% Author: FOSSEE <info at fossee dot in> +% Copyright (c) 2005-2009, FOSSEE Team +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\documentclass[14pt]{article} + +\title{Python for Science and Engineering: Schedule} +\author{FOSSEE Team} +\date{14, 15 December, 2009} + +\begin{document} + \maketitle + Day 1, 14 December, 2009 \\ + \begin{tabular}{| p{.35in} | p{2in} | p{1in} |} + \hline + Session & Title & Time \\\hline + 1 & Interactive Plotting & 09:30 - 10:30 \\\hline + 2 & Plotting experimental data & 10:35 - 11:35 \\\hline + & Tea Break & 11:35 - 11:50 \\\hline + 3 & Statistics & 11:55 - 12:55 \\\hline + & Lunch Break & 12:55 - 13:50 \\\hline + & Quiz 1 & 13:50 - 14:05 \\\hline + 4 & Matrices \& Least Square Fit & 14:10 - 15:10 \\\hline + 5 & Exercises & 15:15 - 16:15 \\\hline + & Tea Break & 16:15 - 16:30 \\\hline + 6 & Matrices \& Least Square Fit & 16:30 - 17:30 \\\hline + & Quiz 2 & 17:30 - 17:45 \\\hline + \end{tabular} + \vspace*{.5in} + \\ Day 2, 15 December, 2009 \\ + \begin{tabular}{| p{.35in} | p{2in} | p{1in} |} + \hline + Session & Title & Time \\\hline + 1 & Python language: Basics & 09:00 - 10:00 \\\hline + 2 & Python language: Data structures and functions & 10:05 - 11:05 \\\hline + & Tea Break & 11:05 - 11:20 \\\hline + 3 & Python language: Functions, modules and objects & 11:25 - 12:25 \\\hline + 4 & Python Development & 12:25 - 13:25 \\\hline + & Lunch Break & 13:25 - 14:20 \\\hline + & Quiz 3 & 14:20 - 14:40 \\\hline + 5 & Exercises & 14:40 - 15:40 \\\hline + & Tea Break & 15:40 - 16:00 \\\hline + 6 & Exercises contd \ldots & 16:00 - 16:30 \\\hline + \end{tabular} +\end{document} |