Skip to content

Instantly share code, notes, and snippets.

View kwinkunks's full-sized avatar
🐍
Writing bugs

Matt Hall kwinkunks

🐍
Writing bugs
View GitHub Profile
@kwinkunks
kwinkunks / Sampling map by indexing.ipynb
Created September 29, 2021 03:06
Indexing a 2D NumPy array to sample a map
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kwinkunks
kwinkunks / Reading_files_from_the_web.ipynb
Last active January 25, 2022 13:42
Reading files from the web in various ways
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kwinkunks
kwinkunks / Publishable_graphics_with_Python.ipynb
Created November 8, 2021 18:47
Publishable graphics with Python
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kwinkunks
kwinkunks / Custom_colourmaps.ipynb
Last active November 9, 2021 18:40
Custom colourmaps for matplotlib
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kwinkunks
kwinkunks / SOM.ipynb
Last active November 14, 2021 20:27
Self-organizing maps of seismic
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kwinkunks
kwinkunks / aoc21-day07.py
Last active December 7, 2021 14:59
A solution to AOC 2021, Day 7
import numpy as np
def get_data(day, dataset):
with open(f'../js/day{day:02d}/{dataset}.txt', 'r') as f:
return np.array(list(map(int, f.read().split(','))))
def part1(data):
return np.abs(data - np.median(data)).sum()
def part2(data):
@kwinkunks
kwinkunks / dtw.py
Last active April 25, 2022 23:56
Dynamic Thing Warping
# DTW, Dynamic Thing Warping
# Where Thing might be time, or depth, or some other linear basis.
# Apache 2.0 licence.
import numpy as np
def cost(s1, s2):
"""
Very basic algorithm, no windowing.
This cost matrix algorithm was adapted from this blog post by Abhishek Mishra:
@kwinkunks
kwinkunks / read_zmapplus.py
Created February 3, 2022 02:51 — forked from wassname/read_zmapplus.py
python function to read zmap plus asci grid format
def read_zmapplusgrid(inputfile,dtype=np.float64):
"""Read ZmapPlus grids
Format is explained here http://lists.osgeo.org/pipermail/gdal-dev/2011-June/029173.html"""
# read header, read until second '@', record header lines and content
infile = open(inputfile,'r')
comments=[]
head=[]
a=0 # count '@'s
headers=0 # cound header+comment lines
@kwinkunks
kwinkunks / Back-interpolate_seismic_onto_wellbore.ipynb
Last active February 24, 2022 19:16
Extract seismic amplitudes onto a well path
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kwinkunks
kwinkunks / Loading_subsurface_data_101.ipynb
Last active April 5, 2022 11:31
How to load various subsurface data types using Python
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.