Set curve units
Overview
This script shows how to change the units associated to a curve in HyperGraph-2D / Line Chart.
It runs through all pages and windows, looping over all curves and sets identical Unit Type (physical quantity) and Unit to each curve.
Note:
This does change the unit system associated with the curve, and curve x/y values stay unchanged.
The purpose is not, to change the axis display units from e.g. [ms] to [s], which would change the curve values according to the axis units. So this is a different attribute / operation, with different effects on the database.
Pre-Requisite
-------------------------------------------------------------------------------------------------------------------------------------------------------------
Usage/Installation Instructions
-------------------------------------------------------------------------------------------------------------------------------------------------------------
Run script from DropDown File > Load > Script
Using GUI this would work through context menu applied on a curve from the graphics window.
In case the user uses Unit Scaling and curve data formats that support unit systems, units are attributes of curve vectors that are saved as metadata. The script does what the user can edit through this GUI. There is a Unit Type and a Unit. Example:
These lines of the script contain the actual unit definition to be set, see below comments to know what is necessary to follow in syntax (in this example for strings "time", "ms", "angular_acceleration", "rad/s2"):
xvec$t$k SetMetaData HWUnitType "time"
xvec$t$k SetMetaData HWUnit "ms"
yvec$t$k SetMetaData HWUnitType "angular_acceleration"
yvec$t$k SetMetaData HWUnit "rad/s2"
It is important to know, that the unit string parameter that is handed over as argument, must be identically in syntax (upper or lower case is important) to the strings that can be seen when using context menu on desired curve with "Edit Data Attributes". So the user should plot a curve manually with desired units upfront, and get the data attribute string for the script from here:
Post-Requisite
-------------------------------------------------------------------------------------------------------------------------------------------------------------