Advanced Octave A09 — Series quality and alignment

by Giux GX-TXT, octave-en, scripts-en 3 min read

Advanced GNU Octave with GX-TXT · Module 02

Two series can cover the same time interval with different samples. Comparing the second value of one with the second of the other can therefore mean comparing different moments. In this lesson we choose a common grid and make explicit interpolation.

Data and objectives

We use the synthetic A series of the lesson A07, sampled every 0,5 s, and a new synthetic B series sampled every 1 s. Both cover 0–5 s and are expressed in volts. The B series follows 0,8 + 0,1 t V; it does not represent measures. The test uses GX-TXT dev112-P011-bis and GNU Octave 9.4.0.

The introductory course introduced the interpolation; here we use it to express the alignment of two Dataset beds from the Bridge. We do not assume that having the same number of values would be enough to ensure synchronization.

Choose a common grid

Import allinea_serie.m to the A07 lesson session and start it from the Runner. The script creates the Dataset B if the ID does not exist and reuses it otherwise; to avoid collisions use a dedicated session or verify the one already present.

After reading both dataset time and voltage, the code controls axis order and the common range:

ta = a.time_s.values(:); va = a.voltage_v.values(:);
tb = b.time_s.values(:); vb = b.voltage_v.values(:);
assert(all(diff(ta)>0) && all(diff(tb)>0));
assert(min(ta)>=min(tb) && max(ta)<=max(tb));
vb_aligned = interp1(tb, vb, ta, 'linear');

The grid you choose is that of A. interp1 estimates B on the A snapshots with linear interpolation, without leaving the range of B. The comparison should be done only after checking that the units and the temporal reference are compatible: in this exercise the conventions are known because we have defined them.

In execution A has 11 samples and B has 6. A 0,5 s, A vale 1,325 V and B interpolated 0,850 V. The latter is an estimated value between two samples of the B series, not a new measure. The example produces alignment in memory and does not publish a new derivative series.

Checks before comparison

In real data it controls identifiers, units, reference and time zone if relevant, non-finished values, duplicates and gaps. Establishing a temporal or interpolar tolerance are different choices: the method must be motivated and documented together with its consequences. Even when the axes have the same length it is necessary to compare the values, because equal length does not mean equal moments.

Exercise

  1. Why doesn’t the second B sample match A’s second?
  2. Does the interpolation at 0,5 s create a new measure?
  3. Why does the script check that the A grid is inside the B range?

Worked solution

  1. The B step is 1 s, that of A is 0,5 s.
  2. No: calculates an estimate based on the chosen interpolation model.
  3. To avoid using the same procedure as extrapolation outside the domain of data B.

Download the Module 02 scripts (ZIP)

#GNU Octave #GX-TXT #GX-TXT public APIs

Other steps of this project

Leave a Reply

Your email address will not be published. Required fields are marked *