summaryrefslogtreecommitdiff
path: root/day1
diff options
context:
space:
mode:
authorSantosh G. Vattam2010-02-22 14:32:01 +0530
committerSantosh G. Vattam2010-02-22 14:32:01 +0530
commit8314fd8a789bf5d67bc373ebeb654028288e1d59 (patch)
tree22f1f627128fa23605fec14b5eb939604944fcc3 /day1
parenta92f17cc899afd79a18f90523e0769cd5d07c5d0 (diff)
downloadworkshops-more-scipy-8314fd8a789bf5d67bc373ebeb654028288e1d59.tar.gz
workshops-more-scipy-8314fd8a789bf5d67bc373ebeb654028288e1d59.tar.bz2
workshops-more-scipy-8314fd8a789bf5d67bc373ebeb654028288e1d59.zip
Commits from NIT DGP and IITK
Diffstat (limited to 'day1')
-rw-r--r--day1/day1quiz1.tex1
-rw-r--r--day1/day1quiz2.tex2
-rw-r--r--day1/session1.tex111
-rw-r--r--day1/session2.tex45
-rw-r--r--day1/session3.tex4
-rw-r--r--day1/session4.tex19
-rw-r--r--day1/session5.tex4
-rwxr-xr-xday1/session6.tex2
8 files changed, 155 insertions, 33 deletions
diff --git a/day1/day1quiz1.tex b/day1/day1quiz1.tex
index f3a7bf4..331eb57 100644
--- a/day1/day1quiz1.tex
+++ b/day1/day1quiz1.tex
@@ -74,6 +74,7 @@ Describe the plot produced by the following:
In []: x = linspace(0, 2*pi, 50)
In []: plot(x, cos(x), 'go')
\end{lstlisting}
+Note: Do not draw it, just describe the plot
\end{frame}
\begin{frame}
diff --git a/day1/day1quiz2.tex b/day1/day1quiz2.tex
index 539e1e5..64bc265 100644
--- a/day1/day1quiz2.tex
+++ b/day1/day1quiz2.tex
@@ -35,7 +35,7 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Title page
-\title[Basic Python]{Python for science and engineering: Day 1, Quiz 2}
+\title[Basic Python]{Python for science and engineering: Day 2, Quiz 1}
\author[FOSSEE Team] {FOSSEE}
diff --git a/day1/session1.tex b/day1/session1.tex
index 309e890..426b9e8 100644
--- a/day1/session1.tex
+++ b/day1/session1.tex
@@ -77,7 +77,7 @@
\author[FOSSEE] {FOSSEE}
\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
-\date[] {28 January, 2010\\Day 1, Session 1}
+\date[] {12 February, 2010\\Day 1, Session 1}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\pgfdeclareimage[height=0.75cm]{iitmlogo}{iitmlogo}
@@ -123,6 +123,65 @@
%% \end{frame}
\begin{frame}
+ \frametitle{Workshop Schedule: Day 1}
+ \begin{description}
+ \item[Session 1] Fri 14:00--15:00
+ \item[Session 2] Fri 15:05--16:05
+ \item[Session 3] Fri 16:10--17:10
+ \item[Quiz 1] Fri 17:10--17:25
+ \item[Exercises] Thu 17:30--18:00
+ \end{description}
+\end{frame}
+
+\begin{frame}
+ \frametitle{Workshop Schedule: Day 2}
+ \begin{description}
+ \item[Session 1] Sat 09:00--10:00
+ \item[Session 2] Sat 10:05--11:05
+ \item[Session 3] Sat 11:20--12:20
+ \item[Quiz 2] Fri 14:25--14:40
+ \end{description}
+\end{frame}
+
+\begin{frame}
+ \frametitle{Workshop Schedule: Day 3}
+ \begin{description}
+ \item[Session 1] Sun 09:00--10:00
+ \item[Session 2] Sun 10:05--11:05
+ \item[Session 3] Sun 11:20--12:20
+ \item[Quiz 3] Sun 12:20--12:30
+ \item[Exercises] Sun 12:30--13:00
+ \end{description}
+\end{frame}
+
+\section{Checklist}
+\begin{frame}
+\frametitle{Checklist}
+ \begin{enumerate}
+ \item IPython
+ \item Editor
+ \item Data files:
+ \begin{itemize}
+ \item \typ{sslc1.txt}
+ \item \typ{pendulum.txt}
+ \item \typ{points.txt}
+ \item \typ{pos.txt}
+ \item \typ{holmes.txt}
+ \end{itemize}
+ \item Python scripts:
+ \begin{itemize}
+ \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}
+
+\begin{frame}
\frametitle{About the Workshop}
\begin{block}{Intended Audience}
\begin{itemize}
@@ -140,6 +199,40 @@
\end{block}
\end{frame}
+\section{Starting up Ipython}
+\begin{frame}[fragile]
+\frametitle{Starting up \ldots}
+\begin{block}{}
+\begin{lstlisting}
+ $ ipython -pylab
+\end{lstlisting} %$
+\end{block}
+\begin{lstlisting}
+ In []: print "Hello, World!"
+ Hello, World!
+\end{lstlisting}
+Exiting
+\begin{lstlisting}
+ In []: ^D(Ctrl-D)
+ Do you really want to exit([y]/n)? y
+\end{lstlisting}
+\end{frame}
+
+\section{Loops}
+\begin{frame}[fragile]
+\frametitle{Loops}
+Breaking out of loops
+\begin{lstlisting}
+ In []: while True:
+ ...: print "Hello, World!"
+ ...:
+ Hello, World!
+ Hello, World!^C(Ctrl-C)
+ ------------------------------------
+ KeyboardInterrupt
+\end{lstlisting}
+\end{frame}
+
\section{Plotting}
\subsection{Drawing plots}
\begin{frame}[fragile]
@@ -301,8 +394,10 @@ In []: figure(1)
In []: plot(y, sin(y))
In []: figure(2)
In []: plot(y, cos(y))
+In []: savefig('cosine.png')
In []: figure(1)
In []: title('sin(y)')
+In []: savefig('sine.png')
In []: close()
In []: close()
\end{lstlisting}
@@ -312,10 +407,10 @@ In []: close()
\frametitle{Showing it better}
\vspace{-0.15in}
\begin{lstlisting}
-In []: plot(y, sin(y), 'g')
+In []: plot(y, cos(y), 'r')
In []: clf()
-In []: plot(y, cos(y), 'r', linewidth=2)
+In []: plot(y, sin(y), 'g', linewidth=2)
\end{lstlisting}
\vspace*{-0.2in}
\begin{center}
@@ -345,8 +440,7 @@ In []: ymin, ymax = ylim()
\end{lstlisting}
\emphbar{Set the axes limits}
\begin{lstlisting}
-In []: xmax = 2*pi
-In []: xlim(xmin, xmax)
+In []: xlim(xmin, 2*pi)
In []: ylim(ymin-0.2, ymax+0.2)
\end{lstlisting}
\end{frame}
@@ -398,9 +492,9 @@ In []: ylim(-5*pi, 5*pi)
\frametitle{Saving Commands}
Save commands of review problem into file
\begin{itemize}
-\item Use \typ{\%hist} command of IPython (Recall \%\typ{hist} from the previous session)
+\item Use \typ{\%hist} command of IPython
\item Identify the required line numbers
-\item Then, use \typ{\%save} command of IPython (Recall \%\typ{save} from the previous session)
+\item Then, use \typ{\%save} command of IPython
\end{itemize}
\typ{In []: \%hist}\\
\typ{In []: \%save four_plot.py} \alert{\typ{16 18-27}}
@@ -421,6 +515,9 @@ Save commands of review problem into file
\begin{frame}[fragile]
\frametitle{What did we learn?}
\begin{itemize}
+ \item Starting up IPython
+ \item \kwrd{\%hist} - History of commands
+ \item \kwrd{\%save} - Saving commands
\item Running a script using \kwrd{\%run -i}
\item Creating simple plots.
\item Adding labels and legends.
diff --git a/day1/session2.tex b/day1/session2.tex
index fb2e128..2e493e4 100644
--- a/day1/session2.tex
+++ b/day1/session2.tex
@@ -78,7 +78,7 @@
\author[FOSSEE] {FOSSEE}
\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
-\date[] {28 January, 2010\\Day 1, Session 2}
+\date[] {12 February, 2010\\Day 1, Session 2}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\pgfdeclareimage[height=0.75cm]{iitmlogo}{iitmlogo}
@@ -208,43 +208,45 @@ In []: mtlist = []
\end{lstlisting}
\emphbar{Empty List}
\begin{lstlisting}
-In []: a = [ 1, 2, 3, 4, 5]
+In []: p = [ 2, 3, 5, 7]
-In []: a[0]+a[1]+a[-1]
-Out[]: 8
+In []: p[0]+p[1]+p[-1]
+Out[]: 12
\end{lstlisting}
\end{frame}
\begin{frame}[fragile]
\frametitle{List: Slicing}
\begin{block}{Remember\ldots}
- \kwrd{In []: a = [ 1, 2, 3, 4, 5]}
+ \kwrd{In []: p = [ 2, 3, 5, 7]}
\end{block}
\begin{lstlisting}
-In []: a[1:3]
-Out[]: [2, 3]
+In []: p[1:3]
+Out[]: [3, 5]
\end{lstlisting}
\emphbar{A slice}
\begin{lstlisting}
-In []: a[1:-1]
-Out[]: [2, 3, 4]
+In []: p[0:-1]
+Out[]: [2, 3, 5]
+In []: p[::2]
+Out[]: [2, 5]
\end{lstlisting}
-\alert{\typ{list[initial:final]}}
+\alert{\typ{list[initial:final:step]}}
\end{frame}
%% more on list slicing
\begin{frame}[fragile]
\frametitle{List operations}
\begin{lstlisting}
-In []: b = [ 6, 7, 8, 9]
-In []: c = a + b
+In []: b = [ 11, 13, 17]
+In []: c = p + b
In []: c
-Out[]: [1, 2, 3, 4, 5, 6, 7, 8, 9]
+Out[]: [2, 3, 5, 7, 11, 13, 17]
-In []: a.append(6)
-In []: a
-Out[]: [ 1, 2, 3, 4, 5, 6]
+In []: p.append(11)
+In []: p
+Out[]: [ 2, 3, 5, 7, 11]
\end{lstlisting}
%\inctime{10}
\end{frame}
@@ -299,6 +301,12 @@ In []: t = [0.69, 0.90, 1.19,
\begin{lstlisting}
In []: tsq = []
+In []: len(l)
+Out[]: 9
+
+In []: len(t)
+Out[]: 9
+
In []: for time in t:
....: tsq.append(time*time)
....:
@@ -312,14 +320,15 @@ This gives \kwrd{tsq} which is the list of squares of \typ{t} values.
\begin{frame}[fragile]
\frametitle{How to come out of the \texttt{for} loop?}
- Recall that hitting the ``ENTER'' key twice returns the cursor to the previous indentation level
+ Hitting the ``ENTER'' key twice returns the cursor to the previous indentation level
\begin{lstlisting}
In []: for time in t:
....: tsq.append(time*time)
....:
....:
- In []: print tsq
+ In []: print tsq, len(tsq)
+ In []: plot(l, tsq)
\end{lstlisting}
\end{frame}
diff --git a/day1/session3.tex b/day1/session3.tex
index e785729..49e5773 100644
--- a/day1/session3.tex
+++ b/day1/session3.tex
@@ -79,7 +79,7 @@
\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
-\date[] {28 January, 2010\\Day 1, Session 3}
+\date[] {12 February, 2010\\Day 1, Session 3}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\pgfdeclareimage[height=0.75cm]{iitmlogo}{iitmlogo}
@@ -319,7 +319,7 @@ science = {}
\end{lstlisting}
\begin{itemize}
\item Keys will be region codes
- \item Values will be the number students who scored more than 90\% in that region
+ \item Values will be the number students who scored more than 90\% in that region in Science
\end{itemize}
\begin{block}{Sample \emph{science} dictionary}
\{'A': 729, 'C': 764, 'B': 1120,'E': 414, 'D': 603, 'F': 500\}
diff --git a/day1/session4.tex b/day1/session4.tex
index 89e5e00..9cf0768 100644
--- a/day1/session4.tex
+++ b/day1/session4.tex
@@ -79,7 +79,7 @@
\author[FOSSEE] {FOSSEE}
\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
-\date[] {28 January, 2010\\Day 1, Session 4}
+\date[] {13 February, 2010\\Day 2, Session 1}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\pgfdeclareimage[height=0.75cm]{iitmlogo}{iitmlogo}
@@ -279,6 +279,21 @@ array([[11, 13],
\end{frame}
\begin{frame}[fragile]
+ \frametitle{Shape of a matrix}
+ \begin{lstlisting}
+In []: c
+Out[]:
+array([[11, 12, 13],
+ [ 0, 0, 0],
+ [31, 32, 33]])
+
+In []: c.shape
+Out[]: (3, 3)
+ \end{lstlisting}
+\emphbar{Shape specifies shape or dimensions of a matrix}
+\end{frame}
+
+\begin{frame}[fragile]
\frametitle{Slicing \& Striding Exercises}
\begin{small}
\begin{lstlisting}
@@ -518,7 +533,7 @@ Out[]: array([-1., 8., -1.])
\begin{frame}[fragile]
\frametitle{Getting $L$ and $T^2$}
-If you \alert{closed} IPython after session 2
+%If you \alert{closed} IPython after session 2
\begin{lstlisting}
In []: l = []
In []: t = []
diff --git a/day1/session5.tex b/day1/session5.tex
index 791b393..4f51519 100644
--- a/day1/session5.tex
+++ b/day1/session5.tex
@@ -78,7 +78,7 @@
\author[FOSSEE] {FOSSEE}
\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
-\date[] {28 January, 2010\\Day 1, Session 5}
+\date[] {12 February, 2010\\Day 1, Session 5}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\pgfdeclareimage[height=0.75cm]{iitmlogo}{iitmlogo}
@@ -189,7 +189,7 @@ In []: plot(x, exp(x/10)*sin(x))
\begin{frame}[fragile]
\frametitle{Problem 3 cont...}
-Create a sequence of images in which the damped oscillator($e^{x/10}sin(x)$) slowly evolves over time.
+Create a sequence of images in which the damped oscillator($e^{-x/10}sin(x)$) slowly evolves over time.
\begin{columns}
\column{0.35\textwidth}
\includegraphics[width=1.5in,height=1.5in, interpolate=true]{data/plot2}
diff --git a/day1/session6.tex b/day1/session6.tex
index 6ef775f..85ff042 100755
--- a/day1/session6.tex
+++ b/day1/session6.tex
@@ -78,7 +78,7 @@
\author[FOSSEE] {FOSSEE}
\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
-\date[] {28 January, 2010\\Day 1, Session 6}
+\date[] {13 February, 2010\\Day 2, Session 2}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\pgfdeclareimage[height=0.75cm]{iitmlogo}{iitmlogo}