day1/session2.tex
author Puneeth Chaganti <punchagan@fossee.in>
Fri, 23 Oct 2009 18:23:32 +0530
changeset 161 ff22fae4fde5
parent 160 058fad7c7d1d
child 162 1af425d33eba
permissions -rw-r--r--
Adding reading files and plotting to day1 session1.
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]
156
6a1388c456f4 Added plotting of points, additional attributes of plots.
Puneeth Chaganti <punchagan@fossee.in>
parents: 153
diff changeset
   196
\frametitle{Additional Plotting Attributes}
153
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
156
6a1388c456f4 Added plotting of points, additional attributes of plots.
Puneeth Chaganti <punchagan@fossee.in>
parents: 153
diff changeset
   199
  \item \kwrd{'.'} - Smaller Dots
153
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   200
  \item \kwrd{'-'} - Lines
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   201
  \item \kwrd{'- -'} - Dashed lines
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   202
\end{itemize}
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   203
\end{frame}
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   204
156
6a1388c456f4 Added plotting of points, additional attributes of plots.
Puneeth Chaganti <punchagan@fossee.in>
parents: 153
diff changeset
   205
\begin{frame}[fragile]
6a1388c456f4 Added plotting of points, additional attributes of plots.
Puneeth Chaganti <punchagan@fossee.in>
parents: 153
diff changeset
   206
\frametitle{Plotting $L$ vs. $T^2$}
6a1388c456f4 Added plotting of points, additional attributes of plots.
Puneeth Chaganti <punchagan@fossee.in>
parents: 153
diff changeset
   207
\begin{itemize}
6a1388c456f4 Added plotting of points, additional attributes of plots.
Puneeth Chaganti <punchagan@fossee.in>
parents: 153
diff changeset
   208
\item We must square each of the values in T
6a1388c456f4 Added plotting of points, additional attributes of plots.
Puneeth Chaganti <punchagan@fossee.in>
parents: 153
diff changeset
   209
\item How to do it?
6a1388c456f4 Added plotting of points, additional attributes of plots.
Puneeth Chaganti <punchagan@fossee.in>
parents: 153
diff changeset
   210
\item T is a \kwrd{list} and we use a \kwrd{for} loop to iterate over it
6a1388c456f4 Added plotting of points, additional attributes of plots.
Puneeth Chaganti <punchagan@fossee.in>
parents: 153
diff changeset
   211
\end{itemize}
6a1388c456f4 Added plotting of points, additional attributes of plots.
Puneeth Chaganti <punchagan@fossee.in>
parents: 153
diff changeset
   212
\end{frame}
153
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   213
159
01f57cda252f Manual merge of conflicting branches.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 158 156
diff changeset
   214
\begin{frame}[fragile]
01f57cda252f Manual merge of conflicting branches.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 158 156
diff changeset
   215
\frametitle{Plotting $L$ vs $T^2$}
158
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   216
\begin{lstlisting}
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   217
In []: TSq = []
153
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   218
158
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   219
In []: for t in T:
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   220
 ....:     TSq.append(t*t)
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   221
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   222
In []: plot(L, TSq, '.')
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   223
Out[]: [<matplotlib.lines.Line2D object at 0xa5b05ac>]
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   224
\end{lstlisting}
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   225
\end{frame}
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   226
161
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   227
\begin{frame}{New Concepts}
158
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   228
  \begin{itemize}
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   229
    \item lists
161
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   230
    \item \typ{for}
158
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   231
  \end{itemize}
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   232
\end{frame}
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   233
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   234
\section{Lists}
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   235
\begin{frame}[fragile]
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   236
  \frametitle{How to create and use lists?}
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   237
\begin{lstlisting}
159
01f57cda252f Manual merge of conflicting branches.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 158 156
diff changeset
   238
In []: mtlist = [] #Empty List
01f57cda252f Manual merge of conflicting branches.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 158 156
diff changeset
   239
158
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   240
In []: lst = [1,2,3,4] 
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   241
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   242
In []: lst[0]+lst[1]+lst[-1]
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   243
Out[]: 7
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   244
\end{lstlisting}
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   245
\end{frame}
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   246
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   247
\begin{frame}[fragile]
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   248
  \frametitle{List: Slicing}
160
058fad7c7d1d Minor edits to Session 2 day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 159
diff changeset
   249
list[initial:final:step]
158
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   250
\begin{lstlisting}
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   251
In []: lst[1:3]  # A slice.
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   252
Out[]: [2, 3]
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   253
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   254
In []: lst[1:-1]
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   255
Out[]: [2, 3]
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   256
\end{lstlisting}
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   257
\end{frame}
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   258
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   259
\begin{frame}[fragile]
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   260
  \frametitle{List methods}
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   261
\begin{lstlisting}
160
058fad7c7d1d Minor edits to Session 2 day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 159
diff changeset
   262
In []: lst.append(6)
158
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   263
In []: lst
160
058fad7c7d1d Minor edits to Session 2 day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 159
diff changeset
   264
Out[]: [1, 2, 3, 4, 5, 6]
158
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   265
\end{lstlisting}
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   266
%\inctime{10}
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   267
\end{frame}
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   268
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   269
\begin{frame}[fragile]
160
058fad7c7d1d Minor edits to Session 2 day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 159
diff changeset
   270
\frametitle{\texttt{for}}
158
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   271
Used to iterate over lists\\ Let us look at another example.
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   272
\begin{lstlisting}
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   273
In []: lst = [1,2,3,4,5,6]
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   274
In []: for num in lst:
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   275
 ....:     print num, num*num
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   276
 ....:    
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   277
1 1
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   278
2 4
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   279
3 9
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   280
4 16
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   281
5 25
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   282
6 36
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   283
\end{lstlisting}
978108b0c02c Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 153
diff changeset
   284
\end{frame}
153
dc0da25b788b Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 151
diff changeset
   285
109
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   286
\begin{frame}[fragile]
161
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   287
\frametitle{Reading pendulum.txt}
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   288
\begin{itemize}
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   289
  \item We now wish to repeat the plot using the values from a file
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   290
  \item Given a file containing L vs. T values 
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   291
  \item Column1 - L; Column2 - T  
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   292
  \item Read the file
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   293
  \item Plot points for L vs. $T^2$ 
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   294
\end{itemize}
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   295
\end{frame}
109
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   296
161
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   297
\begin{frame}[fragile]
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   298
\frametitle{Reading pendulum.txt}
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   299
\begin{lstlisting}
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   300
In []: L = []
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   301
In []: T = []
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   302
In []: for line in open('pendulum.txt'):
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   303
  ....     points = line.split()
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   304
  ....     L.append(float(points[0]))
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   305
  ....     T.append(float(points[1]))
109
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   306
\end{lstlisting}
161
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   307
\begin{itemize}
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   308
\item We now have two lists L and T
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   309
\item Now, Repeat previous steps for plotting
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   310
\end{itemize}
109
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   311
\end{frame}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   312
161
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   313
\begin{frame}[fragile]
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   314
\frametitle{Plotting from pendulum.txt}
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   315
\begin{lstlisting}
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   316
In []: TSq = []
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   317
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   318
In []: for t in T:
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   319
 ....:     TSq.append(t*t)
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   320
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   321
In []: plot(L, TSq, '.')
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   322
\end{lstlisting}
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   323
\end{frame}
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   324
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   325
\begin{frame}{New Concepts}
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   326
  \begin{itemize}
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   327
    \item File handling
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   328
    \item Strings
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   329
    \item Data-type conversion
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   330
  \end{itemize}
109
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   331
\end{frame}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   332
161
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   333
\begin{frame}[fragile]
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   334
  \frametitle{Reading files \ldots}
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   335
\typ{In []: for line in open('pendulum.txt'):}
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   336
\begin{itemize}
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   337
\item opening file `pendulum.txt'
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   338
\item iterating through file using variable \typ{line}
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   339
\item \typ{line} is a \kwrd{string} variable
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   340
\end{itemize}
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   341
\end{frame}
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   342
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   343
\begin{frame}[fragile]
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   344
\frametitle{Strings}
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   345
Anything within ``quotes'' is a string!
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   346
\begin{lstlisting}
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   347
' This is a string '  
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   348
" This too! "
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   349
""" This one too! """
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   350
''' And one more! '''
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   351
\end{lstlisting}
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   352
\end{frame}
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   353
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   354
\begin{frame}[fragile]
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   355
\frametitle{Strings and \typ{split()}}
109
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   356
  \begin{lstlisting}
161
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   357
In []: line = 'hello world'
109
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   358
130
8905a5badd7e Minor edits to day1 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 118
diff changeset
   359
In []: a.split()
8905a5badd7e Minor edits to day1 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 118
diff changeset
   360
Out[]: ['hello', 'world']
109
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   361
  \end{lstlisting}
161
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   362
This is what happens with \typ{line}
109
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   363
  \begin{lstlisting}
161
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   364
In []: line = '1.2000e-01 7.4252e-01'
109
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   365
161
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   366
In []: line.split()
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   367
Out[]: ['1.2000e-01', '7.4252e-01']
109
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   368
  \end{lstlisting}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   369
\end{frame}
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   370
161
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   371
\begin{frame}[fragile]
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   372
\frametitle{Getting floats from strings}
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   373
  \begin{lstlisting}
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   374
In []: type(points[0])
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   375
Out[]: <type 'str'>
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   376
  \end{lstlisting}
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   377
But, we need floating point numbers
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   378
  \begin{lstlisting}
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   379
In []: t = float(point[0])
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   380
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   381
In []: type(t)
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   382
Out[]: <type 'float'>
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   383
  \end{lstlisting}
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   384
\end{frame}
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   385
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   386
\begin{frame}[fragile]
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   387
\begin{figure}
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   388
\includegraphics[width=3.5in]{data/L-Tsq.png}
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   389
\end{figure}
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   390
\vspace{-0.2in}
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   391
Coming up - \alert{Least Square Fit \ldots}
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   392
\end{frame}
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   393
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   394
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   395
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   396
109
16e04782baac Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   397
\end{document}
161
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   398
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   399
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   400
ff22fae4fde5 Adding reading files and plotting to day1 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 160
diff changeset
   401