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

Issue when loading binary .uff in third-party software #91

Open
vlef opened this issue Sep 9, 2024 · 9 comments
Open

Issue when loading binary .uff in third-party software #91

vlef opened this issue Sep 9, 2024 · 9 comments

Comments

@vlef
Copy link

vlef commented Sep 9, 2024

Hello,

I'm encountering an error when loading a .UFF file generated by pyuff into a third-party software (such as NCode Glyphworks for example).

Importing the file results in abnormal values (cf picture below). This error only occurs when the export is in "binary" format.

Attached are two examples : Binary (incorrect) and ASCII (correct) exports. The only difference is the "Binary" field.

I'm using pyuff 2.4.3

Thanks for your help

image
image
test_ascii.uff.txt
test_binary.uff.txt

@jankoslavic
Copy link
Contributor

I can help you with debugging it. Can you please provide the minimal code you use?

@vlef
Copy link
Author

vlef commented Sep 10, 2024

Hi,

Here is my minimal code, I just change the "binary" variable to export in ASCII or Binary encoding.

```
import numpy as np
from pyuff import UFF


x = np.linspace(0, 1000)
y = np.sqrt(x)

binary = 0

data = {'type': 58, 'binary': binary, 'id1': 'NONE', 'id2': 'NONE', 'id3': 'NONE',
        'id4': 'NONE', 'id5': 'NONE', 'func_type': 1, 'rsp_ent_name': 'Pt 1',
        'rsp_node': 0, 'rsp_dir': 0, 'ref_ent_name': 'NONE', 'ref_node': 0,
        'ref_dir': 0,
        'ord_data_type': 2, 'num_pts': 0, 'abscissa_spacing': 1, 'abscissa_min': 0,
        'abscissa_inc': 0, 'z_axis_value': 0, 'abscissa_spec_data_type': 17,
        'abscissa_len_unit_exp': 0, 'abscissa_force_unit_exp': 0,
        'abscissa_temp_unit_exp': 0, 'abscissa_axis_lab': 'Time',
        'abscissa_axis_units_lab': 's', 'ordinate_spec_data_type': 8,
        'ordinate_len_unit_exp': 0, 'ordinate_force_unit_exp': 0,
        'ordinate_temp_unit_exp': 0, 'ordinate_axis_lab': 'Displacement',
        'ordinate_axis_units_lab': 'mm', 'orddenom_spec_data_type': 0,
        'orddenom_len_unit_exp': 0, 'orddenom_force_unit_exp': 0,
        'orddenom_temp_unit_exp': 0, 'orddenom_axis_lab': 'NONE',
        'orddenom_axis_units_lab': 'NONE', 'z_axis_spec_data_type': 0,
        'z_axis_len_unit_exp': 0, 'z_axis_force_unit_exp': 0,
        'z_axis_temp_unit_exp': 0,
        'z_axis_axis_lab': 'NONE', 'z_axis_axis_units_lab': 'NONE',
        'data': y,
        'x': x}

uff_file = UFF("test_ascii.uff")

uff_file.write_sets(data)

@jankoslavic
Copy link
Contributor

jankoslavic commented Sep 11, 2024

Thank you @vlef .
With the code provided everything works fine on my side. Can you please check you are using the latest version (2.4.3)?
Did you by any chance write in and existing file? (in this case the new dataset is added at the end)

Can you please double-check it? (and delete all prior test files, just in case so you do not append data)

@vlef
Copy link
Author

vlef commented Sep 12, 2024

Yes I'm using 2.4.3
No, I create new file, there was no existing file.

With the code provided everything works fine on my side

Did you manage to import the generated binary UFF file in a third-party software such as NCode Glyphworks?

@jankoslavic
Copy link
Contributor

I am sorry, but I do not have NCode Glyphworks. But the data you provided in binary form is readable and does have the required data. I guess this is a problem of NCode, or?

It could be that the NCode has problems with double precision. Can you try using single? Be careful that you use the option .write_sets(data, force_double=False) as pyuff by default forces double precision.

Please report back the progress.

@jankoslavic
Copy link
Contributor

@vlef any progress? Can you try exporting from Ncode in binary format and importing it in pyuff?

@jankoslavic
Copy link
Contributor

@vlef can we close this issue?

@vlef
Copy link
Author

vlef commented Sep 25, 2024

Hi,

the data you provided in binary form is readable

Did you read the data with pyuff again? My point is that it is readable with pyuff, but not readable with other softwares (NCode, but also other signal analysis softwares)

I can export binary signal from NCode and importing in pyuff without issues.

Yes, I tried also with force_double=False, and the result is the same when importing the output in NCode :

image

@jankoslavic
Copy link
Contributor

Can read the txt file in NCode and save it as binary from there? Please provide the binary file, as exported from NCode, here. I will try to help.

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