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.
C-LAB 26.11.0 · November 2026
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
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.
An instance of clab.Array can be created directly using the following functions:
clab.Array(list)listrequiredclab.Array(other)otherrequiredclab.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)lenrequiredclab.Array will be zero-initialized.clab.Array has no publicly exposed member variables.
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()outclab.Array.Return a new clab.Array containing a deep-copy of the caller’s values.
out = clab.Array.to_list()outclab.Array.Export array values as a standard Python list.
out = clab.Array.avg()outReturn the arithmetic mean (average) of the array’s values.
out = clab.Array.sum()outReturn the sum of all elements in the array.
out = clab.Array.count_eq(val)outvalrequiredReturn the number of elements in the array that are exactly equal to val.
out = clab.Array.count_gt(val)outvalrequiredReturn the count of elements that are strictly greater than val.
out = clab.Array.count_lt(val)outvalrequiredReturn the count of elements that are strictly less than val.
out = clab.Array.count_bt(val1, val2)outval1requiredval2requiredReturn the count of elements that are strictly between the provided arguments, i.e., and .
out = clab.Array.logical_and(rhs)outclab.Array.rhsclab.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)outclab.Array.rhsclab.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()outclab.Array.Return a new array (containing 0s and 1s) representing the logical NOT operation on all elements.
out = clab.Array.logical_xor(rhs)outclab.Array.rhsclab.Array.Return a new array (containing 0s and 1s) resulting from the logical XOR operation between the current array and clab.Array rhs.
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.
An instance of clab.Container can be created using:
clab.Container(path, plugin='', realtime=False, samples=300)pathrequiredFull 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.
pluginoptionalFull 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.
clab.Container.id64integerRead-only. Unique 64-bit identifier.
clab.Container.flagsintegerRead-only. Reserved for internal use.
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()outReturns the list of file paths associated with the container.
out = clab.Container.get_size()outReturns the number of TimeSeries objects in the container.
clab.Container.axpb(a, b)arequiredbrequiredApplies the transformation 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)arequiredbrequiredApplies the transformation 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)pathrequiredMerges 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)tsrequiredclab.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).
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:
ydata is stored row by row: the value for x index and z index 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.
An instance of clab.Mesh can be created directly using the following functions:
clab.Mesh()Create an empty clab.Mesh object.
clab.Mesh.id64integerRead-only. Unique 64-bit identifier assigned upon creation.
clab.Mesh.flagsintegerRead-only. Internal use only.
clab.Mesh.xdataclab.ArrayRead/write. clab.Array containing the data points for the x-axis coordinates.
clab.Mesh.ydataclab.ArrayRead/write. clab.Array containing the data values for the y-coordinate, corresponding to the specified and pairs.
clab.Mesh.zdataclab.ArrayRead/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.
clab.Mesh has no public member functions.
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.
An instance of clab.Model can be created using:
clab.Model()Creates an empty clab.Model.
clab.Model(path)pathCreates a clab.Model by loading the JSON file located at the given path. Raises an exception if the file cannot be loaded.
clab.Model.flagsintegerRead-only. Internal use only.
out = clab.Model.get(key, id)outinportCount and outportCount, a float for all other keys.keyrequiredString with the parameter name. It can be one of the following values:
idoptionalReturns model-level (ti, tf, ts) or block-level parameters. Any other key raises a ValueError.
model.get(key='ts')
model.get(key='x', id=1234)clab.Model.set(...)idoptionalxoptionalyoptionalwidthoptionalheightoptionalredoptionalgreenoptionalblueoptionaltioptionaltfoptionalti. It is the time of the last sample when tf - ti is a multiple of ts.tsoptionalSets model-level or block-level parameters. Block-level parameters require id; passing them without it raises a ValueError.
model.set(ti=5.0, tf=10.0)
model.set(id=1234, x=10, y=20)out = clab.Model.create(class, ...)outclassrequiredBlock class. It can be one of the following values:
type parameter ('bool', 'int8', 'int16', 'int32', 'int64', 'uint8', 'uint16', 'uint32', 'uint64', 'flt32', 'flt64').expression parameter.rise and fall parameters (in seconds, default 1.0).-1.target parameter.obj parameter.target parameter.True when the input is greater than valueOn and False when it is less than valueOff. Otherwise, it keeps its last value.portNumber parameter (zero-based indexing).coeffA and coeffB parameters.operator parameter ('and', 'or', 'nand', 'nor').bp1 (breakpoints) and out (output values) parameters.out, bp1 and bp2 parameters.True to False and vice versa.portNumber parameter (zero-based indexing).coeffA and coeffB parameters.initialValue, finalValue and time parameters.min, max and seed parameters.path parameter.operator parameter ('eq', 'ge', 'gt', 'le', 'lt', 'ne').frequency and phase parameters. The frequency is given in hertz and the phase, in degrees.timeOn, timeOff, valueOn and valueOff parameters.initialValue, finalValue and time parameters.name parameter.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).nameoptionalparentoptional...optionalexpression 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.
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)blockFromrequiredblockTorequiredportFromrequiredportTorequirednameoptionalCreates a connection between blocks.
model.link(blockFrom=b1, blockTo=b2, portFrom=0, portTo=1)clab.Model.codegen(lang, path)langrequired'c' or 'python'.pathrequiredGenerates source code from the model. Raises an exception on failure.
out = clab.Model.load()out0 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()outclab.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.
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
An instance of clab.Result can be created using:
clab.Result()Creates an empty clab.Result.
clab.Result.tifloatSimulation start time.
clab.Result.tffloatSimulation end time.
clab.Result.tsfloatSimulation time step.
clab.Result.<name>clab.TimeSeries or clab.ResultOne clab.TimeSeries for each to-workspace block, and one clab.Result for each subsystem, named after the block.
clab.Result.flagsintegerRead-only. Internal use only.
clab.Result does not provide any member functions.
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., for any given .
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)id64requiredCreate a clab.TimeSeries from a valid variable identifier id64. This is for internal usage only.
clab.TimeSeries(xvalues, yvalues)xvaluesrequiredyvaluesrequiredCreate 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)rhsrequiredclab.TimeSeries.Create a clab.TimeSeries from another clab.TimeSeries rhs. Both objects will share the same xdata and ydata objects (shallow copy).
clab.TimeSeries.id64integerRead-only. Unique 64-bit identifier.
clab.TimeSeries.flagsintegerRead-only. Internal use only.
clab.TimeSeries.xdataclab.ArrayRead/write. clab.Array object that stores data to be used in the x-axis (typically time in seconds).
clab.TimeSeries.ydataclab.ArrayRead/write. clab.Array object that stores data to be used in the y-axis.
clab.TimeSeries.zdataclab.ArrayRead/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].
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()outReturn variable’s name. Only available for data loaded directly from sources; calculated variables return an empty string.
out = clab.TimeSeries.get_fs()outReturn the estimated sampling frequency in hertz. If the object has not been loaded yet, this function will force it.
out = clab.TimeSeries.get_ts()outReturn the estimated sampling period in seconds. If the object has not been loaded yet, this function will force it.
clab.TimeSeries.axpb(a, b)arequiredbrequiredApply 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)arequiredbrequiredApply 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()outReturn the average of the object’s yvalues.
out = clab.TimeSeries.max()outReturn the maximum of the object’s yvalues.
out = clab.TimeSeries.min()outReturn the minimum of the object’s yvalues.
out = clab.TimeSeries.sum()outReturn the sum of the object’s yvalues.
out = clab.TimeSeries.index(val, op='eq')outvalrequiredopoptionaleq, 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)outtinirequiredtendrequiredReturn 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)outvalrequiredReturn 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)outvalrequiredReturn 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 is counted when satisfies the condition.
out = clab.TimeSeries.time_ne(val)outvalrequiredReturn total time in which y-axis values are not equal to val.
out = clab.TimeSeries.time_gt(val)outvalrequiredReturn total time in which y-axis values are greater than val.
out = clab.TimeSeries.time_lt(val)outvalrequiredReturn total time in which y-axis values are less than val.
out = clab.TimeSeries.time_bt(val1, val2)outval1requiredval2requiredReturn total time in which y-axis values are between the provided arguments, i.e., simultaneously strictly greater than val1 and strictly less than val2.
Settings can be configured through the dedicated tab in the application UI or via the module functions (see Section 3.3).
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.
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.
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).
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.
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.
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:
Restart not required: the file is read again when it changes, the next time data is loaded.
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:
clab.unpack: USGN, SGN, 2C or BCD (case-insensitive). Any other value, including an empty one or BNR, means USGN.Transformation: alias = source[msb:lsb] resolution offset
Restart not required: the file is read again when a data file is opened.
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.
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.
out = clab.get_config(key, group='general')outkeyrequiredgroupoptional'general'.value = clab.get_config(key='memory')
path = clab.get_config(key='tags', group='presets')Settings take effect at different times; see Sections Section 3.1 and Section 3.2 for details.
clab.set_config(value, key, group='general')valuerequiredmemory must be the string '80', not the integer 80). Floats raise a TypeError.keyrequiredSetting key. Supported values, by group:
'Disabled', 'Every 1 minute', 'Every 10 minutes' (default) or 'Every 30 minutes'. Group: 'general'.'Disabled', 'Fatal', 'Error', 'Warning' (default), 'Info', 'Debug' or 'Trace' (case-sensitive). Group: 'general'.'80' (default); minimum 10. Group: 'general'.'general'.'presets'.'presets'.'dark', or any other value for lite. Group: 'theme'.'dark', or any other value for lite. ui is accepted as an older name. Group: 'theme'.'window'.'window'.'window'.'window'.'window'.'myplugin.dll'). Group: 'plugins'.groupoptional'general'.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)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()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.
When a file is opened, C-LAB determines the appropriate loader using the following procedure:
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).
*.bin, *.log*.csv, *.tsv, *.txt*.hdf5, *.h5*.ch10, *.c10Clock 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:
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.
R-x\AFSI, R-x\ADL, R-x\AOVI); raw values are returned if neither is available.R-x\DMSK), otherwise one series per bit of the 32-bit state.*.ts file in the cache folder; the series holds the byte offset of each TS packet in that proxy file.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.*.xlsx (Office Open XML). The older *.xls format, *.xlsm and *.xlsb are not supported.*.mat*.ncunits, 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._FillValue, missing_value, scale_factor and add_offset are applied.*.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.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.
*.wavchannel1, channel2, …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.
When a file is opened, C-LAB determines plugin compatibility and executes the following sequence:
IsCompatible() for each enabled plugin, in folder order, until one reports compatibility. Plugins are queried before the built-in loaders.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.GetParameterCount(), then GetParameterName() for each index from 0 to count1, to enumerate available parameters. The plugin MUST return consistent and deterministic results.Load() for each requested parameter, when its data is first needed. The plugin MUST return synchronized x- and y-value arrays of equal length.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.
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.
extern 'C') and unmangled names; on x64 there is a single calling convention.const char*). File paths are converted to UTF-8 before the call.p_inConfigs has exactly GetConfigCount() entries (no terminating NULL); unset values are passed as empty strings.GetErrorMessage and GetInfoMessage.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.const char* GetPluginAuthor()
Returns the plugin author. Required.
const char* GetPluginDate()
Returns the plugin release date. Required.
const char* GetPluginHTML()
Returns plugin metadata formatted as HTML. Required.
const char* GetPluginExtension()
Returns the file extension used for filtering in file dialog boxes. Optional.
const char* GetPluginName()
Returns the plugin name. Used in file dialog filters. Required.
const char* GetPluginVersion()
Returns the plugin version. Required.
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.
const char* GetInfoMessage()
Returns a human-readable informational message. May return NULL. Messages shorter than 3 characters are ignored. Optional.
uint32_t GetConfigCount()
Returns the number of configuration entries. Required: DLLs without it are not recognized as plugins.
const char* GetConfigKey(uint32_t p_inIndex)
Returns the configuration key for a given index. Required if GetConfigCount returns more than 0.
const char* GetConfigHint(uint32_t p_inIndex)
Returns a short description for a configuration entry. Required if GetConfigCount returns more than 0.
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.
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.
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.
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.
uint32_t GetParameterCount(const char* p_inPath)
Returns the number of available parameters for the given file path.
const char* GetParameterName(const char* p_inPath, uint32_t p_inIndex)
Returns the parameter name for a given index and file path.
uint8_t Load(const char* p_inPath, uint32_t p_inIndex, uint64_t* p_outCount, double** p_outValuesX, double** p_outValuesY)
Loads parameter data.
*p_outCount and point *p_outValuesX and *p_outValuesY to two arrays: x-values and y-values.*p_outCount elements.Return 0 on success. Any other value is interpreted as error.
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.
When a file is opened, C-LAB determines plugin compatibility and executes the following sequence:
compatible(path) for each enabled plugin, until one reports compatibility. An exception raised here is ignored, and the plugin is treated as not compatible.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.list_names(path) to enumerate available parameters. The plugin MUST return consistent and deterministic results.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.terminate(path). The plugin MUST release all associated resources.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.
plugin_* functions and config_hints; if any of them fails, the plugin is not listed.Determines whether the plugin supports the given file.
Return 0 if not compatible. Any other value is interpreted as compatible.
Initializes the plugin using the provided file path and configuration values.
Return 0 on success. Any other integer is interpreted as error.
Releases resources associated with the provided file path.
The return value is ignored.
Loads parameter data.
Returns a tuple containing two sequences: x-values and y-values.
C-LAB provides support for loading data from real-time sources via external custom plugins, enabling dynamic data integration during runtime.
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.
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:
Initialize() with the connection identifier and the configuration values. The plugin MUST allocate and prepare all required resources during this phase.GetParameterCount(), then GetParameterName() for each index, to enumerate available parameters. The plugin MUST return consistent and deterministic results for a given input.Start() once to signal the beginning of data acquisition. The plugin SHOULD begin producing data after this call.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.Stop() to signal the end of data acquisition. The plugin SHOULD cease data production promptly.Terminate() when the plugin is no longer required. The plugin MUST release all allocated resources.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.
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.
file, folder, text.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.
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.
uint8_t Start(const char* p_inId)
Signals the start of data acquisition.
Return 0 on success. Any other value is interpreted as error.
uint8_t Stop(const char* p_inId)
Signals the stop of data acquisition.
Return 0 on success. Any other value is interpreted as error.
uint32_t GetParameterCount(const char* p_inId)
Returns the number of available parameters for the given connection.
const char* GetParameterName(const char* p_inId, uint32_t p_inIndex)
Returns the parameter name for a given index and connection.
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.
*p_outCount elements.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.
Return a new object, whose values are equal to (Euler’s number, ) raised to power of each value in the input argument.
out = clab.exp(ts)outclab.TimeSeries object.tsrequiredclab.TimeSeries object.Return a new object, whose values are equal to the natural (base ) logarithm of the argument. There is also a version that computes the logarithm with base 10 of the argument.
out = clab.log(ts)outclab.TimeSeries object.tsrequiredclab.TimeSeries object.out = clab.log10(ts)outclab.TimeSeries object.tsrequiredclab.TimeSeries object.Computes the nearest integer value to the argument, following the specified rounding rules:
out = clab.<operation>(ts)outclab.TimeSeries object.tsrequiredclab.TimeSeries object.Return a new object, whose values are equal to the square root of each value in the input argument.
out = clab.sqrt(ts)outclab.TimeSeries object.tsrequiredclab.TimeSeries object.Computes standard trigonometric operations. All results for are in radians unless the degree suffix is used.
out = clab.<operation>(ts)outclab.TimeSeries object.tsrequiredclab.TimeSeries object.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 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.
out = clab.angular_distance(lhs, rhs, type='deg')outclab.TimeSeries.lhsrequiredclab.TimeSeries.rhsrequiredclab.TimeSeries.typeoptionaldeg (for degrees) or rad (for radians).diff = clab.angular_distance(y2, y1, type='rad')The output is calculated as follows:
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)outclab.TimeSeries.tsrequiredclab.TimeSeries.dY = clab.derivative(y)Discrete integration (numerical quadrature), calculated using the trapezoidal rule. The first output sample is 0.0.
Differences between adjacent elements, calculated as The first output sample is 0.0, so the output has the same length as the input.
The nth element is the sum of the 1...n elements of the argument.
out = clab.accumulate(ts)outclab.TimeSeries.tsrequiredclab.TimeSeries.acc = clab.accumulate(y)The output represents the estimated instantaneous sampling frequency corresponding to the provided sample argument.
out = clab.estimate_sampling_frequency(ts)outclab.TimeSeries.tsrequiredclab.TimeSeries.fs = clab.estimate_sampling_frequency(y)The output represents the estimated instantaneous sampling period corresponding to the provided sample argument.
out = clab.estimate_sampling_period(ts)outclab.TimeSeries.tsrequiredclab.TimeSeries.ts = clab.estimate_sampling_period(y)Unpack values, selecting the desired bits and applying resolution and offset (bit extraction).
The output is calculated as where 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')outclab.TimeSeries.tsrequiredclab.TimeSeries.msboptionalbase.lsboptionalbase.baseoptionalgainoptionalbiasoptionaltypeoptionalUSGN (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.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')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)outclab.TimeSeries.tsrequiredclab.TimeSeries.onoptional'on' signal.offoptional'off' signal.out1 = clab.debounce(ts, on=10)
out2 = clab.debounce(ts, off=0.5)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)outclab.TimeSeries.tsrequiredclab.TimeSeries.loweroptionalupperoptionalout = clab.hysteresis(ts, lower=90.0, upper=180.0)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)outclab.TimeSeries.tsrequiredclab.TimeSeries.loweroptionalupperoptionalout = clab.clamp(ts, lower=90.0, upper=180.0)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')outclab.TimeSeries.tsrequiredclab.TimeSeries.lim1optionallim2optionalop1optionalop2optionalout = clab.drop(ts, lim1=90.0, lim2=180.0, op1='lt', op2='gt')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)outclab.TimeSeries.tsrequiredclab.TimeSeries.loweroptionalupperoptionalpersoptionalout1 = clab.in_range(ts, lower=90.0, upper=180.0)
out2 = clab.in_range(ts, upper=180.0, pers=10.0)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)outclab.TimeSeries.tsrequiredclab.TimeSeries.persrequiredout = clab.stale(ts, pers=2.0)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)outclab.TimeSeries.tsrequiredclab.TimeSeries.arequiredbrequiredout = clab.lerp(ts, a=2.0, b=4.0)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)outclab.TimeSeries.tsrequiredclab.TimeSeries.bprequiredvalrequiredclipoptionalout = clab.lut1d(ts, bp=[2.0, 4.0, 8.0], val=[4.0, 16.0, 64.0], clip=True)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)outclab.TimeSeries.in1requiredclab.TimeSeries. This is the row variable in the output values table.in2requiredclab.TimeSeries. This is the column variable in the output values table.bp1requiredin1.bp2requiredin2.valrequiredclipoptionaltable = [
[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)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(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 (, or at 0 Hz, with 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.tsrequiredclab.TimeSeries.inioptionalendoptionalout = clab.fftdata(ts)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)outTuple with the heatmap data, formatted as described:
rows tuples of cols values. Each cell contains the number of samples that fit that square.ts1requiredclab.TimeSeries. Positional-only.ts2requiredclab.TimeSeries. Positional-only.inioptionalendoptionalcolsoptionalrowsoptionalout = clab.heatmapdata(ts1, ts2, cols=8, rows=8)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<b for the first bin, [a,b) for the middle bins and b for the last bin.tsrequiredclab.TimeSeries.inioptionalendoptionalnbinsoptionalbinsoptionalnbins, the latter will be ignored.out = clab.histdata(ts, nbins=4)
out = clab.histdata(ts, bins=[1,3,5,7])Converts a TimeSeries object values to the target unit.
out = clab.convert(ts, source, target)outclab.TimeSeries.tsrequiredclab.TimeSeries.sourcerequiredtargetrequiredString with unit name to convert to. It can be one of the following:
'deg', 'rad'.'feet', 'inches', 'kilometers', 'meters', 'miles', 'nautical miles'.'kilograms', 'pounds'.'knots', 'km/h', 'm/s', 'mph'.'celsius', 'fahrenheit', 'kelvin'.out = clab.convert(ts, 'rad', 'deg')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.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.tinirequiredtendrequireddelimiteroptionalstepoptionaltini, 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.srcrequiredSource data to export. This can be one of the following:
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.tagsoptionalTrue, 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).precisionoptionalstep. Data values are always written with full precision. Used only when exporting to a delimiter-separated file.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)In the clab.TimeSeries and clab.Mesh factories, the x-axis (and z-axis) values are for up to the largest value not greater than . Both ends are inclusive: for instance, xmin=0, xmax=10, xdiff=0.5 gives 21 samples.
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)outclab.Array object.lenrequiredout = clab.create_array_random(500)Create a clab.Array with the length specified and all values set to 1.0.
out = clab.create_array_ones(len)outclab.Array object.lenrequiredout = clab.create_array_ones(500)Create a clab.Array with the length specified and all values set to 0.0.
out = clab.create_array_zeros(len)outclab.Array object.lenrequiredout = clab.create_array_zeros(500)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()outclab.Container object.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)outclab.TimeSeries object.xminoptionalxmaxoptionalxdiffoptionalfreq_startoptionalfreq_endoptionalout = clab.create_chirp(freq_start=8.0, freq_end=0.0)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)outclab.TimeSeries object.valueoptionalxminoptionalxmaxoptionalxdiffoptionalout = clab.create_const(value=3.1415, xmin=10, xmax=20, xdiff=0.5)Create a clab.TimeSeries object with a ramp signal in the y-axis, defined between and over the x-range .
out = clab.create_ramp(rxmin, rxmax, ymin, ymax, xmin, xmax, xdiff)outclab.TimeSeries object.rxminrequiredrxmaxrequiredyminrequiredymaxrequiredxminrequiredxmaxrequiredxdiffrequiredout = clab.create_ramp(rxmin=1, rxmax=5, ymin=0.75, ymax=4, xmin=1, xmax=7, xdiff=0.5)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)outclab.TimeSeries object.distrequired'uniform' or 'normal'.typeoptional'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.seedoptional0 is a valid seed. If omitted, the current time (in seconds) is used.ymin'uniform' distribution is selected.ymax'uniform' distribution is selected. It is excluded for 'flt' and included for 'int'.mean'normal' distribution is selected.stddev'normal' distribution is selected.xminoptionalxmaxoptionalxdiffoptionalout = 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)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)outclab.TimeSeries object.freqoptionalphaseoptionalamplitudeoptionalxminoptionalxmaxoptionalxdiffoptionalout = clab.create_sine(freq=10, phase=90, amplitude=10.0, xmin=10, xmax=20, xdiff=0.5)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)outclab.TimeSeries object.stepoptionalyminoptionalymaxoptionalxminoptionalxmaxoptionalxdiffoptionalout = clab.create_step(step=1.0, xmin=10, xmax=20, xdiff=0.5)Create a clab.Mesh object with a sinc function signal in the y-axis.
For 2 dimensions, is defined as For 3 dimensions, sinc is defined as where , and at .
out = clab.create_mesh_sinc(xmin=-10.0, xmax=+10.0, xdiff=0.5, zmin=-10.0, zmax=+10.0, zdiff=0.5)outclab.Mesh object.xminoptionalxmaxoptionalxdiffoptionalzminoptionalzmaxoptionalzdiffoptionalCreate 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)
First order low pass filter: The first output sample equals the first input sample. A NaN input keeps the previous output. 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)outclab.TimeSeries.tsrequiredclab.TimeSeries.taurequiredfiltered = clab.lowpass(ts, tau=2)First order high pass filter: The first output sample equals the first input sample. is estimated as for the low-pass filter.
out = clab.highpass(ts, tau)outclab.TimeSeries.tsrequiredclab.TimeSeries.taurequiredfiltered = clab.highpass(ts, tau=2)Centered moving average over a window of samples: 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 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)outclab.TimeSeries.tsrequiredclab.TimeSeries.windowrequiredwindow=1 returns a copy of the input with non-finite samples replaced by NaN.smoothed = clab.moving_average(ts, window=5)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)outclab.TimeSeries. If nothing matches, an Exception is raised.textrequiredregexoptionalTrue, 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.out1 = clab.find('.*value', regex=True)
out2 = clab.find('value')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)outclab.TimeSeries objects. If nothing matches, an Exception is raised.textrequiredout1 = clab.list('.*value')
out2 = clab.list('value')List the file system paths of all clab.Container objects currently loaded or accessible by the module.
out = clab.list_paths()outout1 = clab.list_paths()Computes linear regression to fit observed data into a first order linear function
out = clab.fit_linear(ts)outTuple with the following values:
tsrequiredclab.TimeSeries.Computes exponential regression to fit observed data into a function
out = clab.fit_exp(ts)outTuple with the following values:
tsrequiredclab.TimeSeries.Computes polynomial regression to fit observed data into an arbitrary order function
out = clab.fit_polynomial(ts, order)outTuple with the following values:
tsrequiredclab.TimeSeries.orderrequiredMerge 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)outclab.Container object. If no loaded container is compatible, or the merge fails, an Exception is raised.pathrequiredclab.merge(path='c:/user/data.csv')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:
2.718281828459045.1.4426950408889634.0.4342944819032518.3.141592653589793.0.3183098861837907.0.5641895835477563.6.283185307179586.0.6931471805599453.2.302585092994046.1.4142135623730951.1.7320508075688772.0.5773502691896257.0.5772156649015329.1.618033988749895.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:
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).
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.
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.
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')outidoptionalobjoptionalclab.TimeSeries object.nameoptionalsideoptional'left' or 'right'.styleoptional'bool', 'dots' or 'line'.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')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='')outidoptionalobjoptionalclab.TimeSeries object.nameoptionalchart_id1 = clab.bode()
clab.bode(id=chart_id1, obj=f['Input Signal'])
clab.bode(id=chart_id1, obj=f['Output Signal'])
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='')outidoptionalobjoptionalclab.TimeSeries object.nameoptionalts1 = 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')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')outidoptionalobjoptionalclab.TimeSeries object.nameoptionalsideoptional'left' or 'right'. For the first variable, this value is ignored.chart_id1 = clab.crossplot()
clab.crossplot(id=chart_id1, obj=f['Latitude'])
clab.crossplot(id=chart_id1, obj=f['Longitude'])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')outidoptionalobjoptionalclab.TimeSeries object.nameoptionalsideoptional'left' or 'right'. For the first variable, this value is ignored.chart_id1 = clab.xcorrplot()
clab.xcorrplot(id=chart_id1, obj=f['X1'])
clab.xcorrplot(id=chart_id1, obj=f['X2'])
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')outidoptionalobjoptionalclab.TimeSeries object.nameoptionalsideoptional'left' or 'right'.chart_id1 = clab.fft(obj=f['signal_12hz'])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)outidoptionalobjoptionalclab.TimeSeries object.nameoptionalnfftoptionaloverlapoptionalvar1 = 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)
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:
clab.Array representing the unique longitude coordinates. The inner loop iterates through this data to determine the column position for each data point.clab.Array representing the unique latitude coordinates. The outer loop iterates through this data to determine the row position for each data point.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: out = clab.geomap(id=0, obj=None, name='')outidoptionalobjoptionalclab.TimeSeries object.nameoptionalclab.geomap(obj=f['tas'])
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='')outidoptionalobjoptionalclab.TimeSeries object.nameoptionalchart_id1 = clab.heatmap()
clab.heatmap(id=chart_id1, obj=f['X3'])
clab.heatmap(id=chart_id1, obj=f['X4'])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=[])outidoptionalobjoptionalclab.TimeSeries object.nameoptionaltypeoptional'bar' or 'pie'.nbinsoptional'bar' type) or number of slices (for the 'pie' type). Value cannot be less than 3.binsoptionalnbins, the latter will be ignored.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)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)outidoptionalobjoptionalclab.TimeSeries object.nameoptionalnbinsoptionalvar1 = 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)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='')outidoptionalobjoptionalclab.TimeSeries object.nameoptionalchart_id1 = clab.plot3d()
clab.plot3d(id=chart_id1, name='Altitude')
clab.plot3d(id=chart_id1, name='Longitude')Plot a clab.Mesh object in a 3D surface chart.
out = clab.mesh(obj)outobjrequiredclab.Mesh object.mesh1 = clab.create_mesh_sinc(xdiff=1.0, zdiff=1.0)
chart_id1 = clab.mesh(mesh1)
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)outidoptionalobjoptionalclab.TimeSeries object whose value will be displayed on the gauge.nameoptionalxoptionalyoptionalwidthoptionalminoptionalmaxoptionalredoptionalgreenoptionalblueoptionalchart_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 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)outidoptionalobjoptionalclab.TimeSeries video object supplying the frames.nameoptionalbrightnessoptionalcontrastoptionalgammaoptionalposterizationoptionalthresholdingoptionalclab.video(name='VideoCh1', brightness=0.5)Save charts to file. Currently, only PDF and PNG formats are supported.
clab.save(path, id=0, size='')pathrequiredidoptionalname.png, name_1.png, name_2.png, …).sizeoptionalPage 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:
clab.save(path='c:/user/out.pdf')
clab.save(path='c:/user/out.png', id=1234, size='256x128')Set parameters for a single chart.
clab.set_chart(id, ...)idrequiredlmaxoptionallminoptionalrmaxoptionalrminoptionalltickoptionalrtickoptionalfitoptional'exp', 'linear', or 'poly'.xlabeloptionalclab.set_chart(id=1234, lmax=10, lmin=0)
clab.set_chart(id=1234, rtick=2.5)
clab.set_chart(id=1234, fit='linear')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).
Create a circle in a single chart.
clab.circle(chart, xcenter, ycenter, diameter, red, green, blue)chartrequiredxcenterrequiredycenterrequireddiameterrequiredredoptionalgreenoptionalblueoptionalclab.circle(chart=1234, xcenter=10, ycenter=20, diameter=5, red=128, green=128, blue=128)Create a datatip in a single chart.
clab.datatip(chart, name, x, red, green, blue)chartrequirednamerequiredxrequiredredoptionalgreenoptionalblueoptionalclab.datatip(chart=1234, name='value1', x=10, red=128, green=128, blue=128)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)chartoptionaly).xoptionaly is omitted, it creates a vertical flag.yoptionalx is omitted, it creates a horizontal flag.textoptionalredoptionalgreenoptionalblueoptionalclab.flag(x=20.0, text='event', red=128, green=128, blue=128)
clab.flag(chart=1234, y=100.0, text='limit')Create marks in all charts.
clab.mark(x, width, text, red, green, blue)xrequiredwidthrequiredtextoptionalredoptionalgreenoptionalblueoptionalclab.mark(x=10, width=12.5, text='event', red=128, green=128, blue=128)Create a rectangle in a single chart.
clab.rectangle(chart, x, y, width, height, red, green, blue)chartrequiredxrequiredyrequiredwidthrequiredheightrequiredredoptionalgreenoptionalblueoptionalclab.rectangle(chart=1234, x=10, y=20, width=5, height=5, red=128, green=128, blue=128)Create a text label in a single chart.
clab.text(chart, x, y, text, red, green, blue)chartrequiredxrequiredyrequiredtextrequiredredoptionalgreenoptionalblueoptionalclab.text(chart=1234, x=10, y=20, text='this is a text', red=128, green=128, blue=128)Set up a legend for a single chart.
clab.legend(chart, x, y, visible, full)chartrequiredxoptionalyoptionalvisibleoptionalFalse, the legend will not be displayed.fulloptionalTrue, the legend will display full variable names.clab.legend(chart=1234, visible=False)
clab.legend(chart=1234, x=50)Creates a new empty page.
out = clab.new_page(name, id=0)outnamerequiredidoptionalclab.new_page(id=1234, name='page 1')Deletes an existing page.
clab.del_page(id=0, name='')idoptionalnameoptionalName of the page to delete.
At least one of id or name MUST be provided. If both are provided, id will take precedence.
clab.del_page(id=1234)Modifies properties of an existing page.
clab.set_page(id, cols=-1)idrequiredcolsoptionalNumber 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.
clab.set_page(id=1234, cols=3)This section defines functions for interacting with global front-end state, including charts, pages, and navigation controls.
Sets global parameters affecting all charts and pages.
clab.set(key, args…)keyrequiredargs…requiredkey. Argument types and count depend on the selected key.'tab''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'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''hhmmss''unixtime''gpstime'The values are case-sensitive ('HHMMSS' is also accepted); other values are ignored.
'zoom''timelimits'.clab.set('timeformat', 'hhmmss')
clab.set('timelimits', 10.0, 20.0)
Closes charts or pages by identifier.
clab.close(type, id=0)typerequiredIdentifier specifying the target to close. Valid values:
'pages''page''chart'idoptionaltype is page or chart. Ignored when type is pages.clab.close('pages')
clab.close('chart', id=1234)Resets global parameters affecting charts and pages.
clab.reset(key)keyrequiredIdentifier specifying the parameter to reset. Valid values:
'bookmarks''flags''marks''zoom''timelimits' is equivalent.clab.reset('zoom')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)tinirequiredtendrequiredclab.bookmark(tini=1.0, tend=5.0)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.
clab.TimeSeries#Creates a clab.TimeSeries object from two arrays.
HRESULT CreateTimeSeries([in] BSTR name, [in] SAFEARRAY(VARIANT) xvalues, [in] SAFEARRAY(VARIANT) yvalues)namexvaluesyvalues.yvaluesxvalues.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])clab.TimeSeries#Deletes a clab.TimeSeries object from the workspace.
HRESULT DeleteTimeSeries([in] BSTR name)nameclab.TimeSeries object has this name. Objects inside containers cannot be deleted.import win32com.client
obj = win32com.client.Dispatch('ClabApp.ClabObject')
obj.DeleteTimeSeries('parameter1')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)nameclab.TimeSeries object has this name.xvaluesVARIANT (each element of type double).yvaluesVARIANT (each element of type double). In scripting languages (e.g., Python), both arrays are returned directly by the function as a tuple.import win32com.client
obj = win32com.client.Dispatch('ClabApp.ClabObject')
x, y = obj.GetTimeSeries('parameter1')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:
Passing an empty array leaves the corresponding data unchanged.
HRESULT UpdateTimeSeries([in] BSTR name, [in] SAFEARRAY(VARIANT) xvalues, [in] SAFEARRAY(VARIANT) yvalues)namexvaluesyvalues or be empty.yvaluesxvalues or be empty.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])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)chartIdnameside'left', 'right'.style'bool', 'dots', 'line'.resultimport win32com.client
obj = win32com.client.Dispatch('ClabApp.ClabObject')
obj.Plot(1234, 'parameter1', 'left', 'line') # returns 1234Exports 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)pathidsizeOutput page size. An empty string ('') or an unrecognized value selects A4, as in the Python save function. Supported values:
import win32com.client
obj = win32com.client.Dispatch('ClabApp.ClabObject')
obj.Save('c:/file.pdf', 0, '200x100')
obj.Save('c:/file.png', 0, '')Returns the C-LAB version as a string in the format major.minor.patch.
HRESULT GetVersion([out, retval] BSTR* result)resultimport win32com.client
obj = win32com.client.Dispatch('ClabApp.ClabObject')
obj.GetVersion() # e.g. '1.2.3'Closes a chart by identifier.
See Section 10.2 for the Python API equivalent.
HRESULT Close([in] ULONGLONG chartId)chartIdPlot). Must be nonzero.import win32com.client
obj = win32com.client.Dispatch('ClabApp.ClabObject')
obj.Close(1234)Resets global parameters affecting charts and pages.
See Section 10.3 for the Python API equivalent.
HRESULT Reset([in] BSTR key)keyIdentifier specifying the parameter to reset. An error is returned for any other value. Valid values:
'bookmarks''flags''marks''zoom''timelimits' is equivalent.import win32com.client
obj = win32com.client.Dispatch('ClabApp.ClabObject')
obj.Reset('zoom')