day2/session1.tex
author Puneeth Chaganti <punchagan@fossee.in>
Mon, 12 Oct 2009 11:56:07 +0530
changeset 97 555237dbce44
parent 96 a749db24e73b
permissions -rw-r--r--
Changing authors, etc. Changes at BPRIM.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     2
% Tutorial slides on Python.
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     3
%
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     4
% Author: Prabhu Ramachandran <prabhu at aero.iitb.ac.in>
46
63704b5650f1 Changed the copyright and Institute for all the sessions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 44
diff changeset
     5
% Copyright (c) 2005-2009, Prabhu Ramachandran
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     6
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     7
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     8
\documentclass[14pt,compress]{beamer}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     9
%\documentclass[draft]{beamer}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    10
%\documentclass[compress,handout]{beamer}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    11
%\usepackage{pgfpages} 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    12
%\pgfpagesuselayout{2 on 1}[a4paper,border shrink=5mm]
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    13
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    14
% Modified from: generic-ornate-15min-45min.de.tex
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    15
\mode<presentation>
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    16
{
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    17
  \usetheme{Warsaw}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    18
  \useoutertheme{split}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    19
  \setbeamercovered{transparent}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    20
}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    21
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    22
\usepackage[english]{babel}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    23
\usepackage[latin1]{inputenc}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    24
%\usepackage{times}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    25
\usepackage[T1]{fontenc}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    26
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    27
% Taken from Fernando's slides.
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    28
\usepackage{ae,aecompl}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    29
\usepackage{mathpazo,courier,euler}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    30
\usepackage[scaled=.95]{helvet}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    31
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    32
\definecolor{darkgreen}{rgb}{0,0.5,0}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    33
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    34
\usepackage{listings}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    35
\lstset{language=Python,
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    36
    basicstyle=\ttfamily\bfseries,
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    37
    commentstyle=\color{red}\itshape,
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    38
  stringstyle=\color{darkgreen},
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    39
  showstringspaces=false,
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    40
  keywordstyle=\color{blue}\bfseries}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    41
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    42
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    43
% Macros
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    44
\setbeamercolor{emphbar}{bg=blue!20, fg=black}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    45
\newcommand{\emphbar}[1]
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    46
{\begin{beamercolorbox}[rounded=true]{emphbar} 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    47
      {#1}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    48
 \end{beamercolorbox}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    49
}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    50
\newcounter{time}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    51
\setcounter{time}{0}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    52
\newcommand{\inctime}[1]{\addtocounter{time}{#1}{\tiny \thetime\ m}}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    53
20
84458ebb6951 Modified numpy array parts.
Shantanu <shantanu@fossee.in>
parents: 12
diff changeset
    54
\newcommand{\typ}[1]{\lstinline{#1}}
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    55
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    56
\newcommand{\kwrd}[1]{ \texttt{\textbf{\color{blue}{#1}}}  }
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    57
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    58
%%% This is from Fernando's setup.
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    59
% \usepackage{color}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    60
% \definecolor{orange}{cmyk}{0,0.4,0.8,0.2}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    61
% % Use and configure listings package for nicely formatted code
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    62
% \usepackage{listings}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    63
% \lstset{
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    64
%    language=Python,
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    65
%    basicstyle=\small\ttfamily,
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    66
%    commentstyle=\ttfamily\color{blue},
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    67
%    stringstyle=\ttfamily\color{orange},
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    68
%    showstringspaces=false,
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    69
%    breaklines=true,
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    70
%    postbreak = \space\dots
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    71
% }
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    72
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    73
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    74
% Title page
97
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    75
\title[]{Arrays\\ \& \\2D Plotting}
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    76
97
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    77
\author[FOSSEE Team] {FOSSEE}
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    78
46
63704b5650f1 Changed the copyright and Institute for all the sessions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 44
diff changeset
    79
\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    80
\date[] {11, October 2009}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    81
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    82
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    83
%\pgfdeclareimage[height=0.75cm]{iitmlogo}{iitmlogo}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    84
%\logo{\pgfuseimage{iitmlogo}}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    85
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    86
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    87
%% Delete this, if you do not want the table of contents to pop up at
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    88
%% the beginning of each subsection:
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    89
\AtBeginSubsection[]
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    90
{
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    91
  \begin{frame}<beamer>
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    92
    \frametitle{Outline}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    93
    \tableofcontents[currentsection,currentsubsection]
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    94
  \end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    95
}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    96
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    97
\AtBeginSection[]
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    98
{
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    99
  \begin{frame}<beamer>
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   100
    \frametitle{Outline}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   101
    \tableofcontents[currentsection,currentsubsection]
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   102
  \end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   103
}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   104
95
691608044ae7 Minor edits to Session1 Day2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 78
diff changeset
   105
\newcommand{\num}{\texttt{numpy}}
691608044ae7 Minor edits to Session1 Day2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 78
diff changeset
   106
691608044ae7 Minor edits to Session1 Day2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 78
diff changeset
   107
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   108
% If you wish to uncover everything in a step-wise fashion, uncomment
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   109
% the following command: 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   110
%\beamerdefaultoverlayspecification{<+->}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   111
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   112
%\includeonlyframes{current,current1,current2,current3,current4,current5,current6}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   113
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   114
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   115
% DOCUMENT STARTS
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   116
\begin{document}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   117
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   118
\begin{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   119
  \maketitle
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   120
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   121
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   122
\begin{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   123
  \frametitle{Outline}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   124
  \tableofcontents
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   125
  % You might wish to add the option [pausesections]
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   126
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   127
97
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   128
\section{Arrays}
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   129
95
691608044ae7 Minor edits to Session1 Day2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 78
diff changeset
   130
\subsection{Basic \typ{numpy}}
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   131
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   132
\begin{frame}
97
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   133
  \frametitle{The \num\  module}
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   134
  \begin{itemize}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   135
      \item Why?
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   136
  \item What:
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   137
    \begin{itemize}
78
ec1346330649 Minor edits to Day2 handout.
Puneeth Chaganti <punchagan@fossee.in>
parents: 76
diff changeset
   138
    \item An efficient and powerful array type for various common data types
ec1346330649 Minor edits to Day2 handout.
Puneeth Chaganti <punchagan@fossee.in>
parents: 76
diff changeset
   139
    \item Abstracts out the most commonly used standard operations on arrays
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   140
    \end{itemize}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   141
  \end{itemize}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   142
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   143
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   144
\begin{frame}[fragile]
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   145
  \frametitle{Examples of \num}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   146
\begin{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   147
# Simple array math example
97
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   148
>>> from numpy import *
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   149
>>> a = array([1,2,3,4])
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   150
>>> b = arange(2,6)
66
523f788d2147 Minor edits to Day2 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 46
diff changeset
   151
>>> b
523f788d2147 Minor edits to Day2 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 46
diff changeset
   152
array([2,3,4,5])
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   153
>>> a*2 + b + 1 # Basic math!
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   154
array([5, 8, 11, 14])
66
523f788d2147 Minor edits to Day2 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 46
diff changeset
   155
\end{lstlisting}
523f788d2147 Minor edits to Day2 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 46
diff changeset
   156
\end{frame}
523f788d2147 Minor edits to Day2 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 46
diff changeset
   157
523f788d2147 Minor edits to Day2 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 46
diff changeset
   158
\begin{frame}[fragile]
523f788d2147 Minor edits to Day2 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 46
diff changeset
   159
  \frametitle{Examples of \num}
523f788d2147 Minor edits to Day2 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 46
diff changeset
   160
\begin{lstlisting}
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   161
# Pi and e are defined.
97
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   162
>>> x = linspace(0.0, 10.0, 1000)
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   163
>>> x *= 2*pi/10 # inplace.
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   164
# apply functions to array.
97
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   165
>>> y = sin(x)
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   166
>>> z = exp(y)
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   167
\end{lstlisting}
4
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   168
\inctime{5}
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   169
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   170
97
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   171
\begin{frame}[fragile]
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   172
  \frametitle{More examples of \num}
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   173
\vspace*{-8pt}
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   174
\begin{lstlisting}
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   175
>>> x = array([1., 2, 3, 4])
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   176
>>> size(x)
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   177
4
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   178
>>> x.dtype # What is a.dtype?
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   179
dtype('float64')
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   180
>>> x.shape
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   181
(4,)
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   182
>>> print x.itemsize
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   183
8
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   184
>>> x[0] = 10
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   185
>>> print x[0], x[-1]
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   186
10.0 4.0
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   187
\end{lstlisting}
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   188
\end{frame}
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   189
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   190
\begin{frame}[fragile]
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   191
  \frametitle{Multi-dimensional arrays}
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   192
\begin{lstlisting}
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   193
>>> a = array([[ 0, 1, 2, 3],
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   194
...            [10,11,12,13]])
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   195
>>> a.shape # (rows, columns)
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   196
(2, 4)
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   197
>>> a.shape=4,2
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   198
# Accessing and setting values
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   199
>>> a[1][3] 
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   200
>>> a[1,3] 
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   201
>>> a[1,3] = -1
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   202
>>> a[1] # The second row
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   203
\end{lstlisting}
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   204
\end{frame}
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   205
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   206
\begin{frame}[fragile]
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   207
  \frametitle{Array math}
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   208
  \begin{itemize}
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   209
  \item Basic \alert{elementwise} math (given two arrays \typ{a, b}):
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   210
      \typ{+, -, *, /, \%}
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   211
  \item Inplace operators: \typ{a += b}
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   212
  \item \typ{sum(x, axis=0)}, 
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   213
        \typ{product(x, axis=0)},
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   214
        \typ{dot(a, bp)}   
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   215
  \end{itemize}
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   216
\begin{lstlisting}
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   217
>>> x = array([[0,2,4,2],[1,2,3,4]])
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   218
>>> sum(x)
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   219
>>> sum(x,axis=1)
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   220
\end{lstlisting}
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   221
\end{frame}
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   222
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   223
\begin{frame}[fragile]
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   224
  \frametitle{Array math cont.}
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   225
  \begin{itemize}
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   226
  \item Logical operations: \typ{==}, \typ{!=},
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   227
    \typ{<}, \typ{>} etc.
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   228
  \item Trig and other functions: \typ{sin(x),}
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   229
        \typ{arcsin(x), sinh(x),}
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   230
      \typ{exp(x), sqrt(x)} etc.
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   231
  \end{itemize}
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   232
\begin{lstlisting}
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   233
>>> a<4, a!=3
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   234
>>> sqrt(a)
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   235
\end{lstlisting}
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   236
\inctime{10}
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   237
\end{frame}
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   238
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   239
\begin{frame}
97
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   240
  \frametitle{Summary of Concepts}
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   241
  \begin{itemize}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   242
  \item fixed size (\typ{arr.size});
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   243
  \item Same type (\typ{arr.dtype}) of data
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   244
  \item arbitrary dimensionality
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   245
  \item \typ{arr.shape}: size in each dimension
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   246
  \item \alert{Note:} \typ{len(arr) != arr.size} in general
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   247
  \item \alert{Note:} By default array operations are performed
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   248
    \alert{elementwise}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   249
  \end{itemize}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   250
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   251
4
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   252
\subsection{Array Creation \& Slicing, Striding Arrays}
95
691608044ae7 Minor edits to Session1 Day2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 78
diff changeset
   253
4
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   254
\begin{frame}[fragile]
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   255
  \frametitle{Array creation functions}
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   256
  \begin{itemize}
97
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   257
    \item \typ{array?} \alert{\#Doc string reading}
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   258
    \item \typ{array(object,dtype=None,...)}
66
523f788d2147 Minor edits to Day2 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 46
diff changeset
   259
    \begin{lstlisting}
97
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   260
>>> array([2,3,4])  
66
523f788d2147 Minor edits to Day2 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 46
diff changeset
   261
array([2, 3, 4])
523f788d2147 Minor edits to Day2 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 46
diff changeset
   262
    \end{lstlisting}
97
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   263
    \item \typ{linspace(start,stop,num)}
66
523f788d2147 Minor edits to Day2 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 46
diff changeset
   264
    \begin{lstlisting}
97
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   265
>>> linspace(0, 2, 4)   
66
523f788d2147 Minor edits to Day2 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 46
diff changeset
   266
array([0.,0.6666667,1.3333333,2.])
523f788d2147 Minor edits to Day2 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 46
diff changeset
   267
    \end{lstlisting}
97
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   268
    \item \typ{arange?}
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   269
      \alert{\# float version of range}
20
84458ebb6951 Modified numpy array parts.
Shantanu <shantanu@fossee.in>
parents: 12
diff changeset
   270
  \end{itemize}
84458ebb6951 Modified numpy array parts.
Shantanu <shantanu@fossee.in>
parents: 12
diff changeset
   271
\end{frame}
84458ebb6951 Modified numpy array parts.
Shantanu <shantanu@fossee.in>
parents: 12
diff changeset
   272
84458ebb6951 Modified numpy array parts.
Shantanu <shantanu@fossee.in>
parents: 12
diff changeset
   273
\begin{frame}[fragile]
84458ebb6951 Modified numpy array parts.
Shantanu <shantanu@fossee.in>
parents: 12
diff changeset
   274
  \frametitle{Array creation functions cont.}
84458ebb6951 Modified numpy array parts.
Shantanu <shantanu@fossee.in>
parents: 12
diff changeset
   275
  \begin{itemize}  
97
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   276
  \item \typ{ones(shape, dtype=None, ...)}  
20
84458ebb6951 Modified numpy array parts.
Shantanu <shantanu@fossee.in>
parents: 12
diff changeset
   277
  \begin{lstlisting} 
97
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   278
>>> ones((2,2))
66
523f788d2147 Minor edits to Day2 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 46
diff changeset
   279
array([[ 1.,  1.],
523f788d2147 Minor edits to Day2 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 46
diff changeset
   280
     [ 1.,  1.]])
20
84458ebb6951 Modified numpy array parts.
Shantanu <shantanu@fossee.in>
parents: 12
diff changeset
   281
  \end{lstlisting}  
97
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   282
  \item \typ{identity(n)} 
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   283
  \item \typ{ones\_like(x)}  
20
84458ebb6951 Modified numpy array parts.
Shantanu <shantanu@fossee.in>
parents: 12
diff changeset
   284
  \begin{lstlisting} 
97
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   285
>>> a = array([[1,2,3],[4,5,6]])
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   286
>>> ones_like(a)
66
523f788d2147 Minor edits to Day2 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 46
diff changeset
   287
array([[1, 1, 1],
523f788d2147 Minor edits to Day2 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 46
diff changeset
   288
       [1, 1, 1]])
20
84458ebb6951 Modified numpy array parts.
Shantanu <shantanu@fossee.in>
parents: 12
diff changeset
   289
  \end{lstlisting}
66
523f788d2147 Minor edits to Day2 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 46
diff changeset
   290
  \item Also try \typ{zeros, zeros\_like, empty}
4
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   291
  \end{itemize}
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   292
\end{frame}
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   293
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   294
\begin{frame}[fragile]
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   295
  \frametitle{Slicing arrays}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   296
\begin{lstlisting}
97
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   297
>>> a = array([[1,2,3], [4,5,6], 
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   298
               [7,8,9]])
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   299
>>> a[0,1:3]
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   300
array([2, 3])
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   301
>>> a[1:,1:]
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   302
array([[5, 6],
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   303
       [8, 9]])
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   304
>>> a[:,2]
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   305
array([3, 6, 9])
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   306
\end{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   307
\end{frame}
4
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   308
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   309
\begin{frame}[fragile]
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   310
  \frametitle{Striding arrays}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   311
\begin{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   312
>>> a[0::2,0::2]
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   313
array([[1, 3],
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   314
       [7, 9]])
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   315
# Slices are references to the 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   316
# same memory!
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   317
\end{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   318
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   319
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   320
\begin{frame}[fragile]
4
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   321
\frametitle{Random Numbers}
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   322
\begin{lstlisting}
97
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   323
>>> random.random()
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   324
0.94134734326214331
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   325
>>> random.random(2)
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   326
array([ 0.73955352,  0.49463645])
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   327
>>> random.random(3,2)
4
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   328
array([[ 0.96276665,  0.77174861],
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   329
       [ 0.35138557,  0.61462271],
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   330
       [ 0.16789255,  0.43848811]])
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   331
\end{lstlisting}
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   332
\inctime{15}
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   333
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   334
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   335
\begin{frame}[fragile]
97
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   336
  \frametitle{Problem}
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   337
  Finite difference
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   338
  \begin{equation*}
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   339
  \frac{sin(x+h)-sin(x)}{h}
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   340
  \end{equation*}
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   341
  \begin{lstlisting}
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   342
  >>> x = linspace(0,2*pi,100)
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   343
  >>> y = sin(x)
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   344
  >>> deltax = x[1]-x[0]
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   345
  \end{lstlisting}
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   346
  \pause
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   347
    \begin{enumerate}
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   348
      \item Given this, get the finite difference of sin in the range 0 to 2*pi
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   349
    \end{enumerate}
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   350
\end{frame}
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   351
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   352
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   353
\begin{frame}[fragile]
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   354
  \frametitle{Advanced Problem}
6
1f9492506ba2 Added a problem after initial numpy section in session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 4
diff changeset
   355
  \begin{lstlisting}
1f9492506ba2 Added a problem after initial numpy section in session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 4
diff changeset
   356
    >>> from scipy import misc
97
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   357
    >>> A=misc.imread('filename')
6
1f9492506ba2 Added a problem after initial numpy section in session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 4
diff changeset
   358
    >>> misc.imshow(A)
1f9492506ba2 Added a problem after initial numpy section in session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 4
diff changeset
   359
  \end{lstlisting}
1f9492506ba2 Added a problem after initial numpy section in session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 4
diff changeset
   360
    \begin{enumerate}
1f9492506ba2 Added a problem after initial numpy section in session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 4
diff changeset
   361
    \item Convert an RGB image to Grayscale. $ Y = 0.5R + 0.25G + 0.25B $
9
2281002b579b Edited Problem Sets - Added cobweb plot; Removed Koch.
Puneeth Chaganti <punchagan@fossee.in>
parents: 6
diff changeset
   362
    \item Scale the image to 50\%
34
5218871f98f4 Edited image processing example.
Puneeth Chaganti <punchagan@fossee.in>
parents: 20
diff changeset
   363
    \item Introduce some random noise
5218871f98f4 Edited image processing example.
Puneeth Chaganti <punchagan@fossee.in>
parents: 20
diff changeset
   364
    \item Smooth the image using a mean filter
66
523f788d2147 Minor edits to Day2 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 46
diff changeset
   365
      \\\small{Each element in the array is replaced by mean of all the neighbouring elements}
523f788d2147 Minor edits to Day2 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 46
diff changeset
   366
      \\\small{How fast does your code run?}
6
1f9492506ba2 Added a problem after initial numpy section in session1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 4
diff changeset
   367
    \end{enumerate}
4
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   368
\inctime{15}
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   369
\end{frame}
4
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   370
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   371
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   372
\section{2D Plotting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   373
\subsection{Getting Started}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   374
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   375
\begin{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   376
    {IPython's \typ{pylab} mode}
97
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   377
\begin{block}{Immediate use -}
20
84458ebb6951 Modified numpy array parts.
Shantanu <shantanu@fossee.in>
parents: 12
diff changeset
   378
 \typ{\$ ipython -pylab}
84458ebb6951 Modified numpy array parts.
Shantanu <shantanu@fossee.in>
parents: 12
diff changeset
   379
\end{block}
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   380
\begin{itemize}
20
84458ebb6951 Modified numpy array parts.
Shantanu <shantanu@fossee.in>
parents: 12
diff changeset
   381
    \item \typ{pylab}: convenient 2D plotting interface to MPL    
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   382
    \item Imports all of pylab for you!
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   383
    \item Allows for interactive plotting
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   384
\end{itemize}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   385
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   386
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   387
\begin{frame}[fragile]
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   388
    \frametitle{Basic 2D plotting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   389
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   390
\begin{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   391
>>> x = linspace(0, 2*pi, 1000)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   392
>>> plot(x, sin(x)) 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   393
>>> plot(x, sin(x), 'ro')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   394
>>> xlabel(r'$\chi$', color='g')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   395
# LaTeX markup!
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   396
>>> ylabel(r'sin($\chi$)', color='r')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   397
>>> title('Simple figure', fontsize=20)
96
a749db24e73b Added Dialogs Slide; More edits to Day2 slides.
Puneeth Chaganti <punchagan@fossee.in>
parents: 95
diff changeset
   398
>>> savefig('/tmp/test.png')
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   399
\end{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   400
\begin{itemize}
97
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   401
  \item Also: PS, EPS, SVG, PDF
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   402
\end{itemize}
12
996fb264fbe2 Corrected screwed up merge.
Shantanu <shantanu@fossee.in>
parents: 10
diff changeset
   403
\inctime{5}
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   404
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   405
       
4
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   406
\subsection{Plots - Lines, Labels and Legends}
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   407
\begin{frame}[fragile]
12
996fb264fbe2 Corrected screwed up merge.
Shantanu <shantanu@fossee.in>
parents: 10
diff changeset
   408
  \frametitle{Tweaking plots}
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   409
\begin{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   410
# Set properties of objects:
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   411
>>> l, = plot(x, sin(x))
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   412
# Why "l,"?
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   413
>>> setp(l, linewidth=2.0, color='r')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   414
>>> l.set_linewidth(2.0)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   415
>>> draw() # Redraw.
20
84458ebb6951 Modified numpy array parts.
Shantanu <shantanu@fossee.in>
parents: 12
diff changeset
   416
>>> setp(l) # Print properties.
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   417
>>> clf() # Clear figure.
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   418
>>> close() # Close figure.
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   419
\end{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   420
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   421
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   422
\begin{frame}[fragile]
10
84c3f600045f Merged Heads.
Puneeth Chaganti <punchagan@fossee.in>
parents: 9 8
diff changeset
   423
   \frametitle{Working with text \ldots}
7
adcc40e2bf70 Made changes in plotting section.
Shantanu <shantanu@fossee.in>
parents: 6
diff changeset
   424
%\begin{itemize}
adcc40e2bf70 Made changes in plotting section.
Shantanu <shantanu@fossee.in>
parents: 6
diff changeset
   425
%  \item We already saw LaTeX markup support!
adcc40e2bf70 Made changes in plotting section.
Shantanu <shantanu@fossee.in>
parents: 6
diff changeset
   426
%\end{itemize}
adcc40e2bf70 Made changes in plotting section.
Shantanu <shantanu@fossee.in>
parents: 6
diff changeset
   427
\begin{lstlisting}
adcc40e2bf70 Made changes in plotting section.
Shantanu <shantanu@fossee.in>
parents: 6
diff changeset
   428
>>> w = arange(-2,2,.1)
adcc40e2bf70 Made changes in plotting section.
Shantanu <shantanu@fossee.in>
parents: 6
diff changeset
   429
>>> plot(w,exp(-(w*w))*cos)
adcc40e2bf70 Made changes in plotting section.
Shantanu <shantanu@fossee.in>
parents: 6
diff changeset
   430
>>> ylabel('$f(\omega)$')
adcc40e2bf70 Made changes in plotting section.
Shantanu <shantanu@fossee.in>
parents: 6
diff changeset
   431
>>> xlabel('$\omega$')
adcc40e2bf70 Made changes in plotting section.
Shantanu <shantanu@fossee.in>
parents: 6
diff changeset
   432
>>> title(r"$f(\omega)=e^{-\omega^2}
adcc40e2bf70 Made changes in plotting section.
Shantanu <shantanu@fossee.in>
parents: 6
diff changeset
   433
            cos({\omega^2})$")
adcc40e2bf70 Made changes in plotting section.
Shantanu <shantanu@fossee.in>
parents: 6
diff changeset
   434
\end{lstlisting}
10
84c3f600045f Merged Heads.
Puneeth Chaganti <punchagan@fossee.in>
parents: 9 8
diff changeset
   435
    
7
adcc40e2bf70 Made changes in plotting section.
Shantanu <shantanu@fossee.in>
parents: 6
diff changeset
   436
\end{frame}
adcc40e2bf70 Made changes in plotting section.
Shantanu <shantanu@fossee.in>
parents: 6
diff changeset
   437
adcc40e2bf70 Made changes in plotting section.
Shantanu <shantanu@fossee.in>
parents: 6
diff changeset
   438
\begin{frame}[fragile]
8
41bdf277c755 Added legend() section.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
   439
  \frametitle{Legends}
41bdf277c755 Added legend() section.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
   440
\begin{lstlisting}
97
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   441
>>> x = linspace(0, 2*pi, 1000)
8
41bdf277c755 Added legend() section.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
   442
>>> plot(x, cos(5*x), 'r--', 
41bdf277c755 Added legend() section.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
   443
         label='cosine')
41bdf277c755 Added legend() section.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
   444
>>> plot(x, sin(5*x), 'g--', 
41bdf277c755 Added legend() section.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
   445
         label='sine')
41bdf277c755 Added legend() section.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
   446
>>> legend() 
41bdf277c755 Added legend() section.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
   447
# Or use:
41bdf277c755 Added legend() section.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
   448
>>> legend(['cosine', 'sine'])
41bdf277c755 Added legend() section.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
   449
\end{lstlisting}
41bdf277c755 Added legend() section.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
   450
\end{frame}
41bdf277c755 Added legend() section.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
   451
41bdf277c755 Added legend() section.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
   452
\begin{frame}[fragile]
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   453
    \frametitle{Multiple figures}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   454
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   455
\begin{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   456
>>> figure(1)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   457
>>> plot(x, sin(x))
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   458
>>> figure(2)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   459
>>> plot(x, tanh(x))
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   460
>>> figure(1)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   461
>>> title('Easy as 1,2,3')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   462
\end{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   463
    
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   464
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   465
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   466
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   467
\begin{frame}[fragile]
66
523f788d2147 Minor edits to Day2 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 46
diff changeset
   468
    \frametitle{\typ{pylab} in Python scripts}
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   469
\begin{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   470
import pylab
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   471
x = pylab.linspace(0, 20, 1000)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   472
pylab.plot(x, pylab.sin(x))
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   473
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   474
# Can also use:
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   475
from pylab import linspace, sin, plot
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   476
\end{lstlisting}
66
523f788d2147 Minor edits to Day2 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 46
diff changeset
   477
\inctime{10}
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   478
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   479
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   480
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   481
\subsection{Types of Plots}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   482
\begin{frame}[fragile]
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   483
  \frametitle{X-Y plot}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   484
  \begin{columns}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   485
    \column{0.5\textwidth}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   486
    \hspace*{-0.5in}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   487
    \includegraphics[height=2in, interpolate=true]{data/xyplot}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   488
    \column{0.45\textwidth}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   489
    \begin{block}{Example code}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   490
    \tiny
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   491
\begin{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   492
t1 = arange(0.0, 5.0, 0.1)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   493
t2 = arange(0.0, 5.0, 0.02)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   494
t3 = arange(0.0, 2.0, 0.01)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   495
subplot(211)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   496
plot(t1, cos(2*pi*t1)*exp(-t1), 'bo', 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   497
     t2, cos(2*pi*t2)*exp(-t2), 'k')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   498
grid(True)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   499
title('A tale of 2 subplots')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   500
ylabel('Damped')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   501
subplot(212)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   502
plot(t3, cos(2*pi*t3), 'r--')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   503
grid(True)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   504
xlabel('time (s)')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   505
ylabel('Undamped')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   506
\end{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   507
    \end{block}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   508
  \end{columns}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   509
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   510
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   511
\begin{frame}[fragile] \frametitle{Semi-log and log-log plots}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   512
  \begin{columns}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   513
    \column{0.5\textwidth}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   514
    \hspace*{-0.5in}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   515
  \includegraphics[height=2in, interpolate=true]{data/log}  
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   516
    \column{0.45\textwidth}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   517
    \begin{block}{Example code}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   518
    \tiny
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   519
\begin{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   520
dt = 0.01
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   521
t = arange(dt, 20.0, dt)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   522
subplot(311)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   523
semilogy(t, exp(-t/5.0))
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   524
ylabel('semilogy')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   525
grid(True)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   526
subplot(312)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   527
semilogx(t, sin(2*pi*t))
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   528
ylabel('semilogx')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   529
grid(True)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   530
# minor grid on too
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   531
gca().xaxis.grid(True, which='minor')  
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   532
subplot(313)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   533
loglog(t, 20*exp(-t/10.0), basex=4)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   534
grid(True)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   535
ylabel('loglog base 4 on x')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   536
\end{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   537
  \end{block}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   538
\end{columns}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   539
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   540
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   541
\begin{frame}[fragile] \frametitle{Errorbar}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   542
  \begin{columns}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   543
    \column{0.5\textwidth}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   544
    \hspace*{-0.5in}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   545
  \includegraphics[height=2in, interpolate=true]{data/errorbar}  
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   546
    \column{0.45\textwidth}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   547
    \begin{block}{Example code}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   548
    \tiny
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   549
\begin{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   550
t = arange(0.1, 4, 0.1)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   551
s = exp(-t)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   552
e = 0.1*abs(randn(len(s)))
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   553
f = 0.1*abs(randn(len(s)))
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   554
g = 2*e
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   555
h = 2*f
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   556
errorbar(t, s, [e,g], f, fmt='o')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   557
xlabel('Distance (m)')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   558
ylabel('Height (m)')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   559
title('Mean and standard error '\
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   560
      'as a function of distance')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   561
\end{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   562
  \end{block}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   563
\end{columns}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   564
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   565
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   566
\begin{frame}[fragile] \frametitle{Histogram}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   567
  \begin{columns}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   568
    \column{0.5\textwidth}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   569
    \hspace*{-0.5in}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   570
  \includegraphics[height=2in, interpolate=true]{data/histogram}  
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   571
    \column{0.45\textwidth}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   572
    \begin{block}{Example code}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   573
    \tiny
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   574
\begin{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   575
mu, sigma = 100, 15
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   576
x = mu + sigma*randn(10000)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   577
# the histogram of the data
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   578
n, bins, patches = hist(x, 100, normed=1)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   579
# add a 'best fit' line
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   580
y = normpdf( bins, mu, sigma)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   581
l = plot(bins, y, 'r--', linewidth=2)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   582
xlim(40, 160)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   583
xlabel('Smarts')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   584
ylabel('P')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   585
title(r'$\rm{IQ:}\/ \mu=100,\/ \sigma=15$')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   586
\end{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   587
  \end{block}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   588
\end{columns}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   589
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   590
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   591
\begin{frame}[fragile] \frametitle{Bar charts}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   592
  \begin{columns}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   593
    \column{0.5\textwidth}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   594
    \hspace*{-0.5in}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   595
  \includegraphics[height=2in, interpolate=true]{data/barchart}  
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   596
    \column{0.45\textwidth}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   597
    \begin{block}{Example code}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   598
    \tiny
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   599
\begin{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   600
N = 5
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   601
menMeans = (20, 35, 30, 35, 27)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   602
menStd =   ( 2,  3,  4,  1,  2)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   603
# the x locations for the groups
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   604
ind = arange(N) 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   605
# the width of the bars
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   606
width = 0.35       
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   607
p1 = bar(ind, menMeans, width, 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   608
         color='r', yerr=menStd)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   609
womenMeans = (25, 32, 34, 20, 25)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   610
womenStd =   ( 3,  5,  2,  3,  3)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   611
p2 = bar(ind+width, womenMeans, width, 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   612
         color='y', yerr=womenStd)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   613
ylabel('Scores')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   614
title('Scores by group and gender')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   615
xticks(ind+width, 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   616
       ('G1', 'G2', 'G3', 'G4', 'G5'))
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   617
xlim(-width,len(ind))
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   618
yticks(arange(0,41,10))
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   619
legend((p1[0], p2[0]), 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   620
       ('Men', 'Women'), shadow=True)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   621
\end{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   622
  \end{block}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   623
\end{columns}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   624
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   625
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   626
\begin{frame}[fragile] \frametitle{Pie charts}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   627
  \begin{columns}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   628
    \column{0.5\textwidth}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   629
    \hspace*{-0.4in}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   630
  \includegraphics[height=2.0in, interpolate=true]{data/piechart}  
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   631
    \column{0.45\textwidth}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   632
    \begin{block}{Example code}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   633
    \tiny
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   634
\begin{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   635
# make a square figure and axes
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   636
figure(1, figsize=(8,8))
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   637
ax = axes([0.1, 0.1, 0.8, 0.8])
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   638
labels = 'Frogs', 'Hogs', 'Dogs', 'Logs'
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   639
fracs = [15,30,45, 10]
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   640
explode=(0, 0.05, 0, 0)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   641
pie(fracs, explode=explode, labels=labels, 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   642
    autopct='%1.1f%%', shadow=True)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   643
title('Raining Hogs and Dogs', 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   644
      bbox={'facecolor':'0.8', 'pad':5})
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   645
\end{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   646
  \end{block}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   647
\end{columns}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   648
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   649
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   650
\begin{frame}[fragile] \frametitle{Scatter plots}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   651
  \begin{columns}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   652
    \column{0.5\textwidth}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   653
    \hspace*{-0.4in}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   654
  \includegraphics[height=2in, interpolate=true]{data/scatter}  
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   655
    \column{0.45\textwidth}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   656
    \begin{block}{Example code}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   657
    \tiny
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   658
\begin{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   659
N = 30
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   660
x = 0.9*rand(N)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   661
y = 0.9*rand(N)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   662
# 0 to 10 point radiuses
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   663
area = pi*(10 * rand(N))**2 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   664
volume = 400 + rand(N)*450
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   665
scatter(x,y,s=area, marker='o', c=volume, 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   666
        alpha=0.75)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   667
xlabel(r'$\Delta_i$', size='x-large')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   668
ylabel(r'$\Delta_{i+1}$', size='x-large')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   669
title(r'Volume and percent change')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   670
grid(True)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   671
colorbar()
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   672
savefig('scatter')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   673
\end{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   674
  \end{block}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   675
\end{columns}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   676
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   677
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   678
\begin{frame}[fragile] \frametitle{Polar}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   679
  \begin{columns}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   680
    \column{0.5\textwidth}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   681
    \hspace*{-0.5in}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   682
  \includegraphics[height=2in, interpolate=true]{data/polar}  
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   683
    \column{0.45\textwidth}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   684
    \begin{block}{Example code}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   685
    \tiny
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   686
\begin{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   687
figure(figsize=(8,8))
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   688
ax = axes([0.1, 0.1, 0.8, 0.8], 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   689
          polar=True, 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   690
          axisbg='#d5de9c')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   691
r = arange(0,1,0.001)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   692
theta = 2*2*pi*r
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   693
polar(theta, r, color='#ee8d18', lw=3)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   694
# the radius of the grid labels
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   695
setp(ax.thetagridlabels, y=1.075) 
4
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   696
title(r'$\theta=4\pi r$', fontsize=20)
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   697
\end{lstlisting}
4
e5047bcbb608 Moved Array Math, Creation slides around; Added time counters.
Puneeth Chaganti <punchagan@fossee.in>
parents: 3
diff changeset
   698
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   699
  \end{block}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   700
\end{columns}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   701
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   702
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   703
\begin{frame}[fragile] \frametitle{Contours}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   704
  \begin{columns}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   705
    \column{0.45\textwidth}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   706
    \hspace*{-0.5in}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   707
  \includegraphics[height=2in, interpolate=true]{data/contour}  
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   708
    \column{0.525\textwidth}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   709
    \begin{block}{Example code}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   710
    \tiny
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   711
\begin{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   712
x = arange(-3.0, 3.0, 0.025)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   713
y = arange(-2.0, 2.0, 0.025)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   714
X, Y = meshgrid(x, y)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   715
Z1 = bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   716
Z2 = bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   717
# difference of Gaussians
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   718
Z = 10.0 * (Z2 - Z1)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   719
im = imshow(Z, interpolation='bilinear', 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   720
            origin='lower',
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   721
            cmap=cm.gray, extent=(-3,3,-2,2))
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   722
levels = arange(-1.2, 1.6, 0.2)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   723
# label every second level
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   724
clabel(CS, levels[1::2],  inline=1,
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   725
       fmt='%1.1f', fontsize=14)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   726
CS = contour(Z, levels,
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   727
             origin='lower',
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   728
             linewidths=2,
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   729
             extent=(-3,3,-2,2))
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   730
# make a colorbar for the contour lines
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   731
CB = colorbar(CS, shrink=0.8, extend='both')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   732
title('Lines with colorbar')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   733
hot(); flag()
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   734
\end{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   735
  \end{block}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   736
\end{columns}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   737
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   738
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   739
\begin{frame}[fragile] \frametitle{Velocity vectors}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   740
  \begin{columns}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   741
    \column{0.5\textwidth}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   742
    \hspace*{-0.5in}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   743
  \includegraphics[height=2in, interpolate=true]{data/quiver}  
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   744
    \column{0.45\textwidth}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   745
    \begin{block}{Example code}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   746
    \tiny
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   747
\begin{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   748
X,Y = meshgrid(arange(0,2*pi,.2),
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   749
               arange(0,2*pi,.2) )
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   750
U = cos(X)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   751
V = sin(Y)
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   752
Q = quiver(X[::3, ::3], Y[::3, ::3], 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   753
           U[::3, ::3], V[::3, ::3],
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   754
           color='r', units='x', 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   755
           linewidths=(2,), 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   756
           edgecolors=('k'), 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   757
           headaxislength=5 )
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   758
qk = quiverkey(Q, 0.5, 0.03, 1, '1 m/s', 
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   759
               fontproperties=
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   760
               {'weight': 'bold'})
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   761
axis([-1, 7, -1, 7])
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   762
title('triangular head; scale '\
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   763
      'with x view; black edges')
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   764
\end{lstlisting}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   765
  \end{block}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   766
\end{columns}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   767
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   768
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   769
\begin{frame}[fragile] \frametitle{Maps}
8
41bdf277c755 Added legend() section.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
   770
  \includegraphics[height=2.3in, interpolate=true]{data/plotmap}  
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   771
  \begin{center}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   772
    \tiny
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   773
    For details see \url{http://matplotlib.sourceforge.net/screenshots/plotmap.py}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   774
  \end{center}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   775
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   776
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   777
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   778
\begin{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   779
  \frametitle{More information}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   780
  \begin{itemize}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   781
  \item More information here: \url{http://matplotlib.sf.net}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   782
  \item \url{http://matplotlib.sf.net/tutorial.html}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   783
  \item \url{http://matplotlib.sf.net/screenshots.html}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   784
  \end{itemize}
66
523f788d2147 Minor edits to Day2 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents: 46
diff changeset
   785
\inctime{5}
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   786
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   787
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   788
\begin{frame}
9
2281002b579b Edited Problem Sets - Added cobweb plot; Removed Koch.
Puneeth Chaganti <punchagan@fossee.in>
parents: 6
diff changeset
   789
  \frametitle{Problem Set}
97
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   790
  \begin{itemize}
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   791
      \item[1] Write a function that plots any regular n-gon given \typ{n}.
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   792
      \item[2] Consider the logistic map, $f(x) = kx(1-x)$, plot it for
20
84458ebb6951 Modified numpy array parts.
Shantanu <shantanu@fossee.in>
parents: 12
diff changeset
   793
          $k=2.5, 3.5$ and $4$ in the same plot.
97
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   794
\end{itemize}
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   795
\end{frame}
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   796
9
2281002b579b Edited Problem Sets - Added cobweb plot; Removed Koch.
Puneeth Chaganti <punchagan@fossee.in>
parents: 6
diff changeset
   797
\begin{frame}[fragile] 
2281002b579b Edited Problem Sets - Added cobweb plot; Removed Koch.
Puneeth Chaganti <punchagan@fossee.in>
parents: 6
diff changeset
   798
\frametitle{Problem Set}
2281002b579b Edited Problem Sets - Added cobweb plot; Removed Koch.
Puneeth Chaganti <punchagan@fossee.in>
parents: 6
diff changeset
   799
  \begin{columns}
2281002b579b Edited Problem Sets - Added cobweb plot; Removed Koch.
Puneeth Chaganti <punchagan@fossee.in>
parents: 6
diff changeset
   800
    \column{0.6\textwidth}
2281002b579b Edited Problem Sets - Added cobweb plot; Removed Koch.
Puneeth Chaganti <punchagan@fossee.in>
parents: 6
diff changeset
   801
    \small{
97
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   802
    \begin{itemize}
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   803
      \item[3] Consider the iteration $x_{n+1} = f(x_n)$ where $f(x) = kx(1-x)$.  Plot the successive iterates of this process as explained below. 
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   804
    \end{itemize}}
9
2281002b579b Edited Problem Sets - Added cobweb plot; Removed Koch.
Puneeth Chaganti <punchagan@fossee.in>
parents: 6
diff changeset
   805
    \column{0.35\textwidth}
2281002b579b Edited Problem Sets - Added cobweb plot; Removed Koch.
Puneeth Chaganti <punchagan@fossee.in>
parents: 6
diff changeset
   806
    \hspace*{-0.5in}
2281002b579b Edited Problem Sets - Added cobweb plot; Removed Koch.
Puneeth Chaganti <punchagan@fossee.in>
parents: 6
diff changeset
   807
  \includegraphics[height=1.6in, interpolate=true]{data/cobweb}  
2281002b579b Edited Problem Sets - Added cobweb plot; Removed Koch.
Puneeth Chaganti <punchagan@fossee.in>
parents: 6
diff changeset
   808
\end{columns}
97
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   809
\end{frame}
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   810
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   811
\begin{frame}
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   812
  
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   813
  Plot the cobweb plot as follows:
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   814
  \begin{enumerate}
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   815
    \item Start at $(x_0, 0)$ ($\implies$ i=0)
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   816
    \item Draw a line to $(x_i, f(x_i))$
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   817
    \item Set $x_{i+1} = f(x_i)$
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   818
    \item Draw a line to $(x_{i+1}, x_{i+1})$
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   819
    \item $(i\implies i+1)$ 
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   820
    \item Repeat from 2 for as long as you want 
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   821
  \end{enumerate}
9
2281002b579b Edited Problem Sets - Added cobweb plot; Removed Koch.
Puneeth Chaganti <punchagan@fossee.in>
parents: 6
diff changeset
   822
\inctime{20}
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   823
\end{frame}
97
555237dbce44 Changing authors, etc. Changes at BPRIM.
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   824
76
b24c2560f626 Added links.tex, compilation of various links.
Shantanu <shantanu@fossee.in>
parents: 66
diff changeset
   825
\begin{frame}{Summary}
b24c2560f626 Added links.tex, compilation of various links.
Shantanu <shantanu@fossee.in>
parents: 66
diff changeset
   826
  \begin{itemize}
b24c2560f626 Added links.tex, compilation of various links.
Shantanu <shantanu@fossee.in>
parents: 66
diff changeset
   827
  \item Basics of Numpy.
b24c2560f626 Added links.tex, compilation of various links.
Shantanu <shantanu@fossee.in>
parents: 66
diff changeset
   828
  \item Array operations.
b24c2560f626 Added links.tex, compilation of various links.
Shantanu <shantanu@fossee.in>
parents: 66
diff changeset
   829
  \item Plotting in 2D.
b24c2560f626 Added links.tex, compilation of various links.
Shantanu <shantanu@fossee.in>
parents: 66
diff changeset
   830
  \end{itemize}
b24c2560f626 Added links.tex, compilation of various links.
Shantanu <shantanu@fossee.in>
parents: 66
diff changeset
   831
\end{frame}
3
18a010e4caa0 Added day2 session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   832
\end{document}