summaryrefslogtreecommitdiff
path: root/plotting_data/script.rst
blob: 65456a80d8160ce78ebb9d17d86e7daff38cb301 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
.. Objectives
.. ----------

.. By the end of this tutorial, you will be able to

.. 1. Defining a list of numbers
.. 2. Squaring a list of numbers
.. 3. Plotting data points.
.. 4. Plotting errorbars.


.. Prerequisites
.. -------------

..   1. getting started with plotting

     
.. Author              : Amit 
   Internal Reviewer   : Anoop Jacob Thomas<anoop@fossee.in> 
   External Reviewer   :
   Checklist OK?       : <put date stamp here, if OK> [2010-10-05]

.. #[[Anoop: Add quickref]]
.. #[[Anoop: Slides are incomplete, add summary slide, thank you slide
   etc.]]

===============================
Plotting   Experimental  Data  
===============================   

.. L1

{{{ Show the  first slide containing title, name of the production
team along with the logo of MHRD }}}

.. R1 

Hello Friends and Welcome to this tutorial on 
"Plotting Experimental data".

.. L2
 
{{{ Show the Objectives Slide }}}

.. R2

At the end of this tutorial, you will be able to,

 1. Define a list of numbers.
 #. perform elementwise squaring of the list. 
 #. Plot data points.
 #. plot errorbars.

.. R3

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. 

.. L3

{{{ Simple Pendulum data Slide }}} 

.. R4

As we know for a simple pendulum, length L is directly  proportional to 
the square of time T. We shall be plotting L and T^2 values.

First  we will have  to initiate L and  T values. We initiate them as 
sequence of values.  We define a sequence by comma separated values 
inside two square brackets. This is also called a List.
Let's create two sequences L and t.

.. L4
 
::

    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]

.. R5

To obtain the square of sequence T we will use the function square
with argument T.This is saved into the variable Tsquare.

.. L5

::

    Tsquare=square(T)
    Tsqaure
    array([  0.4761, 0.81 , 1.4161,  1.69 , 2.1609,  2.4964, 3.1329, 
    3.3489, 3.7636])

.. R6  

Now to plot L vs T^2, we will simply type 

.. L6

::

    plot(L,Tsquare,'.')

.. R7

'.' here displays the plot in a dot pattern.
You can also specify 'o' for big dots.For this let us clear the plot first.

.. L7
::
    
    clf()
    plot(L,Tsquare,'o')
    clf()

.. R8

Let us move further.For any experimental there is always an error in 
measurements due to instrumental and human constraints.Now we shall try 
and take these errors into account in our plots . 

.. L8

.. L9

{{{ Show the slide 'Exercise 1' }}}

.. R9

Pause the video here, try out the following exercise and resume the video.

Plot the given experimental data with large dots.The data is
on your screen. 

.. L10

{{{ Show slide 'Exercise 1 data' }}}

.. R10

The error data we will use is on your screen.

.. R11

We shall again initialize the sequence values in the same manner as we 
did for L and T.

.. L11

::

    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]

.. R12
  
Now to plot L vs T^2 with an error bar we use the function ``errorbar()``.

.. L12 
::

    errorbar(L,Tsquare,xerr=delta_L, yerr=delta_T, fmt='bo')

.. R13

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
fmt is the format of the plot.

similarly we can draw the same error bar with small red dots just change
the parameters of fmt to 'r.'. 

.. L13
::

    clf()
    errorbar(L,Tsquare,xerr=delta_L, yerr=delta_T, fmt='r.')

.. R14

you can explore other options to errorbar using the documentation 
of errorbar.

.. L14

::

    errorbar?

.. L15

{{{ Show slide with 'Exercise 2' }}}

.. R15

Pause the video here, try out the following exercise and resume the video.

Plot the given experimental data with small dots.Also include
the error in your plot. 

.. L16

{{{ Show slide 'Exercise 2 data' }}}

.. R16

The data is on your screen

.. L17

{{{ Show Summary Slide }}}

.. R17

This brings us to the end of the end of this tutorial.In this tutorial, 
we have learnt to, 

1. to declare a sequence of numbers using the function ``array``.
#. to perform elementwise squaring using the ``square`` function.
#. to use the various options available for plotting like dots,lines.
#. to Plot experimental data such that we can also represent error by 
   using the ``errorbar()`` function. 

.. L18
    
{{Show self assessment questions slide}}

.. R18

Here are some self assessment questions for you to solve

1. Square the following sequence. 
   
   distance_values=[2.1,4.6,8.72,9.03]

2. Plot L v/s T in red plusses.

.. L19

{{{ solution of self assessment questions on slide }}}

.. R19

And the answers,

1.  To square a sequence of values, we use the function ``square``
::
 
    square(distance_values)

2. We pass an additional argument stating the desired parameter
::

    plot(L,T,'r+')

.. L20

{{{ Show the Thank you slide }}}

.. R20

Hope you have enjoyed this tutorial and found it useful.
Thank You!