This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ! ZPL macro for Zemax to initialize multiconfiguration setup for arrangements of angles x and y | |
| ! with the help from https://osphotonics.wordpress.com/2015/05/21/zemax-programming-language-3-11-multi-configuration/ | |
| FOR i, 1, 4, 1 | |
| DELETEMCO 1 | |
| NEXT | |
| ! delete all existing configurations | |
| FOR i, 1, NCON(), 1 | |
| DELETECONFIG 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| def walk_levels(inputpath, outputpath, levels=1): | |
| if levels==0: | |
| return | |
| else: | |
| if not os.path.isdir(outputpath): | |
| os.mkdir(outputpath) | |
| for dirpath in os.listdir(inputpath): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def parse_profilometer_xy_data(filename): | |
| df_header = pd.read_csv(filename, sep='\s+',header=None, nrows=7 ) | |
| df_header = df_header.T | |
| df_header.columns = df_header.iloc[0] | |
| df_header = df_header.reindex(df_header.index.drop(0)) | |
| name = df_header.Data | |
| x_resolution = df_header['X-Resolution'].astype('float').values |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import asyncio | |
| from bleak import BleakScanner | |
| import matplotlib | |
| import PySimpleGUI as sg | |
| from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg | |
| import numpy as np | |
| import matplotlib.pyplot as plt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from collections import deque | |
| class CircularBuffer (deque): | |
| """ Creates a circular buffer class which inherits the deque collection | |
| and implements extract functions""" | |
| def extract(self,n): | |
| """ Extracts n items from the right """ | |
| return list([self.pop() for i in range(n)]) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from collections import deque | |
| class CircularBuffer (deque): | |
| """ Creates a circular buffer class which inherits the deque collection | |
| and implements extract functions""" | |
| def extract(self,n): | |
| """ Extracts n items from the right """ | |
| return list(reversed([self.pop() for i in range(n)])) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import struct | |
| import zlib | |
| import os | |
| import math | |
| def readarc(f, verbose=False): | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # from https://stackoverflow.com/a/15860757/7996766 | |
| import time, sys | |
| from IPython.display import clear_output | |
| def update_progress(progress): | |
| bar_length = 20 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def remap(x, in_min, in_max, out_min, out_max): | |
| """ Remaps X in the range [in_min, in_max] to the range [out_min, out_max] | |
| Equal to the arduino map function.""" | |
| return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min |