Skip to content

Instantly share code, notes, and snippets.

View daguiam's full-sized avatar

Diogo Aguiam daguiam

View GitHub Profile
import numpy as np
import matplotlib.pyplot as plt
from scipy import constants as const
import nidaqmx
# Creating the actuation signal
max_displacement = 250*1e-9
f_displacement = 10000
plt.grid()
plt.minorticks_on()
plt.grid(True, which='minor', linestyle='-', lw=0.1)
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()
! 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
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):
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
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
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)])
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)]))
import struct
import zlib
import os
import math
def readarc(f, verbose=False):