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 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 |
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
# 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: |
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 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): |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.signal import remez, minimum_phase | |
import matplotlib.pyplot as plt | |
# Based on this example from the scipy docs: | |
# https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.minimum_phase.html | |
freq = [0, 0.2, 0.3, 1.0] | |
desired = [1, 0] | |
h_linear = remez(151, freq, desired, Hz=2.0) | |
h_min_hil = minimum_phase(h_linear, method='hilbert') |