day1/session2.tex
changeset 183 b34c3a22d726
parent 179 eea01ca072ff
child 188 15f29c7fd925
equal deleted inserted replaced
182:56ea84dfe38e 183:b34c3a22d726
    71 % }
    71 % }
    72 
    72 
    73 
    73 
    74 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    74 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    75 % Title page
    75 % Title page
    76 \title[Plotting using Python]{Plotting experimental data\\}
    76 \title[Plotting using Python]{Python for Science and Egg. Plotting experimental data}
    77 
    77 
    78 \author[FOSSEE] {FOSSEE}
    78 \author[FOSSEE] {FOSSEE}
    79 
    79 
    80 \institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
    80 \institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
    81 \date[] {31, October 2009\\Day 1, Session 2}
    81 \date[] {31, October 2009\\Day 1, Session 2}
   124 \end{frame}
   124 \end{frame}
   125 
   125 
   126 \begin{frame}
   126 \begin{frame}
   127 \frametitle{Why we didn't close the IPython??}
   127 \frametitle{Why we didn't close the IPython??}
   128 \begin{itemize}
   128 \begin{itemize}
   129   \item Because all the command history is lost
   129   \item IPython provides a convenient feature
   130   \item We can go back, edit, and re-execute our commands
   130   \item To go back, edit, and re-run commands
       
   131   \item But when you close, this is lost
   131 \end{itemize}
   132 \end{itemize}
   132 \end{frame}
   133 \end{frame}
   133 
   134 
   134 \begin{frame}
   135 \begin{frame}
   135 \frametitle{But its impractical..}
   136 \frametitle{But its impractical..}
   136 \begin{itemize}
   137 \begin{itemize}
   137   \item Because we can't always keep running the IPython shell for days
   138   \item We can't keep running the IPython shell for days
   138   \item And lets admit it, its a pain to go back and edit
   139   \item And its a pain to go back and edit
   139 \end{itemize}
   140 \end{itemize}
   140 And the solution is..\\
   141 And the solution is..\\
   141 \begin{center}
   142 \begin{center}
   142 \alert {\typ{Scripts!!}}
   143 \alert {\typ{Scripts!!}}
   143 \end{center}
   144 \end{center}
   144 \end{frame}
   145 \end{frame}
   145 
   146 
   146 \section{Creating and running scripts}
   147 \section{Scripts}
   147 \begin{frame}[fragile]
   148 \begin{frame}[fragile]
   148 \frametitle{Python Scripts}
   149 \frametitle{Python Scripts}
   149 \begin{itemize}
   150 \begin{itemize}
   150 \item Let us now put all the commands used in the review problem into a file. 
   151 \item Put all commands used in review problem into a file. 
   151 \item The following commands of IPython help us do this. 
   152 \item use hist command of IPython.
   152 \end{itemize}
   153 \end{itemize}
   153 \begin{lstlisting}
   154 \begin{lstlisting}
   154   In []: %hist
   155   In []: %hist
   155   In []: %hist -n
   156   In []: %hist -n
   156 \end{lstlisting}
   157 \end{lstlisting}
   167   \item run the file in IPython using \typ{\%run sine_plot.py}\\
   168   \item run the file in IPython using \typ{\%run sine_plot.py}\\
   168   \end{itemize}
   169   \end{itemize}
   169 \end{frame}
   170 \end{frame}
   170 
   171 
   171 \begin{frame}[fragile]
   172 \begin{frame}[fragile]
   172 \frametitle{How often do we plot analytical functions?}
   173   \frametitle{Why would I plot f(x)?}
   173 Let us look at a small example:
   174 How often do we plot analytical functions?\\We plot experimental data more.
   174 \begin{lstlisting}
   175 \begin{lstlisting}
   175 In []: x = [0, 1, 2, 3]
   176 In []: x = [0, 1, 2, 3]
   176 
   177 
   177 In []: y = [7, 11, 15, 19]
   178 In []: y = [7, 11, 15, 19]
   178 
   179 
   182 \end{frame}
   183 \end{frame}
   183 
   184 
   184 \begin{frame}[fragile]
   185 \begin{frame}[fragile]
   185 \frametitle{Plotting points}
   186 \frametitle{Plotting points}
   186 \begin{itemize}
   187 \begin{itemize}
   187 \item What if we want to plot points!
   188 \item What if we want to plot the points!
   188 \end{itemize}
   189 \end{itemize}
   189 \begin{lstlisting}
   190 \begin{lstlisting}
   190   In []: clf()
   191   In []: clf()
   191 
   192 
   192   In []: plot(L, TSq, 'o')
   193   In []: plot(L, TSq, 'o')
   208 \end{itemize}
   209 \end{itemize}
   209 \end{frame}
   210 \end{frame}
   210 
   211 
   211 \section{Lists}
   212 \section{Lists}
   212 \begin{frame}[fragile]
   213 \begin{frame}[fragile]
   213   \frametitle{How to create?}
   214   \frametitle{How to create the data?}
   214 What are \typ{x} and \typ{y} here??\\
   215 What are \typ{x} and \typ{y} here??\\
   215 \begin{center}
   216 \begin{center}
   216 \alert{\typ{lists!!}}
   217 \alert{\typ{lists!!}}
   217 \end{center}
   218 \end{center}
   218 \begin{lstlisting}
   219 \begin{lstlisting}
   284 In []: plot(L, TSq)
   285 In []: plot(L, TSq)
   285 Out[]: [<matplotlib.lines.Line2D object at 0xa5b05ac>]
   286 Out[]: [<matplotlib.lines.Line2D object at 0xa5b05ac>]
   286 \end{lstlisting}
   287 \end{lstlisting}
   287 \end{frame}
   288 \end{frame}
   288 
   289 
   289 \begin{frame}{New Concepts}
   290 
   290   \begin{itemize}
   291 \begin{frame}[fragile]
   291     \item lists
   292 \frametitle{More of \texttt{for}}
   292     \item \typ{for}
       
   293   \end{itemize}
       
   294 \end{frame}
       
   295 
       
   296 \begin{frame}[fragile]
       
   297 \frametitle{\texttt{for}}
       
   298 Used to iterate over lists\\ Let us look at another example.
   293 Used to iterate over lists\\ Let us look at another example.
   299 \begin{lstlisting}
   294 \begin{lstlisting}
   300 In []: lst = [1,2,3,4,5,6]
   295 In []: lst = [1,2,3,4,5,6]
   301 In []: for num in lst:
   296 In []: for num in lst:
   302  ....:     print num, num*num
   297  ....:     print num, num*num