[SciPy-User] scipy.io.loadmat error when trying to read a .mat file
Tue Oct 5 08:55:53 CDT 2010
> I suspect it must be being written from outside matlab.
You are right, this file is being written by a instrument software (Sontek River Surveyor Live). Unfortunately, the new version of this instrument and software no longer allows export of data in any format but .mat.
> Is there any way you can load these into matlab and fix them up before
> loading into scipy?
I'm trying to get rid of the matlab dependency since we only have one copy available and I'm trying to write some automated processing scripts.
> Matlab can handle that, although I don't know how you can make a
> structure that has two fields with the same name - as far as I know
> there's no way to do that with matlab syntax, e.g:
I opened the files in matlab (v R14) and I can see the 4 duplicate StationQ arrays but I don't seem to be able access them separately. The Array Editor view and the tab complete shows the 4 Station_Q but I can only access a Summary.StationQ and I don't know which one of the 4 it is accessing. The documentation for software that describes the matlab variables/structures generated by the matlab export command does not list Summary.StationQ at all. It isn't one of the primary variables we need and I'm not sure what it contains. I am assuming the four copies is a bug in their software, I'm going to call them and submit a bug report, not sure how much traction it will get though. The other option is that it represents data from the 4 sonar beams but in all the other structures that have data from the 4 beams the data is represented by a 2D array.
@Pauli & Mathew
> Renaming to "originalname_counter" sounds like an OK solution. Skipping
> duplicates + emitting a warning might also be OK...
Since it looks like matlab cannot handle duplicate field names (at least w/ R14 I haven't tried more recent versions) in terms of accessing the variable once loaded in, and also since it is impossible to make a structure with duplicate field names within matlab, I think this is an error in the way the data file is being written. My vote would be for skipping the duplicates and issuing a warning. That would allow for a more robust way loading the file into scipy directly and also avoid matlab completely.
Thanks for all your help on this.
More information about the SciPy-User