qats.io#

Sub-package with io for various file formats.

qats.io.csv#

Readers CSV formatted time series files

Functions overview

read_data(path[, ind])

Read time series data arranged column wise on a comma-separated file.

read_names(path)

Read time series names from a comma-separated file.

API

read_names(path)#

Read time series names from a comma-separated file.

Parameters:

path (str) – Name of .csv file

Returns:

Time series names

Return type:

list

Notes

The series names are expected found on the header row. Time is expected to be in the first column.

read_data(path, ind=None)#

Read time series data arranged column wise on a comma-separated file.

Parameters:
  • path (str) – CSV file path (relative or absolute)

  • ind (list|tuple, optional) – Read only a subset of the data series specified by index , with 0 being the first. For example, ind = (1,4,5) will extract the 2nd, 5th and 6th columns. The default, None, results in all columns being read.

Returns:

Time and data

Return type:

array

qats.io.direct_access#

Readers for various direct access formatted time series files

Functions overview

read_dis_data(path[, ind, verbose])

Read cycle distributions from binary direct access formatted '.dis' file.

read_dis_names(path)

Read time series names from key-file associated with the direct access (binary) cycle distribution file format '.dis'.

read_tda_data(path[, ind, verbose])

Read time series from binary direct access formatted '.tda' file.

read_tda_names(path)

Read time series names from key-file associated with the direct access (binary) time series file format '.tda'.

read_ts_data(path[, ind, verbose])

Read time series from binary direct access formatted '.ts' file.

read_ts_names(path)

Read time series names from key-file associated with the direct access (binary) time series file format '.ts'.

write_ts_data(path, time, data)

Write time series direct access formatted file.

API

read_ts_names(path)#

Read time series names from key-file associated with the direct access (binary) time series file format ‘.ts’.

Parameters:

path (str) – Key file path

Returns:

Time series names

Return type:

list

Notes

Names are stored on ASCII file as one name per line. The file is terminated by END.

The associated time series are stored on a binary direct access file with suffix ‘.ts’.

read_tda_names(path)#

Read time series names from key-file associated with the direct access (binary) time series file format ‘.tda’.

Parameters:

path (str) – Key file path

Returns:

Time series names

Return type:

list

Notes

The associated time series are stored on a binary direct access file with suffix ‘.tda’.

read_dis_names(path)#

Read time series names from key-file associated with the direct access (binary) cycle distribution file format ‘.dis’.

Parameters:

path (str) – Key file path

Returns:

Time series names

Return type:

list

Notes

The associated cycle distributions are stored on a binary direct access file with suffix ‘.dis’.

read_ts_data(path, ind=None, verbose=False)#

Read time series from binary direct access formatted ‘.ts’ file.

Parameters:
  • path (str) – File path (relative or absolute)

  • ind (list of integers, optional) – Index of the requested records on the file. By default all time series are read.

  • verbose (bool, optional) – Increase verbosity

Returns:

Time and data

Return type:

array

Examples

>>> data = read_ts_data('data.ts')
>>> t = data[0,:]   # time
>>> x1 = data[1,:]  # first data series

Notes

Note that 0 is the index of the time array. If ind is specified, time array is only included if 0 is included in the specified indices.

read_tda_data(path, ind=None, verbose=False)#

Read time series from binary direct access formatted ‘.tda’ file.

Parameters:
  • path (str) – File path (relative or absolute)

  • ind (list of integers, optional) – Index of the requested records on the file. By default all time series are read.

  • verbose (bool, optional) – Increase verbosity

Returns:

Time and data

Return type:

array

Examples

>>> data = read_tda_data('data.tda')
>>> t = data[0,:]   # time
>>> x1 = data[1,:]  # first data series

Notes

Note that 0 is the index of the time array. If ind is specified, time array is only included if 0 is included in the specified indices.

read_dis_data(path, ind=None, verbose=False)#

Read cycle distributions from binary direct access formatted ‘.dis’ file.

Parameters:
  • path (str) – File path (relative or absolute)

  • ind (list of integers, optional) – Index of the requested records on the file. By default all time series are read.

  • verbose (bool, optional) – Increase verbosity

Returns:

Cycle widths and counts

Return type:

array

Notes

Note that 0 is the index of the time array. If ind is specified, time array is only included if 0 is included in the specified indices.

write_ts_data(path, time: ndarray, data: dict)#

Write time series direct access formatted file.

Parameters:
  • path (str) – File path

  • time (array) – Time

  • data (dict) – Time series data name vs. values

qats.io.sintef_mat#

Readers for SINTEF Ocean test data exhange format based on the Matlab .mat file.

Works for matlab file format version <=7.2 and >=7.3.

Functions overview

read_data(path[, names])

Read time series data from SINTEF Ocean test data exhange format based on the Matlab .mat file.

read_names(path)

Read time series names from SINTEF Ocean test data exhange format based on the Matlab .mat file.

API

read_names(path)#

Read time series names from SINTEF Ocean test data exhange format based on the Matlab .mat file.

Parameters:

path (str) – File path

Returns:

  • str – Name of the time array

  • list – Time series names

Examples

>>> tname, names = read_names('data.mat')
read_data(path: str, names: List[str] | Tuple[str] | None = None)#

Read time series data from SINTEF Ocean test data exhange format based on the Matlab .mat file.

Parameters:
  • path (str) – File path

  • names (Union[List[str], Tuple[str]], optional) – Names of the requested time series incl. the time array itself. Defaults to all time series on the file.

Returns:

Time and data

Return type:

dict

Examples

>>> tname, names = read_names('data.mat')
>>> data = read_data('data.mat', [tname, *names])
>>> t = data[tname]   # time
>>> x1 = data[names[0]]  # first data series

qats.io.other#

Readers for various time series file formats

Functions overview

read_dat_data(path[, ind])

Read time series arranged column wise on ascii formatted file.

read_dat_names(path)

Read time series names from an ASCII file with data arranged column-wise.

write_dat_data(path, time, data[, delim, ...])

Write time series arranged column wise on ascii formatted file.

API

read_dat_names(path)#

Read time series names from an ASCII file with data arranged column-wise. The names are in the first non-commented row.

Parameters:

path (str) – File path

Returns:

Time series names

Return type:

list

Notes

The names are extracted from the header row (the first non-commented row). The comment character is ‘#’. Time is assumed to be in the first column.

read_dat_data(path, ind=None)#

Read time series arranged column wise on ascii formatted file.

Parameters:
  • path (str) – File path

  • ind (list of integers, optional) – Defines which responses to include in returned array. Each of the indices in ind refer the sequence number of the reponses. Note that 0 is the index of the time array.

Returns:

Time and data

Return type:

array

Notes

If ind is specified, time array is only included if 0 is included in the specified indices.

If ind is specified, the response arrays (1-D) are stored in the returned 2-D array in the same order as specified. I.e. if ind=[0,10,2,3], then the response array with index 10 on .ts file is obtained from data[1,:].

write_dat_data(path, time: ndarray, data: dict, delim: str = '\t', skip_header: bool = False)#

Write time series arranged column wise on ascii formatted file.

Parameters:
  • path (str) – File path

  • time (array) – Time

  • data (dict) – Time series data name vs. values

  • delim (str, optional) – Column delimiter

  • skip_header (bool, optional) – Skip header on file

qats.io.sima#

Readers for ASCII and direct access formatted time series files exported from SIMA

Functions overview

read_ascii_data(path[, ind, verbose])

Read time series arranged column wise on ascii formatted file exported from SIMA/RIFLEX Dynmod.

read_bin_data(path[, ind, verbose])

Read time series from binary .bin file exported from RIFLEX Dynmod.

read_names(path)

Read time series names from key-files associated with .bin and .asc time-series files exported from SIMA/RIFLEX Dynmod.

read_sima_wind_names(path)

Read time series names from key-files associated with '<>_witurb.bin' and '<>_blresp.bin' time-series files exported from SIMA/RIFLEF Dynmod.

write_simo_file(path, time, data[, dt, ...])

Write time series on simo input format

API

read_sima_wind_names(path)#

Read time series names from key-files associated with ‘<>_witurb.bin’ and ‘<>_blresp.bin’ time-series files exported from SIMA/RIFLEF Dynmod.

Parameters:

path (str) – Keyfile path

Returns:

Time series names

Return type:

list

read_names(path)#

Read time series names from key-files associated with .bin and .asc time-series files exported from SIMA/RIFLEX Dynmod.

Parameters:

path (str) – Keyfile path

Returns:

Time series names

Return type:

list

Warning

This function is under development, and does not presently handle all kinds of response listings. If an unknown response description is encountered, the key suffix will be DOF<xx>.

read_bin_data(path, ind=None, verbose=False)#

Read time series from binary .bin file exported from RIFLEX Dynmod.

Parameters:
  • path (str) – Path to .bin file

  • ind (list of integers, optional) – Defines which responses to include in returned array. Each of the indices in ind refer the sequence number of the reponses. Note that 0 is the index of the time array.

  • verbose (bool, optional) – Increase verbosity

Returns:

Time and data

Return type:

array

Notes

If ind is specified, time array is only included if 0 is included in the specified indices.

If ind is specified, the response arrays (1-D) are stored in the returned 2-D array in the same order as specified. I.e. if ind=[0,10,2,3], then the response array with index 10 on .ts file is obtained from arr[1,:].

read_ascii_data(path, ind=None, verbose=False)#

Read time series arranged column wise on ascii formatted file exported from SIMA/RIFLEX Dynmod.

Parameters:
  • path (str) – Name of the binary file (incl. extension).

  • ind (list or tuple, optional) – Which columns to read, with 0 being the first. For example, ind=(1,4,5) will extract the 2nd, 5th and 6th columns. The default, None, results in all columns being read.

  • verbose (bool, optional) – Increase verbosity

Returns:

Time and data

Return type:

array

Notes

Time is assummed to be in the first column If ind is specified, time array is only included if 0 is included in the specified indices.

If ind is specified, the response arrays (1-D) are stored in the returned 2-D array in the same order as specified. I.e. if ind=[0,10,2,3], then the response array with index 10 on ascii file is obtained from data[1,:].

write_simo_file(path, time: ndarray, data: ndarray, dt: float = 0.2, description: str | None = None)#

Write time series on simo input format

Parameters:
  • path (str) – File path

  • time (array) – Time (s)

  • data (array) – Time series data

  • dt (float, optional) – Time step on file, default 0.2 seconds

  • description (str, optional) – Description printed to file

qats.io.sima_h5#

Readers for HDF5 formatted time series files exported from SIMA

Functions overview

read_data(path[, names, verbose])

Extracts time series data from .h5 (or hdf5) file exported from SIMA.

read_names(path[, verbose])

Extracts time series names for h5 data sets containing (or; interpreted as) time series from h5-file exported from SIMA.

write_data(path, data)

Write time series to SIMA HDF5 file.

API

read_names(path, verbose=False)#

Extracts time series names for h5 data sets containing (or; interpreted as) time series from h5-file exported from SIMA.

Parameters:
  • path (str) – Path (relative or absolute) to h5-file

  • verbose (bool, optional) – If True, print info.

Returns:

List of time series names (datasets)

Return type:

list

read_data(path, names=None, verbose=False)#

Extracts time series data from .h5 (or hdf5) file exported from SIMA.

Parameters:
  • path (str) – File name.

  • names (str or list, optional) – Timeseries/dataset names. If None (default), all time series are read.

  • verbose (bool, optional) – Increase verbosity

Returns:

List of arrays with time and data

Return type:

list

Notes

If keys is not specified, all datasets that are interpreted as time series will be read. See also read_h5_keys.

Note that the hdf5 is an extremely flexible file format and this reader is tailored to the SIMA h5 file format.

write_data(path, data: dict)#

Write time series to SIMA HDF5 file.

Parameters:
  • path (str) – File path

  • data (dict) – Time series data name vs. time and values

qats.io.tdms#

Functions overview

read_data(path[, names])

Read time series data from Technical Data Management Streaming (TDMS) files typically exported from LabVIEW.

read_names(path)

Read time series names from Technical Data Management Streaming (TDMS) file.

API

read_names(path)#

Read time series names from Technical Data Management Streaming (TDMS) file.

Parameters:

path (str) – Path (relative or absolute) to tdms-file

Returns:

List of time series names (datasets)

Return type:

list

References

  1. http://www.ni.com/product-documentation/3727/en/

read_data(path: str, names: List[str] | Tuple[str] | None = None)#

Read time series data from Technical Data Management Streaming (TDMS) files typically exported from LabVIEW.

Parameters:
  • path (str) – File name.

  • names (str or list, optional) – Timeseries/dataset names. If None (default), all time series are read.

Returns:

List of arrays with time and data

Return type:

list