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 / Mountain_heights.ipynb
Last active August 29, 2015 14:09
Heights of mountains, compared to the centre of the earth. View IPython Notebook... http://nbviewer.ipython.org/gist/kwinkunks/a449bff4c8c35952e6ce
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kwinkunks
kwinkunks / Seismic_acquisition_oo.ipynb
Last active August 29, 2015 14:11
Simple seismic acquisition modeling
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kwinkunks
kwinkunks / min-char-rnn.py
Created May 28, 2016 12:42 — forked from karpathy/min-char-rnn.py
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@kwinkunks
kwinkunks / Xmas_2017.py
Created November 27, 2017 14:29
Makes a festive and reproducible image from a wireline log
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.patches import Rectangle
import requests
from io import StringIO
from welly import Well
# Fetch LAS file.
url = "https://dropbox.com/s/n52qezp5byap4mi/WellA.las?raw=1"
r = requests.get(url)
@kwinkunks
kwinkunks / blur_pure_NumPy.py
Created September 26, 2019 15:57
Implementing a 3 x 3 boxcar filter over a 2D image in pure NumPy
import numpy as np
arr = np.random.randint(0, 256, (200, 200), dtype=np.uint8)
def func(arr1d):
kernel = np.ones(3) / 3
return np.convolve(arr1d, kernel, mode='same')
first_pass = np.apply_along_axis(func, axis=0, arr=arr)
final_result = np.apply_along_axis(func, axis=1, arr=first_pass)
@kwinkunks
kwinkunks / volumes.py
Last active October 18, 2019 08:14
Two functions implementing very naive 3d spatial analysis of a point cloud
import numpy as np
import scipy.signal as ss
def to_volume(points, max_mb=10):
"""
Convert N x 3 array of points in a point cloud to a 3D image
or 'volume'. The degree of upscaling is controlled by ``max_mb``
which is the target size of the 3D image in memory.
@kwinkunks
kwinkunks / holiday19.py
Last active November 27, 2019 16:15
A holiday card for 2019
import io
import requests
import numpy as np
from PIL import Image
import matplotlib.pyplot as plt
from matplotlib.colors import LinearSegmentedColormap as LSC
from scipy.interpolate import Rbf
class HolidayCard():
"""A holiday card class."""
@kwinkunks
kwinkunks / SEG-Y_revisions_and_segyio.md
Last active January 27, 2020 17:21
How various features map to SEG-Y Revision numbers and `segyio`'s capability
Rev 0 Rev 1 Rev 2 segyio r segyio w
Byte order
Big endian 1 1 1
Little endian 0 0 1
Pairwise byte-swapped 0 0 1
Number formats
8-bit int 0 1 1
@kwinkunks
kwinkunks / Colours.py
Created December 28, 2014 21:22
RGB triples for USGS lithology colours http://pubs.usgs.gov/of/2005/1314/
colours = {
'Alkali-feldpar syenite': (244, 60, 108),
'Alkali-feldspar granite': (255, 209, 220),
'Alkali-feldspar rhyolite': (254, 220, 126),
'Alkali-feldspar trachyte': (254, 183, 134),
'Alkalic intrusive rock': (255, 111, 145),
'Alkalic volcanic rock': (194, 65, 0),
'Alkaline basalt': (169, 101, 55),
'Alluvial fan': (255, 255, 183),
'Alluvial terrace': (250, 238, 122),
@kwinkunks
kwinkunks / Nonspatial_clustering_of_map_features.py
Created April 22, 2020 16:26
Small demo of how you might cluster mapped features, ignore (x, y) location and accounting for some NaNs around the edge.
import numpy as np
# Make some fake data
# Make array with 100 rows, 100 columns, and 6 'features' (different maps)
shape = (100, 100, 3)
data = np.random.random(shape)
# Pretend it has NaNs around edge.
data[:10] = np.nan
data[-10:] = np.nan