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).
- 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)
- post_process_data(data)[source]¶
Transform the output data from Matlab to GEMSEO.
- Parameters
data (Mapping[str, matlab.double]) – The data with matlab arrays.
- Returns
The data with numpy arrays.
- Return type
Mapping[str, numpy.ndarray]
- pre_process_data(data)[source]¶
Transform data from GEMSEO to Matlab.
The function takes a dict of ndarray and return a dict of matlab.double.
- Parameters
data (Mapping[str, numpy.ndarray]) – The input data.
- Returns
The data with matlab array types.
- Return type
Mapping[str, matlab.double]
- gemseo.wrappers.matlab.matlab_data_processor.array2double(data_array)[source]¶
Turn a ndarray into a matlab.double.
- Parameters
data_array (numpy.ndarray) – The numpy array to be converted.
- Returns
The matlab.double value.
- Return type
matlab.double
- 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, numpy.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, numpy.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
- gemseo.wrappers.matlab.matlab_data_processor.load_matlab_file(file_path)[source]¶
Read .mat file and convert it to usable format for Matlab.
- gemseo.wrappers.matlab.matlab_data_processor.save_matlab_file(data, file_path='output_dict', **options)[source]¶
Save data to a MATLAB-style .mat file.
- Parameters
- Raises
ValueError – If some values in
data
are not NumPy arrays.- Return type
None