diff options
Diffstat (limited to 'day1')
-rw-r--r-- | day1/data/position.png | bin | 0 -> 28574 bytes | |||
-rw-r--r-- | day1/session1.tex | 46 | ||||
-rw-r--r-- | day1/session4.tex | 64 |
3 files changed, 78 insertions, 32 deletions
diff --git a/day1/data/position.png b/day1/data/position.png Binary files differnew file mode 100644 index 0000000..f4108bc --- /dev/null +++ b/day1/data/position.png diff --git a/day1/session1.tex b/day1/session1.tex index 3e12da9..8eb1226 100644 --- a/day1/session1.tex +++ b/day1/session1.tex @@ -215,11 +215,13 @@ In []: ylabel('sin(x)') \frametitle{Another example} \begin{lstlisting} In []: clf() +#Clears the plot area. In []: y = linspace(0, 2*pi, 51) In []: plot(y, sin(2*y)) In []: xlabel('y') In []: ylabel('sin(2y)') \end{lstlisting} +\emphbar{By default plots would be overlayed!} \end{frame} \begin{frame}[fragile] @@ -231,7 +233,6 @@ In []: ylabel('sin(2y)') In []: title('Sinusoids') #Sets the title of the figure In []: legend(['sin(2y)']) -# When no label, or to change \end{lstlisting} % \small % \end{block} @@ -243,30 +244,17 @@ In []: legend(['sin(2y)']) \begin{frame}[fragile] \frametitle{Changing Legend Placement} -\vspace*{-0.1in} -\begin{lstlisting} -In []: legend(['sin(2y)'], loc=(.8,.1)) -#(x,y) is position of lower-left -#corner of legend box. -\end{lstlisting} -%\vspace*{-0.2in} -\begin{center} - \includegraphics[height=2in, interpolate=true]{data/loc} -\end{center} -\end{frame} - -\begin{frame}[fragile] -\frametitle{Changing Legend Placement} \begin{columns} \column{0.6\textwidth} \begin{block}{} \small \begin{lstlisting} In []: legend(['sin(2y)'], - loc='right') + loc='center') \end{lstlisting} \small \end{block} + \includegraphics[height=2in, interpolate=true]{data/position} \column{0.45\textwidth} \vspace{-0.2in} \begin{lstlisting} @@ -287,6 +275,19 @@ Location String \end{columns} \end{frame} +\begin{frame}[fragile] +\frametitle{For placing legend at $(x,y)$} +\vspace*{-0.1in} +\begin{lstlisting} +In []: legend(['sin(2y)'], loc=(.8,.1)) +#(x,y) is position of lower-left +#corner of legend box. +\end{lstlisting} +%\vspace*{-0.2in} +\begin{center} + \includegraphics[height=2in, interpolate=true]{data/loc} +\end{center} +\end{frame} \begin{frame}[fragile] \frametitle{Saving \& Closing} @@ -298,7 +299,7 @@ In []: close() \end{frame} \begin{frame}[fragile] -\frametitle{Multiple Figures} +\frametitle{Plotting seprate figures} \begin{lstlisting} In []: figure(1) In []: plot(y, sin(y)) @@ -359,7 +360,7 @@ In []: ylim(ymin, ymax) \begin{frame}[fragile] \frametitle{Review Problem} \begin{enumerate} -\item Plot x, -x, sin(x), xsin(x) in the range $-5\pi$ to $5\pi$ +\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 @@ -392,7 +393,14 @@ In []: ylim(5*pi, 5*pi) \end{lstlisting} } \end{frame} - +\begin{frame} + \frametitle{Things we have learned} + \begin{itemize} + \item Creating plots. + \item Handling labels and legends. + \item Changing properties of plot. + \end{itemize} +\end{frame} \begin{frame}[fragile] \begin{center} End of Session-1\\ diff --git a/day1/session4.tex b/day1/session4.tex index c01c20e..67988de 100644 --- a/day1/session4.tex +++ b/day1/session4.tex @@ -210,8 +210,59 @@ Example problem: Consider the set of equations \end{lstlisting} \end{frame} + \section{Integration} +\subsection{Quadrature} + +\begin{frame}[fragile] +\frametitle{Quadrature} +\begin{itemize} +\item We wish to find area under a curve +\item Area under $(sin(x) + x^2)$ in $(0,1)$ +\item scipy has functions to do that +\end{itemize} +\small{\typ{In []: from scipy.integrate import quad}} +\begin{itemize} +\item Inputs - function to integrate, limits +\end{itemize} +\begin{lstlisting} +In []: x = 0 +In []: integrate.quad(sin(x)+x**2, 0, 1) +\end{lstlisting} +\alert{\typ{error:}} +\typ{First argument must be a callable function.} +\end{frame} + +\begin{frame}[fragile] +\frametitle{Functions - Definition} +\begin{lstlisting} +In []: def f(x): + return sin(x)+x**2 +In []: integrate.quad(f, 0, 1) +\end{lstlisting} +\begin{itemize} +\item \typ{def} +\item arguments +\item \typ{return} +\end{itemize} +\end{frame} + +\begin{frame}[fragile] + \frametitle{More on functions} + \begin{itemize} + \item Support default and keyword arguments + \item Scope of variables in the function is local + \item Mutable items are \alert{passed by reference} + \item First line after definition may be a documentation string + (\alert{recommended!}) + \item Function definition and execution defines a name bound to the + function + \item You \emph{can} assign a variable to a function! + \end{itemize} +\end{frame} + + \subsection{ODEs} \begin{frame}[fragile] @@ -272,18 +323,5 @@ In []: pend_sol = odeint(pend_int, \end{lstlisting} \end{frame} -\subsection{Quadrature} - -\begin{frame}[fragile] -\frametitle{Quadrature} -Calculate the area under $(sin(x) + x^2)$ in the range $(0,1)$ -\small{\typ{In []: from scipy.integrate import quad}} - \begin{lstlisting} -In []: f(x): - return sin(x)+x**2 -In []: integrate.quad(f, 0, 1) - \end{lstlisting} -\end{frame} - \end{document} |