View voronoi.py
This file contains 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.spatial import KDTree | |
import matplotlib.pyplot as plt | |
import numpy as np | |
# SETUP | |
points = np.array([[1,2],[5,9],[-8,-2],[5,-5],[-4,-1]]) | |
xmin, xmax, ymin, ymax = -10, 10, -10, 10 | |
x_resolution = y_resolution = 300 | |
pixel_size = max((xmax-xmin)/x_resolution, (ymax-ymin)/y_resolution) | |
radius = 3 |
View whalesong.py
This file contains 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 pathlib import Path | |
from scipy.io import wavfile | |
from scipy.fft import fft, fftfreq | |
import matplotlib.pyplot as plt | |
import numpy as np | |
path = Path('.') # path to whale song files | |
files = list(path.glob('*.wav')) |
View voltage_divider.py
This file contains 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
#!/usr/bin/env python3 | |
from itertools import combinations_with_replacement | |
from typing import List, Tuple, Generator | |
VALID_E_SERIES = (3, 6, 12, 24, 48, 96, 192) | |
def E(m: int) -> Generator[float, None, None]: | |
""" A generator of IEEE E-series values. |
View mavlogparse.py
This file contains 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
#!/usr/bin/env python3 | |
''' Mavlink telemetry (.tlog) file parser. | |
Operates as a generator. Allows csv output or listing useful types/fields. | |
''' | |
import json | |
from pathlib import Path | |
from fnmatch import fnmatch | |
from pymavlink import mavutil |
View mavactive.py
This file contains 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 builtins import object | |
from time import sleep | |
from threading import Thread, Event, Lock | |
from pymavlink import mavutil | |
mavlink = mavutil.mavlink | |
class WriteLockedFile(object): | |
""" A file with thread-locked writing. """ |
View ssa_encoder.py
This file contains 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
#!/usr/bin/env python3 | |
def parse(file): | |
''' Generates encoded characters from file byte data. | |
Encoding is suitable for embedded [Graphics] in SubStation Alpha files. | |
See here for encoding specification and other details: | |
http://www.tcax.org/docs/ass-specs.htm | |
Bytes are split into groups of 6 bits, then 33 is added to each group |
View inpaint-stitching-edges.py
This file contains 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 cv2 | |
image = cv2.imread('combine.jpg') | |
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) | |
mask = (gray == 0).astype('uint8') * 255 | |
blurred = cv2.GaussianBlur(mask, (15,15), 10) | |
result = cv2.inpaint(image, blurred, 3, cv2.INPAINT_TELEA) | |
cv2.imshow('result', result) | |
print('press any key to exit') |