Advanced Octave A16 — Reproducible transformations
Advanced GNU Octave with GX-TXT · Module 03
A transformation can produce a new Dataset while keeping the source separate. In GX-TXT the Dataset Transform public service allows you to describe the operation, plan it and publish the result through the Script Bridge.
Objectives and prerequisites
We use the octave_advanced_sensor synthetic series of lesson A07, which contains time and tension. We take note of introductory course publications and previous advanced lessons. The test uses GX-TXT dev112-P011-bis and Octave 9.4.0.
We design the two variables in a new Dataset. In this example the source contains only two: the didactic value is to observe the transformation cycle, not to reduce the number of columns. The octave_advanced_projection result is created-only: to repeat the exercise choose a free ID or a new Session.
Describe the transformation
Import proietta_dataset.m, register it and run it from Runner.
The request brings together operation, source, output ID and options in a poster:
src = struct('dataset_id','octave_advanced_sensor', ...
'variable_ids',{{'time_s','voltage_v'}});
output = struct('dataset_id','octave_advanced_projection','storage','auto');
manifest = struct('api_version',1,'operation','project_variables', ...
'sources',{{src}},'output',output,'options',struct(), ...
'schema_policy',struct());
plan = gxtxt_api_call(api,'plan',{manifest});
project_variables selects the variables indicated in the order required. The double levels of cells preserve the ID and source collection as fields of the Octave structure. The plan describes the operation before the publication; the number of rows envisaged is read by the result of the planning.
Run and release
The program uses unwind_protect to release the plan even if the execution fails:
unwind_protect
fprintf('Planned rows: %d\n', plan.row_count);
result = gxtxt_api_call(api,'execute',{plan});
assert(strcmp(result.dataset_id,output.dataset_id));
unwind_protect_cleanup
gxtxt_api_call(api,'release_plan',{plan.plan_id});
end_unwind_protect
Finally, he reads the Dataset derived through the canonical API. A transformation of this type produces a distinct resource and does not require to modify the internal files of the Session.
The test shows 11 rows and 11 rows read in the result. This control does not compare all values: in a real analysis it also checks content, order, unity and origin. Different operations, such as filtering or converting units, require specific options and controls; are not implicit in this projection.
Exercise
- What role does the
octave_advanced_projectionID play? - Why is the plan released in the cleaning section?
- Why don’t 11 incoming and outgoing rows just prove that every value is correct?
Worked solution
- Identify the new derived Dataset, distinct from the source.
- To free the resource even in the presence of a mistake during the execution.
- Counting does not verify content, order, unity or correspondence of variables.
Other steps of this project
- Advanced Octave A75 — Dynamical systems in phase space
- Advanced Octave A81 — Geography of the waves and a 3D surface
- Advanced Octave A82 — Age, sex and demographic inequalities
- Advanced Octave A83 — All-cause mortality, certified COVID deaths and surveillance
- Advanced Octave A84 — A reproducible public account
- Advanced Octave A73 — Optimization landscapes and 3D trajectories