# HG changeset patch # User Amit Sethi # Date 1289295613 -19800 # Node ID 06ac45f4de88ddf5779a67f96ad6b5b724a9e189 # Parent 8afa31ae6129d78fdc8a4ae76a19612873e6b5c8 Changed Plotting Data according to review diff -r 8afa31ae6129 -r 06ac45f4de88 additional_ipython/script.rst --- a/additional_ipython/script.rst Tue Nov 09 12:42:40 2010 +0530 +++ b/additional_ipython/script.rst Tue Nov 09 15:10:13 2010 +0530 @@ -214,5 +214,5 @@ This tutorial was created as a part of FOSSEE project, NME ICT, MHRD India Hope you have enjoyed and found it useful. -Thank you! +Thank You! diff -r 8afa31ae6129 -r 06ac45f4de88 basic-data-type/slides.org --- a/basic-data-type/slides.org Tue Nov 09 12:42:40 2010 +0530 +++ b/basic-data-type/slides.org Tue Nov 09 15:10:13 2010 +0530 @@ -18,7 +18,7 @@ #+LaTeX_HEADER: commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen}, #+LaTeX_HEADER: showstringspaces=false, keywordstyle=\color{blue}\bfseries} -#+TITLE: Plotting Data +#+TITLE: Basic Data Types #+AUTHOR: FOSSEE #+DATE: 2010-09-14 Tue #+EMAIL: info@fossee.in diff -r 8afa31ae6129 -r 06ac45f4de88 input_output/script.rst --- a/input_output/script.rst Tue Nov 09 12:42:40 2010 +0530 +++ b/input_output/script.rst Tue Nov 09 15:10:13 2010 +0530 @@ -19,7 +19,7 @@ Script ------ -Hello friends and welcome to the tutorial on Input/Output +Hello friends and welcome to this tutorial on Input/Output {{{ Show the slide containing title }}} @@ -38,10 +38,12 @@ a print a -print a prints the value of a which is obvious. +print a, prints the value of a. As you can see, even when you type just a, the value of a is shown. But there is a difference. +.. #[Amit: The next sentence does seem to be clear enough] + Typing a shows the value of a while print a prints the string. This difference becomes more evident when we use strings with newlines in them. type @@ -59,7 +61,10 @@ We shall look at different ways of outputting the data. -print statement also accepts the syntax of C's printf statement. +.. #[Amit: C's printf syntax ?? i think its better to elaborate the + idea] + +print statement in python supports string formatting. Various arguments can be passed to print using modifiers. type :: @@ -168,24 +173,27 @@ {{{ Pause here and try out the following exercises }}} -%% 4 %% How do you display a prompt and let the user enter input in a new line +%% 4 %% How do you display a prompt and let the user enter input in next line {{{ continue from paused state }}} .. #[Puneeth: We didn't talk of new-line character till now, did we?] .. #[Puneeth: non-programmers might not know?] +.. #[Amit: Well there is a discussion earlier about new lines, I think its good +.. as a slight trick question. But may be next line is a more easier lexicon] + The trick is to include a newline character at the end of the prompt string. :: ip = raw_input("Please enter a number in the next line\n> ") -prints the newline character and hence the user enters input in the new line +prints the newline character and hence the user enters input in the next line {{{ Show summary slide }}} This brings us to the end of the tutorial. -we have learnt +In this totorial we have learnt * How to print some value * How to print using modifiers @@ -194,9 +202,9 @@ {{{ Show the "sponsored by FOSSEE" slide }}} -#[Nishanth]: Will add this line after all of us fix on one. + This tutorial was created as a part of FOSSEE project, NME ICT, MHRD India Hope you have enjoyed and found it useful. -Thankyou +Thank You. diff -r 8afa31ae6129 -r 06ac45f4de88 plotting-data/questions.rst --- a/plotting-data/questions.rst Tue Nov 09 12:42:40 2010 +0530 +++ b/plotting-data/questions.rst Tue Nov 09 15:10:13 2010 +0530 @@ -19,14 +19,16 @@ -3. How do you plot points ? +3. How do you plot the data as points using plot function? By passing an extra parameter '.'. .. #[[Anoop: It can better if asked as, How do you plot the data as points using plot function?]] -4. What does the parameter 'o' do ? +4. Can you comment about the result of this plot command . + plot(x, y,'o') + It plots large points. diff -r 8afa31ae6129 -r 06ac45f4de88 plotting-data/script.rst --- a/plotting-data/script.rst Tue Nov 09 12:42:40 2010 +0530 +++ b/plotting-data/script.rst Tue Nov 09 15:10:13 2010 +0530 @@ -44,13 +44,14 @@ 2. We will also become familiar with elementwise squaring of such a sequence. -3. We will also see how we can use our graph to indicate Error. +3. How to plot data points using python. + +4. We will also see how we can use our graph to indicate Error. One needs to be familiar with the concepts of plotting mathematical functions in Python. -We will use data from a Simple Pendulum Experiment to illustrate our -points. +We will use data from a Simple Pendulum Experiment to illustrate. .. #[[Anoop: what do you mean by points here? if you mean the points/numbered list in outline slide, then remove the usage point @@ -67,29 +68,28 @@ First we will have to initiate L and T values. We initiate them as sequence -of values. To tell ipython a sequence of values we write the sequence in -comma seperated values inside two square brackets. This is also called List -so to create two sequences +of values. We define a sequence by comma seperated values inside two square brackets. +This is also called List.Lets create two sequences L and t. .. #[[Anoop: instead of saying "to tell ipython a sequence of values" and make it complicated, we can tell, we define a sequence as]] -L,t type in ipython shell. - .. #[[Anoop: sentence is incomplete, can be removed]] -:: +{{{ Show the initializing L&T slide }}} + +Type in ipython shell :: - In []: L = [0.1, 0.2, 0.3, 0.4, 0.5,0.6, 0.7, 0.8, 0.9] + L = [0.1, 0.2, 0.3, 0.4, 0.5,0.6, 0.7, 0.8, 0.9] - In []: t= [0.69, 0.90, 1.19,1.30, 1.47, 1.58, 1.77, 1.83, 1.94] + t= [0.69, 0.90, 1.19,1.30, 1.47, 1.58, 1.77, 1.83, 1.94] -To obtain the square of sequence t we will use the function square +To obtain the square of sequence t we will use the function square with argument t.This is saved into the variable tsquare.:: - In []: tsquare=square(t) - + tsquare=square(t) + tsqaure array([ 0.4761, 0.81 , 1.4161, 1.69 , 2.1609, 2.4964, 3.1329, 3.3489, 3.7636]) @@ -98,49 +98,51 @@ Now to plot L vs T^2 we will simply type :: - In []: plot(L,t,'.') + plot(L,tsquare,'.') .. #[[Anoop: be consistent with the spacing and all.]] '.' here represents to plot use small dots for the point. :: - In []: clf() + clf() You can also specify 'o' for big dots.:: - In []: plot(L,t,'o') + plot(L,tsquare,'o') - In []: clf() + clf() .. #[[Anoop: Make sure code is correct, corrected plot(L,t,o) to plot(L,t,'o')]] -{{{ Slide with Error data included }}} + .. #[[Anoop: again slides are incomplete.]] -Now we shall try and take into account error into our plots . The -Error values for L and T are on your screen.We shall again intialize -the sequence values in the same manner as we did for L and t +For any experimental there is always an error in measurements due to +instrumental and human constaraints.Now we shall try and take into +account error into our plots . The Error values for L and T are on +your screen.We shall again intialize the sequence values in the same +manner as we did for L and t +The error data we will use is on your screen. + +{{{ Show the Adding Error Slide }}} .. #[[Anoop: give introduction to error and say what we are going to do]] :: - In []: delta_L= [0.08,0.09,0.07,0.05,0.06,0.00,0.06,0.06,0.01] - - In []: delta_T= [0.04,0.08,0.11,0.05,0.03,0.03,0.01,0.07,0.01] - - + delta_L= [0.08,0.09,0.07,0.05,0.06,0.00,0.06,0.06,0.01] + delta_T= [0.04,0.08,0.03,0.05,0.03,0.03,0.04,0.07,0.08] Now to plot L vs T^2 with an error bar we use the function errorbar() The syntax of the command is as given on the screen. :: - In []: errorbar(L,tsquare,xerr=delta_L, yerr=delta_T, fmt='b.') + errorbar(L,tsquare,xerr=delta_L, yerr=delta_T, fmt='b.') This gives a plot with error bar for x and y axis. The dots are of blue color. The parameters xerr and yerr are error on x and y axis and @@ -150,18 +152,18 @@ similarly we can draw the same error bar with big red dots just change the parameters to fmt to 'ro'. :: - In []: clf() - In []: errorbar(L,tsquare,xerr=delta_L, yerr=delta_T, fmt='ro') + clf() + errorbar(L,tsquare,xerr=delta_L, yerr=delta_T, fmt='ro') thats it. you can explore other options to errorbar using the documentation of errorbar.:: - In []: errorbar? + errorbar? -{{{ Summary Slides }}} +{{{ Show Summary Slide }}} In this tutorial we have learnt : @@ -182,5 +184,5 @@ Hope you have enjoyed and found it useful. - Thankyou +Thank You! diff -r 8afa31ae6129 -r 06ac45f4de88 plotting-data/slides.org --- a/plotting-data/slides.org Tue Nov 09 12:42:40 2010 +0530 +++ b/plotting-data/slides.org Tue Nov 09 15:10:13 2010 +0530 @@ -2,26 +2,40 @@ #+LaTeX_CLASS_OPTIONS: [presentation] #+BEAMER_FRAME_LEVEL: 1 -#+BEAMER_HEADER_EXTRA: \usetheme{Warsaw}\useoutertheme{infolines}\usecolortheme{default}\setbeamercovered{transparent} +#+BEAMER_HEADER_EXTRA: \usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent} #+COLUMNS: %45ITEM %10BEAMER_env(Env) %10BEAMER_envargs(Env Args) %4BEAMER_col(Col) %8BEAMER_extra(Extra) #+PROPERTY: BEAMER_col_ALL 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 :ETC -#+OPTIONS: H:5 num:t toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t + +#+LaTeX_CLASS: beamer +#+LaTeX_CLASS_OPTIONS: [presentation] + +#+LaTeX_HEADER: \usepackage[english]{babel} \usepackage{ae,aecompl} +#+LaTeX_HEADER: \usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet} + +#+LaTeX_HEADER: \usepackage{listings} + +#+LaTeX_HEADER:\lstset{language=Python, basicstyle=\ttfamily\bfseries, +#+LaTeX_HEADER: commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen}, +#+LaTeX_HEADER: showstringspaces=false, keywordstyle=\color{blue}\bfseries} #+TITLE: Plotting Experimental Data #+AUTHOR: FOSSEE #+DATE: 2010-09-14 Tue #+EMAIL: info@fossee.in -# \author[FOSSEE] {FOSSEE} - -# \institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay} -# \date{} +#+DESCRIPTION: +#+KEYWORDS: +#+LANGUAGE: en +#+OPTIONS: H:3 num:nil toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t +#+OPTIONS: TeX:t LaTeX:nil skip:nil d:nil todo:nil pri:nil tags:not-in-toc -* Tutorial Plan -** Plotting Experiment Data and Error Bars -* Pre-requisites -** Plotting simple analytical Functions -* plot L vs. T^2 +* Outline + - Defining sequence of numbers + - Squaring sequence of numbers + - Plotting Data Points + - Indicating Error through Errorbars + +* Simple Pendulum Data #+ORGTBL: L vs T^2 orgtbl-to-latex @@ -36,41 +50,27 @@ | 0.8 | 1.83 | | 0.9 | 1.94 | - - * Initializing L & T - : In []: L = [0.1, 0.2, 0.3, 0.4, 0.5, - : 0.6, 0.7, 0.8, 0.9] - : In []: t = [0.69, 0.90, 1.19, - : 1.30, 1.47, 1.58, - : 1.77, 1.83, 1.94] -* square() - : In []: tsquare=square(t) - - : array([ 0.4761, 0.81 , 1.4161, 1.69 , 2.1609, 2.4964, 3.1329, - : 3.3489, 3.7636]) - - -* Plotting - : In[]: plot(L,t,.) - - - : In[]: plot(L,t,o) + : L = [0.1, 0.2, 0.3, 0.4, 0.5, + : 0.6, 0.7, 0.8, 0.9] + : t = [0.69, 0.90, 1.19, + : 1.30, 1.47, 1.58, + : 1.77, 1.83, 1.94] * Adding Error - | L | T | /Delta L | /Delta T | + | L | T | \delta L | \delta T | | 0.1 | 0.69 | 0.08 | 0.04 | | 0.2 | 0.90 | 0.09 | 0.08 | - | 0.3 | 1.19 | 0.07 | 0.11 | + | 0.3 | 1.19 | 0.07 | 0.03 | | 0.4 | 1.30 | 0.05 | 0.05 | | 0.5 | 1.47 | 0.06 | 0.03 | | 0.6 | 1.58 | 0.00 | 0.03 | - | 0.7 | 1.77 | 0.06 | 0.01 | + | 0.7 | 1.77 | 0.06 | 0.04 | | 0.8 | 1.83 | 0.06 | 0.07 | - | 0.9 | 1.94 | 0.01 | 0.01 | + | 0.9 | 1.94 | 0.01 | 0.08 | * Plotting Error bar @@ -78,4 +78,9 @@ : In[]: errorbar(L,tsquare,xerr=delta_L, yerr=delta_T, : fmt='b.') - +* Summary + : L = [0.1, 0.2, 0.3, 0.4, 0.5, | + : 0.6, 0.7, 0.8, 0.9] + : plot(x,y,'o') + : plot(x,y,'.') + : errorbar(L,tsquare,xerr=delta_L, yerr=delta_T, fmt='b.') diff -r 8afa31ae6129 -r 06ac45f4de88 plotting-data/slides.tex --- a/plotting-data/slides.tex Tue Nov 09 12:42:40 2010 +0530 +++ b/plotting-data/slides.tex Tue Nov 09 15:10:13 2010 +0530 @@ -1,4 +1,4 @@ -% Created 2010-11-07 Sun 18:57 +% Created 2010-11-09 Tue 15:09 \documentclass[presentation]{beamer} \usepackage[latin1]{inputenc} \usepackage[T1]{fontenc} @@ -16,13 +16,19 @@ \usepackage{amssymb} \usepackage{hyperref} \tolerance=1000 +\usepackage[english]{babel} \usepackage{ae,aecompl} +\usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet} +\usepackage{listings} +\lstset{language=Python, basicstyle=\ttfamily\bfseries, +commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen}, +showstringspaces=false, keywordstyle=\color{blue}\bfseries} \providecommand{\alert}[1]{\textbf{#1}} \title{Plotting Experimental Data} \author{FOSSEE} \date{2010-09-14 Tue} -\usetheme{Warsaw}\useoutertheme{infolines}\usecolortheme{default}\setbeamercovered{transparent} +\usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent} \begin{document} \maketitle @@ -32,27 +38,23 @@ + + + \begin{frame} -\frametitle{Tutorial Plan} +\frametitle{Outline} \label{sec-1} + \begin{itemize} - -\item Plotting Experiment Data and Error Bars\\ -\label{sec-1_1}% -\end{itemize} % ends low level +\item Defining sequence of numbers +\item Squaring sequence of numbers +\item Plotting Data Points +\item Indicating Error through Errorbars +\end{itemize} \end{frame} \begin{frame} -\frametitle{Pre-requisites} +\frametitle{Simple Pendulum Data} \label{sec-2} -\begin{itemize} - -\item Plotting simple analytical Functions\\ -\label{sec-2_1}% -\end{itemize} % ends low level -\end{frame} -\begin{frame} -\frametitle{plot L vs. T$^2$} -\label{sec-3} @@ -74,70 +76,38 @@ - \end{frame} \begin{frame}[fragile] \frametitle{Initializing L \& T} -\label{sec-4} - -\begin{verbatim} - In []: L = [0.1, 0.2, 0.3, 0.4, 0.5, - 0.6, 0.7, 0.8, 0.9] - In []: t = [0.69, 0.90, 1.19, - 1.30, 1.47, 1.58, - 1.77, 1.83, 1.94] -\end{verbatim} -\end{frame} -\begin{frame}[fragile] -\frametitle{square()} -\label{sec-5} +\label{sec-3} \begin{verbatim} - In []: tsquare=square(t) -\end{verbatim} - - -\begin{verbatim} - array([ 0.4761, 0.81 , 1.4161, 1.69 , 2.1609, 2.4964, 3.1329, - 3.3489, 3.7636]) -\end{verbatim} - - - -\end{frame} -\begin{frame}[fragile] -\frametitle{Plotting} -\label{sec-6} - -\begin{verbatim} - In[]: plot(L,t,.) -\end{verbatim} - - - -\begin{verbatim} - In[]: plot(L,t,o) + L = [0.1, 0.2, 0.3, 0.4, 0.5, + 0.6, 0.7, 0.8, 0.9] + t = [0.69, 0.90, 1.19, + 1.30, 1.47, 1.58, + 1.77, 1.83, 1.94] \end{verbatim} \end{frame} \begin{frame} \frametitle{Adding Error} -\label{sec-7} +\label{sec-4} \begin{center} \begin{tabular}{rrrr} - L & T & /Delta L & /Delta T \\ - 0.1 & 0.69 & 0.08 & 0.04 \\ - 0.2 & 0.90 & 0.09 & 0.08 \\ - 0.3 & 1.19 & 0.07 & 0.11 \\ - 0.4 & 1.30 & 0.05 & 0.05 \\ - 0.5 & 1.47 & 0.06 & 0.03 \\ - 0.6 & 1.58 & 0.00 & 0.03 \\ - 0.7 & 1.77 & 0.06 & 0.01 \\ - 0.8 & 1.83 & 0.06 & 0.07 \\ - 0.9 & 1.94 & 0.01 & 0.01 \\ + L & T & $\delta$ L & $\delta$ T \\ + 0.1 & 0.69 & 0.08 & 0.04 \\ + 0.2 & 0.90 & 0.09 & 0.08 \\ + 0.3 & 1.19 & 0.07 & 0.03 \\ + 0.4 & 1.30 & 0.05 & 0.05 \\ + 0.5 & 1.47 & 0.06 & 0.03 \\ + 0.6 & 1.58 & 0.00 & 0.03 \\ + 0.7 & 1.77 & 0.06 & 0.04 \\ + 0.8 & 1.83 & 0.06 & 0.07 \\ + 0.9 & 1.94 & 0.01 & 0.08 \\ \end{tabular} \end{center} @@ -147,7 +117,7 @@ \end{frame} \begin{frame}[fragile] \frametitle{Plotting Error bar} -\label{sec-8} +\label{sec-5} \begin{verbatim} @@ -155,5 +125,17 @@ fmt='b.') \end{verbatim} \end{frame} +\begin{frame}[fragile] +\frametitle{Summary} +\label{sec-6} + +\begin{verbatim} + L = [0.1, 0.2, 0.3, 0.4, 0.5, | + 0.6, 0.7, 0.8, 0.9] + plot(x,y,'o') + plot(x,y,'.') + errorbar(L,tsquare,xerr=delta_L, yerr=delta_T, fmt='b.') +\end{verbatim} +\end{frame} \end{document} diff -r 8afa31ae6129 -r 06ac45f4de88 progress.org --- a/progress.org Tue Nov 09 12:42:40 2010 +0530 +++ b/progress.org Tue Nov 09 15:10:13 2010 +0530 @@ -5,7 +5,7 @@ | 1.4 LO: | embellishing a plot | 2 | Nishanth | Anoop (Done) | | | 1.5 LO: | saving plots | 2 | Anoop | Punch (Done) | | | 1.6 LO: | multiple plots | 3 | Madhu | Nishanth (Done) | | -| 1.7 LO: | additional features of IPython | 2 | Nishanth | Amit (Pending) | | +| 1.7 LO: | additional features of IPython | 2 | Nishanth | Amit (Done) | | | 1.8 LO: | module level assessment | 3 | Madhu | | | |---------+----------------------------------------+-------+----------+-----------------+-----------| | 2.2 LO: | loading data from files | 3 | Punch | Nishanth (Done) | |