Manual merge of branches.
authorSantosh G. Vattam <vattam.santosh@gmail.com>
Tue, 27 Oct 2009 16:06:08 +0530
changeset 194 7288d3867df2
parent 193 a31b0e76c0fb (diff)
parent 189 baf196170c08 (current diff)
child 195 89e912d8c87f
Manual merge of branches.
day1/session2.tex
--- a/day1/session2.tex	Tue Oct 27 14:26:18 2009 +0530
+++ b/day1/session2.tex	Tue Oct 27 16:06:08 2009 +0530
@@ -170,7 +170,7 @@
 \end{frame}
 
 \begin{frame}[fragile]
-  \frametitle{Why would I plot f(x)?}
+\frametitle{Why would I plot f(x)?}
 How often do we plot analytical functions?\\We plot experimental data more.
 \begin{lstlisting}
 In []: x = [0, 1, 2, 3]
@@ -183,6 +183,12 @@
 \end{frame}
 
 \begin{frame}[fragile]
+\begin{figure}
+\includegraphics[width=3.5in]{data/straightline.png}
+\end{figure}
+\end{frame}
+
+\begin{frame}[fragile]
 \frametitle{Plotting points}
 \begin{itemize}
 \item What if we want to plot the points!
@@ -227,14 +233,14 @@
 \frametitle{Accessing elements of a list}
 \begin{lstlisting}
 In []: lst[0]+lst[1]+lst[-1]
-Out[]: 7
+Out[]: 8
 \end{lstlisting}
 \end{frame}
 
 \begin{frame}[fragile]
   \frametitle{List: Slicing}
   \begin{block}{Remember\ldots}
-	In []: lst = [1,2,3,4,5] 
+	\kwrd{In []: lst = [1,2,3,4,5]}
   \end{block}
 \alert{\typ{list[initial:final:step]}}
 \begin{lstlisting}
@@ -266,14 +272,43 @@
 \begin{frame}[fragile]
 \frametitle{Simple Pendulum - L and T}
 Let us look at a more realistic example of the Simple Pendulum experiment.
+\begin{center}
+\begin{small}
+\begin{tabular}{| l | c | r |}
+\hline
+L & T & T^2 \\ \hline
+0.1 & 0.6900 & \\ \hline
+0.2 & 0.8989 & \\ \hline
+0.3 & 1.1867 & \\ \hline
+0.4 & 1.2991 & \\ \hline
+0.5 & 1.4656 & \\ \hline
+0.6 & 1.5843 & \\ \hline
+0.7 & 1.7706 & \\ \hline
+0.8 & 1.8296 & \\ \hline
+0.9 & 1.9440 & \\ \hline
+\end{tabular}
+\end{small}\\
+\alert{$L$ \alpha $T^2$}
+\end{center}
 \end{frame}
 
 \begin{frame}[fragile]
-\frametitle{Plotting $L$ vs. $T^2$}
+\frametitle{Lets use lists}
+\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.69, 0.8989, 1.1867, 
+1.2991, 1.4656, 1.5843, 1.7706, 1.8296, 1.9440]
+\end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{Plotting $L$ vs $T^2$}
 \begin{itemize}
 \item We must square each of the values in T
 \item How to do it?
-\item T is a \kwrd{list} and we use a \kwrd{for} loop to iterate over it
+\item We use a \kwrd{for} loop to iterate over T
 \end{itemize}
 \end{frame}
 
@@ -288,12 +323,15 @@
 In []: plot(L, TSq)
 Out[]: [<matplotlib.lines.Line2D object at 0xa5b05ac>]
 \end{lstlisting}
+This gives the list \kwrd{TSq} which is the list of squares of T values.
 \end{frame}
 
-
 \begin{frame}[fragile]
 \frametitle{More of \texttt{for}}
-Used to iterate over lists\\ Let us look at another example.
+\begin{itemize}
+\item Used to iterate over lists
+\item Let us look at another example.
+\end{itemize}
 \begin{lstlisting}
 In []: lst = [1,2,3,4,5,6]
 In []: for num in lst:
@@ -309,6 +347,22 @@
 \end{frame}
 
 \begin{frame}[fragile]
+\frametitle{Whats unusual about the previous example??}
+\alert{Data is usually present in a file!} \\
+Lets look at the pendulum.txt file.
+\begin{lstlisting}
+cat data/pendulum.txt
+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
+\end{lstlisting}
+\ldots
+\end{frame}
+
+\begin{frame}[fragile]
 \frametitle{Reading pendulum.txt}
 \begin{itemize}
   \item We now wish to repeat the plot using the values from a file
@@ -347,14 +401,6 @@
 \end{lstlisting}
 \end{frame}
 
-\begin{frame}{New Concepts}
-  \begin{itemize}
-    \item File handling
-    \item Strings
-    \item Data-type conversion
-  \end{itemize}
-\end{frame}
-
 \begin{frame}[fragile]
   \frametitle{Reading files \ldots}
 \typ{In []: for line in open('pendulum.txt'):}
@@ -365,6 +411,7 @@
 \end{itemize}
 \end{frame}
 
+\section{Strings}
 \begin{frame}[fragile]
 \frametitle{Strings}
 Anything within ``quotes'' is a string!
@@ -410,10 +457,24 @@
 
 \begin{frame}[fragile]
 \begin{figure}
-%\includegraphics[width=3.5in]{data/L-Tsq.png}
+\includegraphics[width=3.5in]{data/L-Tsq.png}
 \end{figure}
 \vspace{-0.2in}
 Coming up - \alert{Least Square Fit \ldots}
 \end{frame}
 
+\section {Summary}
+\begin{frame}
+\frametitle{Summary}
+So what did we learn in this session??
+\begin{itemize}
+  \item Creating and running Python scripts
+  \item Plotting points and Plotting attributes
+  \item Lists
+  \item \kwrd{for}
+  \item Reading files
+  \item Strings
+\end{itemize}
+\end{frame}
+
 \end{document}