Skip to content

sift_py.data_import.tdms

CLASS DESCRIPTION
TdmsTimeFormat
TdmsUploadService

Service to upload TDMS files.

FUNCTION DESCRIPTION
sanitize_string

Removes the characters ", \, `, ~, and | from the input string.

ATTRIBUTE DESCRIPTION
CHARACTER_REPLACEMENTS

TDMS_TO_SIFT_TYPES

TIME_CHANNEL_NAME

CHARACTER_REPLACEMENTS module-attribute

CHARACTER_REPLACEMENTS = {
    '"': "_",
    "\\": "_",
    "`": "_",
    "~": "_",
    "|": "_",
}

TDMS_TO_SIFT_TYPES module-attribute

TDMS_TO_SIFT_TYPES = {
    Boolean: BOOL,
    Int8: INT_32,
    Int16: INT_32,
    Int32: INT_32,
    Int64: INT_64,
    Uint8: UINT_32,
    Uint16: UINT_32,
    Uint32: UINT_32,
    Uint64: UINT_64,
    SingleFloat: FLOAT,
    DoubleFloat: DOUBLE,
    String: STRING,
}

TIME_CHANNEL_NAME module-attribute

TIME_CHANNEL_NAME = 'Time'

TdmsTimeFormat

Bases: Enum

ATTRIBUTE DESCRIPTION
TIME_CHANNEL

WAVEFORM

TIME_CHANNEL class-attribute instance-attribute

TIME_CHANNEL = 'time_channel'

WAVEFORM class-attribute instance-attribute

WAVEFORM = 'waveform'

TdmsUploadService

TdmsUploadService(rest_conf: SiftRestConfig)

Service to upload TDMS files.

METHOD DESCRIPTION
upload

Uploads the TDMS file pointed to by path to the specified asset.

upload

upload(
    path: Union[str, Path],
    asset_name: str,
    prefix_channel_with_group: bool = False,
    group_into_components: bool = False,
    ignore_errors: bool = False,
    run_name: Optional[str] = None,
    run_id: Optional[str] = None,
    tdms_time_format: TdmsTimeFormat = WAVEFORM,
    include_metadata: bool = False,
) -> DataImportService

Uploads the TDMS file pointed to by path to the specified asset.

PARAMETER DESCRIPTION
path

The path to the file to upload.

TYPE: Union[str, Path]

asset_name

The name of the asset to upload to.

TYPE: str

prefix_channel_with_group

Set to True if you want to prefix the channel name with TDMS group. This can later be used to group into folders in the Sift UI. Default is False.

TYPE: bool DEFAULT: False

ignore_errors

If True will skip channels without timing information. Default is False.

TYPE: bool DEFAULT: False

run_name

The name of the run to create for this data. Default is None.

TYPE: Optional[str] DEFAULT: None

run_id

The id of the run to add this data to. Default is None.

TYPE: Optional[str] DEFAULT: None

tdms_time_format

Specify how timing information is encoded in the file. Default is WAVEFORM. If using the TIME_CHANNEL format, timestamps should use the LabVIEW/TDMS epoch (number of seconds since 01/01/1904 00:00:00.00 UTC).

TYPE: TdmsTimeFormat DEFAULT: WAVEFORM

include_metadata

Whether to include TDMS file metadata as Run metadata.

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
DataImportService

The DataImportService used to get the status of the import.

sanitize_string

sanitize_string(input_string: str) -> str

Removes the characters ", \, `, ~, and | from the input string.

See https://docs.siftstack.com/docs/data-model/assets-channels-runs#assets-and-channels

PARAMETER DESCRIPTION
input_string

The string to sanitize.

TYPE: str

RETURNS DESCRIPTION
str

The sanitized string.