Skip to content

Instantly share code, notes, and snippets.

@daguiam
Created March 1, 2021 13:56
Show Gist options
  • Save daguiam/aaf44efcf5cf70ed5bba17df2253622c to your computer and use it in GitHub Desktop.
Save daguiam/aaf44efcf5cf70ed5bba17df2253622c to your computer and use it in GitHub Desktop.
import os
import re
def read_optical_profilometer_data(filename):
with open(filename, "r") as f:
line = f.readline()
# reading the resolutuon line
line = f.readline()
# Read the x-length and x-resolution
# example line: X-Maß = 17.50 X-Auflösung = 1000.00 Punkte/Zeile: 17501
data = re.findall(r"[-+]?\d*\.\d+|\d+", line)
# print(line)
x_length, x_resolution, x_total = [float(value) for value in data]
# Load all the profile data and construct the x and y topography
profile = np.loadtxt(filename, skiprows=2)
xdata = np.linspace(0,x_length, int(x_total))
return (xdata, profile)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment