ContactEngineering / SurfaceTopography

Read and analyze surface topographies
https://contactengineering.github.io/SurfaceTopography/
MIT License
15 stars 9 forks source link

Issue Reading Zygo Optical Profiler MetroPro Format Data with open_topography #364

Closed nombac closed 4 months ago

nombac commented 4 months ago

I'm experiencing a problem while attempting to load a data file from a Zygo optical profiler, which should be in the MetroPro format, using the SurfaceTopography Python package. Notably, the file can be correctly read by Gwyddion, suggesting the data itself is not corrupted. Below is the code snippet I executed:

import sys
from SurfaceTopography import open_topography

if __name__ == '__main__':
    open_topography(sys.argv[1])

Upon running this code, I am faced with a series of errors indicating that none of the readers available in the package could properly detect or read the file format. The traceback highlights that there might be an issue with the file parsing or format recognition. Here's the pertinent part of the traceback:

Traceback (most recent call last):
  File "/Users/shirose/Desktop/test.py", line 5, in <module>
    open_topography(sys.argv[1])
  File "/Users/shirose/Library/Python/3.12/lib/python/site-packages/SurfaceTopography/IO/__init__.py", line 235, in open_topography
    raise CannotDetectFileFormat(msg)
SurfaceTopography.Exceptions.CannotDetectFileFormat: tried XYZReader: 
 Could not parse file as XYZ.

... [Additional errors for each reader type] ...

tried MetroProReader: 
 bad char in struct format

This data is crucial for my work. Since I cannot attach the file directly here, please find the data accessible via the following Dropbox link for your reference and testing: test.dat Could anyone assist in resolving this issue or suggest an alternative approach? Thank you!

pastewka commented 4 months ago

Thank you for reporting. I'll resolve this asap.

pastewka commented 4 months ago

Hi @nombac - the problem occurs at a part of the code that starts with the comment

# TODO: We have no example file to actually test this code

--- so I am not surprised that it breaks. I will fix this. My question to you: Can I include the file that you posted here into the repository for automated testing? This will make sure this code does not break with future changes. It would appear in the test/file_format_examples directory as the file metropro-2.dat?

pastewka commented 4 months ago

@nombac I've release v1.13.13 - can you check whether this fixes the issue for you?

nombac commented 4 months ago

Thank you for your work on this! I've confirmed that v1.13.13 works. I'm also okay with including my data file in the repository.

pastewka commented 4 months ago

Okay perfect, thank you!