Skip to content

openstb.simulator.result_converter.matlab

Convert simulation results to MATLAB files.

Classes:

Name Description
MATLABConverter

Convert simulation results to a MATLAB file.

MATLABConverter

MATLABConverter(filename, format='5', long_field_names=False, do_compression=False, oned_as='row')

Bases: ResultConverter

Convert simulation results to a MATLAB file.

This writes the data with the following variables:

  • baseband_frequency: the frequency used to baseband the data
  • ping_start_time: seconds since the start of the trajectory that the pings were sent
  • pressure: the simulated pressure at each receiver
  • pressure_dimensions: string array giving the order of dimensions in pressure.
  • sample_time: seconds since the start of its ping that each sample was captured

Parameters:

Name Type Description Default
filename PathLike[str] | str

The path to save the converted results at.

required
format Literal['5', '4']

The version of the MATLAB file format to use. See scipy.io.savemat for details.

'5'
long_field_names bool

Whether to enable long field names. See scipy.io.savemat for details.

False
do_compression bool

Whether to compress matrices within the file. See scipy.io.savemat for details.

False
oned_as Literal['row', 'column']

Whether to write one-dimensional arrays as row or column vectors. See scipy.io.savemat for details.

'row'
Source code in openstb/simulator/result_converter/matlab.py
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
def __init__(
    self,
    filename: os.PathLike[str] | str,
    format: Literal["5", "4"] = "5",
    long_field_names: bool = False,
    do_compression: bool = False,
    oned_as: Literal["row", "column"] = "row",
):
    """
    Parameters
    ----------
    filename
        The path to save the converted results at.
    format
        The version of the MATLAB file format to use. See [scipy.io.savemat][] for
        details.
    long_field_names
        Whether to enable long field names. See [scipy.io.savemat][] for details.
    do_compression
        Whether to compress matrices within the file. See [scipy.io.savemat][] for
        details.
    oned_as
        Whether to write one-dimensional arrays as row or column vectors. See
        [scipy.io.savemat][] for details.

    """
    self.filename = Path(filename)
    self.format = format
    self.long_field_names = long_field_names
    self.do_compression = do_compression
    self.oned_as = oned_as

    if self.filename.exists():
        raise ValueError(
            _("output file {filename} already exists").format(
                filename=self.filename
            )
        )