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 interpolate_scandata_2d(x,y,z, fast_axis=0, min_signal_size=500, points=100, filter_positive=False, center_to_peak=False, normalize=False): | |
| if fast_axis == 0: | |
| vector = x | |
| else: | |
| vector = y | |
| # consider only the positive direction of the x values | |
| if filter_positive: |
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 scipy import interpolate | |
| import numpy as np | |
| # x_resolution = 0.38 | |
| # y_resolution = 0.38 | |
| # z = matrix_data | |
| # xsize,ysize = z.shape | |
| # x = np.arange(0,xsize+extra,1)*x_resolution | |
| # y = np.arange(0,ysize+extra,1)*y_resolution |
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 clip_remainder(x, clip): | |
| if isinstance(clip, tuple): | |
| print("is tuple") | |
| assert len(clip) == 2, "Clip should be (min, max)" | |
| clipmin,clipmax = clip | |
| else: | |
| clipmin = -clip | |
| clipmax = clip | |
| clipptp = np.ptp([clipmin, clipmax]) |
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 |
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
| 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 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
| 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
| 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
| 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 |