Open a 'VAX' file in python

64 views Asked by At

I'm trying to open a 'VAX' file without success in python. In old Matlab versions (before 2008) it was possible to do it using the commands:

    fid = fopen(filename, 'r', 'vaxd');                  
    data = fread(fid, inf, 'float32');

But I'm not able to replicate this in python or other programming languages.

I tried to use pyvax (https://github.com/garydoranjr/pyvax), a python wrapper for libvaxdata library in C, but without success. This is what I tried.

import pyvax 
import numpy as np

file = "filepath"

with open(file, 'rb') as fl:
    data = fl.read()
        
fstr = pyvax.from_vax_d8(data)
np.frombuffer(fstr, dtype = 'float32', count=-1, offset=0)

But the data I get are not correct (non sense numbers, not what I expect to be contained in the file). I also tried other functions in the pyvax package and different "dtype" values in the np.frombuffer function. Do you have any suggestion on what to try next?

EDIT: Here a dropbox link to download an example of the file I'm trying to open:https://www.dropbox.com/s/unn10jfmclwh7d6/testfile.THK?dl=0 I expect it to contain about 8k numbers, I suppose float32 (from the matlab code provided). I expect the majority of values to be close to the number 700, but I'm not sure about this last one.

0

There are 0 answers