matlab_data_processor module¶
Definition of Matlab data processor.
Overview¶
The class and functions in this module enables to manipulate data from and toward the Matlab workspace. It also enables to read and write Matlab data file (.mat).
Classes:
A Matlab data processor. |
Functions:
|
Turn a ndarray into a matlab.double. |
Convert dict of matlab.output to dict of ndarray. |
|
|
Convert gems dict of ndarray to dict of matlab.double. |
|
Turn a matlab double into ndarray. |
|
Read .mat file and convert it to usable format for Matlab. |
|
Create a .mat file from dict of ndarray. |
- class gemseo.wrappers.matlab.matlab_data_processor.MatlabDataProcessor[source]¶
Bases:
gemseo.core.data_processor.DataProcessor
A Matlab data processor.
Convert GEMSEO format to Matlab format.
Examples
>>> # Build a new instance >>> proc = MatlabDataProcessor() >>> # initial python data >>> d = {"x": array([2]), "y": array([2j], dtype="complex")} >>> # process data to matlab format >>> res = proc.pre_process_data(d) >>> print(res) >>> >>> # initial data in matlab format >>> d = {"y": double([2, 3]), "x": double([2j], is_complex=True)} >>> # process to Python format >>> res = proc.post_process_data(d) >>> print(res)
Methods:
post_process_data
(data)Transform the output data from Matlab to GEMSEO.
pre_process_data
(data)Transform data from GEMSEO to Matlab.
- gemseo.wrappers.matlab.matlab_data_processor.array2double(data_array)[source]¶
Turn a ndarray into a matlab.double.
- Parameters
data_array – The numpy array to be converted.
- Returns
The matlab.double value.
- gemseo.wrappers.matlab.matlab_data_processor.convert_array_from_matlab(data)[source]¶
Convert dict of matlab.output to dict of ndarray.
- Parameters
data (Mapping[str, matlab.double]) – The dict of matlab.double.
- Returns
The dict of ndarray.
- Return type
Mapping[str, ndarray]
- gemseo.wrappers.matlab.matlab_data_processor.convert_array_to_matlab(data)[source]¶
Convert gems dict of ndarray to dict of matlab.double.
- Parameters
data (Mapping[str, ndarray]) – The dict of ndarray.
- Returns
The dict of matlab.double.
- Return type
Mapping[str, matlab.double]
- gemseo.wrappers.matlab.matlab_data_processor.double2array(matlab_double)[source]¶
Turn a matlab double into ndarray.
- Parameters
matlab_double (matlab.double) – The matlab.double values.
- Returns
The array of values.
- Return type
ndarray
- gemseo.wrappers.matlab.matlab_data_processor.load_matlab_file(file_path)[source]¶
Read .mat file and convert it to usable format for Matlab.
- Parameters
file_path (Union[str, Path]) – The path to a .mat file.
- Returns
The dict of matlab.double.
- Return type
Mapping[str, matlab.double]
- gemseo.wrappers.matlab.matlab_data_processor.save_matlab_file(dict_to_save, file_path='output_dict', *args, **kwargs)[source]¶
Create a .mat file from dict of ndarray.
- Parameters
dict_to_save (dict) – The dict of ndarray to be saved.
file_path (Union[str, pathlib.Path]) –
The path where to sabe the file.
By default it is set to output_dict.
*args (bool) – The list of scipy.io.savemat options.
**kwargs (bool) – The dict of scipy.io.savemat options.
- Raises
ValueError – If the saved dictionary is nor composed of ndarray only.
- Return type
None