From ea33cd842392f392e17fc9624601ddb2edcfd31a Mon Sep 17 00:00:00 2001 From: Santosh G. Vattam Date: Wed, 11 Nov 2009 12:52:50 +0530 Subject: Updated session 1 of day 1. --- day1/session1.tex | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/day1/session1.tex b/day1/session1.tex index 125f823..61cc0d7 100644 --- a/day1/session1.tex +++ b/day1/session1.tex @@ -162,7 +162,7 @@ \begin{block}{Goal: Successful participants will be able to} \begin{itemize} \item Use Python as plotting, computational tool - \item Understand how Python can be used as a scripting and problem solving language. + \item Understand how to use Python as a scripting and problem solving language. \item Train students for the same \end{itemize} \end{block} @@ -186,6 +186,11 @@ \item \typ{sslc_allreg.py} \item \typ{sslc_science.py} \end{itemize} + \item Images + \begin{itemize} + \item \typ{lena.png} + \item \typ{smoothing.gif} + \end{itemize} \end{enumerate} \end{frame} @@ -290,7 +295,9 @@ In []: ylabel('sin(x)') \frametitle{Another example} \begin{lstlisting} In []: clf() -#Clears the plot area. + \end{lstlisting} +\emphbar{Clears the plot area.} + \begin{lstlisting} In []: y = linspace(0, 2*pi, 50) In []: plot(y, sin(2*y)) In []: xlabel('y') @@ -306,7 +313,6 @@ In []: ylabel('sin(2y)') % \small \begin{lstlisting} In []: title('Sinusoids') -#Sets the title of the figure In []: legend(['sin(2y)']) \end{lstlisting} % \small @@ -352,8 +358,8 @@ In []: legend(['sin(2y)'], loc = 'center') \vspace*{-0.1in} \begin{lstlisting} In []: legend(['sin(2y)'], loc=(.8,.1)) -# Specify south-east corner position \end{lstlisting} +\emphbar{Specify south-east corner position} %\vspace*{-0.2in} \begin{center} \includegraphics[height=2in, interpolate=true]{data/loc} @@ -406,7 +412,7 @@ In []: close() In []: plot(y, sin(y), 'g') In []: clf() -In []: plot(y, sin(y), 'g', linewidth=2) +In []: plot(y, cos(y), 'r', linewidth=2) \end{lstlisting} \vspace*{-0.2in} \begin{center} @@ -429,13 +435,14 @@ In []: annotate('local max', xy=(1.5, 1)) \begin{frame}[fragile] \frametitle{Axes lengths} +\emphbar{Get the axes limits} \begin{lstlisting} -#Get the axes limits In []: xmin, xmax = xlim() In []: ymin, ymax = ylim() - + \end{lstlisting} +\emphbar{Set the axes limits} + \begin{lstlisting} In []: xmax = 2*pi -#Set the axes limits In []: xlim(xmin, xmax) In []: ylim(ymin-0.2, ymax+0.2) \end{lstlisting} @@ -447,7 +454,7 @@ In []: ylim(ymin-0.2, ymax+0.2) \item Plot x, -x, sin(x), xsin(x) in range $-5\pi$ to $5\pi$ \item Add a legend \item Annotate the origin -\item Set axis limits to the range of x +\item Set axes limits to the range of x \end{enumerate} \begin{lstlisting} In []: x=linspace(-5*pi, 5*pi, 500) @@ -481,23 +488,28 @@ Save commands of review problem into file \item Identify the required line numbers \item Then, use \typ{\%save} command of IPython \end{itemize} -\begin{lstlisting} - In []: %hist - In []: %save four_plot.py 16 18-27 -\end{lstlisting} +\typ{In []: \%hist}\\ +\typ{In []: \%save four_plot.py} \alert{\typ{16 18-27}} +\begin{block}{Careful about errors!} + \kwrd{\%hist} will contain the errors as well,\\ + so be careful while selecting line numbers. +\end{block} \end{frame} \begin{frame} \frametitle{Python Scripts\ldots} This is called a Python Script. \begin{itemize} - \item run the script in IPython using \typ{\%run -i sine_plot.py}\\ + \item run the script in IPython using \typ{\%run -i four_plot.py}\\ \end{itemize} \end{frame} -\begin{frame} +\begin{frame}[fragile] \frametitle{What did we learn?} \begin{itemize} + \item \kwrd{\%hist} + \item Saving commands to a script + \item Running a script using \kwrd{\%run -i} \item Creating simple plots. \item Adding labels and legends. \item Annotating plots. -- cgit