C-LAB Module Documentation 26.11.0 ← Website

C-LAB Python Module Documentation

C-LAB 26.11.0 · November 2026

1About#

This document describes the API of the C-LAB Python module distributed with C-LAB 26.11.0. Get the latest version from https://www.c-lab.tech.

For additional information, support, or feedback, contact us at info@c-lab.tech.

Python® is a registered trademark of the Python Software Foundation.

Copyright 2018 – 2026

All rights reserved

2Classes#

C-LAB module defines 6 custom classes, as listed below. Refer to each section for further information.

clab.Array
Stores data as a contiguous array of IEEE 754 double-precision (64-bit) floating-point values.
clab.Container
Container with all variables (as TimeSeries) read from file.
clab.Mesh
Stores mesh data to be used in surface 3D plots.
clab.Model
Simulation model object.
clab.Result
Container with data results from a simulation model.
clab.TimeSeries
Stores series of data indexed in chronological order.

2.1clab.Array#

clab.Array stores data as a contiguous array of IEEE 754 double-precision (64-bit) floating-point values.

Constructor

An instance of clab.Array can be created directly using the following functions:

clab.Array(list)
listrequired
Python list with numeric values. Behavior with non-numeric types is undefined.
clab.Array(other)
otherrequired
clab.Array. This constructor will shallow-copy other to the new object. Therefore, both objects will share the same underlying data values: modifications done in one object will reflect upon the other. Check the clone function if a deep-copy is required.
clab.Array(len)
lenrequired
Length of the new array. The new clab.Array will be zero-initialized.

Member Variables

clab.Array has no publicly exposed member variables.

Member Functions

clab.Array implements the Number Protocol, supporting standard arithmetic operations: addition, subtraction, multiplication, remainder, division, exponentiation, negation (unary -), absolute value (abs), and the logical operators AND (&), OR (|), XOR (^) and NOT (∼). In-place equivalents are also supported.

The logical operators treat any non-zero value as true and return 1.0 or 0.0: AND (&), OR (|), XOR (^) and NOT (∼, which returns 1.0 where the value is 0.0 and 0.0 otherwise). They are logical, not bitwise.

clab.Array implements the Sequence Protocol, allowing element access via the standard [] operator.

Besides standard protocols, the following member functions are available:

out = clab.Array.clone()
out
clab.Array.

Return a new clab.Array containing a deep-copy of the caller’s values.

out = clab.Array.to_list()
out
Python list with the same length as the clab.Array.

Export array values as a standard Python list.

out = clab.Array.avg()
out
Float.

Return the arithmetic mean (average) of the array’s values.

out = clab.Array.sum()
out
Float.

Return the sum of all elements in the array.

out = clab.Array.count_eq(val)
out
Integer.
valrequired
Numeric value.

Return the number of elements in the array that are exactly equal to val.

out = clab.Array.count_gt(val)
out
Integer.
valrequired
Numeric value.

Return the count of elements that are strictly greater than val.

out = clab.Array.count_lt(val)
out
Integer.
valrequired
Numeric value.

Return the count of elements that are strictly less than val.

out = clab.Array.count_bt(val1, val2)
out
Integer.
val1required
Numeric lower bound.
val2required
Numeric upper bound.

Return the count of elements that are strictly between the provided arguments, i.e., >val1 and <val2.

out = clab.Array.logical_and(rhs)
out
clab.Array.
rhs
clab.Array.

Return a new array (containing 0s and 1s) resulting from the logical AND operation between the current array and clab.Array rhs.

out = clab.Array.logical_or(rhs)
out
clab.Array.
rhs
clab.Array.

Return a new array (containing 0s and 1s) resulting from the logical OR operation between the current array and clab.Array rhs.

out = clab.Array.logical_not()
out
clab.Array.

Return a new array (containing 0s and 1s) representing the logical NOT operation on all elements.

out = clab.Array.logical_xor(rhs)
out
clab.Array.
rhs
clab.Array.

Return a new array (containing 0s and 1s) resulting from the logical XOR operation between the current array and clab.Array rhs.

2.2clab.Container#

The clab.Container class stores variables loaded from a file or acquired from a real-time source (experimental feature). Each clab.TimeSeries is also exposed as an attribute of the container, with its name automatically converted into a valid Python identifier.

Constructor

An instance of clab.Container can be created using:

clab.Container(path, plugin='', realtime=False, samples=300)
pathrequired

Full path to the input file.

If the file is compressed, C-LAB will first decompress it into the cache directory and then load the extracted file using the appropriate loader.

pluginoptional

Full path to a plugin.

If omitted, C-LAB automatically selects a compatible loader by testing installed plugins and built-in loaders. If provided, the specified plugin is used directly, bypassing compatibility checks.

realtimeoptional

[experimental] Enables acquisition from a real-time data source when set to True.

This feature is experimental and its API may change in future releases.

samplesoptional

[experimental] Maximum number of samples stored when acquiring real-time data.

Once this limit is reached, older samples are discarded to accommodate new data. This feature is experimental and subject to change.

Member Variables

clab.Container.id64integer

Read-only. Unique 64-bit identifier.

clab.Container.flagsinteger

Read-only. Reserved for internal use.

Member Functions

clab.Container partially implements the Mapping Protocol, allowing access to individual clab.TimeSeries objects via the [] operator using their source names.

In addition to standard protocol behavior, the following member functions are available:

out = clab.Container.get_path()
out
List.

Returns the list of file paths associated with the container.

out = clab.Container.get_size()
out
Integer.

Returns the number of TimeSeries objects in the container.

clab.Container.axpb(a, b)
arequired
Numeric value.
brequired
Numeric value.

Applies the transformation A⋅X+B to the x-axis of all variables, in place (returns None).

If the data is not yet loaded, the operation is deferred until loading completes.

clab.Container.aypb(a, b)
arequired
Numeric value.
brequired
Numeric value.

Applies the transformation A⋅Y+B to the y-axis of all variables, in place (returns None).

If the data is not yet loaded, the operation is deferred until loading completes.

clab.Container.merge(path)
pathrequired
File path.

Merges the contents of the specified file into the container, without checking compatibility (unlike clab.merge, see Section 6.8.1).

All TimeSeries loaded after this call will use data from this file in addition to previously loaded sources: the samples from all sources are interleaved in time order. Samples with the same time are all kept, with those from earlier sources first. Already loaded TimeSeries remain unchanged.

clab.Container.replace_xdata(ts)
tsrequired
clab.TimeSeries used as the source for x-axis data.

Replaces the x-axis data of all loaded variables using the y-data from ts.

Only already loaded TimeSeries are affected: a TimeSeries loaded after this call (e.g., via clab.TimeSeries.load) uses the x-axis data read from file.

The source data must be strictly increasing (monotonically increasing with no repeated or decreasing values).

If data sizes differ, the maximum compatible subset is copied without overflow, and a warning message is issued.

clab.Container.rt_read()

Refreshes data from a real-time source by invoking the Load function (see Section 5.1.2).

clab.Container.rt_start()

Starts real-time data acquisition by invoking the Start function (see Section 5.1.2).

clab.Container.rt_stop()

Stops real-time data acquisition by invoking the Stop function (see Section 5.1.2).

2.3clab.Mesh#

clab.Mesh stores clab.Array data of the x, y and z-axis to be plotted in a surface mesh plot. X and Z are the input of the mesh function. Y is the output matrix, where x values are stored contiguously:

Y=(yx:0,z:0yx:1,z:0yx:2,z:0⋯yx:0,z:1yx:1,z:1yx:2,z:1⋯⋮⋮⋮yx:0,z:Nyx:1,z:Nyx:2,z:N⋯)

ydata is stored row by row: the value for x index i and z index j is ydata[i + j * len(xdata)]. Therefore len(ydata) must be equal to len(xdata) * len(zdata), and xdata and zdata must have at least 2 elements each; otherwise the Mesh chart rejects the object.

Constructor

An instance of clab.Mesh can be created directly using the following functions:

clab.Mesh()

Create an empty clab.Mesh object.

Member Variables

clab.Mesh.id64integer

Read-only. Unique 64-bit identifier assigned upon creation.

clab.Mesh.flagsinteger

Read-only. Internal use only.

clab.Mesh.xdataclab.Array

Read/write. clab.Array containing the data points for the x-axis coordinates.

clab.Mesh.ydataclab.Array

Read/write. clab.Array containing the data values for the y-coordinate, corresponding to the specified x and z pairs.

clab.Mesh.zdataclab.Array

Read/write. clab.Array containing the data points for the z-axis coordinates.

Only clab.Array objects should be assigned to these members; the type is not checked.

Member Functions

clab.Mesh has no public member functions.

2.4clab.Model#

The clab.Model class represents a simulation model. It can be created programmatically or loaded from a JSON file and used for validation, execution, and code generation. Models cannot be saved to JSON from Python; use the Model Builder tab to save them.

Constructor

An instance of clab.Model can be created using:

clab.Model()

Creates an empty clab.Model.

clab.Model(path)
path
String with the full path to a JSON file.

Creates a clab.Model by loading the JSON file located at the given path. Raises an exception if the file cannot be loaded.

Member Variables

clab.Model.flagsinteger

Read-only. Internal use only.

Member Functions

out = clab.Model.get(key, id)
out
Value of the requested parameter: an integer for inportCount and outportCount, a float for all other keys.
keyrequired

String with the parameter name. It can be one of the following values:

inportCount
Number of inports.
outportCount
Number of outports.
x
Block position (x-axis).
y
Block position (y-axis).
width
Block dimension.
height
Block dimension.
red
Block color channel.
green
Block color channel.
blue
Block color channel.
ti
Simulation initial time (seconds).
tf
Simulation final time (seconds).
ts
Simulation step time (seconds).
idoptional
Block unique identifier. Required when accessing block-specific parameters.

Returns model-level (ti, tf, ts) or block-level parameters. Any other key raises a ValueError.

Examples
model.get(key='ts')
model.get(key='x', id=1234)
clab.Model.set(...)
idoptional
Block unique identifier. Required when modifying block parameters.
xoptional
Block position (x-axis). Values outside the range [0, 10000] are ignored.
yoptional
Block position (y-axis). Values outside the range [0, 10000] are ignored.
widthoptional
Block dimension. Values outside the range [1, 1000] are ignored.
heightoptional
Block dimension. Values outside the range [1, 1000] are ignored.
redoptional
Block color channel, as a float from 0.0 to 1.0 (unlike chart objects, which use integers from 0 to 255). Values outside the range [0.0, 1.0] are ignored.
greenoptional
Block color channel. Values outside the range [0.0, 1.0] are ignored.
blueoptional
Block color channel. Values outside the range [0.0, 1.0] are ignored.
tioptional
Simulation initial time (seconds). It is the time of the first sample.
tfoptional
Simulation final time (seconds). Must be greater than ti. It is the time of the last sample when tf - ti is a multiple of ts.
tsoptional
Simulation step time (seconds). Must be greater than 0.

Sets model-level or block-level parameters. Block-level parameters require id; passing them without it raises a ValueError.

Examples
model.set(ti=5.0, tf=10.0)
model.set(id=1234, x=10, y=20)
out = clab.Model.create(class, ...)
out
Block unique identifier.
classrequired

Block class. It can be one of the following values:

abs
Calculates the absolute value of the input.
acc
Outputs the sum of values from the first port; resets the accumulation to the value of the second port if the third port is True.
acos
Calculates the arccosine of the input.
add
Computes the sum of all inputs.
asin
Calculates the arcsine of the input.
atan
Calculates the arctangent of the input.
cast
Converts the input to a different data type, as specified by the type parameter ('bool', 'int8', 'int16', 'int32', 'int64', 'uint8', 'uint16', 'uint32', 'uint64', 'flt32', 'flt64').
clamp
Limits the value of the first input based on the boundaries set by the second and third inputs.
constant
Represents a constant value source, with its value defined by the expression parameter.
cos
Calculates the cosine of the input.
debounce
Debounces input signals, introducing a delay to filter out rapid changes or noise. The delays are set by the rise and fall parameters (in seconds, default 1.0).
delta
Computes the difference between the current sample and the previous one. The first sample outputs 0.
display
Displays input data.
divide
Computes the quotient of the first input divided by the second input.
enable
Enables or disables sub-system simulation. By default, enable ports are assigned to the port number -1.
from
Used with goto as an alternative for line connections. This block connects to its goto counterpart by its target parameter.
from_workspace
Imports data from a clab.TimeSeries variable, set by the obj parameter.
goto
Used with from as an alternative for line connections. This block connects to its from counterpart by its target parameter.
hysteresis
The output is True when the input is greater than valueOn and False when it is less than valueOff. Otherwise, it keeps its last value.
if
Implements conditional logic. It has 3 inputs: port 0 is the condition, port 1 the value output when the condition is true, and port 2 the value output when it is false.
inport
Represents an input port for receiving external signals into a subsystem. Its number is set by the portNumber parameter (zero-based indexing).
lerp
Computes linear interpolation between two values. Effectively, it outputs A+U×(B−A). The equation coefficients are set by the coeffA and coeffB parameters.
log
Computes the logarithm (base e) of the input.
logical
Performs logical operations on input signals. The logical operation is set by the operator parameter ('and', 'or', 'nand', 'nor').
lut1d
Performs a one-dimensional lookup table operation. Its values are set by the bp1 (breakpoints) and out (output values) parameters.
lut2d
Performs a two-dimensional lookup table operation. Its values are set by the out, bp1 and bp2 parameters.
max
Outputs the maximum value of the input over all samples so far (running maximum).
memory
Delays input sample, by storing its current value and outputting it on the next simulation loop.
min
Outputs the minimum value of the input over all samples so far (running minimum).
mod
Calculates the remainder of the division of the first input by the second input.
multiply
Computes the multiplication of all input values.
not
Performs logical negation, converting True to False and vice versa.
outport
Represents an output port for transmitting signals out of the subsystem. Its number is set by the portNumber parameter (zero-based indexing).
poly1st
Outputs the result of a first-order polynomial, as f(x)=A×x+B. The equation coefficients are set by the coeffA and coeffB parameters.
pow
Raises the first input to the power of the second input.
ramp
Generates a ramp, defined by the initialValue, finalValue and time parameters.
random
Generates random values, defined by the min, max and seed parameters.
refsys
Represents a reference to a subsystem defined in an external file, set by the path parameter.
relational
Compares input values based on relational operations, set by the operator parameter ('eq', 'ge', 'gt', 'le', 'lt', 'ne').
sin
Calculates the sine of the input.
sinewave
Generates a sinusoidal waveform, as specified by the frequency and phase parameters. The frequency is given in hertz and the phase, in degrees.
sqrt
Calculates the square root of the input.
squarewave
Generates a square waveform, as specified by the timeOn, timeOff, valueOn and valueOff parameters.
step
Outputs a step function, defined by the initialValue, finalValue and time parameters.
subsys
Represents a subsystem or a modular block that encapsulates a specific functionality within a larger system.
subtract
Calculates the difference between the first input and the second input.
switch
Routes input signals to the output based on a control signal. It has 3 to 8 inputs: port 0 is the selector. A selector value of 0 outputs port 2, 1 outputs port 3, and so on; any other value outputs port 1 (the default).
tan
Calculates the tangent of the input.
time
Outputs the current simulation time.
to_workspace
Exports to a clab.TimeSeries variable, whose name is set by the name parameter.
unpack
Unpacks the input value, selecting the desired bits and applying a scale factor and offset (bit extraction), as specified by the lsb, msb, coeffA (scale factor, default 1.0) and coeffB (offset, default 0.0) parameters. The bits indexing is zero-based, and the bits are always read as an unsigned binary (USGN).
nameoptional
Block name.
parentoptional
Parent block identifier. If omitted, the block is created in the root subsystem.
...optional
Block-specific parameters, named as in the class list above (e.g., expression for constant, rise and fall for debounce). Classes such as if, switch, max, min, display and subsys take no extra parameters.

Creates a new block and returns its unique identifier.

Examples
model = clab.Model()
c0 = model.create('constant', expression=3.14)
s0 = model.create('sinewave', frequency=2.0)
clab.Model.link(blockFrom, blockTo, portFrom, portTo, name)
blockFromrequired
Source block identifier.
blockTorequired
Destination block identifier.
portFromrequired
Source port index (zero-based).
portTorequired
Destination port index (zero-based).
nameoptional
Connection label.

Creates a connection between blocks.

Examples
model.link(blockFrom=b1, blockTo=b2, portFrom=0, portTo=1)
clab.Model.codegen(lang, path)
langrequired
Target language: 'c' or 'python'.
pathrequired
Output directory path.

Generates source code from the model. Raises an exception on failure.

out = clab.Model.load()
out
Integer: 0 on success, -1 on failure.

Reloads the model from the JSON file given to the constructor, discarding the current model. Unlike the other functions, it does not raise an exception on failure: the errors are printed to the console and -1 is returned.

out = clab.Model.run()
out
clab.Result with the simulation output (see Section 2.5).

Runs the simulation. Raises an exception on failure.

clab.Model.validate()

Validates the model. Raises an exception if errors are found.

2.5clab.Result#

The clab.Result class stores the output data generated by a simulation. It is returned by clab.Model.run (see Section 2.4). Each subsystem in the model is represented by a corresponding clab.Result object, nested as an attribute of its parent’s clab.Result.

The data is accessed through attributes named after the blocks (converted to valid Python identifiers); clab.Result has no mapping or sequence protocol. For instance, with a to-workspace block out1 in the main system and another one in subsystem sub1:

res = model.run()
print(res.ti, res.tf, res.ts)
y1 = res.out1
y2 = res.sub1.out1

Constructor

An instance of clab.Result can be created using:

clab.Result()

Creates an empty clab.Result.

Member Variables

clab.Result.tifloat

Simulation start time.

clab.Result.tffloat

Simulation end time.

clab.Result.tsfloat

Simulation time step.

clab.Result.<name>clab.TimeSeries or clab.Result

One clab.TimeSeries for each to-workspace block, and one clab.Result for each subsystem, named after the block.

clab.Result.flagsinteger

Read-only. Internal use only.

Member Functions

clab.Result does not provide any member functions.

2.6clab.TimeSeries#

clab.TimeSeries stores two clab.Array instances of the same size, holding the x-axis data (typically time, hence the name TimeSeries) and the y-axis data. A third array, zdata, is used only by gridded data such as NetCDF geographic variables. The x-axis values are expected to be strictly increasing, i.e., xdatak<xdatak+1 for any given k.

Constructor

An instance of clab.TimeSeries can be created directly using the following functions:

clab.TimeSeries()

Create an empty clab.TimeSeries object. It’s recommended not to use this function. It’s listed here only for the sake of completeness.

clab.TimeSeries(id64)
id64required
Unique identifier.

Create a clab.TimeSeries from a valid variable identifier id64. This is for internal usage only.

clab.TimeSeries(xvalues, yvalues)
xvaluesrequired
Python List or Python Tuple with the x-axis values. All elements in the sequence must be numeric.
yvaluesrequired
Python List or Python Tuple with the y-axis values. All elements in the sequence must be numeric.

Create a clab.TimeSeries from two Python Lists or from two Python Tuples. The first one has the values for the x-axis and the second one for the y-axis. Both must have the same length; otherwise a ValueError is raised.

clab.TimeSeries(xvalues, yvalues, zvalues)

Same as above, with a third sequence for zdata (e.g., to build a grid for the GeoMap chart). The lengths are not checked.

clab.TimeSeries(rhs)
rhsrequired
clab.TimeSeries.

Create a clab.TimeSeries from another clab.TimeSeries rhs. Both objects will share the same xdata and ydata objects (shallow copy).

Member Variables

clab.TimeSeries.id64integer

Read-only. Unique 64-bit identifier.

clab.TimeSeries.flagsinteger

Read-only. Internal use only.

clab.TimeSeries.xdataclab.Array

Read/write. clab.Array object that stores data to be used in the x-axis (typically time in seconds).

clab.TimeSeries.ydataclab.Array

Read/write. clab.Array object that stores data to be used in the y-axis.

clab.TimeSeries.zdataclab.Array

Read/write. clab.Array object with grid values. Empty for ordinary time series. For geographic data (see the GeoMap chart), xdata holds the longitudes, ydata the latitudes, and zdata the values, row by row: zdata[i_lat * len(xdata) + i_lon].

Member Functions

clab.TimeSeries implements the Number Protocol, i.e., clab.TimeSeries supports the standard operations: add, subtract, multiply, remainder, divide, power, and (&), xor (^), or (|) (and their in-place equivalents), negation (unary -), not (∼), absolute value (abs). For all the aforementioned functions that require two or more operands, the ydata is aligned over time using the xdata values.

The logical operators treat any non-zero value as true and return 1.0 or 0.0: AND (&), OR (|), XOR (^) and NOT (∼, which returns 1.0 where the value is 0.0 and 0.0 otherwise). They are logical, not bitwise.

clab.TimeSeries partially implements the Mapping Protocol. With an integer key, ts[i] works as in the Sequence Protocol below. With a string key, ts['name'] returns the child clab.TimeSeries with that name, for series loaded from a file that have children in the variable tree. A KeyError is raised if there is no such child.

clab.TimeSeries implements the Sequence Protocol, meaning that it’s possible to read each x-y pair in the TimeSeries using the [] operator. Each item contains a two-element tuple: the first element contains the x value and the second, the y value.

Besides the standard protocols, the following member functions are available:

out = clab.TimeSeries.get_name()
out
String.

Return variable’s name. Only available for data loaded directly from sources; calculated variables return an empty string.

out = clab.TimeSeries.get_fs()
out
Sampling frequency in hertz.

Return the estimated sampling frequency in hertz. If the object has not been loaded yet, this function will force it.

out = clab.TimeSeries.get_ts()
out
Sampling period in seconds.

Return the estimated sampling period in seconds. If the object has not been loaded yet, this function will force it.

clab.TimeSeries.axpb(a, b)
arequired
Numeric value.
brequired
Numeric value.

Apply A⋅X+B for all values in the x-axis, in place (returns None). If the data is empty, this operation will be postponed until the data has been successfully loaded.

clab.TimeSeries.aypb(a, b)
arequired
Numeric value.
brequired
Numeric value.

Apply A⋅Y+B for all values in the y-axis, in place (returns None). If the data is empty, this operation will be postponed until the data has been successfully loaded.

out = clab.TimeSeries.avg()
out
Float value.

Return the average of the object’s yvalues.

out = clab.TimeSeries.max()
out
Float value.

Return the maximum of the object’s yvalues.

out = clab.TimeSeries.min()
out
Float value.

Return the minimum of the object’s yvalues.

out = clab.TimeSeries.sum()
out
Float value.

Return the sum of the object’s yvalues.

out = clab.TimeSeries.index(val, op='eq')
out
Integer value.
valrequired
Numeric value. Positional-only.
opoptional
Operator used by search. Valid operators are eq, ne, le, lt, ge or gt.

Return the index of the first sample whose y-value satisfies y op val. If no sample matches, or op is invalid, a ValueError is raised.

clab.TimeSeries.inspect()

Print TimeSeries internal information for debugging and troubleshooting.

clab.TimeSeries.load()

Load TimeSeries values from source file, if they haven’t been already. On success, the members xdata and ydata are filled with the loaded values.

out = clab.TimeSeries.slice(tini, tend)
out
clab.TimeSeries.
tinirequired
Numeric value. Slice initial time.
tendrequired
Numeric value. Slice final time.

Return a new object containing a slice (or subsequence) of the source object, with the samples whose x-values lie between tini and tend, both inclusive.

clab.TimeSeries.sort()

Sort samples chronologically (i.e. by x-axis values).

out = clab.TimeSeries.tag(val)
out
String value.
valrequired
Numeric value.

Return the tag associated with the value val for this object, looked up in the Tags File by this series’ name and the exact value val. If there’s no tag associated, it will return 'n/a'. Series that were not loaded from a file (e.g., calculated ones) have no name, and raise an Exception.

out = clab.TimeSeries.time_eq(val)
out
Numeric value.
valrequired
Numeric value.

Return total time in which y-axis values are equal to val. In all time_* functions, each sample’s value is held until the next sample (zero-order hold): the interval xk+1−xk is counted when yk satisfies the condition.

out = clab.TimeSeries.time_ne(val)
out
Numeric value.
valrequired
Numeric value.

Return total time in which y-axis values are not equal to val.

out = clab.TimeSeries.time_gt(val)
out
Numeric value.
valrequired
Numeric value.

Return total time in which y-axis values are greater than val.

out = clab.TimeSeries.time_lt(val)
out
Numeric value.
valrequired
Numeric value.

Return total time in which y-axis values are less than val.

out = clab.TimeSeries.time_bt(val1, val2)
out
Numeric value.
val1required
Numeric lower bound.
val2required
Numeric upper bound.

Return total time in which y-axis values are between the provided arguments, i.e., simultaneously strictly greater than val1 and strictly less than val2.

3Settings#

Settings can be configured through the dedicated tab in the application UI or via the module functions (see Section 3.3).

3.1UI Settings#

3.1.1UI Theme#

Controls the color theme of the user interface. Default: 'dark'. Configuration key: live, group theme.

Setting this option to 'lite' enables the lite theme.

Changes are applied immediately.

3.1.2Export Theme#

Controls the color theme used when exporting charts to files. Default: 'dark'. Configuration key: file, group theme.

Setting this option to 'lite' enables the lite theme for exported charts. This allows dark UI users to export charts with a light background without changing the UI theme.

Changes are applied immediately.

3.2General Settings#

Each setting below states when a change takes effect. Except where noted, the timing is the same whether the change is made in the Settings tab or with clab.set_config (see Section 3.3).

3.2.1Autosave#

Enables autosave and defines the interval for saving charts and models in memory to a backup file.

Autosave files are stored in: C:\Users\<user>\.clab\cache.

Applied immediately when saved in the Settings tab. When set with clab.set_config, it is applied the next time the Settings tab is opened.

3.2.2Log Severity Level#

Defines the minimum severity level to be logged. Supported values (in increasing order): Trace, Debug, Info, Warning, Error, Fatal, or Disabled.

Logs are stored in: C:\Users\<user>\.clab\logs.

Applied immediately when set with clab.set_config. When changed in the Settings tab, a restart is required.

3.2.3Tags File Path#

Path to a TSV file used to assign tags to specific values in data tips.

If both the parameter name and value match an entry, the corresponding tag is displayed.

Useful for parameters with discrete meanings (e.g., states, modes).

An example file is available in the example directory of the installation folder.

Required TSV columns:

Source
Parameter name.
Value
Parameter value.
Tag
Displayed text.

Restart not required: the file is read again when it changes, the next time data is loaded.

3.2.4Unpack File Path#

Path to a TSV file used to automatically unpack clab.TimeSeries data. If a parameter name matches an entry, its data is unpacked into one or more derived series, equivalent to clab.unpack() (see Section 6.2.8).

An example file is available in the example directory of the installation folder.

The file is tab-separated, and its first line is a header. The first six columns are required; Unit, Type and Indexing are optional.

TSV columns:

Source
Parameter name used for matching.
Alias
Name of the generated series.
MSB
Most significant bit (see Indexing).
LSB
Least significant bit (see Indexing).
Resolution
Scaling factor in the transformation.
Offset
Offset in the transformation.
Unit
Documentation only.
Type
Conversion type, as in clab.unpack: USGN, SGN, 2C or BCD (case-insensitive). Any other value, including an empty one or BNR, means USGN.
Indexing
Bit indexing scheme (e.g., 0 for zero-based).

Transformation: alias = source[msb:lsb] × resolution + offset

Restart not required: the file is read again when a data file is opened.

3.2.5Python Dynamic Library Path#

Specifies the path to the Python 3 dynamic library (.dll) used by C-LAB.

If not set, the embedded version is used: C:\<clab folder>\python\python3.dll.

Restart required.

3.2.6Memory Allowed#

Defines the maximum fraction of system RAM that C-LAB may use. Default: 80%.

If the limit is exceeded, least frequently used data is unloaded until usage falls below the threshold.

Memory usage (used, available, total) is displayed in the application status area.

Restart required.

3.3Using the Module#

3.3.1Read Configuration Values#

out = clab.get_config(key, group='general')
out
Value associated with the specified key: a string, an integer or a boolean, depending on the key (see the table below). Theme keys return an integer: 0 for dark, 1 for lite.
keyrequired
Setting key.
groupoptional
Setting group. Default: 'general'.
Examples
value = clab.get_config(key='memory')
path = clab.get_config(key='tags', group='presets')

3.3.2Write Configuration Values#

Settings take effect at different times; see Sections Section 3.1 and Section 3.2 for details.

clab.set_config(value, key, group='general')
valuerequired
Setting value: a string, a boolean or an integer, as listed below. A value of the wrong type is silently ignored (for instance, memory must be the string '80', not the integer 80). Floats raise a TypeError.
keyrequired

Setting key. Supported values, by group:

autosave
String. One of 'Disabled', 'Every 1 minute', 'Every 10 minutes' (default) or 'Every 30 minutes'. Group: 'general'.
log
String. One of 'Disabled', 'Fatal', 'Error', 'Warning' (default), 'Info', 'Debug' or 'Trace' (case-sensitive). Group: 'general'.
memory
String. Percentage of system RAM, e.g. '80' (default); minimum 10. Group: 'general'.
python3
String. Path to the Python DLL; empty for the embedded one. Group: 'general'.
tags
String. Path to the Tags File. Group: 'presets'.
unpack
String. Path to the Unpack File. Group: 'presets'.
file
String. Export theme: 'dark', or any other value for lite. Group: 'theme'.
live
String. UI theme: 'dark', or any other value for lite. ui is accepted as an older name. Group: 'theme'.
x
Integer. Window horizontal position (not saved). Group: 'window'.
y
Integer. Window vertical position (not saved). Group: 'window'.
height
Integer. Window height. Group: 'window'.
width
Integer. Window width. Group: 'window'.
maximized
Integer. Non-zero to start maximized. Group: 'window'.
<plugin>
Boolean. Enables or disables the plugin with that file name (e.g. 'myplugin.dll'). Group: 'plugins'.
groupoptional
Setting group. Default: 'general'.
Examples
clab.set_config(key='memory', value='80')
clab.set_config(key='tags', group='presets', value='C:/data/tags.tsv')
clab.set_config(key='live', group='theme', value='dark')
clab.set_config(key='width', group='window', value=800)

3.3.3Reload Configuration Values from File#

Reloads configuration data from file. Required only if the configuration file is modified externally. Settings that are applied only at startup (such as the log level and memory) are not re-applied.

clab.reload_config()

4Loading Data From Files#

C-LAB supports loading data from a wide range of file formats using either native loaders or external plugins.

C-LAB does not require the user to explicitly specify the file format. Instead, format detection is performed automatically.

Format Resolution#

When a file is opened, C-LAB determines the appropriate loader using the following procedure:

  1. C-LAB queries all enabled plugins, in folder order, to determine compatibility with the target file. Each plugin MUST evaluate the file and indicate whether it can handle the format. The first compatible plugin is used.
  2. If no plugin reports compatibility, C-LAB attempts to load the file using its native loaders.

Compressed Files#

If the input file is a compressed archive (*.zip, *.7z, *.tar.gz or *.tgz), and no plugin handles it, C-LAB will extract its contents to a cache directory prior to loading. Only the first file in the archive is loaded. Single-file compression such as plain *.gz is not supported.

After extraction, C-LAB applies the standard format resolution process to the extracted file (which may itself be an archive).

4.1Built-In Loaders#

4.1.1ArduPilot Dataflash Logs#

File Extensions
*.bin, *.log
Supported Data Types
Numeric and string values only.
Reference
https://ardupilot.org/copter/docs/common-downloading-and-analyzing-data-logs-in-mission-planner.html

4.1.2Delimiter-Separated Values#

File Extensions
*.csv, *.tsv, *.txt
Format
Values will be separated by a delimiter character.
Supported Delimiters
comma (ASCII 0x2C), semicolon (ASCII 0x3B), pipe (ASCII 0x7C), tab (ASCII 0x09).
Header
The first row will contain parameter names.
Time Axis
The first column will contain time values.

4.1.3Hierarchical Data Format (HDF5)#

File Extensions
*.hdf5, *.h5
Supported Numeric Types
One-dimensional arrays of signed/unsigned integers (8, 16, 32, 64-bit) and IEEE 754 single/double precision.
Supported String Types
Two-dimensional arrays of fixed-length or variable-length ASCII strings.
String Handling
String values will be mapped to unique numeric identifiers.
Time Axis
Array indices will be used as x-axis values.

4.1.4IRIG106 Chapter 10 Files#

File Extensions
*.ch10, *.c10
Formats
PCM Format 1, Analog Format 1, Discrete Format 1, ARINC 429 Format 0, Video Formats 0, 1 and 2 (MPEG-2 transport streams only; program streams are not supported), and Time Format 1.
Setup Record
Data sources are read from the first TMATS setup record of the file; later configuration changes are reported but not applied. Only enabled data sources that have packets in the file produce series.
Time Axis

Clock time in seconds, mapped from the relative time counter (RTC) of the packets by interpolation between time references, so RTC drift and time jumps are followed:

  • UTC seconds since 1970-01-01 when the time packets carry a date (day-month-year format) or IEEE-1588 time is present;
  • seconds since 1 January of an unknown year when the time packets use the day-of-year format;
  • seconds since the first packet of the file when there is no usable time packet.

Time references come from the time packets (the first TIMEIN data source with usable packets, otherwise the first channel with them); without usable time packets, the IEEE-1588 or Chapter 4 secondary headers are used. Intra-packet time stamps are used where present. Samples are sorted by time.

PCM
One series per TMATS measurand (D-record) of the format, otherwise one raw series per word of the minor frame. Packed, unpacked and throughput modes are decoded. Supercommutated and fragmented measurands are supported; subcommutated measurands are selected using the subframe ID counter when available. Minor frames without frame lock are skipped.
Analog
Packed and unpacked (16-bit) samples. Subchannels sampled at different rates within one channel are not supported. Values are converted by the C-record of the measurement when present, otherwise to volts from the full-scale range, data length and offset (R-x\AFSI, R-x\ADL, R-x\AOVI); raw values are returned if neither is available.
Discrete
One series per TMATS discrete measurement (bit mask R-x\DMSK), otherwise one series per bit of the 32-bit state.
ARINC 429
Payload and SSM of each label/SDI pair found in the file. Words received with parity or format errors are ignored.
Video
The transport stream is extracted to a proxy *.ts file in the cache folder; the series holds the byte offset of each TS packet in that proxy file.
Time
For each time channel: the time source, and the drift between the time packet clock and the RTC alone (in seconds).
Engineering Units
C-record conversions (pair sets, polynomial coefficients) and binary formats (unsigned, two’s complement, sign-magnitude, one’s complement, offset binary, BCD, IEEE 754 single/double precision) are applied for PCM measurands and analog measurements.
Parameter Names

The data source ID falls back to ch<channel ID>; duplicate names receive a _2, _3, … suffix.

  • PCM.<DataSourceID>.<MeasurandName>, or W<n> for raw words;
  • Analog.<DataSourceID>.<MeasurementName>, or the subchannel index if there is no measurement name;
  • Discrete.<DataSourceID>.<MeasurementName>, or B<n> for single bits;
  • A429.<SubchannelName>.L<octal label>.SDI<n>.Payload and .SSM, with Bus<n> if the subchannel has no name;
  • Video.<DataSourceID>;
  • Time.<DataSourceID>.Drift and .Source.

4.1.5Microsoft Excel (2007 and Later)#

File Extensions
*.xlsx (Office Open XML). The older *.xls format, *.xlsm and *.xlsb are not supported.
Header
The first row will contain parameter names.
Time Axis
The first column will contain time values.
Limitations
Formulas are not supported; only evaluated values may be processed.

4.1.6MATLAB/Octave MAT Files#

File Extensions
*.mat
Supported Numeric Types
Arrays of signed/unsigned integers (8, 16, 32, 64-bit) and IEEE 754 single/double precision.
Time Axis
Array indices will be used as x-axis values.
Limitations
Cells, structures, and non-numeric objects are not supported.
Supported Versions
Versions 4, 5, and 7.3.

4.1.7Network Common Data Form (NetCDF) Files#

File Extensions
*.nc
Status
Experimental. This feature may be subject to change in future releases.
Data Mapping
Each variable (except text, scalar, and bounds variables) becomes a series with the variable’s name. Groups are not read. Multi-dimensional variables are flattened.
Time Axis
Array indices will be used as x-axis values; time coordinates are not used.
Geographic Data
Variables with latitude and longitude dimensions (detected by name, units, standard_name or axis) are loaded as grids for the GeoMap chart: xdata holds the longitudes (wrapped to ±180), ydata the latitudes and zdata the values.
Attributes
_FillValue, missing_value, scale_factor and add_offset are applied.

4.1.8Parquet Files#

File Extensions
*.parquet. Files are also detected by their content (the PAR1 signature), so gzip-compressed Parquet files saved with the *.gzip extension (as pandas does) are loaded too.
Data Mapping
Each column will be treated as an independent variable.
Supported Types
Only numeric columns are processed; non-numeric columns are ignored.
Null Handling
Null samples will be skipped.
Time Axis

If one or more time-typed columns are present, the first (lowest index) will be used as the time vector.

If no time-typed column is present, the time vector will be generated as a strictly increasing sequence starting at zero.

4.1.9Waveform Audio File Format (WAV)#

File Extensions
*.wav
Description
Standard uncompressed audio file format.
Supported Formats
PCM with 8, 16 or 32 bits per sample. Values are the raw integer samples (8-bit samples are unsigned), with no normalization. 24-bit and floating-point files are not supported.
Time Axis
Sample index divided by the sample rate, in seconds, starting at zero.
Parameter Names
One series per channel: channel1, channel2, …

4.2Custom DLL Plugin Loaders#

C-LAB supports custom Dynamic Link Libraries (DLLs) as user-defined plugins for loading data from files.

A plugin MUST implement the API defined in Section 4.2.2 and MUST be located in the plugins directory at C:\Users\<user>\.clab\plugins.

A DLL will be loaded only once per process. Therefore, a plugin implementation MUST support concurrent handling of multiple files.

A DLL is treated as a file plugin if it exports IsCompatible, and as a live plugin (see Section 5.1.2) if it exports both Start and Stop. The same DLL may be both.

4.2.1Plugin Lifecycle#

When a file is opened, C-LAB determines plugin compatibility and executes the following sequence:

  1. C-LAB calls IsCompatible() for each enabled plugin, in folder order, until one reports compatibility. Plugins are queried before the built-in loaders.
  2. C-LAB calls Initialize() with the file path and the configuration values. This happens once per plugin and file, even if the file is opened again. The plugin MUST initialize internal state and allocate required resources.
  3. C-LAB calls GetParameterCount(), then GetParameterName() for each index from 0 to count−1, to enumerate available parameters. The plugin MUST return consistent and deterministic results.
  4. C-LAB calls Load() for each requested parameter, when its data is first needed. The plugin MUST return synchronized x- and y-value arrays of equal length.
  5. When the last object using the file is released, C-LAB calls Terminate() (only if Initialize() succeeded). The plugin MUST release all associated resources.

The metadata functions (GetPlugin* and GetConfig*) may be called at any time, for instance when the Plugins tab or the Open File dialog is shown.

Error Handling

Initialize() and Load() return 0 on success. On a non-zero value, C-LAB calls GetErrorMessage() (if implemented) and raises a Python exception with that message.

On success, C-LAB calls GetInfoMessage() (if implemented) and prints the message, if any, to the console.

Conventions

Platform
64-bit only. Functions MUST be exported with C linkage (extern 'C') and unmangled names; on x64 there is a single calling convention.
Strings
All strings, in both directions, are null-terminated UTF-8 (const char*). File paths are converted to UTF-8 before the call.
Input Lifetime
Input strings are valid only during the call. p_inConfigs has exactly GetConfigCount() entries (no terminating NULL); unset values are passed as empty strings.
Output Memory
Returned strings and arrays are owned by the plugin and are never freed by C-LAB. C-LAB copies them as soon as the call returns, so they only need to remain valid until then. String functions MUST NOT return NULL, except GetErrorMessage and GetInfoMessage.
Threads
IsCompatible, Initialize, GetParameter*, Load and Terminate are called from the thread running the Python code that opens the file. The metadata functions may be called from the user interface thread at the same time. Plugins MUST be thread-safe.

4.2.2Plugin API#

GetPluginAuthor

const char* GetPluginAuthor()

Returns the plugin author. Required.

GetPluginDate

const char* GetPluginDate()

Returns the plugin release date. Required.

GetPluginHTML

const char* GetPluginHTML()

Returns plugin metadata formatted as HTML. Required.

GetPluginExtension

const char* GetPluginExtension()

Returns the file extension used for filtering in file dialog boxes. Optional.

GetPluginName

const char* GetPluginName()

Returns the plugin name. Used in file dialog filters. Required.

GetPluginVersion

const char* GetPluginVersion()

Returns the plugin version. Required.

GetErrorMessage

const char* GetErrorMessage()

Returns a human-readable error message associated with the most recent failure. May return NULL. Messages shorter than 3 characters are ignored. Optional.

GetInfoMessage

const char* GetInfoMessage()

Returns a human-readable informational message. May return NULL. Messages shorter than 3 characters are ignored. Optional.

GetConfigCount

uint32_t GetConfigCount()

Returns the number of configuration entries. Required: DLLs without it are not recognized as plugins.

GetConfigKey

const char* GetConfigKey(uint32_t p_inIndex)

Returns the configuration key for a given index. Required if GetConfigCount returns more than 0.

GetConfigHint

const char* GetConfigHint(uint32_t p_inIndex)

Returns a short description for a configuration entry. Required if GetConfigCount returns more than 0.

GetConfigType

const char* GetConfigType(uint32_t p_inIndex)

Returns the configuration value type for a given index: file, folder or text. Any other value is treated as text. Optional.

IsCompatible

uint8_t IsCompatible(const char* p_inPath)

Determines whether the plugin supports the given file.

Return 0 if not compatible. Any other value is interpreted as compatible.

Initialize

uint8_t Initialize(const char* p_inPath, const char** p_inConfigs)

Initializes the plugin using the provided file path and configuration values.

Return 0 on success. Any other value is interpreted as error.

Terminate

uint8_t Terminate(const char* p_inPath)

Releases resources associated with the provided file path.

Return 0 on success. The return value is currently ignored.

GetParameterCount

uint32_t GetParameterCount(const char* p_inPath)

Returns the number of available parameters for the given file path.

GetParameterName

const char* GetParameterName(const char* p_inPath, uint32_t p_inIndex)

Returns the parameter name for a given index and file path.

Load

uint8_t Load(const char* p_inPath, uint32_t p_inIndex, uint64_t* p_outCount, double** p_outValuesX, double** p_outValuesY)

Loads parameter data.

  • The plugin MUST set *p_outCount and point *p_outValuesX and *p_outValuesY to two arrays: x-values and y-values.
  • Both arrays MUST have *p_outCount elements.
  • X-values typically represent time (in seconds).

Return 0 on success. Any other value is interpreted as error.

4.3Custom Python Plugin Loaders#

C-LAB supports custom Python® 3 modules as user-defined plugins for loading data from files.

A plugin MUST implement the API defined in Section 4.3.2 and MUST be located in the plugins directory at C:\Users\<user>\.clab\plugins.

A Python module is imported only once per interpreter session. Therefore, a plugin implementation MUST support concurrent handling of multiple files.

4.3.1Plugin Lifecycle#

When a file is opened, C-LAB determines plugin compatibility and executes the following sequence:

  1. C-LAB calls compatible(path) for each enabled plugin, until one reports compatibility. An exception raised here is ignored, and the plugin is treated as not compatible.
  2. If a compatible plugin is found, C-LAB calls init(path, values), where values is a list of strings with the configuration values, in the order of config_keys(). The plugin MUST initialize internal state and allocate required resources.
  3. C-LAB calls list_names(path) to enumerate available parameters. The plugin MUST return consistent and deterministic results.
  4. C-LAB calls load(path, name) for each requested parameter, passing the parameter’s name (not an index). The plugin MUST return synchronized x- and y-value sequences of equal length.
  5. When the file is closed or no longer required, C-LAB calls terminate(path). The plugin MUST release all associated resources.

Error Handling

Plugins SHOULD report errors by raising exceptions: C-LAB passes the exception message on to the user. There is no equivalent of GetErrorMessage.

init() may also report failure by returning a non-zero integer, but then only the error code is shown. list_names() and load() can only report errors by raising exceptions. Exceptions raised by terminate() are logged as warnings.

Unlike DLL plugins, Python plugins have no configuration types: all configuration entries are text.

4.3.2Plugin API#

plugin_author
Returns the plugin author.
plugin_date
Returns the plugin release date.
plugin_doc
Returns plugin metadata formatted as HTML.
plugin_ext
Returns the file extension used for filtering in file dialog boxes.
plugin_name
Returns the plugin name. Used in file dialog filters.
plugin_version
Returns the plugin version.
config_keys
Returns a sequence containing all required configuration keys. Required, as are all the plugin_* functions and config_hints; if any of them fails, the plugin is not listed.
config_hints
Returns a sequence of descriptions corresponding to each configuration key.
compatible

Determines whether the plugin supports the given file.

Return 0 if not compatible. Any other value is interpreted as compatible.

init

Initializes the plugin using the provided file path and configuration values.

Return 0 on success. Any other integer is interpreted as error.

terminate

Releases resources associated with the provided file path.

The return value is ignored.

list_names
Returns a sequence containing the parameter names for the given file path.
load

Loads parameter data.

Returns a tuple containing two sequences: x-values and y-values.

  • Both sequences MUST be provided.
  • Both sequences MUST have identical, non-zero length.
  • x-values typically represent time (in seconds).

5Loading Data From Real-Time Sources#

C-LAB provides support for loading data from real-time sources via external custom plugins, enabling dynamic data integration during runtime.

5.1Custom DLL Plugin Loaders#

C-LAB supports custom Dynamic Link Libraries (DLLs) as user-defined plugins for loading data from real-time sources.

A plugin MUST implement the API described in Section 5.1.2 and MUST be located in the plugins directory at C:\Users\<user>\.clab\plugins.

A DLL is treated as a live plugin if it exports both Start and Stop. Only DLLs can be live plugins; Python plugins are not supported.

The conventions for platform, strings, memory ownership and thread safety are the same as for file plugins (see the Conventions that precede Section 4.2.2). In addition, Start, Load and Stop are called from a dedicated worker thread, one per connection.

5.1.1Plugin Lifecycle#

Each connection is identified by a unique connection identifier, generated by C-LAB and passed in place of a file path. The plugin lifecycle is defined as follows:

  1. C-LAB calls Initialize() with the connection identifier and the configuration values. The plugin MUST allocate and prepare all required resources during this phase.
  2. C-LAB calls GetParameterCount(), then GetParameterName() for each index, to enumerate available parameters. The plugin MUST return consistent and deterministic results for a given input.
  3. C-LAB calls Start() once to signal the beginning of data acquisition. The plugin SHOULD begin producing data after this call.
  4. C-LAB calls Load() periodically for each requested parameter. Each call MUST return only the samples produced since the previous call, as synchronized x- and y-value arrays of equal length. C-LAB keeps the most recent samples, up to the samples limit of the clab.Container.
  5. C-LAB calls Stop() to signal the end of data acquisition. The plugin SHOULD cease data production promptly.
  6. C-LAB calls Terminate() when the plugin is no longer required. The plugin MUST release all allocated resources.

Error Handling

If Initialize(), Start(), Stop() or Load() returns a non-zero value, C-LAB will invoke GetErrorMessage() (if implemented) to obtain diagnostic information, and reports the error. A failure in Start() or Stop() is printed to the console, but does not stop the acquisition loop.

If no error is reported, C-LAB invokes GetInfoMessage() (if implemented) and prints the message, if any.

5.1.2Plugin API#

The functions and their signatures are the same as for file plugins (see Section 4.2.2), with the connection identifier (p_inId) in place of the file path. IsCompatible and GetPluginExtension are not used.

GetPluginAuthor
Returns the plugin author.
GetPluginDate
Returns the plugin release date.
GetPluginHTML
Returns plugin metadata formatted as HTML.
GetPluginName
Returns the plugin name.
GetPluginVersion
Returns the plugin version.
GetErrorMessage
Returns a human-readable error message associated with the most recent failure.
GetInfoMessage
Returns a human-readable informational message.
GetConfigCount
Returns the number of configuration entries.
GetConfigKey
Returns the configuration key for a given index.
GetConfigHint
Returns a short description for a configuration entry.
GetConfigType
Returns the configuration value type for a given index. Valid values are file, folder, text.
Initialize

uint8_t Initialize(const char* p_inId, const char** p_inConfigs)

Initializes the plugin using the provided connection identifier and configuration values.

Return 0 on success. Any other value is interpreted as error.

Terminate

uint8_t Terminate(const char* p_inId)

Releases resources associated with the provided connection identifier.

Return 0 on success. The return value is currently ignored.

Start

uint8_t Start(const char* p_inId)

Signals the start of data acquisition.

Return 0 on success. Any other value is interpreted as error.

Stop

uint8_t Stop(const char* p_inId)

Signals the stop of data acquisition.

Return 0 on success. Any other value is interpreted as error.

GetParameterCount

uint32_t GetParameterCount(const char* p_inId)

Returns the number of available parameters for the given connection.

GetParameterName

const char* GetParameterName(const char* p_inId, uint32_t p_inIndex)

Returns the parameter name for a given index and connection.

Load

uint8_t Load(const char* p_inId, uint32_t p_inIndex, uint64_t* p_outCount, double** p_outValuesX, double** p_outValuesY)

Loads the new samples of a parameter.

  • The plugin MUST return two arrays: x-values and y-values.
  • Both arrays MUST have *p_outCount elements.
  • X-values typically represent time (in seconds).

6Built-In Functions#

The C-LAB module provides a set of built-in functions for processing clab.Array, clab.Mesh, and clab.TimeSeries objects, in addition to those described in their respective sections.

The input object of a built-in (shown as ts in the signatures) is positional-only: it must be passed by position, never as a keyword. The only exceptions are lut2d, whose inputs can also be passed as in1= and in2=, and insight. Functions that take no optional arguments (for example derivative, convert and the math functions) accept positional arguments only.

Time ranges are named ini/end in the analysis functions (fftdata, heatmapdata, histdata) and tini/tend elsewhere (export_to_file, TimeSeries.slice, bookmark). The names are not interchangeable.

6.1Standard Math Functions#

6.1.1Exponential Functions#

Return a new object, whose values are equal to e (Euler’s number, 2.7182818...) raised to power of each value in the input argument.

out = clab.exp(ts)
out
clab.TimeSeries object.
tsrequired
clab.TimeSeries object.

6.1.2Logarithm Functions#

Return a new object, whose values are equal to the natural (base e) logarithm of the argument. There is also a version that computes the logarithm with base 10 of the argument.

out = clab.log(ts)
out
clab.TimeSeries object.
tsrequired
clab.TimeSeries object.
out = clab.log10(ts)
out
clab.TimeSeries object.
tsrequired
clab.TimeSeries object.

6.1.3Rounding Functions#

Computes the nearest integer value to the argument, following the specified rounding rules:

ceil
Computes the smallest integer value not less than the argument (ceiling).
floor
Computes the largest integer value not greater than the argument (floor).
round
Computes the nearest integer value to the argument, rounding halfway cases away from zero.
trunc
Computes the integer value by discarding the fractional part (truncation towards zero).
out = clab.<operation>(ts)
out
clab.TimeSeries object.
tsrequired
clab.TimeSeries object.

6.1.4Square Root Functions#

Return a new object, whose values are equal to the square root of each value in the input argument.

out = clab.sqrt(ts)
out
clab.TimeSeries object.
tsrequired
clab.TimeSeries object.

6.1.5Trigonometric Functions#

Computes standard trigonometric operations. All results for sin,cos,tan,arc… are in radians unless the degree suffix is used.

cos
Computes the cosine (radians).
sin
Computes the sine (radians).
tan
Computes the tangent (radians).
cosd
Computes the cosine (degrees).
sind
Computes the sine (degrees).
tand
Computes the tangent (degrees).
acos
Computes the arc cosine (radians).
asin
Computes the arc sine (radians).
atan
Computes the arc tangent (radians).
acosd
Computes the arc cosine (degrees).
asind
Computes the arc sine (degrees).
atand
Computes the arc tangent (degrees).
out = clab.<operation>(ts)
out
clab.TimeSeries object.
tsrequired
clab.TimeSeries object.

6.2Custom Functions#

6.2.1Angular Distance#

Calculate the minimum difference between two angles in a circle.

The function computes lhs - rhs, but taking into account the angle position in the circle. The result is signed and lies in the range [−180,180) degrees ([−π,π) radians). For instance, the distance between 0.0 and 360.0 is 0.0, with lhs=170.0 and rhs=-170.0 it is -20.0, and with lhs=-170.0 and rhs=170.0 it is +20.0.

170° −170° x y
out = clab.angular_distance(lhs, rhs, type='deg')
out
clab.TimeSeries.
lhsrequired
clab.TimeSeries.
rhsrequired
clab.TimeSeries.
typeoptional
String with the angle value type. It can be either deg (for degrees) or rad (for radians).
Examples
diff = clab.angular_distance(y2, y1, type='rad')

6.2.2Discrete Derivative#

The output is calculated as follows: outk=ink−ink−1tk−tk−1

The first output sample is 0.0, so the output has the same length as the input. If two consecutive samples have the same time, the previous output value is kept.

out = clab.derivative(ts)
out
clab.TimeSeries.
tsrequired
clab.TimeSeries.
Examples
dY = clab.derivative(y)

6.2.3Discrete Integration#

Discrete integration (numerical quadrature), calculated using the trapezoidal rule. The first output sample is 0.0.

out = clab.integral(ts)
out
clab.TimeSeries.
tsrequired
clab.TimeSeries.
Examples
yint = clab.integral(y)

6.2.4Adjacent Differences#

Differences between adjacent elements, calculated as outk=ink−ink−1 The first output sample is 0.0, so the output has the same length as the input.

out = clab.diff(ts)
out
clab.TimeSeries.
tsrequired
clab.TimeSeries.
Examples
dy = clab.diff(y)

6.2.5Accumulate#

The nth element is the sum of the 1...n elements of the argument.

out = clab.accumulate(ts)
out
clab.TimeSeries.
tsrequired
clab.TimeSeries.
Examples
acc = clab.accumulate(y)

6.2.6Estimate Sampling Frequency#

The output represents the estimated instantaneous sampling frequency corresponding to the provided sample argument.

out = clab.estimate_sampling_frequency(ts)
out
clab.TimeSeries.
tsrequired
clab.TimeSeries.
Examples
fs = clab.estimate_sampling_frequency(y)

6.2.7Estimate Sampling Period#

The output represents the estimated instantaneous sampling period corresponding to the provided sample argument.

out = clab.estimate_sampling_period(ts)
out
clab.TimeSeries.
tsrequired
clab.TimeSeries.
Examples
ts = clab.estimate_sampling_period(y)

6.2.8Unpack#

Unpack values, selecting the desired bits and applying resolution and offset (bit extraction).

The output is calculated as outk=unpackedk[msb:lsb]×resolution+offset where unpacked is obtained by converting the input using the selected conversion type.

out = clab.unpack(ts, msb=0, lsb=0, base=0, resolution=1.0, offset=0.0, type='USGN')
out
clab.TimeSeries.
tsrequired
clab.TimeSeries.
msboptional
Most significant bit, indexed from base.
lsboptional
Least significant bit, indexed from base.
baseoptional
Smallest value in the bit indexing system.
gainoptional
Value gain.
biasoptional
Value bias.
typeoptional
Type conversion method (case-insensitive). It can be USGN (unsigned binary, the default), SGN (signed binary), 2C (two’s complement) or BCD (binary coded decimal). BNR is accepted as a deprecated alias of USGN.
Examples
unpacked1 = clab.unpack(ts, msb=10, lsb=2)
unpacked2 = clab.unpack(ts, msb=32, lsb=28, gain=0.5, bias=10.0)
unpacked3 = clab.unpack(ts, msb=28, lsb=10, type='2C')

6.2.9Debounce#

Delay output of boolean signal after rising or falling edge. Persistences should be provided in the same unit of the argument’s time vector.

out = clab.debounce(ts, on=0.0, off=0.0)
out
clab.TimeSeries.
tsrequired
clab.TimeSeries.
onoptional
Persistence (in x-data units) for output 'on' signal.
offoptional
Persistence (in x-data units) for output 'off' signal.
Examples
out1 = clab.debounce(ts, on=10)
out2 = clab.debounce(ts, off=0.5)

6.2.10Hysteresis#

Output 1 if the argument is strictly greater than the upper threshold, 0 if it is strictly less than the lower threshold, and keep the last value otherwise (including when it equals a threshold). The initial state is 0.

out = clab.hysteresis(ts, lower=0.0, upper=0.0)
out
clab.TimeSeries.
tsrequired
clab.TimeSeries.
loweroptional
Lower threshold.
upperoptional
Upper threshold.
Examples
out = clab.hysteresis(ts, lower=90.0, upper=180.0)

6.2.11Clamp#

For each input sample, if value is less than lower limit, returns lower limit. If argument is greater than upper limit, returns upper limit. Otherwise returns input value.

out = clab.clamp(ts, lower=-inf, upper=+inf)
out
clab.TimeSeries.
tsrequired
clab.TimeSeries.
loweroptional
Lower limit.
upperoptional
Upper limit.
Examples
out = clab.clamp(ts, lower=90.0, upper=180.0)

6.2.12Drop#

Create a new clab.TimeSeries, dropping every sample y for which op1(y, lim1) or op2(y, lim2) is true.

Valid operators are eq, ne, le, lt, ge or gt.

out = clab.drop(ts, lim1=-inf, lim2=+inf, op1='le', op2='ge')
out
clab.TimeSeries.
tsrequired
clab.TimeSeries.
lim1optional
Limit 1.
lim2optional
Limit 2.
op1optional
Operator applied to limit 1.
op2optional
Operator applied to limit 2.
Examples
out = clab.drop(ts, lim1=90.0, lim2=180.0, op1='lt', op2='gt')

6.2.13In Range#

For each input sample, if its value has been within the limits (inclusive: lower ≤ value ≤ upper) for longer than the defined persistence time, returns 1.0. Otherwise returns 0.0. Samples within the first pers x-data units of the series always return 0.0.

out = clab.in_range(ts, lower=-inf, upper=+inf, pers=0.0)
out
clab.TimeSeries.
tsrequired
clab.TimeSeries.
loweroptional
Lower limit.
upperoptional
Upper limit.
persoptional
Persistence time (in x-data units).
Examples
out1 = clab.in_range(ts, lower=90.0, upper=180.0)
out2 = clab.in_range(ts, upper=180.0, pers=10.0)

6.2.14Stale#

This function detects staleness of the input argument during the defined persistence window.

It returns 1.0 to indicate staleness, or 0.0 if the value has changed within the persistence window.

out = clab.stale(ts, pers)
out
clab.TimeSeries.
tsrequired
clab.TimeSeries.
persrequired
Persistence time (in x-data units). Must be greater than zero.
Examples
out = clab.stale(ts, pers=2.0)

6.2.15Linear Interpolation#

Computes a + ts × (b - a), i.e. the linear interpolation between a and b for the parameter ts (or extrapolation, when ts is outside the range [0,1]).

out = clab.lerp(ts, a, b)
out
clab.TimeSeries.
tsrequired
clab.TimeSeries.
arequired
Start value.
brequired
End value.
Examples
out = clab.lerp(ts, a=2.0, b=4.0)

6.2.16Lookup Table Interpolation (1D)#

Computes intermediate values of the input from the provided set of discrete data points using linear interpolation.

out = clab.lut1d(ts, bp, val, clip=True)
out
clab.TimeSeries.
tsrequired
clab.TimeSeries.
bprequired
Breakpoints list.
valrequired
Values list.
clipoptional
If true, inputs outside the breakpoint range return the first or last value. If false, the output is linearly extrapolated from the two first or two last breakpoints.
Examples
out = clab.lut1d(ts, bp=[2.0, 4.0, 8.0], val=[4.0, 16.0, 64.0], clip=True)
0 2 4 6 8 10 0 20 40 60 80 Input Interpolated output (clipped) Breakpoints

6.2.17Lookup Table Interpolation (2D)#

Computes intermediate values of the inputs from the provided set of discrete data points using bilinear interpolation. The two inputs are combined on a common time axis; at each time, each input takes its latest sample (no interpolation in time).

Unlike the other built-ins, the inputs can be passed as keywords (in1=, in2=).

out = clab.lut2d(in1, in2, bp1, bp2, val, clip=True)
out
clab.TimeSeries.
in1required
clab.TimeSeries. This is the row variable in the output values table.
in2required
clab.TimeSeries. This is the column variable in the output values table.
bp1required
Breakpoints list for in1.
bp2required
Breakpoints list for in2.
valrequired
Values matrix. This should be a list of lists.
clipoptional
If true, inputs outside the breakpoint ranges are clipped to the table edges. If false, the output is linearly extrapolated.
Examples
table = [ 
[1.0, 2.0, 3.0, 4.0],
[2.0, 3.0, 4.0, 5.0],
[3.0, 4.0, 5.0, 6.0],
[4.0, 5.0, 6.0, 7.0],
[5.0, 6.0, 7.0, 8.0]]
out = clab.lut2d(in1=ts1, in2=ts2, bp1=[1.0, 2.0, 3.0, 4.0, 5.0], bp2=[0.0, 1.0, 2.0, 3.0], val=table)

6.2.18Fast Fourier Transform Data#

This function shares similarities with the Fast Fourier Transform Plot (see Section 8.1.6), except that it doesn’t create a graphical plot; instead, it provides the data as a tuple.

out = clab.fftdata(ts, ini=-inf, end=+inf)
out
Tuple (freqs, amps): freqs is a tuple of frequencies in hertz and amps a tuple of the matching amplitudes. The spectrum is the single-sided amplitude (2|X|/N, or |X|/N at 0 Hz, with N the number of samples), with no window applied. The data is zero-padded to the next power of two. At least 3 samples are required.
tsrequired
clab.TimeSeries.
inioptional
Initial time of the range to be analyzed.
endoptional
Final time of the range to be analyzed.
Examples
out = clab.fftdata(ts)

6.2.19HeatMap Data#

This function shares similarities with the HeatMap Plot (see Section 8.1.9), except that it doesn’t create a graphical heatmap; instead, it provides the data as a tuple.

out = clab.heatmapdata(ts1, ts2, ini=-inf, end=+inf, cols=30, rows=30)
out

Tuple with the heatmap data, formatted as described:

Index 0
Matrix (tuple of tuples) with rows tuples of cols values. Each cell contains the number of samples that fit that square.
Index 1
List with the column labels.
Index 2
List with the row labels.
ts1required
clab.TimeSeries. Positional-only.
ts2required
clab.TimeSeries. Positional-only.
inioptional
Initial time of the range to be analyzed.
endoptional
Final time of the range to be analyzed.
colsoptional
Number of columns in the heatmap. Value is limited between 3 and 1000.
rowsoptional
Number of rows in the heatmap. Value is limited between 3 and 1000.
Examples
out = clab.heatmapdata(ts1, ts2, cols=8, rows=8)

6.2.20Histogram Data#

This function shares similarities with the Histogram Plot (see Section 8.1.10), except that it doesn’t create a graphical histogram; instead, it provides the data as a tuple.

out = clab.histdata(ts, ini=-inf, end=+inf, nbins=8, bins=[])
out
Matrix (tuple of tuples) with the histogram data. The first element of each tuple is the bin’s label and the second the number of samples in the bin. Labels are <b for the first bin, [a,b) for the middle bins and ≥b for the last bin.
tsrequired
clab.TimeSeries.
inioptional
Initial time of the range to be analyzed.
endoptional
Final time of the range to be analyzed.
nbinsoptional
Number of bins, from 1 to 100000. Values less than 3 are raised to 3.
binsoptional
List with the bin limits, in ascending order. Its length cannot be less than 2. Values below the first limit form the first bin and values from the last limit up form the last bin, so N limits give N+1 bins. If this argument is provided along with nbins, the latter will be ignored.
Examples
out = clab.histdata(ts, nbins=4)
out = clab.histdata(ts, bins=[1,3,5,7])

6.2.21Convert Units#

Converts a TimeSeries object values to the target unit.

out = clab.convert(ts, source, target)
out
clab.TimeSeries.
tsrequired
clab.TimeSeries.
sourcerequired
String with unit name to convert from.
targetrequired

String with unit name to convert to. It can be one of the following:

Angle
'deg', 'rad'.
Length
'feet', 'inches', 'kilometers', 'meters', 'miles', 'nautical miles'.
Mass
'kilograms', 'pounds'.
Speed
'knots', 'km/h', 'm/s', 'mph'.
Temperature
'celsius', 'fahrenheit', 'kelvin'.
Examples
out = clab.convert(ts, 'rad', 'deg')

6.3Export Functions#

6.3.1Export To File#

Export a clab.Container or a list of clab.TimeSeries objects to a delimiter-separated file, to an HDF5 file or to a Parquet file.

clab.export_to_file(path, tini, tend, src, tags=False, step=1.0, delimiter='\t', precision=0)
pathrequired
Full path of the output file. C-LAB selects the output type from the extension: .hdf5 for HDF5 and .parquet for Parquet (both lowercase, matched exactly). Any other extension (e.g., .tsv, .csv, .txt, or .h5) produces a delimiter-separated file.
tinirequired
Start time for the export window (inclusive).
tendrequired
End time for the export window (inclusive).
delimiteroptional
Character used to separate the values in the exported file. Default is a tab. Used only when exporting to a delimiter-separated file.
stepoptional
Sampling step period, default 1.0. Delimiter-separated and Parquet files are resampled at tini, tini + step, … up to tend, holding the last value of each series (zero-order hold). HDF5 files contain the original samples within the export window and ignore this argument.
srcrequired

Source data to export. This can be one of the following:

  • List of tuples: Each tuple must contain a clab.TimeSeries object and the desired name to be used as the column header in the file. E.g., [(obj1, name1), (obj2, name2)].
  • clab.Container object: The function will use each clab.TimeSeries name within the container as a column header.
tagsoptional
If True, for series that have tags in the Tags File, the tag text is written instead of the numeric value (in Parquet files these columns are stored as strings).
precisionoptional
Number of decimal places used for the time column. If greater than zero, the specified precision is used; otherwise, it is derived from step. Data values are always written with full precision. Used only when exporting to a delimiter-separated file.
Examples
clab.export_to_file(path='c:/output.tsv', step=0.2, tini=0.0, tend=100.0, delimiter='\t', src=[(obj1, 'name1'),(obj2, 'name2')])
clab.export_to_file(path='c:/output.hdf5', tini=0.0, tend=100.0, src=f)

6.4Factory Functions#

In the clab.TimeSeries and clab.Mesh factories, the x-axis (and z-axis) values are xmin+k⋅xdiff for k=0,1,… up to the largest value not greater than xmax. Both ends are inclusive: for instance, xmin=0, xmax=10, xdiff=0.5 gives 21 samples.

6.4.1Create Random clab.Array#

Create a clab.Array with the length specified and all values set to random values, uniformly distributed in the interval [-1.0, +1.0). The generator is seeded differently on every call, so the values cannot be reproduced; use create_random with a seed for reproducible data.

out = clab.create_array_random(len)
out
clab.Array object.
lenrequired
Length of the new array.
Examples
out = clab.create_array_random(500)

6.4.2Create All-One clab.Array#

Create a clab.Array with the length specified and all values set to 1.0.

out = clab.create_array_ones(len)
out
clab.Array object.
lenrequired
Length of the new array.
Examples
out = clab.create_array_ones(500)

6.4.3Create All-Zero clab.Array#

Create a clab.Array with the length specified and all values set to 0.0.

out = clab.create_array_zeros(len)
out
clab.Array object.
lenrequired
Length of the new array.
Examples
out = clab.create_array_zeros(500)

6.4.4Create clab.Container from Clipboard#

Create a clab.Container object from clipboard content.

This functionality is also available from the UI, allowing the user to edit a data file (an Excel file for instance), CTRL+C its content into the clipboard and import it into C-LAB without saving it to the disk.

out = clab.create_from_clipboard()
out
clab.Container object.

6.4.5Create Chirp Signal clab.TimeSeries#

Create a clab.TimeSeries object with a chirp signal (sine sweep) values in the y-axis. The frequency changes linearly from freq_start to freq_end over the x-range, and the amplitude is 1.0.

out = clab.create_chirp(xmin=0.0, xmax=100.0, xdiff=0.01, freq_start=0.0, freq_end=10.0)
out
clab.TimeSeries object.
xminoptional
Minimum value for the x-axis (in engineering units, usually time in seconds).
xmaxoptional
Maximum value for the x-axis (in engineering units, usually time in seconds). Inclusive.
xdiffoptional
Difference between adjacent elements in the x-axis (in engineering units).
freq_startoptional
Start frequency (in hertz).
freq_endoptional
End frequency (in hertz).
Examples
out = clab.create_chirp(freq_start=8.0, freq_end=0.0)

6.4.6Create Constant clab.TimeSeries#

Create a clab.TimeSeries object with a constant value in the y-axis.

out = clab.create_const(value=1.0, xmin=0.0, xmax=100.0, xdiff=0.01)
out
clab.TimeSeries object.
valueoptional
Constant value.
xminoptional
Minimum value for the x-axis (in engineering units, usually time in seconds).
xmaxoptional
Maximum value for the x-axis (in engineering units, usually time in seconds). Inclusive.
xdiffoptional
Difference between adjacent elements in the x-axis (in engineering units).
Examples
out = clab.create_const(value=3.1415, xmin=10, xmax=20, xdiff=0.5)

6.4.7Create Ramp clab.TimeSeries#

Create a clab.TimeSeries object with a ramp signal in the y-axis, defined between ymin and ymax over the x-range [xmin,xmax].

(xmin, ymin) (xrmin, ymin) (xrmax, ymax) (xmax, ymax) x y
out = clab.create_ramp(rxmin, rxmax, ymin, ymax, xmin, xmax, xdiff)
out
clab.TimeSeries object.
rxminrequired
Value for the x-axis at the start of the ramp (xrmin).
rxmaxrequired
Value for the x-axis at the end of the ramp (xrmax).
yminrequired
Minimum value for the y-axis.
ymaxrequired
Maximum value for the y-axis.
xminrequired
Minimum value for the x-axis (in engineering units, usually time in seconds).
xmaxrequired
Maximum value for the x-axis (in engineering units, usually time in seconds). Inclusive.
xdiffrequired
Difference between adjacent elements in the x-axis (in engineering units).
Examples
out = clab.create_ramp(rxmin=1, rxmax=5, ymin=0.75, ymax=4, xmin=1, xmax=7, xdiff=0.5)

6.4.8Create Random clab.TimeSeries#

Create a clab.TimeSeries object with random values in the y-axis, generated from a specified distribution.

out = clab.create_random(dist, type='flt', seed, ymin, ymax, mean, stddev, xmin=0.0, xmax=100.0, xdiff=0.01)
out
clab.TimeSeries object.
distrequired
Type of distribution for the random values. Options are 'uniform' or 'normal'.
typeoptional
Type of data. Options are 'flt' (floating point, the default) or 'int'. With 'int', the uniform limits are truncated to integers and both are included; normal values are truncated towards zero.
seedoptional
Seed for the pseudo-random generator (a non-negative integer). The same seed always produces the same values; 0 is a valid seed. If omitted, the current time (in seconds) is used.
ymin
Minimum value for the y-axis. Required when 'uniform' distribution is selected.
ymax
Maximum value for the y-axis. Required when 'uniform' distribution is selected. It is excluded for 'flt' and included for 'int'.
mean
Mean value for the y-axis. Required when 'normal' distribution is selected.
stddev
Standard deviation value for the y-axis. Required when 'normal' distribution is selected.
xminoptional
Minimum value for the x-axis (in engineering units, usually time in seconds).
xmaxoptional
Maximum value for the x-axis (in engineering units, usually time in seconds). Inclusive.
xdiffoptional
Difference between adjacent elements in the x-axis (in engineering units).
Examples
out = clab.create_random(dist='normal', mean=1.0, stddev=2.0)
out = clab.create_random(dist='uniform', ymin=-1.0, ymax=1.0, xmin=10, xmax=20, xdiff=0.5)
out = clab.create_random(dist='uniform', type='int', seed=42, ymin=1, ymax=6)

6.4.9Create Sine Signal clab.TimeSeries#

Create a clab.TimeSeries object with a sine wave in the y-axis.

out = clab.create_sine(freq=1.0, phase=0.0, amplitude=1.0, xmin=0.0, xmax=100.0, xdiff=0.01)
out
clab.TimeSeries object.
freqoptional
Frequency in hertz of the sine wave.
phaseoptional
Phase in degrees of the sine wave.
amplitudeoptional
Peak amplitude of the sine wave.
xminoptional
Minimum value for the x-axis (in engineering units, usually time in seconds).
xmaxoptional
Maximum value for the x-axis (in engineering units, usually time in seconds). Inclusive.
xdiffoptional
Difference between adjacent elements in the x-axis (in engineering units).
Examples
out = clab.create_sine(freq=10, phase=90, amplitude=10.0, xmin=10, xmax=20, xdiff=0.5)

6.4.10Create Step Signal clab.TimeSeries#

Create a clab.TimeSeries object with a step signal in the y-axis. The signal will start with the minimum value defined and switch to the maximum when the time is equal to or greater than step.

out = clab.create_step(step=50.0, ymin=0.0, ymax=1.0, xmin=0.0, xmax=100.0, xdiff=0.01)
out
clab.TimeSeries object.
stepoptional
Step in engineering units, usually time in seconds.
yminoptional
Minimum value for the y-axis.
ymaxoptional
Maximum value for the y-axis.
xminoptional
Minimum value for the x-axis (in engineering units, usually time in seconds).
xmaxoptional
Maximum value for the x-axis (in engineering units, usually time in seconds). Inclusive.
xdiffoptional
Difference between adjacent elements in the x-axis (in engineering units).
Examples
out = clab.create_step(step=1.0, xmin=10, xmax=20, xdiff=0.5)

6.4.11Create Sinc Signal clab.Mesh Grid#

Create a clab.Mesh object with a sinc function signal in the y-axis.

For 2 dimensions, sinc is defined as sinc(X)=sin(X)X For 3 dimensions, sinc is defined as sinc(X,Z)=sin(R)R where R=X2+Z2, and sinc=1 at R=0.

out = clab.create_mesh_sinc(xmin=-10.0, xmax=+10.0, xdiff=0.5, zmin=-10.0, zmax=+10.0, zdiff=0.5)
out
clab.Mesh object.
xminoptional
Minimum value for the x-axis.
xmaxoptional
Maximum value for the x-axis (inclusive).
xdiffoptional
Step value for the x-axis.
zminoptional
Minimum value for the z-axis.
zmaxoptional
Maximum value for the z-axis (inclusive).
zdiffoptional
Step value for the z-axis.
Examples

Create a mesh with 1681 values (41×41) in the Y matrix

out = clab.create_mesh_sinc()

Create a mesh with 40401 values (201×201) in the Y matrix

out = clab.create_mesh_sinc(xdiff=0.1, zdiff=0.1)

6.5Filter Functions#

6.5.1Low-pass Filter#

First order low pass filter: outk=outk−1+α(ink−outk−1),α=dtτ+dt The first output sample equals the first input sample. A NaN input keeps the previous output. dt is the estimated sampling period: the median of the first 9 time steps for series with at least 10 samples, otherwise the mean time step.

out = clab.lowpass(ts, tau)
out
clab.TimeSeries.
tsrequired
clab.TimeSeries.
taurequired
Filter time constant, in x-data units.
Examples
filtered = clab.lowpass(ts, tau=2)

6.5.2High-pass Filter#

First order high pass filter: outk=α(outk−1+ink−ink−1),α=ττ+dt The first output sample equals the first input sample. dt is estimated as for the low-pass filter.

out = clab.highpass(ts, tau)
out
clab.TimeSeries.
tsrequired
clab.TimeSeries.
taurequired
Filter time constant, in x-data units.
Examples
filtered = clab.highpass(ts, tau=2)

6.5.3Moving Average#

Centered moving average over a window of w=2h+1 samples: outk=1|Vk|∑j∈Vkinj,Vk={j:|j−k|≤h,0≤j<N,injfinite} The window is counted in samples, not in x-data units, so the x-data is not used. Near the ends of the series the window is truncated, so the first and last h outputs average fewer samples. Non-finite inputs (NaN or ±∞) are left out of the average, so they are replaced by the average of the valid samples around them; if a window holds no valid sample, the output is NaN. A window longer than the series averages all of its valid samples. The output has the same length as the input.

out = clab.moving_average(ts, window)
out
clab.TimeSeries.
tsrequired
clab.TimeSeries.
windowrequired
Window length, in samples. It must be a positive odd integer; window=1 returns a copy of the input with non-finite samples replaced by NaN.
Examples
smoothed = clab.moving_average(ts, window=5)

6.6Find Functions#

6.6.1Find a Specific clab.TimeSeries#

Returns a clab.TimeSeries object whose name matches the specified text. If several series match, which one is returned is not defined; use list to get all of them.

out = clab.find(text, regex=False)
out
clab.TimeSeries. If nothing matches, an Exception is raised.
textrequired
The string or regular expression pattern to search for. Positional-only.
regexoptional
If True, text is evaluated as a regular expression and matches anywhere in the name. If False (default), performs an exact match against the full or short name.
Examples
out1 = clab.find('.*value', regex=True)
out2 = clab.find('value')

6.6.2List Matching clab.TimeSeries#

List all clab.TimeSeries objects whose names match the regular expression provided. Unlike find, text is always a regular expression, and it matches anywhere in the name (use ^ and $ to anchor it).

out = clab.list(text)
out
List of clab.TimeSeries objects. If nothing matches, an Exception is raised.
textrequired
Valid regular expression. Positional-only.
Examples
out1 = clab.list('.*value')
out2 = clab.list('value')

6.6.3List Paths From Opened clab.Container#

List the file system paths of all clab.Container objects currently loaded or accessible by the module.

out = clab.list_paths()
out
List of strings (file system paths).
Examples
out1 = clab.list_paths()

6.7Fit Functions#

6.7.1Linear Data Fit#

Computes linear regression to fit observed data into a first order linear function Y=A×X+B

out = clab.fit_linear(ts)
out

Tuple with the following values:

0
Correlation coefficient between X and Y.
1
Coefficient A (slope).
2
Coefficient B (Y-intercept).
tsrequired
clab.TimeSeries.

6.7.2Exponential Data Fit#

Computes exponential regression to fit observed data into a function Y=A×e(X×B)

out = clab.fit_exp(ts)
out

Tuple with the following values:

0
Correlation coefficient between X and Y.
1
Coefficient A.
2
Coefficient B.
tsrequired
clab.TimeSeries.

6.7.3Polynomial Data Fit#

Computes polynomial regression to fit observed data into an arbitrary order function Y=B0+B1×X+B2×X2+⋯+BN×XN

out = clab.fit_polynomial(ts, order)
out

Tuple with the following values:

0
Correlation coefficient between X and Y.
1...order+1
Polynomial coefficients (B0,B1,…,BN).
tsrequired
clab.TimeSeries.
orderrequired
Polynomial order (N).

6.8Merge Functions#

6.8.1Merge File Into clab.Container#

Merge the content of a file into the most compatible clab.Container already loaded.

For each loaded container, C-LAB computes the fraction of the file’s top-level names that the container already has. The container with the highest fraction is chosen, provided that fraction is at least 0.5 (if several containers have the same fraction, any of them may be chosen). The data is then combined as described for the merge member function of clab.Container.

If you need to force merging the content of a file into a specific clab.Container (regardless of compatibility), use the merge member function of clab.Container (refer to Section 2.2).

out = clab.merge(path)
out
The updated clab.Container object. If no loaded container is compatible, or the merge fails, an Exception is raised.
pathrequired
File path to the data to be merged.
Examples
clab.merge(path='c:/user/data.csv')

7Constants#

7.1Immutable Constants#

The clab module provides a collection of predefined mathematical constants. These constants are immutable, meaning their values cannot be modified at runtime.

clab.<constant>

The following immutable constants are available:

e
Euler’s number, the base of the natural logarithm. Value: 2.718281828459045.
log2e
Base-2 logarithm of e. Useful for converting natural logarithms to base-2 logarithms. Value: 1.4426950408889634.
log10e
Base-10 logarithm of e. Useful for converting natural logarithms to base-10 logarithms. Value: 0.4342944819032518.
pi
Archimedes’ constant, defined as the ratio of a circle’s circumference to its diameter. Value: 3.141592653589793.
inv_pi
Multiplicative inverse of π (1/π). Value: 0.3183098861837907.
inv_sqrtpi
Multiplicative inverse of π (1/π). Commonly used in probability theory and statistics. Value: 0.5641895835477563.
tau
Circle constant, defined as 2π. Value: 6.283185307179586.
ln2
Natural logarithm of 2. Value: 0.6931471805599453.
ln10
Natural logarithm of 10. Value: 2.302585092994046.
sqrt2
Square root of 2. Frequently appears in geometry, linear algebra, and signal processing. Value: 1.4142135623730951.
sqrt3
Square root of 3. Frequently appears in geometry, particularly in equilateral triangles and hexagonal structures. Value: 1.7320508075688772.
inv_sqrt3
Multiplicative inverse of 3 (1/3). Value: 0.5773502691896257.
egamma
Euler–Mascheroni constant γ. Appears in number theory, harmonic analysis, and special functions. Value: 0.5772156649015329.
phi
The golden ratio, φ=(1+5)/2. Appears in geometry, algebra, and certain natural growth patterns. Value: 1.618033988749895.

7.2Mutable Constants#

The clab module also provides a collection of system-defined constants. These constants are mutable, meaning their values may change during program execution to reflect the current runtime state.

clab.<constant>

The following mutable constants are available:

tini
Start time of the current plot window (the visible time range of the Charts tab), as a float in x-axis units (usually seconds).
tend
End time of the current plot window, as a float in x-axis units (usually seconds).

These constants are read-only from Python: assigning a value (e.g., clab.tini = 0) does not change the plot window, and hides the current value until the module is reloaded. To change the window, use clab.set('timelimits', tini, tend) (see Section 10.1).

8Chart Functions#

The C-LAB module provides functions to create and manipulate charts.

Each chart has a unique identifier (a 64-bit unsigned integer) which is returned by the plotting functions. Henceforth, this unique identifier will be referred to as id. This id shall be passed as an argument to all functions that modify a chart. The argument is named id in the chart-creation functions, set_chart and save, but chart in the functions that add objects to a chart (circle, datatip, flag, legend, rectangle and text). The two names are not interchangeable.

Colors of charts and chart objects are given as integers from 0 to 255 for each channel (red, green, blue). Note that clab.Model.set uses floats from 0.0 to 1.0 instead.

8.1Functions to Create 2D Charts#

All functions in this section require either a clab.TimeSeries object or the name of a variable. When only the variable’s name is supplied, C-LAB will attempt to locate an object whose name corresponds to the given string. If both the object and the name are provided, C-LAB will utilize the data from the specified object and label it using the provided variable’s name.

8.1.1Time Series Plot#

Plot a clab.TimeSeries object, displaying the engineering values in the y-axis and time in the x-axis. If the object was created using the built-in loaders, the x-axis will display time in seconds.

out = clab.plot(id=0, obj=None, name='', side='left', style='line')
out
Chart’s unique identifier.
idoptional
Chart’s unique identifier. This argument is used to add an object to an existing chart.
objoptional
clab.TimeSeries object.
nameoptional
Variable’s name.
sideoptional
Y-axis side. It can be either 'left' or 'right'.
styleoptional
Draw style. It can be 'bool', 'dots' or 'line'.
Examples
chart_id1 = clab.plot()
clab.plot(id=chart_id1, obj=f['roll_angle (deg)'])
clab.plot(id=chart_id1, obj=f['pitch_angle (deg)'], side='right')
Time Series Plot

8.1.2Bode Diagram#

Estimate the transfer function of a system using the FFT of the input and output signals and plot its Bode Diagram. The first signal added to the plot will be used as input, and the second as output.

out = clab.bode(id=0, obj=None, name='')
out
Chart’s unique identifier.
idoptional
Chart’s unique identifier. This argument is used to add an object to an existing chart.
objoptional
clab.TimeSeries object.
nameoptional
Variable’s name.
Examples
chart_id1 = clab.bode()
clab.bode(id=chart_id1, obj=f['Input Signal'])
clab.bode(id=chart_id1, obj=f['Output Signal'])
Bode Diagram

8.1.3Boolean Plot#

This function plots data points based on boolean values. A dot is plotted for each value different from zero in the data; zero values result in no plot for that specific data point.

out = clab.boolplot(id=0, obj=None, name='')
out
Chart’s unique identifier.
idoptional
Chart’s unique identifier. This argument is used to add an object to an existing chart.
objoptional
clab.TimeSeries object.
nameoptional
Variable’s name.
Examples
ts1 = clab.create_random(dist='uniform', seed=1234, type='int', ymin=0.0, ymax=1.0, xdiff=0.5)
ts2 = clab.create_random(dist='uniform', seed=4321, type='int', ymin=0.0, ymax=1.0, xdiff=0.5)
chart_id1 = clab.boolplot()
clab.boolplot(id=chart_id1, obj=ts1, name='VAR1')
clab.boolplot(id=chart_id1, obj=ts2, name='VAR2')
Boolean Plot

8.1.4Cross Plot#

Plot a clab.TimeSeries object against another one, displaying the engineering values in both the x-axis and y-axis.

The plotting is done by pairs: the first variable added to the chart will be the x-axis variable and the second, the y-axis. If there is an odd number of variables in the chart, the last pair will be incomplete and will not be displayed.

out = clab.crossplot(id=0, obj=None, name='', side='left')
out
Chart’s unique identifier.
idoptional
Chart’s unique identifier. This argument is used to add an object to an existing chart.
objoptional
clab.TimeSeries object.
nameoptional
Variable’s name.
sideoptional
Y-axis side. It can be either 'left' or 'right'. For the first variable, this value is ignored.
Examples
chart_id1 = clab.crossplot()
clab.crossplot(id=chart_id1, obj=f['Latitude'])
clab.crossplot(id=chart_id1, obj=f['Longitude'])
Cross Plot

8.1.5Cross-Correlation Plot#

Calculate and plot the cross-correlation (also known as a sliding dot product or sliding inner-product) of a clab.TimeSeries object against another one (the reference variable).

The first variable added to the chart will be the reference variable.

out = clab.xcorrplot(id=0, obj=None, name='', side='left')
out
Chart’s unique identifier.
idoptional
Chart’s unique identifier. This argument is used to add an object to an existing chart.
objoptional
clab.TimeSeries object.
nameoptional
Variable’s name.
sideoptional
Y-axis side. It can be either 'left' or 'right'. For the first variable, this value is ignored.
Examples
chart_id1 = clab.xcorrplot()
clab.xcorrplot(id=chart_id1, obj=f['X1'])
clab.xcorrplot(id=chart_id1, obj=f['X2'])
Cross-Correlation Plot

8.1.6Fast Fourier Transform Plot#

Plot the Fast Fourier Transform of a clab.TimeSeries object. The x-axis will display frequency in hertz.

If you only need the FFT data, use the clab.fftdata function (refer to Section 6.2.18).

out = clab.fft(id=0, obj=None, name='', side='left')
out
Chart’s unique identifier.
idoptional
Chart’s unique identifier. This argument is used to add an object to an existing chart.
objoptional
clab.TimeSeries object.
nameoptional
Variable’s name.
sideoptional
Y-axis side. It can be either 'left' or 'right'.
Examples
chart_id1 = clab.fft(obj=f['signal_12hz'])
Fast Fourier Transform Plot

8.1.7Spectrogram Plot#

Plot the spectrogram of a clab.TimeSeries object. The y-axis will display frequency in hertz.

This function computes the Fast Fourier Transform (FFT) of consecutive time windows (spectrogram), with no window function applied (rectangular window). The window size is determined by the nfft parameter, and the overlap between adjacent windows is controlled by the overlap parameter.

out = clab.spectrogram(id=0, obj=None, name='', nfft=256, overlap=0.1)
out
Chart’s unique identifier.
idoptional
Chart’s unique identifier. This argument is used to add an object to an existing chart.
objoptional
clab.TimeSeries object.
nameoptional
Variable’s name.
nfftoptional
Number of samples in the FFT window. Any value from 1 up is accepted, but the chart uses a power of two (at least 64), rounding up when the value increases and down when it decreases.
overlapoptional
Fraction of overlap between two windows, from 0.0 to less than 1.0. Values above 0.8 are reduced to 0.8.
Examples
var1 = clab.create_random(dist='normal', mean=0.0, stddev=1.0, xdiff=0.02) * 0.5
var2 = clab.create_sine(xdiff=0.02, freq=16)
var3 = clab.create_chirp(xdiff=0.02)
signal = var1 + var2 + var3
clab.spectrogram(obj=signal, nfft=128)
Spectrogram Plot

8.1.8GeoMap Plot#

Generates a geographical map visualization from latitude/longitude data contained within a clab.TimeSeries object.

Currently, such objects are produced natively only by the NetCDF loader for variables with latitude and longitude dimensions (see Section 4.1); they can also be built with the three-sequence clab.TimeSeries constructor.

Each plot supports a single variable, whose data must present the following layout:

xdata
A 1D clab.Array representing the unique longitude coordinates. The inner loop iterates through this data to determine the column position for each data point.
ydata
A 1D clab.Array representing the unique latitude coordinates. The outer loop iterates through this data to determine the row position for each data point.
zdata
A flattened 1D clab.Array representing a 2D grid of values (len(ydata) × len(xdata)). It is stored in row-major order, where all the X-values for a given Y-row are contiguous in memory. The element at a specific grid intersection is accessed using the formula: z=x+y×len(xdata)
out = clab.geomap(id=0, obj=None, name='')
out
Chart’s unique identifier.
idoptional
Chart’s unique identifier. This argument is used to add an object to an existing chart.
objoptional
clab.TimeSeries object.
nameoptional
Variable’s name.
Examples
clab.geomap(obj=f['tas'])
GeoMap Plot

8.1.9HeatMap Plot#

Plot the heatmap between two clab.TimeSeries objects. Each call adds one series, so the function is called twice with the same id: the first series is placed on the x-axis and the second on the y-axis. The grid is fixed at 50 columns by 30 rows and covers the visible time range; use clab.heatmapdata to choose the grid size and time range.

If you only need the underlying data matrix, use the clab.heatmapdata function (refer to Section 6.2.19).

out = clab.heatmap(id=0, obj=None, name='')
out
Chart’s unique identifier.
idoptional
Chart’s unique identifier. This argument is used to add an object to an existing chart.
objoptional
clab.TimeSeries object.
nameoptional
Variable’s name.
Examples
chart_id1 = clab.heatmap()
clab.heatmap(id=chart_id1, obj=f['X3'])
clab.heatmap(id=chart_id1, obj=f['X4'])
HeatMap Plot

8.1.10Histogram Plot#

Plot the histogram of a clab.TimeSeries object.

If you only need the histogram data, use the clab.histdata function (refer to Section 6.2.20).

out = clab.hist(id=0, obj=None, name='', type='bar', nbins=8, bins=[])
out
Chart’s unique identifier.
idoptional
Chart’s unique identifier. This argument is used to add an object to an existing chart.
objoptional
clab.TimeSeries object.
nameoptional
Variable’s name.
typeoptional
Chart’s type. It can be either 'bar' or 'pie'.
nbinsoptional
Number of bars (for the 'bar' type) or number of slices (for the 'pie' type). Value cannot be less than 3.
binsoptional
List with the bins limits. Its length cannot be less than 2. If this argument is provided along with nbins, the latter will be ignored.
Examples
rand = clab.create_random(dist='normal', mean=0.0, stddev=1.0)
chart_id1 = clab.hist(obj=rand, nbins=10)
chart_id2 = clab.hist(obj=rand, type='pie', nbins=4)
Histogram PlotHistogram Plot

8.1.11Violin Plot#

Plot the violin diagram of a clab.TimeSeries object.

If you only need the violin data, use the clab.histdata function (refer to Section 6.2.20).

out = clab.violinplot(id=0, obj=None, name='', nbins=100)
out
Chart’s unique identifier.
idoptional
Chart’s unique identifier. This argument is used to add an object to an existing chart.
objoptional
clab.TimeSeries object.
nameoptional
Variable’s name.
nbinsoptional
Number of horizontal bars. Value cannot be less than 10.
Examples
var1 = clab.create_random(dist='normal', mean=0.0, stddev=1.0, seed=1234)
var2 = clab.create_random(dist='normal', mean=1.0, stddev=1.0, seed=1234)
chart_id = clab.violinplot()
clab.violinplot(id=chart_id, obj=var1, name='VAR1', nbins=25)
clab.violinplot(id=chart_id, obj=var2, name='VAR2', nbins=25)
Violin Plot

8.2Functions to Create 3D Charts#

8.2.1Time Series Plot With 3 Axes#

Plot two clab.TimeSeries objects to display engineering values on the y-axis and z-axis, with time on the x-axis. If the objects were created using built-in loaders, the x-axis will display time in seconds. Only two variables can be added to a single chart: one for the y-axis and one for the z-axis.

out = clab.plot3d(id=0, obj=None, name='')
out
Chart’s unique identifier.
idoptional
Chart’s unique identifier. This argument is used to add an object to an existing chart.
objoptional
clab.TimeSeries object.
nameoptional
Variable’s name.
Examples
chart_id1 = clab.plot3d()
clab.plot3d(id=chart_id1, name='Altitude')
clab.plot3d(id=chart_id1, name='Longitude')
Time Series Plot With 3 Axes

8.2.2Mesh Plot#

Plot a clab.Mesh object in a 3D surface chart.

out = clab.mesh(obj)
out
Chart’s unique identifier.
objrequired
clab.Mesh object.
Examples
mesh1 = clab.create_mesh_sinc(xdiff=1.0, zdiff=1.0)
chart_id1 = clab.mesh(mesh1)
Mesh Plot

8.3Functions to Create Specialized Charts#

8.3.1Create a Synoptic Chart with Gauges#

Create a chart with gauges that visualize clab.TimeSeries values. The gauge values dynamically update based on the input clab.TimeSeries they are linked to. To update the gauge values manually, hold CTRL while moving the mouse cursor along a standard 2D chart.

out = clab.synoptic(id=0, obj=None, name='', x=-1, y=-1, width=250, min=0.0, max=10.0, red=0x36, green=0x7b, blue=0xf5)
out
Chart’s unique identifier.
idoptional
Chart’s unique identifier. Use this argument to add an object (the gauge) to an existing chart.
objoptional
The clab.TimeSeries object whose value will be displayed on the gauge.
nameoptional
The display name for the variable being visualized.
xoptional
Object’s position on the x-axis, in pixels. If this value is negative, the object will be automatically positioned in the chart.
yoptional
Object’s position on the y-axis, in pixels. If this value is negative, the object will be automatically positioned in the chart.
widthoptional
Object’s width, in pixels. If this value is negative, the object will be automatically sized.
minoptional
Minimum value in the scale (the gauge’s lower bound).
maxoptional
Maximum value in the scale (the gauge’s upper bound).
redoptional
Red channel intensity (0 to 255).
greenoptional
Green channel intensity (0 to 255).
blueoptional
Blue channel intensity (0 to 255).
Examples
chart_id1 = clab.synoptic()
clab.synoptic(id=chart_id1, name='roll_angle (deg)', min=-180.0, max=180.0)
clab.synoptic(id=chart_id1, name='pitch_angle (deg)', min=-180.0, max=180.0)
clab.synoptic(id=chart_id1, name='heading (deg)', min=0.0, max=360.0)
Create a Synoptic Chart with Gauges

8.3.2Create a Chart with Video Frame#

Create a chart embedding a synchronized video frame from a clab.TimeSeries that contains video data. To manually scrub through video frames, hold CTRL while moving the mouse cursor along a standard 2D chart.

out = clab.video(id=0, obj=None, name='', brightness=0.0, contrast=1.0, gamma=1.0, posterization=1, thresholding=0)
out
Chart’s unique identifier.
idoptional
Chart’s unique identifier. Use this argument to add the video frame to an existing chart view.
objoptional
The clab.TimeSeries video object supplying the frames.
nameoptional
The display name or title for the video panel component.
brightnessoptional
Adjusts the overall light intensity (-1.0 to +1.0). Negative values darken the frame, while positive values uniformly brighten it. Default is 0.0 (no change).
contrastoptional
Scales the difference between light and dark areas (0.0 to 4.0). Values below 1.0 reduce contrast (flattening the image), while values above 1.0 expand it, making highlights brighter and shadows deeper. Default is 1.0.
gammaoptional
Applies non-linear gamma correction (0.0 to 99.0). Adjusting gamma optimizes the balance of mid-tones without blowing out the highlights or crushing deep blacks. Each channel value p (from 0 to 1) becomes pgamma: values less than 1.0 lighten mid-tones, values greater than 1.0 darken them, and 0.0 turns the whole frame white. Default is 1.0.
posterizationoptional
Number of tones per channel, to create a blocked, poster-like effect (1 to 128). Values 1 and 0 are special: they retain full color depth. From 2 up, each channel is reduced to that number of tones, so lower values quantize colors more aggressively (2 gives the strongest effect). Default is 1.
thresholdingoptional
Converts the image to binary black-and-white (0 to 255). A value of 0 leaves the image unchanged. Setting a value between 1 and 255 forces pixels darker than the threshold to black, and pixels brighter to pure white—ideal for segmentation or isolating high-contrast features.
Examples
clab.video(name='VideoCh1', brightness=0.5)

8.4Functions to Export Charts#

8.4.1Save Charts to File#

Save charts to file. Currently, only PDF and PNG formats are supported.

clab.save(path, id=0, size='')
pathrequired
File’s full path. The path must include the desired extension (e.g., .pdf, .png).
idoptional
Chart’s or page’s unique identifier. If not provided, all pages are exported: to a single file for PDF, or to one file per page for PNG (name.png, name_1.png, name_2.png, …).
sizeoptional

Page size specification. If no size is provided (or the value is not recognized), A4 is used: portrait when saving several pages or a page with several rows of charts, landscape otherwise. Supported values are:

a3
A3 Paper Size.
a4
A4 Paper Size.
a5
A5 Paper Size.
a6
A6 Paper Size.
letter
Letter Paper Size.
<width>x<height>
Custom size (e.g., 200x100), in pixels for PNG and in points (1/72 inch) for PDF.
Examples
clab.save(path='c:/user/out.pdf')
clab.save(path='c:/user/out.png', id=1234, size='256x128')

8.5Functions to Modify/Configure Charts#

8.5.1Set Chart Parameters#

Set parameters for a single chart.

clab.set_chart(id, ...)
idrequired
Chart’s unique identifier.
lmaxoptional
Maximum value (in engineering units) of the left axis. Setting this parameter disables auto-zoom for the left y-axis.
lminoptional
Minimum value (in engineering units) of the left axis. Setting this parameter disables auto-zoom for the left y-axis.
rmaxoptional
Maximum value (in engineering units) of the right axis. Setting this parameter disables auto-zoom for the right y-axis.
rminoptional
Minimum value (in engineering units) of the right axis. Setting this parameter disables auto-zoom for the right y-axis.
ltickoptional
Tick step value (in engineering units) for the left axis. Setting this parameter disables auto-tick for the left y-axis.
rtickoptional
Tick step value (in engineering units) for the right axis. Setting this parameter disables auto-tick for the right y-axis.
fitoptional
Show fitted curve information. Options are 'exp', 'linear', or 'poly'.
xlabeloptional
Text to be displayed near the x-axis ticks.
Examples
clab.set_chart(id=1234, lmax=10, lmin=0)
clab.set_chart(id=1234, rtick=2.5)
clab.set_chart(id=1234, fit='linear')

8.6Functions to Create Objects on 2D Charts#

In all these functions, the chart is selected with the chart argument. Colors are integers from 0 to 255 for each channel (values outside that range are clamped). If all three channels are omitted, the theme’s foreground color is used; if only some are given, the omitted ones are 0.

Objects cannot be removed individually from Python. Vertical flags and marks can be removed all at once with clab.reset (see Section 10.3), or the whole chart can be closed with clab.close. Individual objects can be deleted from the chart’s context menu (right-click).

8.6.1Create a Circle#

Create a circle in a single chart.

clab.circle(chart, xcenter, ycenter, diameter, red, green, blue)
chartrequired
Chart’s unique identifier.
xcenterrequired
Circle center coordinate in the x-axis. Units match the target chart’s x-axis.
ycenterrequired
Circle center coordinate in the y-axis. Units match the target chart’s y-axis.
diameterrequired
Circle diameter. Units match the target chart’s x-axis units.
redoptional
Red channel intensity (0 to 255).
greenoptional
Green channel intensity (0 to 255).
blueoptional
Blue channel intensity (0 to 255).
Examples
clab.circle(chart=1234, xcenter=10, ycenter=20, diameter=5, red=128, green=128, blue=128)

8.6.2Create a DataTip#

Create a datatip in a single chart.

clab.datatip(chart, name, x, red, green, blue)
chartrequired
Chart’s unique identifier.
namerequired
Parameter’s name.
xrequired
Position in the x-axis (in the target chart’s coordinate units).
redoptional
Red channel intensity (0 to 255).
greenoptional
Green channel intensity (0 to 255).
blueoptional
Blue channel intensity (0 to 255).
Examples
clab.datatip(chart=1234, name='value1', x=10, red=128, green=128, blue=128)

8.6.3Create a Flag#

Create a vertical flag across all charts (if only x is provided) or a horizontal flag in a single chart (if only y is provided). Exactly one of x and y must be given; passing both or neither raises a ValueError.

clab.flag(chart, x, y, text, red, green, blue)
chartoptional
Chart’s unique identifier. Required for horizontal flags (with y).
xoptional
Position in the x-axis. If y is omitted, it creates a vertical flag.
yoptional
Position in the y-axis. If x is omitted, it creates a horizontal flag.
textoptional
Flag’s text.
redoptional
Red channel intensity (0 to 255).
greenoptional
Green channel intensity (0 to 255).
blueoptional
Blue channel intensity (0 to 255).
Examples
clab.flag(x=20.0, text='event', red=128, green=128, blue=128)
clab.flag(chart=1234, y=100.0, text='limit')

8.6.4Create Marks in All Charts#

Create marks in all charts.

clab.mark(x, width, text, red, green, blue)
xrequired
Starting position in the x-axis (in x-axis units, shared by all charts).
widthrequired
Width of the mark (in x-axis units, shared by all charts).
textoptional
Text to display on the mark.
redoptional
Red channel intensity (0 to 255).
greenoptional
Green channel intensity (0 to 255).
blueoptional
Blue channel intensity (0 to 255).
Examples
clab.mark(x=10, width=12.5, text='event', red=128, green=128, blue=128)

8.6.5Create a Rectangle#

Create a rectangle in a single chart.

clab.rectangle(chart, x, y, width, height, red, green, blue)
chartrequired
Chart’s unique identifier.
xrequired
Position in the x-axis (in the target chart’s coordinate units).
yrequired
Position in the y-axis (in the target chart’s coordinate units).
widthrequired
Rectangle width (in the target chart’s x-axis units).
heightrequired
Rectangle height (in the target chart’s y-axis units).
redoptional
Red channel intensity (0 to 255).
greenoptional
Green channel intensity (0 to 255).
blueoptional
Blue channel intensity (0 to 255).
Examples
clab.rectangle(chart=1234, x=10, y=20, width=5, height=5, red=128, green=128, blue=128)

8.6.6Create a Text Label#

Create a text label in a single chart.

clab.text(chart, x, y, text, red, green, blue)
chartrequired
Chart’s unique identifier.
xrequired
Text coordinate in the x-axis (in the target chart’s coordinate units).
yrequired
Text coordinate in the y-axis (in the target chart’s coordinate units).
textrequired
Text to be displayed.
redoptional
Red channel intensity (0 to 255).
greenoptional
Green channel intensity (0 to 255).
blueoptional
Blue channel intensity (0 to 255).
Examples
clab.text(chart=1234, x=10, y=20, text='this is a text', red=128, green=128, blue=128)

8.6.7Set Up Legend#

Set up a legend for a single chart.

clab.legend(chart, x, y, visible, full)
chartrequired
Chart’s unique identifier.
xoptional
Horizontal position of the legend, in pixels from the chart’s left edge. Default is 20. If omitted, the current position is kept.
yoptional
Vertical position of the legend, in pixels from the chart’s top edge (downwards). Default is 0. If omitted, the current position is kept.
visibleoptional
If False, the legend will not be displayed.
fulloptional
If True, the legend will display full variable names.
Examples
clab.legend(chart=1234, visible=False)
clab.legend(chart=1234, x=50)

9Page Functions#

9.1Create Page#

Creates a new empty page.

out = clab.new_page(name, id=0)
out
Unique identifier of the created page.
namerequired
Page name.
idoptional
Unique identifier to assign to the page. If not provided, C-LAB will generate a unique identifier.
Examples
clab.new_page(id=1234, name='page 1')

9.2Delete Page#

Deletes an existing page.

clab.del_page(id=0, name='')
idoptional
Unique identifier of the page to delete.
nameoptional

Name of the page to delete.

At least one of id or name MUST be provided. If both are provided, id will take precedence.

Examples
clab.del_page(id=1234)

9.3Set Page Properties#

Modifies properties of an existing page.

clab.set_page(id, cols=-1)
idrequired
Unique identifier of the page.
colsoptional

Number of columns in the page layout. If the value is negative, the column count will not be modified.

The page identified by id MUST exist. If cols is provided and non-negative, the layout will be updated accordingly.

Examples
clab.set_page(id=1234, cols=3)

10Miscellaneous Functions#

This section defines functions for interacting with global front-end state, including charts, pages, and navigation controls.

10.1Set Global Parameters#

Sets global parameters affecting all charts and pages.

clab.set(key, args…)
keyrequired
Identifier specifying the parameter to modify.
args…required
Values assigned to the parameter identified by key. Argument types and count depend on the selected key.
'tab'
Set the active tab. Argument must be an integer in the range 1–4: 1 for Settings, 2 for Plugins, 3 for Model Builder and 4 for Charts (the same as the F1–F4 keys).
'globaltime'

Set the current global time. Takes one number (integer or float), in x-axis units.

Used by time-dependent features such as clab.synoptic (see Section 8.3.1).

'timelimits'
Set the global time limits. Takes two numbers, the start and the end time (clab.set('timelimits', tini, tend)); the end must be greater than the start.
'timeformat'

Set the time display format used by charts. Argument must be one of the following values:

'default'
Display raw time values as loaded (no formatting).
'hhmmss'
Interpret values as seconds and format as HH:MM:SS (hours wrap at 24).
'unixtime'
Interpret values as seconds since 00:00:00 UTC, January 1, 1970.
'gpstime'
Interpret values as seconds since 00:00:00 UTC, January 5, 1980 (no leap second adjustment).

The values are case-sensitive ('HHMMSS' is also accepted); other values are ignored.

'zoom'
Equivalent to 'timelimits'.
Examples
clab.set('timeformat', 'hhmmss')
clab.set('timelimits', 10.0, 20.0)

10.2Close Charts and Pages#

Closes charts or pages by identifier.

clab.close(type, id=0)
typerequired

Identifier specifying the target to close. Valid values:

'pages'
Close all pages.
'page'
Close a single page.
'chart'
Close a single chart.
idoptional
Unique identifier of the target. Required when type is page or chart. Ignored when type is pages.
Examples
clab.close('pages')
clab.close('chart', id=1234)

10.3Reset Parameters#

Resets global parameters affecting charts and pages.

clab.reset(key)
keyrequired

Identifier specifying the parameter to reset. Valid values:

'bookmarks'
Remove all bookmarks.
'flags'
Remove all vertical flags (see Section 8.6.3) from all charts, and stop them from being added to newly created charts.
'marks'
Remove all marks (see Section 8.6.4) from all charts, and stop them from being added to newly created charts.
'zoom'
Reset zoom levels for all pages. 'timelimits' is equivalent.
Examples
clab.reset('zoom')

10.4Create Bookmark#

Creates a bookmark representing a time interval in the front-end interface.

Bookmarks allow navigation between predefined time ranges and can also be created via the horizontal scrollbar context menu.

clab.bookmark(tini, tend)
tinirequired
Start time of the bookmark.
tendrequired
End time of the bookmark.
Examples
clab.bookmark(tini=1.0, tend=5.0)

11COM Server Functions#

C-LAB provides support for COM servers (IDispatch-compatible) through an out-of-process architecture. It exposes an API that allows external applications to interact with C-LAB from a separate process.

The examples in the following subsections are written in Python; however, the same principles can be applied to other programming languages.

11.1Create and Update C-LAB Objects#

11.1.1Create clab.TimeSeries#

Creates a clab.TimeSeries object from two arrays.

HRESULT CreateTimeSeries([in] BSTR name, [in] SAFEARRAY(VARIANT) xvalues, [in] SAFEARRAY(VARIANT) yvalues)
name
Name of the object.
xvalues
X-axis values. Must have the same length as yvalues.
yvalues
Y-axis values. Must have the same length as xvalues.
Examples
import win32com.client
obj = win32com.client.Dispatch('ClabApp.ClabObject')
obj.CreateTimeSeries('parameter1', [1,2,3,4,5,6,7,8], [10,20,30,40,50,60,70,80])

11.1.2Delete clab.TimeSeries#

Deletes a clab.TimeSeries object from the workspace.

HRESULT DeleteTimeSeries([in] BSTR name)
name
Name of the object. An error is returned if no clab.TimeSeries object has this name. Objects inside containers cannot be deleted.
Examples
import win32com.client
obj = win32com.client.Dispatch('ClabApp.ClabObject')
obj.DeleteTimeSeries('parameter1')

11.1.3Get clab.TimeSeries#

Returns the values of an existing clab.TimeSeries object as two arrays.

The name may also refer to an object inside a container (e.g., 'container.parameter').

HRESULT GetTimeSeries([in] BSTR name, [out] VARIANT* xvalues, [out] VARIANT* yvalues)
name
Name of the object. An error is returned if no clab.TimeSeries object has this name.
xvalues
Returns the x-axis values as an array of VARIANT (each element of type double).
yvalues
Returns the y-axis values as an array of VARIANT (each element of type double). In scripting languages (e.g., Python), both arrays are returned directly by the function as a tuple.
Examples
import win32com.client
obj = win32com.client.Dispatch('ClabApp.ClabObject')
x, y = obj.GetTimeSeries('parameter1')

11.1.4Update clab.TimeSeries#

Updates a clab.TimeSeries object. If the object does not exist, it is created.

The length of an existing object is not modified:

  • If input arrays are shorter, remaining values are preserved.
  • If input arrays are longer, excess elements are ignored.

Passing an empty array leaves the corresponding data unchanged.

HRESULT UpdateTimeSeries([in] BSTR name, [in] SAFEARRAY(VARIANT) xvalues, [in] SAFEARRAY(VARIANT) yvalues)
name
Name of the object.
xvalues
X-axis values. Must match the length of yvalues or be empty.
yvalues
Y-axis values. Must match the length of xvalues or be empty.
Examples
import win32com.client
obj = win32com.client.Dispatch('ClabApp.ClabObject')
obj.UpdateTimeSeries('parameter1', [1,2,3,4,5,6,7,8], [10,20,30,40,50,60,70,80])

11.2Functions to Create 2D Charts#

11.2.1Time Series Plot#

Plots a clab.TimeSeries object. The x-axis represents time, and the y-axis represents the corresponding values. If the object was created using built-in loaders, time is expressed in seconds.

See Section 8.1.1 for the Python API equivalent.

HRESULT Plot([in] ULONGLONG chartId, [in] BSTR name, [in] BSTR side, [in] BSTR style, [out, retval] ULONGLONG* result)
chartId
Unique chart identifier. If 0, a new chart is created with a new identifier. If nonzero, the object is added to that chart; if no chart has that identifier, a new chart is created with it, on the selected page (or the last page).
name
Name of the object.
side
Y-axis side. Valid values: 'left', 'right'.
style
Rendering style. Valid values: 'bool', 'dots', 'line'.
result
Returns the chart identifier used for the operation. In scripting languages (e.g., Python, VBScript), this value is returned directly by the function.
Examples
import win32com.client
obj = win32com.client.Dispatch('ClabApp.ClabObject')
obj.Plot(1234, 'parameter1', 'left', 'line') # returns 1234

11.3Functions to Export Charts#

11.3.1Save Charts to File#

Exports charts to a file. Supported formats: PDF and PNG.

See Section 8.4.1 for the Python API equivalent.

HRESULT Save([in] BSTR path, [in] ULONGLONG id, [in] BSTR size)
path
Full file path, including extension.
id
Unique identifier of the chart or page. If 0, all pages are exported.
size

Output page size. An empty string ('') or an unrecognized value selects A4, as in the Python save function. Supported values:

a3
A3 paper size.
a4
A4 paper size.
a5
A5 paper size.
a6
A6 paper size.
letter
Letter paper size.
<width>x<height>
Custom size (e.g., 200x100), in pixels for PNG and in points for PDF.
Examples
import win32com.client
obj = win32com.client.Dispatch('ClabApp.ClabObject')
obj.Save('c:/file.pdf', 0, '200x100')
obj.Save('c:/file.png', 0, '')

11.4Miscellaneous Functions#

11.4.1Get Version#

Returns the C-LAB version as a string in the format major.minor.patch.

HRESULT GetVersion([out, retval] BSTR* result)
result
Returns the version string. In scripting languages (e.g., Python, VBScript), this value is returned directly by the function.
Examples
import win32com.client
obj = win32com.client.Dispatch('ClabApp.ClabObject')
obj.GetVersion() # e.g. '1.2.3'

11.4.2Close Chart#

Closes a chart by identifier.

See Section 10.2 for the Python API equivalent.

HRESULT Close([in] ULONGLONG chartId)
chartId
Unique chart identifier (e.g., the value returned by Plot). Must be nonzero.
Examples
import win32com.client
obj = win32com.client.Dispatch('ClabApp.ClabObject')
obj.Close(1234)

11.4.3Reset Parameters#

Resets global parameters affecting charts and pages.

See Section 10.3 for the Python API equivalent.

HRESULT Reset([in] BSTR key)
key

Identifier specifying the parameter to reset. An error is returned for any other value. Valid values:

'bookmarks'
Remove all bookmarks.
'flags'
Remove all vertical flags from all charts.
'marks'
Remove all marks from all charts.
'zoom'
Reset zoom levels for all pages. 'timelimits' is equivalent.
Examples
import win32com.client
obj = win32com.client.Dispatch('ClabApp.ClabObject')
obj.Reset('zoom')