Added interpolate and loadtxt section to session 5 day 1.
authorShantanu <shantanu@fossee.in>
Wed, 28 Oct 2009 20:35:55 +0530
changeset 256 a06196a05043
parent 252 359f77927931
child 257 e6e09098bd39
Added interpolate and loadtxt section to session 5 day 1.
day1/data/points.txt
day1/session5.tex
day2/session3.tex
day2/session4.tex
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/day1/data/points.txt	Wed Oct 28 20:35:55 2009 +0530
@@ -0,0 +1,40 @@
+0.01 153.990844267
+0.06 156.161844972
+0.11 158.226964724
+0.16 160.191367397
+0.21 162.059965021
+0.26 163.837430063
+0.31 165.528207113
+0.36 167.136523992
+0.41 168.666402332
+0.46 170.121667625
+0.51 171.505958792
+0.56 172.822737282
+0.61 174.075295727
+0.66 175.266766176
+0.71 176.400127926
+1.26 185.75176924
+1.31 186.373771356
+1.36 186.965438071
+1.41 187.52824886
+1.46 188.063611042
+1.51 187.533026401
+1.56 177.900088899
+1.61 168.736955303
+1.66 160.020713006
+1.71 151.729566862
+1.76 143.842784687
+1.81 136.340645417
+1.86 129.204389797
+1.91 122.416173471
+1.96 115.959022361
+2.51 62.67951023
+2.56 59.135750565
+2.61 55.7648220983
+2.66 52.5582957529
+2.71 49.5081535427
+2.76 46.6067685235
+2.81 43.8468857214
+2.86 41.2216039918
+2.91 38.7243587631
+2.96 36.3489056213
--- a/day1/session5.tex	Wed Oct 28 20:33:17 2009 +0530
+++ b/day1/session5.tex	Wed Oct 28 20:35:55 2009 +0530
@@ -129,20 +129,30 @@
 \begin{frame}[fragile]
 \frametitle{Interpolation}
 \begin{itemize}
-\item Let's use the L and T arrays and interpolate this data to obtain data at new points
+  \item Given data file \typ{points.txt}.
+  \item It contains x,y position of particle.
+  \item Plot the given points.
+%%  \item Interpolate the missing region.
 \end{itemize}
+\emphbar{Loading data (revisited)}
 \begin{lstlisting}
-In []: L = []
-In []: T = []
-In []: for line in open('pendulum.txt'):
-           l, t = line.split()
-           L.append(float(l))
-           T.append(float(t))
-In []: L = array(L)
-In []: T = array(T)
+In []: data = loadtxt('points.txt')
+In []: data.shape
+Out[]: (40, 2)
+In []: x = data[:,0]
+In []: y = data[:,1]
+In []: plot(x, y, '.')
 \end{lstlisting}
 \end{frame}
 
+\begin{frame}
+  \frametitle{\typ{loadtxt}}
+  \begin{itemize}
+  \item Load data from a text file.
+  \item Each row must have same number of values.
+  \end{itemize}
+\end{frame}
+
 %% \begin{frame}[fragile]
 %% \frametitle{Interpolation \ldots}
 %% \begin{small}
@@ -192,29 +202,29 @@
 
 \begin{frame}[fragile]
 \frametitle{\typ{splrep}}
-To find the B-spline representation
+To find the spline curve
 \begin{lstlisting}
-In []: tck = splrep(L, T)
+In []: tck = splrep(x, y)
 \end{lstlisting}
-Returns 
-\begin{enumerate}
-\item the vector of knots, 
-\item the B-spline coefficients 
-\item the degree of the spline (default=3)
-\end{enumerate}
+\typ{tck} contains parameters required for representing the spline curve!
 \end{frame}
 
 \begin{frame}[fragile]
 \frametitle{\typ{splev}}
 To Evaluate a B-spline and it's derivatives
 \begin{lstlisting}
-In []: Lnew = arange(0.1,1,0.005)
-In []: Tnew = splev(Lnew, tck)
+In []: Xnew = arange(0.01,3,0.02)
+In []: Ynew = splev(Xnew, tck)
+
+In []: y.shape
+Out[]: (40,)
 
-#To obtain derivatives of the spline
-#use der=1, 2,.. for 1st, 2nd,.. order
-In []: Tnew = splev(Lnew, tck, der=1)
+In []: Ynew.shape
+Out[]: (150,)
+ 
+In []: plot(Xnew, Ynew)
 \end{lstlisting}
+
 \end{frame}
 
 %% \begin{frame}[fragile]
--- a/day2/session3.tex	Wed Oct 28 20:33:17 2009 +0530
+++ b/day2/session3.tex	Wed Oct 28 20:35:55 2009 +0530
@@ -386,7 +386,7 @@
   \end{itemize}
   \pause
   \begin{block}{The Goal}
-      Provide a \alert{flexible} library/app for every one of these needs!
+      Provide a \alert{flexible} library/app for all of these needs!
   \end{block}
 \end{frame}
 
--- a/day2/session4.tex	Wed Oct 28 20:33:17 2009 +0530
+++ b/day2/session4.tex	Wed Oct 28 20:35:55 2009 +0530
@@ -74,7 +74,7 @@
 
 \newcommand{\tvtk}{\texttt{tvtk}}
 \newcommand{\mlab}{\texttt{mlab}}
-
+\newcommand{\typ}[1]{\lstinline{#1}}
 \newcounter{time}
 \setcounter{time}{0}
 \newcommand{\inctime}[1]{\addtocounter{time}{#1}{\vspace*{0.1in}\tiny \thetime\ m}}
@@ -190,7 +190,7 @@
 \begin{frame}[fragile]
     \frametitle{Debugging effectively}
     \begin{itemize}
-        \item \kwrd{print} based strategy
+        \item \typ{print} based strategy
         \item Process:
     \end{itemize}
 \begin{center}