Methods of processing data from a physical experiment

Despite the fact that in most educational institutions in Russia laboratory work takes place in the old format (when a poor student, collecting data from prehistoric equipment, manually measuring the oscillation period with a timer, painfully tries to find an explanation for the unrealistic data), some universities purchased sensors, boards and (most important) computers for the convenience of students. Of course, good equipment improves the accuracy of the experiment. Nevertheless, your humble servant many times came across the nagging of classmates: “Well, what gave us these sensors? It’s easier to draw graphics with pens and time to measure, than tormenting with programming on a compuhter. ”I admit - I also had a similar adaptation period, which, however, passed quite quickly. So, I share my experience.


Perhaps this is the simplest thing that they could show us in the first place (with the possible exception of, perhaps, Word or Excel). Processing data using gluplot is extremely simple and does not require special knowledge in programming, the language is close to algorithmic. Ideal for starting work on graphical data processing.

How to use

Suppose we have a file with data - one column with the measurement values ​​of some parameter. Let's name this file data.dat. We know that the data is a normal distribution, let it be the mass distribution of a batch of screws. Our task is to determine the average value of the mass of the screw. My solution is to plot a histogram from the data and then approximate it with a curve$ f (x) = ae ^ \ frac {{(xc)} ^ 2} {b} $. Below is an example of code for such a construction:

set boxwidth 0.9*bin_width absolute
plot ‘data.dat’ using (rounded($1)):(1) smooth frequency with boxes
set table ‘table.dat’
replot #построение новой таблицы нужно, чтобы не покалечить аппроксимацией исходные данные
unset table
a=6#для точной аппроксимации необходимо "прикинуть" параметры сглаживающей кривой
fit f(x) ‘table.dat’ using 1:2 via a, b, c
plot f(x), ‘data.dat’ using (rounded($1)):(1) smooth frequency with boxes

In the approximation, the values ​​of a, b, and c will be determined with fairly good accuracy. In our problem, it is easy to guess that the parameter c is the average value of the mass of the measured objects. Thus, using simple code and some considerations, you can quickly analyze the collected data.

My conclusions about working with GNUplot

In cases where you need fast graphical processing of large amounts of data (large in the framework of laboratory work), GNUplot is ideal. Nevertheless, sometimes bugs appear, the nature of which you have to think about. I recommend using it for beginners for some basic work, for example, statistical research.


This monster is designed for real lab owners! A purely visual platform for simulating laboratory work. It itself collects data from ComPorts, processes it itself, and itself builds dynamic graphs. Opportunities - a lot. Most engineers work specifically for Labview. BUT! It takes a lot of effort to figure it out.


My conclusions about working with LabVIEW

Definitely not for beginners! If you want, you can sit a couple of days and figure it out, after that the processing time for laboratory work in which you can use microcontrollers with sensors (in my case it was laboratory with all kinds of pendulums) will be significantly reduced.


This language is a great find for physicists. Most often I use it to solve problems of computational physics, for example, the numerical solution of differential equations. Like guplot, this language is good for graphical data processing, it has fewer bugs and simplicity of syntax (although I do not complain about guplot). Personally, I like Python more, but each one has his own.

As an example of working with Python, I give point interpolation by the Lagrange polynomial, because there was no more obvious example of data analysis at hand . Interpolation is usually used to obtain an approximate formula for the dependence of two quantities.

import numpy as np
import matplotlib.pyplot as plt
def f(x, y, t):
    lag = 0
    for j in range(len(y)):
        n = 1
        dn = 1
        for i in range(len(x)): #Многочлен Лагранжа
            if i == j:#Чтобы знаменатель не обращался в ноль
                n = n * 1
                dn = dn * 1
                n = n * (t - x[i])
                dn = dn * (x[j] - x[i])
        lag = lag + y[j] * n / dn
    return lag
xk = np.linspace(-1, 1, 11)
yk = 1/(1+xk**2)
xnew = np.linspace(-1, 1, 200)
ynew = [f(xk, yk, i) for i in xnew]
plt.title(u'Интерполяция по точкам')
plt.plot(xk, yk, '.', xnew, ynew)

My conclusions about working with Python

For me, Python is a priority. Much more features than GNUplot, does not require much effort to understand. Of course, the use of Labview is much more professional, but since I am too lazy to master it requires an impressive amount of time, I prefer to learn all the charms of Python.

Instead of a conclusion

In this short review, I decided to share my experience in using some data processing software. I hope he helps you with your research activities.

Good luck!

Also popular now: