next up previous contents
Next: 6.2 Data manipulation II: Up: 6. Manipulating and analysing Previous: 6. Manipulating and analysing

   
6.1 Data manipulation I: Build in functions

A common task is the numerical manipulation of a data set, e.g. to add some constant to a data set or inverse all y-values. The command 'ccal' offers a variety of manipulation functions for a specific data set. The command 'kcal' on the other had allows simple arithmetic operations between two data sets. The commands and valid operations are listed in table 6.1.


 
Table 6.1: Data manipulation functions
Command Operation Description
ccal add Performs xi = xi + a
  exp Performs $x_{i} = \exp (x_{i})$
  inv Performs $x_{i} = \frac {1} {x_{i}}$
  log Performs $x_{i} = \ln (x_{i})$
  mul Performs $x_{i} = f \cdot x_{i}$
  sqr Performs $x_{i} = \sqrt {x_{i}}$
  squ Performs xi = xi2
kcal add Performs x'''i = x''i + x'i
  mul Performs $x'''_{i} = x''_{i} \cdot x'_{i}$

Note that xi in table 6.1 stands for x-, y-, z- and $\sigma_{x}$- or $\sigma_{y}$-values depending on the given parameters. The following simple command will multiply all y-values of data set one with the factor 1.75:

     ccal mul,wy,1,1.75

The parameter 'mul' indicates that a multiplication is to be performed using the y-values which are selected by the next parameter ('wy'). Finally data set one and the desired factor of 1.75 are specified. For x- and z-values use 'wx' and 'wz', the standard deviations $\sigma_{x}$ and $\sigma_{y}$ are selected using the parameters 'dx' and 'dy'.


  
Figure 6.1: Demonstration of data smoothing
\includegraphics[scale=0.8]{mat.2.eps}

Another data manipulation command is 'glat'. The name is a reminder that the first KUPLOT version was in German. This command performs data smoothing for both 1D and 2D data sets (smoothing in German is 'glätten'). The smoothing is performed by a gliding average of n neighbouring points. The value of n is given as parameter of the command 'glat'. An example for the smoothing operation is given in figure 6.1. The view graph on the right show the raw data showing quite noisy contour lines. The picture ion the right show the same view graph after the data set was smoothed with a value of n=5 using the command 'glat 1,5' assuming the values are stored as data set one. You might have noticed that these data shown in earlier examples were already slightly smoothed.

Another feature $\star$]$\star$of KUPLOT is the capability to create a data set from an arithmetic expression rather than reading it from a file. This is done using the command 'func'. The following two commands demonstrate usage of 'func' to create a 1D data set ( $y =
\sin(x))$ and a 2D data set ( $z = \sin(x) \cdot \cos(y))$.

  func sin(r[0]),0.0,6.3,0.1
  func sin(r[0])*cos(r[1]),0,6,0.1,0,6,0.1

Note that the variable 'r[0]' is used for the x-argument and r[1] is used as y-argument. Thus values previously stored in these two variables are destroyed by the 'func' command. The following commands are the range and the grid size in the two directions. In our first example, the desired x-range is $0.0 \rightarrow 6.3$ with a grid size of $\Delta x = 0.1$. This results the creation of a data set with 64 points. The second 'func' command shown above creates a 2D data set ranging from 0.0 to 6.1 in x- and y-direction with a grid size of $\Delta x = \Delta y = 0.1$ given a size of 61x61 data points. Because the function values are calculated using the internal interpreter of KUPLOT the creation of large data sets from an arithmetic expression might be relatively slow.


next up previous contents
Next: 6.2 Data manipulation II: Up: 6. Manipulating and analysing Previous: 6. Manipulating and analysing
Thomas Proffen {Billinge}
1999-02-09