Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unv data file with bad data format exported from simcenter test.lab can not read #88

Open
masonacezllk opened this issue Mar 29, 2024 · 2 comments

Comments

@masonacezllk
Copy link

The following data file 'test.unv',which exported from Simcenter Test.lab 2021 in binary format, can not load with pyuff in python.
I found that this unv file is badly format.
I changed the _extract58 function in dataset_58.py file to correct load my 'test.unv' data, code changed list below:

if binary:
            split_data = b''.join(block_data.splitlines(True)[13:])
            if dset['byte_ordering'] == 1:
                bo = '<'
            else:
                bo = '>'
            if (dset['ord_data_type'] == 2) or (dset['ord_data_type'] == 5):
                # single precision - 4 bytes
                values = np.asarray(struct.unpack('%c%sf' % (bo, int(len(split_data) / 4)), split_data[:int(len(split_data) / 4)*4]), 'd')
            else:
                # double precision - 8 bytes
                values = np.asarray(struct.unpack('%c%sd' % (bo, int(len(split_data) / 8)), split_data[:int(len(split_data) / 8)*8]), 'd')

After Changed this codes, I finally load my data.
Is that right?

test.zip

@jankoslavic
Copy link
Contributor

Thank you @masonacezllk ! can you prepare a pull request please?

@jankoslavic
Copy link
Contributor

dear @masonacezllk there are several datasets in the attached test.zip file. Can you please prepare a minimum working example? (single dataset, short example of data)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants