day1/session1.tex
changeset 303 26f5e864a135
parent 293 f7d7b5565232
child 307 be62ebb11407
equal deleted inserted replaced
301:49bdffe4dca5 303:26f5e864a135
   160   \end{block}  
   160   \end{block}  
   161 
   161 
   162   \begin{block}{Goal: Successful participants will be able to}
   162   \begin{block}{Goal: Successful participants will be able to}
   163     \begin{itemize}
   163     \begin{itemize}
   164       \item Use Python as plotting, computational tool
   164       \item Use Python as plotting, computational tool
   165       \item Understand how Python can be used as a scripting and problem solving language.
   165       \item Understand how to use Python as a scripting and problem solving language.
   166       \item Train students for the same
   166       \item Train students for the same
   167     \end{itemize}
   167     \end{itemize}
   168   \end{block}
   168   \end{block}
   169 \end{frame}
   169 \end{frame}
   170 
   170 
   184     \item Python scripts: 
   184     \item Python scripts: 
   185       \begin{itemize}
   185       \begin{itemize}
   186       \item \typ{sslc_allreg.py}
   186       \item \typ{sslc_allreg.py}
   187       \item \typ{sslc_science.py}
   187       \item \typ{sslc_science.py}
   188       \end{itemize}
   188       \end{itemize}
       
   189     \item Images
       
   190       \begin{itemize}
       
   191       \item \typ{lena.png}
       
   192       \item \typ{smoothing.gif}
       
   193       \end{itemize}
   189   \end{enumerate}
   194   \end{enumerate}
   190 \end{frame}
   195 \end{frame}
   191 
   196 
   192 \begin{frame}[fragile]
   197 \begin{frame}[fragile]
   193 \frametitle{Starting up \ldots}
   198 \frametitle{Starting up \ldots}
   288 
   293 
   289 \begin{frame}[fragile]
   294 \begin{frame}[fragile]
   290 \frametitle{Another example}
   295 \frametitle{Another example}
   291   \begin{lstlisting}
   296   \begin{lstlisting}
   292 In []: clf()
   297 In []: clf()
   293 #Clears the plot area.
   298   \end{lstlisting}
       
   299 \emphbar{Clears the plot area.}
       
   300   \begin{lstlisting}
   294 In []: y = linspace(0, 2*pi, 50)
   301 In []: y = linspace(0, 2*pi, 50)
   295 In []: plot(y, sin(2*y))
   302 In []: plot(y, sin(2*y))
   296 In []: xlabel('y')
   303 In []: xlabel('y')
   297 In []: ylabel('sin(2y)')
   304 In []: ylabel('sin(2y)')
   298   \end{lstlisting}
   305   \end{lstlisting}
   304 \vspace*{-0.15in}
   311 \vspace*{-0.15in}
   305 %  \begin{block}{}
   312 %  \begin{block}{}
   306 %  \small
   313 %  \small
   307 \begin{lstlisting}
   314 \begin{lstlisting}
   308 In []: title('Sinusoids')
   315 In []: title('Sinusoids')
   309 #Sets the title of the figure
       
   310 In []: legend(['sin(2y)'])
   316 In []: legend(['sin(2y)'])
   311 \end{lstlisting}
   317 \end{lstlisting}
   312 %  \small
   318 %  \small
   313 %  \end{block}
   319 %  \end{block}
   314   \vspace*{-0.1in}
   320   \vspace*{-0.1in}
   350 \begin{frame}[fragile]
   356 \begin{frame}[fragile]
   351   \frametitle{For arbitrary location}
   357   \frametitle{For arbitrary location}
   352 \vspace*{-0.1in}
   358 \vspace*{-0.1in}
   353 \begin{lstlisting}
   359 \begin{lstlisting}
   354 In []: legend(['sin(2y)'], loc=(.8,.1)) 
   360 In []: legend(['sin(2y)'], loc=(.8,.1)) 
   355 # Specify south-east corner position
   361 \end{lstlisting}
   356 \end{lstlisting}
   362 \emphbar{Specify south-east corner position}
   357 %\vspace*{-0.2in}
   363 %\vspace*{-0.2in}
   358 \begin{center}
   364 \begin{center}
   359   \includegraphics[height=2in, interpolate=true]{data/loc}  
   365   \includegraphics[height=2in, interpolate=true]{data/loc}  
   360 \end{center}
   366 \end{center}
   361 %\inctime{10}
   367 %\inctime{10}
   404 \vspace{-0.15in}
   410 \vspace{-0.15in}
   405 \begin{lstlisting}
   411 \begin{lstlisting}
   406 In []: plot(y, sin(y), 'g')
   412 In []: plot(y, sin(y), 'g')
   407 
   413 
   408 In []: clf()
   414 In []: clf()
   409 In []: plot(y, sin(y), 'g', linewidth=2)
   415 In []: plot(y, cos(y), 'r', linewidth=2)
   410 \end{lstlisting}
   416 \end{lstlisting}
   411 \vspace*{-0.2in}
   417 \vspace*{-0.2in}
   412 \begin{center}
   418 \begin{center}
   413   \includegraphics[height=2.2in, interpolate=true]{data/green}  
   419   \includegraphics[height=2.2in, interpolate=true]{data/green}  
   414 \end{center}
   420 \end{center}
   427 \end{center}
   433 \end{center}
   428 \end{frame}
   434 \end{frame}
   429 
   435 
   430 \begin{frame}[fragile]
   436 \begin{frame}[fragile]
   431 \frametitle{Axes lengths}
   437 \frametitle{Axes lengths}
       
   438 \emphbar{Get the axes limits}
   432   \begin{lstlisting}
   439   \begin{lstlisting}
   433 #Get the axes limits
       
   434 In []: xmin, xmax = xlim() 
   440 In []: xmin, xmax = xlim() 
   435 In []: ymin, ymax = ylim() 
   441 In []: ymin, ymax = ylim() 
   436 
   442   \end{lstlisting}
       
   443 \emphbar{Set the axes limits}
       
   444   \begin{lstlisting}
   437 In []: xmax = 2*pi
   445 In []: xmax = 2*pi
   438 #Set the axes limits
       
   439 In []: xlim(xmin, xmax) 
   446 In []: xlim(xmin, xmax) 
   440 In []: ylim(ymin-0.2, ymax+0.2) 
   447 In []: ylim(ymin-0.2, ymax+0.2) 
   441   \end{lstlisting}
   448   \end{lstlisting}
   442 \end{frame}
   449 \end{frame}
   443 
   450 
   445 \frametitle{Review Problem}
   452 \frametitle{Review Problem}
   446 \begin{enumerate}
   453 \begin{enumerate}
   447 \item Plot x, -x, sin(x), xsin(x) in range $-5\pi$ to $5\pi$
   454 \item Plot x, -x, sin(x), xsin(x) in range $-5\pi$ to $5\pi$
   448 \item Add a legend
   455 \item Add a legend
   449 \item Annotate the origin
   456 \item Annotate the origin
   450 \item Set axis limits to the range of x
   457 \item Set axes limits to the range of x
   451 \end{enumerate}
   458 \end{enumerate}
   452 \begin{lstlisting}
   459 \begin{lstlisting}
   453 In []: x=linspace(-5*pi, 5*pi, 500)
   460 In []: x=linspace(-5*pi, 5*pi, 500)
   454 In []: plot(x, x, 'b')
   461 In []: plot(x, x, 'b')
   455 In []: plot(x, -x, 'b')
   462 In []: plot(x, -x, 'b')
   479 \begin{itemize}
   486 \begin{itemize}
   480 \item Use \typ{\%hist} command of IPython 
   487 \item Use \typ{\%hist} command of IPython 
   481 \item Identify the required line numbers
   488 \item Identify the required line numbers
   482 \item Then, use \typ{\%save} command of IPython
   489 \item Then, use \typ{\%save} command of IPython
   483 \end{itemize}
   490 \end{itemize}
   484 \begin{lstlisting}
   491 \typ{In []: \%hist}\\
   485   In []: %hist
   492 \typ{In []: \%save four_plot.py} \alert{\typ{16 18-27}} 
   486   In []: %save four_plot.py 16 18-27
   493 \begin{block}{Careful about errors!}
   487 \end{lstlisting}
   494   \kwrd{\%hist} will contain the errors as well,\\
       
   495   so be careful while selecting line numbers.
       
   496 \end{block}
   488 \end{frame}
   497 \end{frame}
   489 
   498 
   490 \begin{frame}
   499 \begin{frame}
   491 \frametitle{Python Scripts\ldots}
   500 \frametitle{Python Scripts\ldots}
   492  This is called a Python Script.
   501  This is called a Python Script.
   493  \begin{itemize}
   502  \begin{itemize}
   494  \item run the script in IPython using \typ{\%run -i sine_plot.py}\\
   503  \item run the script in IPython using \typ{\%run -i four_plot.py}\\
   495  \end{itemize}
   504  \end{itemize}
   496 \end{frame}
   505 \end{frame}
   497 
   506 
   498 \begin{frame}
   507 \begin{frame}[fragile]
   499   \frametitle{What did we learn?}
   508   \frametitle{What did we learn?}
   500   \begin{itemize}
   509   \begin{itemize}
       
   510     \item \kwrd{\%hist}
       
   511     \item Saving commands to a script
       
   512     \item Running a script using \kwrd{\%run -i}
   501     \item Creating simple plots.
   513     \item Creating simple plots.
   502     \item Adding labels and legends.
   514     \item Adding labels and legends.
   503     \item Annotating plots.
   515     \item Annotating plots.
   504     \item Changing the looks: size, linewidth
   516     \item Changing the looks: size, linewidth
   505   \end{itemize}
   517   \end{itemize}