Skip to content

Instantly share code, notes, and snippets.

View tobiscode's full-sized avatar

Tobias Köhne tobiscode

View GitHub Profile
@tobiscode
tobiscode / lin_tri_interpolator.py
Created August 22, 2025 11:20
Linear interpolator for a function sampled at vertices of a triangular mesh
def lin_tri_interpolator(
vertices: np.ndarray, triangles: np.ndarray, values: np.ndarray, targets: np.ndarray
) -> np.ndarray:
"""
Interpolate values defined at the vertices of triangles
onto arbitrary points projected to the closest triangle they
are contained in.
Parameters
----------
@tobiscode
tobiscode / replace_pdf_images.py
Created May 15, 2025 15:36
After UB-Mannheim/zotero-ocr of PDF where every page is a single image, re-insert those into the output
import sys
import re
import subprocess
from tqdm import tqdm
# byte representations of PDF constants
B_STREAM = bytes("stream", "ansi")
B_ENDSTREAM = bytes("endstream", "ansi")
B_JBIGGLOBALS = bytes("/JBIG2Globals", "ansi")
B_NEWLINE = bytes("\n", "ansi")
@tobiscode
tobiscode / powerlevel10k_superlean.omp.json
Last active January 9, 2025 08:57
My oh-my-posh theme, an even leaner version of powerlevel10k_lean
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"blocks": [
{
"alignment": "left",
"segments": [
{
"foreground": "#b07aa1",
"style": "plain",
"template": "{{ if .Error }}!{{ .Error }}! {{ else }}{{ if .Venv }}({{ .Venv }}) {{ else }}({{ .Full }}) {{ end }}{{ end }}",
@tobiscode
tobiscode / load_srcmod_mat.py
Last active January 9, 2024 19:49
Load SRCMOD finite fault Matlab files in Python
"""
Simple functions to interact with the Matlab files provided by the SRCMOD database.
"""
import numpy as np
from scipy.io import loadmat
# function copied from
# https://github.com/thearagon/srcmod2cmt/blob/f1d701f0927c2a5d923c2a36eb5dd8c56cc85281/cmtsol.py