[SciPy-User] loadmat: Unknown mat file type, version 49

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[SciPy-User] loadmat: Unknown mat file type, version 49

Florian Lindner
Hello,

when trying to read a matlab file, writen bei petSC, I get this error:

Traceback (most recent call last):
  File "petsc_plot.py", line 9, in <module>
    rbf_results = scipy.io.loadmat("rbf_results")
  File "/usr/lib/python3.4/site-packages/scipy/io/matlab/mio.py", line 131,
in loadmat
    MR = mat_reader_factory(file_name, appendmat, **kwargs)
  File "/usr/lib/python3.4/site-packages/scipy/io/matlab/mio.py", line 55,
in mat_reader_factory
    mjv, mnv = get_matfile_version(byte_stream)
  File "/usr/lib/python3.4/site-packages/scipy/io/matlab/miobase.py", line
237, in get_matfile_version
    % ret)
ValueError: Unknown mat file type, version 49, 49


The file contains a matrix and a vector and looks like that:

%Mat Object:Nodes 1 MPI processes
%  type: seqdense
% Size = 10 2
Nodes = zeros(10,2);
Nodes = [
7.2003197397953400e-01 4.0114727059134836e-01
6.1793966542126100e-02 5.2764865382548720e-01
1.0022337819588500e-02 1.4405427480322786e-01
1.4463931936456476e-01 9.9650445216117589e-01
3.9777780919128602e-01 1.0677308875937896e-01
7.3036588248200474e-02 9.8905332488367748e-01
1.0386628927366459e-01 7.3131275919223881e-01
2.5078039364333193e-01 3.0846024921541471e-01
9.8405227390177075e-01 1.8055644102282642e-01
7.3851607000756303e-01 9.8604536855510361e-01
];
%Vec Object:Coefficients 1 MPI processes
%  type: seq
Coefficients = [
5.0245251254608746e+04
2.3659864438721524e+04
-1.4592196188522011e+05
1.4189477757354762e+04
7.8494387129370181e+04
2.5176418131682707e+05
-4.3384330330706594e+04
-1.7567379893104360e+05
6.5349663489607065e+02
-5.4052285933927575e+04
];


The petsc C code:

  PetscViewer viewer;
  PetscViewerASCIIOpen(PETSC_COMM_WORLD, "rbf_results", &viewer);
  PetscViewerSetFormat(viewer, PETSC_VIEWER_ASCII_MATLAB);
  MatView(Nodes, viewer);
  VecView(c, viewer);
  PetscViewerDestroy(&viewer);

Any idea what could be the problem here?

System is ArchLinux, SciPy 0.14, NumPy 1.8.2, Python 3.4.1

Thanks,
Florian

_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

Re: loadmat: Unknown mat file type, version 49

Matthew Brett
Hi,

On Wed, Aug 27, 2014 at 10:23 AM, Florian Lindner <[hidden email]> wrote:

> Hello,
>
> when trying to read a matlab file, writen bei petSC, I get this error:
>
> Traceback (most recent call last):
>   File "petsc_plot.py", line 9, in <module>
>     rbf_results = scipy.io.loadmat("rbf_results")
>   File "/usr/lib/python3.4/site-packages/scipy/io/matlab/mio.py", line 131,
> in loadmat
>     MR = mat_reader_factory(file_name, appendmat, **kwargs)
>   File "/usr/lib/python3.4/site-packages/scipy/io/matlab/mio.py", line 55,
> in mat_reader_factory
>     mjv, mnv = get_matfile_version(byte_stream)
>   File "/usr/lib/python3.4/site-packages/scipy/io/matlab/miobase.py", line
> 237, in get_matfile_version
>     % ret)
> ValueError: Unknown mat file type, version 49, 49
>
>
> The file contains a matrix and a vector and looks like that:
>
> %Mat Object:Nodes 1 MPI processes
> %  type: seqdense
> % Size = 10 2
> Nodes = zeros(10,2);
> Nodes = [
> 7.2003197397953400e-01 4.0114727059134836e-01
> 6.1793966542126100e-02 5.2764865382548720e-01
> 1.0022337819588500e-02 1.4405427480322786e-01
> 1.4463931936456476e-01 9.9650445216117589e-01
> 3.9777780919128602e-01 1.0677308875937896e-01
> 7.3036588248200474e-02 9.8905332488367748e-01
> 1.0386628927366459e-01 7.3131275919223881e-01
> 2.5078039364333193e-01 3.0846024921541471e-01
> 9.8405227390177075e-01 1.8055644102282642e-01
> 7.3851607000756303e-01 9.8604536855510361e-01
> ];
> %Vec Object:Coefficients 1 MPI processes
> %  type: seq
> Coefficients = [
> 5.0245251254608746e+04
> 2.3659864438721524e+04
> -1.4592196188522011e+05
> 1.4189477757354762e+04
> 7.8494387129370181e+04
> 2.5176418131682707e+05
> -4.3384330330706594e+04
> -1.7567379893104360e+05
> 6.5349663489607065e+02
> -5.4052285933927575e+04
> ];
>
>
> The petsc C code:
>
>   PetscViewer viewer;
>   PetscViewerASCIIOpen(PETSC_COMM_WORLD, "rbf_results", &viewer);
>   PetscViewerSetFormat(viewer, PETSC_VIEWER_ASCII_MATLAB);
>   MatView(Nodes, viewer);
>   VecView(c, viewer);
>   PetscViewerDestroy(&viewer);
>
> Any idea what could be the problem here?
>
> System is ArchLinux, SciPy 0.14, NumPy 1.8.2, Python 3.4.1

Sorry - I wasn't sure from what you said whether this is actually a
matlab .mat file in matlab 4 / 5 / 6 binary format?

Cheers,

matthew
_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

Re: loadmat: Unknown mat file type, version 49

Florian Lindner
Matthew Brett wrote:

> Hi,
>
> On Wed, Aug 27, 2014 at 10:23 AM, Florian Lindner <[hidden email]>
> wrote:
>> Hello,

>> The petsc C code:
>>
>>   PetscViewer viewer;
>>   PetscViewerASCIIOpen(PETSC_COMM_WORLD, "rbf_results", &viewer);
>>   PetscViewerSetFormat(viewer, PETSC_VIEWER_ASCII_MATLAB);
>>   MatView(Nodes, viewer);
>>   VecView(c, viewer);
>>   PetscViewerDestroy(&viewer);
>>
>> Any idea what could be the problem here?
>>
>> System is ArchLinux, SciPy 0.14, NumPy 1.8.2, Python 3.4.1
>
> Sorry - I wasn't sure from what you said whether this is actually a
> matlab .mat file in matlab 4 / 5 / 6 binary format?

Actually I got no idea. petSC gives no information about the specific
version. I've pasted the relevant file how it's cat'ted into my console.

Thx,
Florian

_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

Re: loadmat: Unknown mat file type, version 49

Pauli Virtanen-3
27.08.2014, 23:33, Florian Lindner kirjoitti:
> Matthew Brett wrote:
[clip]
>>>   PetscViewerSetFormat(viewer, PETSC_VIEWER_ASCII_MATLAB);
[clip]
>> Sorry - I wasn't sure from what you said whether this is actually a
>> matlab .mat file in matlab 4 / 5 / 6 binary format?

Given that it says PETSC_VIEWER_ASCII_MATLAB, it's probably saved just
as a text file. scipy.io.loadmat loads files in the matlab binary format.


_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user