day1/session2.tex
author Shantanu <shantanu@fossee.in>
Fri, 23 Oct 2009 16:16:10 +0530
changeset 155 069a9aed1027
parent 153 dc0da25b788b
child 156 6a1388c456f4
child 158 978108b0c02c
permissions -rw-r--r--
Merged branch with puneeth's branch.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
109
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
     1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
     2
%Tutorial slides on Python.
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
     3
%
153
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
     4
% Author: FOSSEE
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
     5
% Copyright (c) 2009, FOSSEE, IIT Bombay
109
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
     6
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
     7
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
     8
\documentclass[14pt,compress]{beamer}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
     9
%\documentclass[draft]{beamer}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    10
%\documentclass[compress,handout]{beamer}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    11
%\usepackage{pgfpages} 
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    12
%\pgfpagesuselayout{2 on 1}[a4paper,border shrink=5mm]
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    13
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    14
% Modified from: generic-ornate-15min-45min.de.tex
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    15
\mode<presentation>
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    16
{
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    17
  \usetheme{Warsaw}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    18
  \useoutertheme{split}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    19
  \setbeamercovered{transparent}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    20
}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    21
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    22
\usepackage[english]{babel}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    23
\usepackage[latin1]{inputenc}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    24
%\usepackage{times}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    25
\usepackage[T1]{fontenc}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    26
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    27
% Taken from Fernando's slides.
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    28
\usepackage{ae,aecompl}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    29
\usepackage{mathpazo,courier,euler}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    30
\usepackage[scaled=.95]{helvet}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    31
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    32
\definecolor{darkgreen}{rgb}{0,0.5,0}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    33
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    34
\usepackage{listings}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    35
\lstset{language=Python,
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    36
    basicstyle=\ttfamily\bfseries,
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    37
    commentstyle=\color{red}\itshape,
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    38
  stringstyle=\color{darkgreen},
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    39
  showstringspaces=false,
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    40
  keywordstyle=\color{blue}\bfseries}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    41
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    42
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    43
% Macros
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    44
\setbeamercolor{emphbar}{bg=blue!20, fg=black}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    45
\newcommand{\emphbar}[1]
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    46
{\begin{beamercolorbox}[rounded=true]{emphbar} 
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    47
      {#1}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    48
 \end{beamercolorbox}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    49
}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    50
\newcounter{time}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    51
\setcounter{time}{0}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    52
\newcommand{\inctime}[1]{\addtocounter{time}{#1}{\tiny \thetime\ m}}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    53
130
8905a5badd7e Minor edits to day1 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 118
diff changeset
    54
\newcommand{\typ}[1]{\lstinline{#1}}
109
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    55
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    56
\newcommand{\kwrd}[1]{ \texttt{\textbf{\color{blue}{#1}}}  }
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    57
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    58
%%% This is from Fernando's setup.
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    59
% \usepackage{color}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    60
% \definecolor{orange}{cmyk}{0,0.4,0.8,0.2}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    61
% % Use and configure listings package for nicely formatted code
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    62
% \usepackage{listings}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    63
% \lstset{
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    64
%    language=Python,
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    65
%    basicstyle=\small\ttfamily,
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    66
%    commentstyle=\ttfamily\color{blue},
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    67
%    stringstyle=\ttfamily\color{orange},
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    68
%    showstringspaces=false,
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    69
%    breaklines=true,
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    70
%    postbreak = \space\dots
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    71
% }
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    72
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    73
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    74
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    75
% Title page
144
0407ddc37038 Updated session 2, day 1 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 134
diff changeset
    76
\title[Plotting using Python]{Plotting experimental data\\}
109
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    77
153
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
    78
\author[FOSSEE] {FOSSEE}
109
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    79
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    80
\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    81
\date[] {31, October 2009\\Day 1, Session 2}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    82
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    83
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    84
%\pgfdeclareimage[height=0.75cm]{iitmlogo}{iitmlogo}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    85
%\logo{\pgfuseimage{iitmlogo}}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    86
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    87
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    88
%% Delete this, if you do not want the table of contents to pop up at
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    89
%% the beginning of each subsection:
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    90
\AtBeginSubsection[]
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    91
{
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    92
  \begin{frame}<beamer>
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    93
    \frametitle{Outline}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    94
    \tableofcontents[currentsection,currentsubsection]
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    95
  \end{frame}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    96
}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    97
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    98
\AtBeginSection[]
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    99
{
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   100
  \begin{frame}<beamer>
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   101
    \frametitle{Outline}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   102
    \tableofcontents[currentsection,currentsubsection]
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   103
  \end{frame}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   104
}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   105
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   106
% If you wish to uncover everything in a step-wise fashion, uncomment
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   107
% the following command: 
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   108
%\beamerdefaultoverlayspecification{<+->}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   109
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   110
%\includeonlyframes{current,current1,current2,current3,current4,current5,current6}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   111
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   112
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   113
% DOCUMENT STARTS
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   114
\begin{document}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   115
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   116
\begin{frame}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   117
  \titlepage
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   118
\end{frame}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   119
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   120
\begin{frame}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   121
  \frametitle{Outline}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   122
  \tableofcontents
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   123
  % You might wish to add the option [pausesections]
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   124
\end{frame}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   125
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   126
\section{Creating and running scripts}
151
55c22520ff5e Added IPython history to Day1 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 146
diff changeset
   127
\begin{frame}[fragile]
55c22520ff5e Added IPython history to Day1 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 146
diff changeset
   128
\frametitle{Python Scripts}
55c22520ff5e Added IPython history to Day1 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 146
diff changeset
   129
\begin{itemize}
55c22520ff5e Added IPython history to Day1 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 146
diff changeset
   130
\item Let us now put all the commands used in the review problem into a file. 
55c22520ff5e Added IPython history to Day1 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 146
diff changeset
   131
\item The following commands of IPython help us do this. 
55c22520ff5e Added IPython history to Day1 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 146
diff changeset
   132
\end{itemize}
55c22520ff5e Added IPython history to Day1 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 146
diff changeset
   133
\begin{lstlisting}
55c22520ff5e Added IPython history to Day1 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 146
diff changeset
   134
  In []: %hist
55c22520ff5e Added IPython history to Day1 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 146
diff changeset
   135
  In []: %hist -n
55c22520ff5e Added IPython history to Day1 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 146
diff changeset
   136
\end{lstlisting}
55c22520ff5e Added IPython history to Day1 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 146
diff changeset
   137
\end{frame}
55c22520ff5e Added IPython history to Day1 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 146
diff changeset
   138
109
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   139
\begin{frame}
151
55c22520ff5e Added IPython history to Day1 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 146
diff changeset
   140
\frametitle{Python Scripts\ldots}
109
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   141
  \begin{itemize}
151
55c22520ff5e Added IPython history to Day1 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 146
diff changeset
   142
    \item Open a new file in an \alert{editor}
55c22520ff5e Added IPython history to Day1 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 146
diff changeset
   143
    \item Copy and paste required lines from the output of \typ{\%hist -n}
55c22520ff5e Added IPython history to Day1 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 146
diff changeset
   144
    \item Save the file as \typ{first_plot.py}
109
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   145
  \end{itemize}
151
55c22520ff5e Added IPython history to Day1 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 146
diff changeset
   146
  \begin{itemize}
55c22520ff5e Added IPython history to Day1 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 146
diff changeset
   147
  \item run the file in IPython using \typ{\%run first_plot.py}\\
55c22520ff5e Added IPython history to Day1 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 146
diff changeset
   148
  \end{itemize}
109
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   149
\end{frame}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   150
153
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   151
\section{Plotting Points}
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   152
\begin{frame}[fragile]
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   153
\frametitle{Simple Pendulum - L and T}
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   154
  \begin{itemize}
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   155
    \item Given data of Length and Time-period of a Simple pendulum 
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   156
    \item We wish to plot L vs. \alert{$T^2$}
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   157
  \end{itemize}    
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   158
\begin{lstlisting}
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   159
In []: L = [0.1,  0.2,  0.3,  
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   160
            0.4,  0.5,  0.6,  
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   161
            0.7,  0.8,  0.9]
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   162
In []: T = [0.6529, 0.8485, 1.0590, 
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   163
            1.2390, 1.4124, 1.5061, 
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   164
            1.6441, 1.7949, 1.8758]
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   165
\end{lstlisting}
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   166
\end{frame}
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   167
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   168
\begin{frame}[fragile]
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   169
\frametitle{Simple Pendulum \ldots}
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   170
\begin{itemize}
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   171
\item Let us begin with $L$ vs. \alert{$T$}
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   172
\end{itemize}
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   173
\begin{lstlisting}
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   174
  In []: plot(L, T)
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   175
\end{lstlisting}
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   176
\begin{itemize}
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   177
\item But we wish to plot points!
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   178
\end{itemize}
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   179
\end{frame}
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   180
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   181
\begin{frame}[fragile]
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   182
\frametitle{Plotting points}
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   183
\begin{lstlisting}
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   184
  In []: clf()
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   185
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   186
  In []: plot(L, T, 'o')
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   187
  Out[]: [<matplotlib.lines.Line2D object at 0xac17e0c>]
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   188
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   189
  In []: clf()
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   190
  In []: plot(L, T, '.')
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   191
  Out[]: [<matplotlib.lines.Line2D object at 0xac17e0c>]
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   192
\end{lstlisting}
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   193
\end{frame}
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   194
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   195
\begin{frame}[fragile]
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   196
\frametitle{Plotting Attributes}
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   197
\begin{itemize}
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   198
  \item \kwrd{'o'} - Dots
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   199
  \item \kwrd{'-'} - Lines
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   200
  \item \kwrd{'- -'} - Dashed lines
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   201
\end{itemize}
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   202
\end{frame}
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   203
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   204
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   205
134
31b3e5051b06 Updated Session 1, day 2 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 132
diff changeset
   206
\section{File Handling}
109
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   207
\begin{frame}[fragile]
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   208
    \frametitle{File and \kwrd{for}}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   209
\begin{lstlisting}
130
8905a5badd7e Minor edits to day1 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 118
diff changeset
   210
In []: f = open('dummyfile')
109
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   211
130
8905a5badd7e Minor edits to day1 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 118
diff changeset
   212
In []: for line in f:
109
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   213
    ...:     print line
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   214
    ...:  
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   215
\end{lstlisting}
132
c10d8cb8d690 Updated session 2 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 130
diff changeset
   216
\inctime{5}
109
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   217
\end{frame}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   218
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   219
\section{Strings}
132
c10d8cb8d690 Updated session 2 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 130
diff changeset
   220
\begin{frame}{Strings}
c10d8cb8d690 Updated session 2 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 130
diff changeset
   221
Anything within ``quotes'' is a string!
109
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   222
\end{frame}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   223
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   224
\begin{frame}[fragile]\frametitle{Strings and \typ{split()}}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   225
  \begin{lstlisting}
130
8905a5badd7e Minor edits to day1 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 118
diff changeset
   226
In []: a = 'hello world'
109
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   227
130
8905a5badd7e Minor edits to day1 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 118
diff changeset
   228
In []: a.split()
8905a5badd7e Minor edits to day1 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 118
diff changeset
   229
Out[]: ['hello', 'world']
109
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   230
  \end{lstlisting}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   231
Now try this:
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   232
  \begin{lstlisting}
130
8905a5badd7e Minor edits to day1 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 118
diff changeset
   233
In []: b = 'KD, MCS, PC, SC, SV'
109
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   234
130
8905a5badd7e Minor edits to day1 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 118
diff changeset
   235
In []: b.split(',')
8905a5badd7e Minor edits to day1 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 118
diff changeset
   236
Out[]: ['KD', 'MCS', 'PC', 'SC', 'SV']
109
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   237
  \end{lstlisting}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   238
\inctime{5}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   239
\end{frame}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   240
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   241
\section{Plotting points}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   242
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   243
\section{Lists}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   244
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   245
\begin{frame}[fragile]
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   246
  \frametitle{List creation and indexing}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   247
\begin{lstlisting}
130
8905a5badd7e Minor edits to day1 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 118
diff changeset
   248
In []: lst = [1,2,3,4] 
109
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   249
130
8905a5badd7e Minor edits to day1 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 118
diff changeset
   250
In []: lst[0]+lst[1]+lst[-1]
8905a5badd7e Minor edits to day1 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 118
diff changeset
   251
Out[]: 7
109
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   252
\end{lstlisting}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   253
\begin{itemize}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   254
  \item Indices start with ?
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   255
  \item Negative indices indicate ?
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   256
  \end{itemize}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   257
\end{frame}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   258
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   259
\begin{frame}[fragile]
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   260
  \frametitle{List: slices}
132
c10d8cb8d690 Updated session 2 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 130
diff changeset
   261
  \typ{list[initial:final:step]}
109
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   262
\begin{lstlisting}
130
8905a5badd7e Minor edits to day1 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 118
diff changeset
   263
In []: lst[1:3]  # A slice.
8905a5badd7e Minor edits to day1 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 118
diff changeset
   264
Out[]: [2, 3]
109
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   265
130
8905a5badd7e Minor edits to day1 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 118
diff changeset
   266
In []: lst[1:-1]
8905a5badd7e Minor edits to day1 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 118
diff changeset
   267
Out[]: [2, 3]
109
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   268
\end{lstlisting}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   269
\end{frame}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   270
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   271
\begin{frame}[fragile]
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   272
  \frametitle{List methods}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   273
\begin{lstlisting}
130
8905a5badd7e Minor edits to day1 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 118
diff changeset
   274
In []: lst.append([6,7])
8905a5badd7e Minor edits to day1 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 118
diff changeset
   275
In []: lst
8905a5badd7e Minor edits to day1 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 118
diff changeset
   276
Out[]: [1, 2, 3, 4, 5, [6, 7]]
109
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   277
\end{lstlisting}
132
c10d8cb8d690 Updated session 2 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 130
diff changeset
   278
\inctime{10}
109
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   279
\end{frame}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   280
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   281
\end{document}