diff options
author | Shantanu Choudhary | 2010-01-04 19:02:28 +0530 |
---|---|---|
committer | Shantanu Choudhary | 2010-01-04 19:02:28 +0530 |
commit | 0cac67f75c05d43c64c269c589b356a514428cc2 (patch) | |
tree | 559e6246d0e65a5b0f8fa81e535024af3e7032ea /day1 | |
parent | 04c772d6e467b97b941db712571e0c7547bebae9 (diff) | |
download | workshops-0cac67f75c05d43c64c269c589b356a514428cc2.tar.gz workshops-0cac67f75c05d43c64c269c589b356a514428cc2.tar.bz2 workshops-0cac67f75c05d43c64c269c589b356a514428cc2.zip |
Added changes to exercise session of day1.
Diffstat (limited to 'day1')
-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/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/points.png | bin | 0 -> 19613 bytes | |||
-rw-r--r-- | day1/data/smoothing.png | bin | 0 -> 200973 bytes | |||
-rw-r--r-- | day1/exercises.tex | 138 |
7 files changed, 127 insertions, 11 deletions
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/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/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/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 91310ef..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[] {14 December, 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} |