JuliaIO / MAT.jl

Julia module for reading MATLAB files
MIT License
278 stars 71 forks source link

Can't correctly convert datetime type #133

Open henry2004y opened 4 years ago

henry2004y commented 4 years ago

Hi,

I recently found that the datetime type in Matlab cannot be correctly read in Julia. For example, in Matlab

t = datetime('now','TimeZone','local','Format','d-MMM-y HH:mm:ss Z')
save('test.mat', t)

In Matlab it has the following display

 datetime

   17-Dec-2019 10:25:30 -0500

Then in Julia,

using MAT
vars = matread("test.mat")

It showed

Dict{String,Any} with 2 entries:
  "__opaque__" => Dict{String,Any}("s1"=>Int8[77, 67, 79, 83],"arr"=>("", UInt32[0xdd000000; 0x00000002; … ; 0x00000001; 0x00000001]),"s0"=>Int8[116],"s2"=>Int8[1…
  ""           => UInt8[0x00 0x01 … 0x00 0x00]

Anybody knows how to fix this? Thanks!

StefanPofahl commented 4 years ago

I can confirm, the bug is still there, tested with Matlab v2018b. Where do you see the problem? In module "HDF5", or in module "mat"?

StefanPofahl commented 4 years ago

I will have a closer look, what happens, if I export in different mat-formats, like -v7

StefanPofahl commented 4 years ago

I have the impression it is a module "HDF5" issue, see: issue 626

jebej commented 4 years ago

Could you try with the branch from this PR to see if you can load the file? It won't make any unsupported types work, but at least the rest of the file will be readable.

In julia:

]add https://github.com/jebej/MAT.jl.git#patch-1
wsshin commented 1 year ago

It showed

Dict{String,Any} with 2 entries:
  "__opaque__" => Dict{String,Any}("s1"=>Int8[77, 67, 79, 83],"arr"=>("", UInt32[0xdd000000; 0x00000002; … ; 0x00000001; 0x00000001]),"s0"=>Int8[116],"s2"=>Int8[1…
  ""           => UInt8[0x00 0x01 … 0x00 0x00]

I have a related question. When I load a .mat file using MAT.jl, I see that some entries are precisely in the format of the value of __opaque__ above. In my case, the entry has the following format:

Dict{String, Any} with 4 entries:
  "s1"  => Int8[77, 67, 79, 83]
  "arr" => ("", UInt32[0xdd000000; 0x00000002; … ; 0x00000001; 0x00000001;;])
  "s0"  => Int8[]
  "s2"  => Int8[112, 111, 105, 110, 116, 67, 108, 111, 117, 100]

In MATLAB, this entry is stored as a pointCloud (see MATLAB documentation) that has several fields, most importantly Location: an N-by-3 matrix containing 3D coordinates of N points.

Is there a way to decode the above entry to retrieve the Location information? I am wondering if the value corresponding to the "arr" key is some kind of pointers for the pointCloud fields.

Potentially related to https://github.com/JuliaIO/MAT.jl/pull/23.